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


D3D hierarchies?

Recommended Posts

BeanDog    1065
I have gotten D3D to work and render T+L''ed polys and then had it T my L''ed polys for me, and I figure the L will be pretty easy to do, too, so now I''m working to clean up my code and encapsulate my functionality. I have a class that is a d3dObject, that has an array of pointers to other d3dObjects in it. Each one has a bunch of D3DVERTEX''s in it. This way, I can call the render for each main object and it will do it for each below it, like I call Hand.Render(), which will call MainObj.objs[0]->Render(), and objs[0] will call objs[0]->objs[0]->Render(), and so on. This is my scheme for hierarchies, too. I just create, say, a hand d3dObject, and five finger d3dObject''s, and set the first five pointers in the hand''s objs array to these fingers. Then all I do is say Hand.rotateX(5), and it will rotate the entire hand, and I can rotate a single finger by saying Finger1.rotateX(5) OR Hand.objs[0]->rotateX(5) because of my hierarchy setup. Each d3dObject (the hand and the fingers) has a world-matrix set up for where it is in the world coords. Only problem with this is, how do I make it so that the fingers will rotate and the joints and not around the world origin? And so that I can rotate the hand, making the fingers rotate around the hand''s rotation point, not their connection to the hand? Do you see my dilemma? If I can make this work, I can make my own animation software with some wicked compression - I could just store rotation coords and stuff, but that''s way in the future... Any 3d geniuses out there that could help me out here? Thanks a ton, ~BenDilts( void );

Share this post

Link to post
Share on other sites
remo    122
well i''m no 3d genius but i would say that the answer lies in the order in which you multiply the rotation matrixes and that you would need throw in a couple of translation matrixes in there too...

basically it is impossible (i think, at least with euler coords) to specify an origin when you rotate something... the solution is only to move everything else in relation to the origin. so what you need to do is translate the finger so that it''s origin is at the world''s origin, rotate the finger, and then move the finger''s origin back.

i don''t really know if that answers your question

Share this post

Link to post
Share on other sites
Memir    129
I''ve been working on an ASE mesh converter (.ASE = 3ds MAX Ascii Export). Everything is done, just gotta sort out the KeyFrames.

I think what your saying about storing just the rotations of the objects is not way into the Future, but quite present....

3dsMAX and earlier versions store ''keys'' for different Frames in the animation. All the objects in the ''Man'' or whatever it is is linked in a Hierachy (sp?) with pivot points representing the origins. The ''Keys'' in the Keyframe are like:

/* mesh data */

/* key frame data */
ROTATE_OBJECT 0, rotate_angle,rotate_x,rotate_y,rotate_z...

ROTATE_OBJECT 100, rotate_angle,rotate_x,rotate_y,rotate_z...

where 100 would represent the frame where this rotation state is happening.

Storing all the VTX coords every frame consumes a LOT of memory, and time, so no one does that - Well actually I done this last year, but now I''m changing to the professional way of doing things .

Basically to Transform the Fingers (BODY->SHOULDER->ELBOW->HAND->FINGER1)

you would do the standard transformation you normal do for a single object. The perform another transformation for the next joint and so on (So they all concatenate into the same MATRIX) i.e:

RESET_TRANSFORM(); // Identity matrix.
TRANSFORM(body.pos,body.scale,body.rot); // Body orientation
TRANSFORM(shoulder.pos,shoulder.scale,shoulder.rot); // Body orientation
TRANSFORM(finger1.pos,finger1.scale,finger1.rot); // Finger Orientaion


If there are any 3D math geniuses out there then can you explain this for me:
(This concerns the .ASE - 3dsMax export FORMAT)

*TM_ROW0 1.0000 0.0000 0.0000
*TM_ROW1 0.0000 0.0000 1.0000
*TM_ROW2 0.0000 -1.0000 0.0000
*TM_ROW3 33.3333 0.0000 -25.1208
*TM_POS 33.3333 0.0000 -25.1208
*TM_ROTAXIS -1.0000 0.0000 0.0000
*TM_SCALE 1.0000 1.0000 1.0000
*TM_SCALEAXIS 0.0000 0.0000 0.0000

Ok this is part of the *NODE_TM section of an ASE file (for an Object, just a simple CUBE).

I figured out that TM_ROW0~3 were just a 4x4 Matrix, ignoring the Right Hand Column (which is always 0,0,0,1).

TM_POS is the pivot point (x,y,z)
TM_SCALE is the scale factor of the object.
But ROTAXIS & ROTANGLE are confusing me. I mean I''m used to having just 3 Rotation values (ROTX,ROTY,ROTZ). But this has an AXIS & ANGLE

Can anyone enlighten me on how this concept works, any url''s to useful pages would be VERY VERY helpful.

btw Check out my 3D-Demo: This was before I had begun working on my ASE->M3D (Memir 3D) converter.


Share this post

Link to post
Share on other sites
BeanDog    1065
Hey guys, guess what?! I got a little demo of a hand working great! And, by the way, I can specify a rotation/translation center/axis for each object relative to the object above it''s rotation/translation center/axis. This means I can just rotate the hand, and all the fingers rotate with it. It works extremely quick and well, so now I''m on to the next challenge:


And then storing animation to files. Due to my wierd arrangement of data, I''ll probably need to do my own model editor.

Share this post

Link to post
Share on other sites