DosTips.com

A Forum all about DOS Batch
It is currently 24 Feb 2017 22:34

All times are UTC-06:00




Post new topic  Reply to topic  [ 79 posts ]  Go to page 1 2 3 4 5 6 Next
Author Message
PostPosted: 15 May 2016 15:19 
Offline

Joined: 02 May 2016 18:20
Posts: 222
Here is a little something I threw together by using an old graphics engine I made and adding conversion to text.

Where? http://www.mediafire.com/download/x2lrkla93bd149o/cmdgfx.zip

Also, source code for cmdgfx etc is here: https://github.com/misol1/cmdgfx


Some screenshots:

Image

Syntax:
Code: Select all
Usage: cmdgfx [operations] [flags] [fgpalette] [bgpalette]

Drawing operations (separated by &):

poly     fgcol bgcol char x1,y1,x2,y2,x3,y3[,x4,y4...,y24]
ipoly    fgcol bgcol char bitop x1,y1,x2,y2,x3,y3[,x4,y4...,y24]
gpoly    palette x1,y1,c1,x2,y2,c2,x3,y3,c3[,x4,y4,c4...,c24]
tpoly    image fgcol bgcol char transpchar/transpcol x1,y1,tx1,ty1,x2,y2,tx2,ty2,x3,y3,tx3,ty3[...,ty24]
image    image fgcol bgcol char transpchar/transpcol x,y [xflip] [yflip] [w h]
box      fgcol bgcol char x,y,w,h
fbox     fgcol bgcol char x,y,w,h
line     fgcol bgcol char x1,y1,x2,y2 [bezierPx1,bPy1[,...,bPx6,bPy6]]
pixel    fgcol bgcol char x,y
circle   fgcol bgcol char x,y,r
fcircle  fgcol bgcol char x,y,r
ellipse  fgcol bgcol char x,y,rx,ry
fellipse fgcol bgcol char x,y,rx,ry
text     fgcol bgcol char string x,y
block    mode[:1233] x,y,w,h x2,y2 [transpchar] [xflip] [yflip] [transform] [colExpr] [xExpr yExpr]
3d       objectfile drawmode,drawoption rx[:rx2],ry[:ry2],rz[:rz2] tx[:tx2],ty[:ty2],tz[:tz2] scalex,scaley,scalez,xmod,ymod,zmod face_culling,z_culling_near,z_culling_far,z_sort_levels xpos,ypos,distance,aspect fgcol1 bgcol1 char1 [...fgcol32 bgcol32 char32]
insert   file

Fgcol and bgcol can be specified either as decimal or hex.
Char is specified either as a char or a two-digit hexadecimal ASCII code.
For both char and fgcol+bgcol, specify ? to use existing.
Bitop: 0=Normal, 1=Or, 2=And, 3=Xor, 4=Add, 5=Sub, 6=Sub-n, 7=Normal ipoly.

Image: 256 color pcx file (first 16 colors used), or gxy file, or text file.
If a pcx file is used, transpcol should be specified, otherwise transpchar. Always set transp to -1 if transparency is not needed!

Gpoly palette follows '1233,' repeated, 1=fgcol, 2=bgcol, 3=char (all in hex).
Transform follows '1233=1233,' repeated, ?/x/- supported. Mode 0=copy, 1=move

String for text op has all _ replaced with ' '. Supports a subset of gxy codes.

Objectfile should point to either a plg, ply or obj file.
Drawmode: 0 for flat/texture, 1 for flat z-sourced, 2 for goraud-shaded z-sourced, 3 for wireframe, 4 for flat,  5=persp. correct texture/flat, 6=affine char/persp. correct color.
Drawoption: Mode 0 textured=transpchar/transpcol(-1 if not used!). Mode 0/4 flat=bitop. Mode 1/2: 0=static col, 1=even col. Mode 2: put bitop in high byte.

[flags]: 'p' preserve buffer content, 'k' return code of last keypress, 'K' wait and return key, 'e/E' suppress/pause errors,
         'wn/Wn' wait/await n ms, 'M[wait]' return key/mouse bit pattern(see mouse examples), 'Zn' set projection depth,
         'o' write errorlevel to EL.dat.

An "ipoly" is an intersecting polygon. If lines are intersecting, the regular "poly" will not draw properly. Normally though, use "poly".

A "tpoly" is a texture-mapped polygon (not perspective-corrected). if you use another char than db, the bgcol will show through. Texture map coordinates are floating point values from 0...1, though higher values can be used to repeat the pattern.

rx,ry,rz are rotations in degrees, but for added precision a full circle is not 360 but 360*4=1440. So just multiply angles by 4.


Last edited by misol101 on 10 Jan 2017 05:43, edited 26 times in total.

Top
   
PostPosted: 15 May 2016 15:44 
Offline

Joined: 02 May 2016 18:20
Posts: 222
Simple use:

Draw an ellipse with character # and color white:

cmdgfx "ellipse f 0 # 40,25,20,15"

Draw a blue filled box with space char, then a red polygon with char 01 with 3 points on top of that:

cmdgfx "fbox 0 9 20 15,9,50,35 & poly c 4 01 20,5,76,15,45,40"


Top
   
PostPosted: 15 May 2016 20:06 
Offline

Joined: 02 May 2016 18:20
Posts: 222
Since it was there to use anyway, I added texture mapping (not perspective-correct). See above.

Screenshot from gfxtest2.bat: http://www.mediafire.com/view/xtpp876t42pewe6/textured.PNG

I've included one 256 color pcx (only the first 16 are used, but my pcx loader only loads 256 color ones).
Note that it doesn't matter what the palette is (the normal DOS colors are used in any case). But setting the palette to match the DOS colors sure helps when making the image...


Top
   
PostPosted: 16 May 2016 05:43 
Offline

Joined: 02 May 2016 18:20
Posts: 222
Found a little bug in the texturemapper, it would not repeat the pattern in the y direction.

Archive updated, and new gfxtest3.bat added.

This shows repeating patterns in a classic demo effect: http://www.mediafire.com/view/0xa6smzz50nd3mi/textured2.PNG


Top
   
PostPosted: 16 May 2016 08:09 
Offline
Expert

Joined: 10 Feb 2012 02:20
Posts: 6033
That's interesting kind of image magic you've been into...


Top
   
PostPosted: 16 May 2016 13:35 
Offline

Joined: 02 May 2016 18:20
Posts: 222
Thanks, glad you think so!

I'm not quite done yet, spinning 3d objects are coming... unfortunately I won't be able to work on any of this stuff for a month or so, but I'm leaving an unfinished teaser :mrgreen:

Archive updated, run gfxtest4.bat

Screenshots:
http://www.mediafire.com/view/tm7nkqf5x92nf4m/ico.PNG
http://www.mediafire.com/view/8pfgnyjs4yjella/shark.PNG


Top
   
PostPosted: 18 Jun 2016 10:19 
Offline

Joined: 02 May 2016 18:20
Posts: 222
Archive was updated (see top). Now there is official support for 3d objects (ply,plg,obj), and "text" operation was added as well. See top post for syntax.

Run gfxtest4.bat to display 17 different 3d objects, with 3 different draw modes.

No texture mapping for 3d objects at the moment, may be added later possibly.

http://www.mediafire.com/view/dlyb8lsvjpql69b/gfxtest4.PNG

As with my other stuff, if things run slowly, try disabling your antivirus or adding an exception for cmdgfx.exe.


Top
   
PostPosted: 19 Jun 2016 15:44 
Offline

Joined: 02 May 2016 18:20
Posts: 222
Archive updated once more, link at the top. Added a few more 3d options for z culling/sorting (see top for syntax).

Also added 3dworld.bat, a little FPS 3d world which you can explore using the cursor keys. The 3d engine is quite limited for this type of thing but it works ok for this example.


Top
   
PostPosted: 22 Jun 2016 14:22 
Offline

Joined: 02 May 2016 18:20
Posts: 222
Archive updated, see top for link.

I have added an "image" operation, basically to add "sprites". It takes either a pcx file, a gxy file (can be created with my gotoxy editor etc, see viewtopic.php?f=3&t=7129), or actually any text file.

Also, the tpoly operation accepts gxy and text files now, in addition to pcx.

Added a new example called hills.bat which shows Super Mario running around in a parallax scrolling world.


Edit: for those familiar with my gotoxy tool, cmdgfx accepts only a small subset of gxy codes, i.e. \xx, \gxx, \n, \-, \\, and colors can not use v/u/x/y/z/q/+///H/h. Editor.bat (and cmdwiz saveblock) use only this subset anyway, but take note if you create gxy files manually.


Top
   
PostPosted: 23 Jun 2016 09:29 
Offline

Joined: 02 May 2016 18:20
Posts: 222
Archive update, fixed a bug when using tpoly with gxy or text file.

Changed gfxtest3.bat to test this, now press RETURN to switch between textures.


Top
   
PostPosted: 25 Jun 2016 17:41 
Offline

Joined: 02 May 2016 18:20
Posts: 222
Archive updated (see top for link). Found and fixed a bug in the gxy reader.


Top
   
PostPosted: 03 Jul 2016 07:54 
Offline

Joined: 02 May 2016 18:20
Posts: 222
Archive updated.

The following was added:

1. gpoly, i.e. goraud shaded polygon. Added gfxtest6.bat to demonstrate this. Press SPACE to switch colors. Not available for 3d, that would be tricky with the current approach

2. Texture mapping for 3d objects (not perspective corrected unfortunately). This is available for .obj (3ds) 3d files only, and also, so far only pcx files are supported as textures. I added gfxtest5.bat to demonstrate this. Press 'N' while running to see the Incredible HULK spin around. Unfortunately he is rather slow, due to having to read and parse something like 3000 vertices and 5000 polygon faces every time cmdgfx runs. In pure C code, he spins nicely... too bad :)

3. Re-use of the same 3d object for a single call to cmdgfx. This speeds things up if the same object is used multiple times in one call, as in CmdRunner for instance.

4. New draw mode (3) for 3d, but nothing exciting. The modes are 0.Flat or texture(if texture exists) 1.Z("light")-sourced 2. Wireframe 3. Always flat


Top
   
PostPosted: 14 Jul 2016 20:17 
Offline

Joined: 02 May 2016 18:20
Posts: 222
Major update, still same link: http://www.mediafire.com/download/x2lrkla93bd149o/cmdgfx.zip

1. Transparency support for 3d object textures.
To use this, the new *drawoption* parameter must be set to the texture color that should be transparent. Only pcx files are currently supported as 3d textures (whether transparent or not). It's important to set drawoption to -1 if transparency for a texture is not needed, to avoid speed hits.
Run scrolltext.bat for an example. Then run scrolltext.bat with a parameter (any will do) to see two scrolls on top of each other. Neat, huh? :mrgreen:

2. Transparency support for tpoly operation (both pcx and gxy).
No real good example, but run gfxtest3.bat and press RETURN to see it (SPACE to switch textures)

3. Goraud shading support for 3d objects, as well as improved z-sourcing ("lightsource") drawmode with wider range of colors.
Run the updated gfxtest4.bat to see goraud shaded objects. The first one you see is a goraud-shaded torus.

4. For 3d object files, faces with only 1 coordinate are assumed to be pixels.
This only works in drawmode 1 (z-sourcing/lightsource mode).
There are plenty of examples of this one: starfield.bat, pixeltest.bat, pixeltest2.bat, pixeltunnel.bat

5. Similarly, faces with only 2 coordinates are assumed to be lines.
Run linetest.bat for an example.

6. 3d objects now have separate scaling for x,y,z.
The object in starfield.bat is non-uniformly scaled.

7. Support for bit operators was added (OR, AND, XOR etc) for ipoly operation and for 3d for flat and z-sourced drawmodes.
To use them in 3d, the new *drawoption* argument must be set to something other than 0. To use them in z-sourced mode, the bit operator must be put in the high byte (hackish, but needed).
Plenty examples of this: glenz.bat, interference.bat, bit-test.bat, bit-balls2.bat. In gfxtest4.bat, press 'b' to switch bitop for flat drawmodes.

8. The text operation now supports the same subset of gotoxy codes as for the gxy files.
It's used in various places, e.g. pixeltest2.bat.

9. As mentioned in (3), z-sourced light (drawmode 1 and 2) was improved.
For both of these mode, the *drawoption* can be either 0 or 1, where 1 "scales" the colors to fit the object's z-values, whereas 0 do not. (setting this option is the reason the bitop must be set in the high byte for drawmode 2).
While running gfxtest4.bat and gfxtest5.bat, press 'c' to switch between the 2 z-light modes.

10. 'insert' is a new operation to insert the contents of a file into the operation string.
No example using this. Perhaps it's kind of useless... anyway...

11. New flag 'K' that waits for a key input
As opposed to 'k' that just checks without waiting

12. Also, check out dot-flag.bat and bob-flag.bat.
They don't really show new functionality, just a test to see if I could do it. Hackery and precalculation was needed.

Phew! :D

And here's a little collage of screenshots made with batch files and cmdgfx:

Image


Top
   
PostPosted: 17 Jul 2016 07:54 
Offline

Joined: 02 May 2016 18:20
Posts: 222
Alright, one more and then I'll let this be... a while :mrgreen:

New functionality in updated archive:

1. For all operations, it's now possible to specify ? as color or char.
What this means is that either color or char is not written, instead the old value is used. This can be used for some nice overlay effects. Note that if either fgcol OR bgcol is set to ?, then no color is written (neither fgcol nor bgcol).

See colorwrite-test.bat and charwrite-test.bat for examples.

2. Error reporting.
All errors encountered during one run of cmdgfx.exe is reported on top of the screen at the end of the run. At the moment too few/malformed parameter errors and load/parse errors of image/obj files are reported.
Also, two new flags: e and E. e suppresses all errors(not shown), E waits for a keypress if there are errors

3. Gxy files now recognize \r

4. Some bugs in obj reader and box/fbox found and fixed

And here is another (slightly morbid-looking) collage of screenshots from colorwrite-test.bat and charwrite-test.bat:

Image


Top
   
PostPosted: 18 Jul 2016 08:02 
Offline

Joined: 02 May 2016 18:20
Posts: 222
Small bugfix for "text", plus new example!

3dworld2.bat is a textured world, as opposed to the old 3dworld.bat. I also added collision detection (which works ok, but not great)

If you get tired of colliding, press Pgup/PgDown to elevate yourself, in which case colision detection turns off.

H for help.

Screenshots:

Image


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 79 posts ]  Go to page 1 2 3 4 5 6 Next

All times are UTC-06:00


Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited