Archived

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

nick5454

Framemove please help - newbie ?

Recommended Posts

Okay I cant afford to buy book being unemployed and all so please dont recommend one. Okay so I create my classes to control a mesh. My question is: In the frame move method of my d3d9 application I need to move my mesh do I keep a variable for x,y,z then increment the values, multiply the matrix and then do this call g_pd3dDevice(D3DTS_WORLD, &matWorld); but what if several objects are on the screen at 0nce? How does it know to not apply these changes to them And a last one is I want to maintain frames, is there a class that will control the parent-child frames or do I have to provide my own class with calculations? thanks, nick

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
if you have several objects you''re trying to transform (position/rotate/scale) differently prior to rendering, then you''ll want to delay the setting of the device''s world transform until just before the rendering of those objects. so, what you''ll want to do is keep a separate world matrix variable for each object and modify each one of those in FrameMove according to what that particular object is doing (moving, rotating, increasing in size, etc). if you''re using an object class then you could put the world matrix variable in there or you could just use an array of D3DXMATRIXs or a list of them via std::vector. then in the Render function you''ll want to set the device world transform from the appropriate object matrix variable just prior to rendering the associated object.

as far as your question on frames, i''m not sure what type of "frame" you''re referring to. are you asking about model frame/mesh heirarchy frames, or other types of frames of reference, or rendering frames, or ?

Share this post


Link to post
Share on other sites
Thank you so much. First follow up. When I use g_pd3dDevice(D3DTS_WORLD, &myObjectsMatrix); does this have anything to do with the rest of the objects or just that one in particular?

I am using the structure from the dx9 wizard in VC 7.0.

The frame hierarchy is simply like the earth and the moon hierarchy. I need objects to rotate around the parent, but I''m not sure what that would actually be called.

Thanks so much

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
setting the device''s world transform will impact anything that''s rendered after that call (assuming use of the fixed function pipelline), until the next "set world transform" call is made. it basically tells the pipeline that any vertices sent to it for rendering should first go through that transformation in the world coordinate system.

using your earth/moon example, you would have one matrix for the earth and another one for the moon. in FrameMove you would then adjust the position/rotation of each, using their respective matrices, depending upon what type of animation you were attempting to accomplish. a good example might be an outer space scene which had the earth rotating in a stationary position while the moon rotated around its own axis while also revolving around the earth. all of this would be done by updating, using matrix concatenation, those 2 matrices. the moon matrix would involve a concatenation of the earth''s position via a translation matrix as well since one of its rotations would be relative to the earth''s coordinate system (the moon revolving around the earth).

then in the Render function you would first set the device world transform to the earth matrix, render the earth, set the device world transform to the moon matrix, and then render the moon.

i haven''t looked at the dx9 generated wizard code yet, but the dx8 code had a set of classes generated, CD3DFile, CD3DFrame, and CD3DMesh, iirc, that would give you the mesh-based frame hierarchy you''re looking for. they might be a bit overkill for you as they''re primary use is for .x file hierarchies, but maybe looking at the CD3DFrame code would give you an idea how at least some people would go about developing a hierarchy of mesh frames.

also, there are several good references here on GameDev concerning matrices and their use with coordinate systems if you''re unfamiliar with the topic. drunkenhyena.com might also be a good reference for learning the 3D basics while using DX.

Share this post


Link to post
Share on other sites
Well thanks for an excellent review. I did use the frame hierarchy with dx6 so I''m trying to adjust.

Thanks for the help. everything is much clearer now.

Share this post


Link to post
Share on other sites