Archived

This topic is now archived and is closed to further replies.

bjmumblingmiles

API-less 3d question

Recommended Posts

I''m doing a simple (wireframe as of now) 3d engine- doing all my own math, etc, so that I can know how it all works for myself before i get into D3D and OpenGL. I''ve kind made a vertex buffer system, where I just pass my buffers of any size to the functions. I''m not quite sure how to handle my transformation matrix though- I have model space, world space, and camera space. So every object will share the camera transformations, every object will have its own world transformations, and the model space vertices shouldnt ever change. Now, how do I do this? Say I pass a buffer of 12 tris to my function. What is the order I should do my transformations in, and how do I leave my original vertex buffer unchanged- I want to avoid making a copy. Any help would be appreciated. Brian

Share this post


Link to post
Share on other sites
If a single object resides inside your vertex buffer and you need to xform this object then you use model to world space xform. However, if your buffer contains multiple objects which need to be xformed individually then you need to invoke xform for each one so you can''t xform the entire vertex buffer at once. D3d has a concept of dynamic vertex buffers that work like this: you create on huge buffer at game start time, then you xform your objects from model to world space by object''s own xform matrix then you shove those xformed verts into the dynamic vb and send them off to render.

I suggest you stop working on your software rasterizer and concentrate on gfx api like opengl or d3d. They do things differently than your own sw rast. and have shaders or multitexturing capabilities that would be time consuming to implement in your rast. and would be slow as well as compared to hw doing things fast. I never did a sw rast. but I learned all I needed to know from gl/d3d docs, even screen space xforms and homogenous divides and such. So, in effect you can make gfx api act like a software rasterizer or full hw one. It''s up to you. I''m now doing a doom3 like engine on my gf2 and I can see where shaders would make things even more easier for me so it''s a good time to concentrate on latest and greatest for the ease of programming and gaining speed

Share this post


Link to post
Share on other sites
I don''t agree with JD. I figured out how to make a wireframe 3d graphics engine from scratch when I was in highschool and I learned ALOT! hehehe it was also the messiest program I''ve probably ever seen I didn''t even know what a matrix was until a month after I finished it . But anyway, you do it like this: assuming you already know how to create a transformation matrix from object coordinates (otherwise go here http://www.gamedev.net/hosted/3dgraphics/basics/index.html) , say you''re function gets a list of triangles(all from the same object of course), first you multiply the camera matrix by the object matrix (object*camera) then start with the first triangle and you multiply the resulting matrix of object*camera by a point on the triangle (point*(object*camera)) and you project it. After you do this with the rest of the points you draw the triangle on the screen using the three transformed and projected points. And you continue on through the rest of the triangles. Of course, if you do it this way you end up transforming the same point multiple times (once for every triangle) but its really simple and you dont have to make and copies of anything...

hope that helps

Share this post


Link to post
Share on other sites