how to asemble several objects as one

Started by urd, June 10, 2003, 05:57:51 AM

Previous topic - Next topic

urd

hello everyone,i am a fresh guy programming 3d.^^
this engine is very cool:lol: ..can't imagine that before,making 3d game is not hard work.
i have a question that if i load objects from a 3ds file including head,leg,body,arm....which each is a object
how do  i assemble and fix the arm to the "correct position" ?can i make it is jpct?

EgonOlsen

Quote from: "urd"hello everyone,i am a fresh guy programming 3d.^^
this engine is very cool:lol: ..can't imagine that before,making 3d game is not hard work.
i have a question that if i load objects from a 3ds file including head,leg,body,arm....which each is a object
how do  i assemble and fix the arm to the "correct position" ?can i make it is jpct?
I'm not quite sure if i'm understanding your problem correctly. Do the objects reside in different 3ds-files or are they all in one? The the later case, the positions of the parts should be fine, because jPCT will import them as they are placed in the orginal model. In the former case, you would need to do the positioning "by hand" by finding the right position for every part.
If this wasn't the question, then maybe you are referring to a possibility to group seperate objects into a single entity. What you can't do (not yet) in jPCT is merging objects into a new one. What you can do, is building up a hierarchie between them by using the addChild() and/or addParent()-methods from Object3D. With them, you may add all body-parts to the chest (or to whatever is appropiate in your case...maybe a dummy object...whatever...) and then the child-objects will inherit all transformations of the parent object.
Does this answer your question somehow?

urd

Quote from: "EgonOlsen"I'm not quite sure if i'm understanding your problem correctly. Do the objects reside in different 3ds-files or are they all in one? The the later case, the positions of the parts should be fine, because jPCT will import them as they are placed in the orginal model. In the former case, you would need to do the positioning "by hand" by finding the right position for every part.
yes,i just import  a 3ds file ,all the objects is in the same 3ds file .^_^
so what should i need to do ,i guess that is to get each fixed point( body_centerpnt+x,body_centerpnt+y,body_centerpnt+z) of the body.and then command other object for instance:my arm ,set the fixed point as the same as (body_centerpnt+x,body_centerpnt+y,body_centerpnt+z)
,so if center point of the body change(ex:move),then the arm will move together.is it correct?
Quote from: "EgonOlsen"
If this wasn't the question, then maybe you are referring to a possible to group seperate objects into a single entity. What you can't do (not yet) in jPCT is merging objects into a new one. What you can do, is building up a hierachie between them by using the addChild() and/or addParent()-methods from Object3D. With them, you may add all body-parts to the chest (or to whatever is appropiate in your case...maybe a dummy object...whatever...) and then the child-objects will inherit all transformations of the parent object.
Does this answer your question somehow?
i got it.so if i have the need to rotate and transform my arm fixed to my body at the same time,i need to asemble object by hand,and use addchild/add parent to make they have hierachie relation.then i use transform to the main body, other arm/leg/head....will  transform as the same.is it correct?^^||.sorry it seem i am somewhat suck in 3d progaming/_\

EgonOlsen

Quotei got it.so if i have the need to rotate and transform my arm fixed to my body at the same time,i need to asemble object by hand,and use addchild/add parent to make they have hierachie relation.then i use transform to the main body, other arm/leg/head....will  transform as the same.is it correct?^^||.sorry it seem i am somewhat suck in 3d progaming/_\
Yes. A child object inherits the transformations (rotation/translation) of its parent. There can be more than one parent, but i would try to organize my scene in a way that i get away with max. one parent per object. I don't even know anymore, how multiple parents are implemented exactly... :D
Example: You make the arm a child of the body and the hand a child of the arm. This way, hand and arm are transformed if the the body is and the hand inherits the transformations of the arm in addition. Sometimes, it's usefull to use "virtual" objects to build up your hierachie. You can achieve this by using "dummy"-object (see: Object3D.createDummyObj()).
Hope this helps.

Anonymous

Quote from: "EgonOlsen"
Sometimes, it's usefull to use "virtual" objects to build up your hierachie. You can achieve this by using "dummy"-object (see: Object3D.createDummyObj()).
Hope this helps.
EgonOlsen thank u teach me a lot :D
i have one more question..
is the"dummy" means a ..human body model?

EgonOlsen

Quote from: "Anonymous"is the"dummy" means a ..human body model?
No, it's not a crash test dummy or something... :D It's called "dummy", because it's not a real (i.e. complete) Object3D. It has no polygons, no vertices and no properties (well, it has them but there are ignored). It doesn't have to be added to an instance of World either. All it really is, is a kind of container for a transformation matrix. This is due to the fact that jPCT is not a pure scene-graph based API but borrows some elements from the scene-graph concept.
Anyway, what is it good for? Ok, imagine a planet spinning around the sun and a moon spinning around the planet. The planet itself is spinning around its vertical axis too. So the basic transformation the planet does is the rotation around its own center while the moon should rotate around the planet. Two problems arise here: The moon should follow the planet if it's moving (i.e. spinning around the sun, which i'll cover later) but it can't be a child of it, because it must not inherit the planet's rotation around its center. The other problem is, that the planet is spinning around itself, but not around the sun. A dummy object is a convienient way to solve this. You create a dummy object and place it into the center of the planet. This dummy object has its rotation pivot in the center of the sun. This way, the dummy rotates around the sun, which is what the planet should do to. So you attach the planet as a child of the dummy. The same goes for the moon: Set the rotation pivot to the center of the planet and attach it as a child to the dummy. This way, both objects will follow the dummy around the sun while performing their own, independent rotations too.
Have a look at the downloadable jPCT-demo. There is a room with a planet and a moon rotating around a pillar that illustrate exactly (almost...) this effect.
Somewhat clearer now?

urd

i guess i got it..what dummy mean  is a "unseen skeleton".it can assemble objects with an "unseen skeleton"is my thought correct? ^^||

EgonOlsen

Quote from: "urd"i guess i got it..what dummy mean  is a "unseen skeleton".it can assemble objects with an "unseen skeleton"is my thought correct? ^^||
Hmmm, i wouldn't call it a skeleton because that sounds like it has a dimension somehow...it's just an unseen "point" in space that can do transformations. Like an infinitely small object. A kind of connector between otherwise unrelated objects. The example of the planet above shows, that such a functionality is needed (or at least very helpfull) in some cases.

Albareth

So the dummy object is a null point, correct?

EgonOlsen

Quote from: "Albareth"So the dummy object is a null point, correct?
Kind of...it's an object without any geometry data associated to it.