Log in

View Full Version : Simulating Vector (wireframe) graphics games, with bitmaps


Uhfgood
08-08-2003, 11:31 PM
For a while i've been wanting to make some vector graphics style games. Only problem is I don't know much about the math, nor do I really have anything suitable to create a 2d polygonal wireframe graphics engine with. So i'm thinking possibly could just fake it with bitmaps. I'm sort of wondering if you think this would be a bad move? If maybe since i'm using simple bounding box collisions, and would be not as accurate as true vector graphics games, that it would ruin the experience or something?

Any thoughts?

Keith

aspiral
08-09-2003, 01:34 AM
i don't think it's a good idea. the point of vector graphics is, drawing things that are defined by points and lines etc., and applying some sort of "paint rules" to these defined objects.

imagine a spaceship object or something:

you'd need only a few vertices, forming a polygon which you can freely rotate/scale etc.. you could also apply a
"fill" rule function to fill such an outlined object with a shading color or pattern.
and you have the option to calculate your collisions with true vector intersections and/or bounding boxes to speed things up.

with your bitmap approach you'd need a set of 64x64 bitmaps (or whatever size), for every object, PLUS, if you need it, at least 8 or 16 directions, which is a waste of memory if they just represent vector-style objects.

a very nice standard for vector graphics is SVG (http://www.w3.org/TR/SVG/), maybe you can find the link useful.

Nick Bischoff
08-09-2003, 02:59 AM
Ive also played around with vector based gfx, the fantastic thing about them is they have a very 'unique' feel. There are lots of physics tutorials on the net and open sourced apps to get you started.

I was very inspired by http://www.sodaplay.com < Check out the 'constructor' there.

patrox
08-09-2003, 03:56 AM
who said vectrex :) ?

http://www.roachnest.com/vectrex.html

We were dreaming about these machines at the time...
patrice.

Raptisoft
08-09-2003, 05:09 AM
Hi Keith,

I think simulating it with bitmaps would be a huge waste of space. If you really want to make a wireframe graphic game, you could probably end up with a HUGE game with a download under .5mb (assuming you're going for sales/distribution).

The math for 2D wireframe is very simple, tho.

Consider this:

Point theCenter;
Point anotherPoint;

anotherPoint.x=theCenter.x+(sin(45*PI/180)*20);
anotherPoint.y=theCenter.y+(cos(45*PI/180)*20);

This makes anotherPoint equal to a point 20 pixels away from theCenter, at an angle of 45 degrees. Make three of those points, all at different positions on the compass, and you have a triangle ship that you can rotate just by making the angle variable.

If you want a small math library I've written for this purpose, drop me an e-mail (john@raptisoft.com). It's kind of a rough library, but the most important function in it is this one:

float Math::GetAngle2D(float theX, float theY, float theCenterX, float theCenterY)
{
float aAngle;
float aWorkx,aWorky;

aWorkx=(float)(theCenterX-theX);
aWorky=(float)(theCenterY-theY);
if (aWorky==0)
{
if (aWorkx<=0) return 270.0f;
return 90.0f;
}

aAngle=(float)atan(aWorkx/aWorky);
aAngle=(float)fabs((aAngle/PI)*180);

if (aWorkx>=0 && aWorky<0) return aAngle;
if (aWorkx<0 && aWorky<0) return (360.0f-aAngle);
if (aWorkx>=0 && aWorky>0) return (180.0f-aAngle);
return (180.0f+aAngle);
}

...which will give you the angle between two points onscreen (it's set up for my arbitrary preferences on what direction angle 0 is in, so you'd have to play around with it to get used to it).

Anyway, by using that function, you can "draw" your objects with just points, retrieve the angle of the point to wherever you want the center of the graphic to be, take the distance from it, and very quickly have rotatable vector graphics drawn from points.

svero
08-09-2003, 07:02 AM
I have some vector drawing code in C++ if you want it. It's a very simple 1 file thing with functions to size, draw, and rotate a vector object. There's some velocity and acceleration stuff there too. If you're interested then PM me or email me.

JackNathan
08-09-2003, 10:13 AM
Couldn't you use d3d with the wire frame draw mode?

Jack

Uhfgood
08-09-2003, 11:47 AM
The problem being right now, I don't have a copy of c/c++ compiler to play with. I'm using blitz, but it's graphics primatives are supposedly slow, and it's supposed to be slow to do stuff in software (although i'd have to spend the time to figure that out)...

Yes I know doing multiple images for rotations takes up space, of course, this would only take up memory, as I would probably pre-generate rotations from a single image...

Hmm okay the concensus is that it's not a good thing to do anyhow, thanks for the input

Keith

Ratboy
08-09-2003, 01:12 PM
Vectors in Blitz, huh? This might help:

http://www.blitzbasic.com/bbs/posts.php?topic=19109

Uhfgood
08-09-2003, 03:10 PM
Actually the other thing, is it might take a lot of graphics for doing rotations... If you treat it like a regular sprite game, then it would only take as much space or memory as a regular game does anyways. It's just the look that always caught my eye.

Keith

ps Ratboy thanks for the link, I may do something like that.