Author Topic: how to asemble several objects as one  (Read 5960 times)

Offline urd

  • byte
  • *
  • Posts: 8
    • View Profile
how to asemble several objects as one
« on: June 10, 2003, 05:57:51 am »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: how to asemble several objects as one
« Reply #1 on: June 10, 2003, 09:20:17 pm »
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?

Offline urd

  • byte
  • *
  • Posts: 8
    • View Profile
Re: how to asemble several objects as one
« Reply #2 on: June 11, 2003, 05:11:26 am »
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/_\

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: how to asemble several objects as one
« Reply #3 on: June 11, 2003, 06:03:23 pm »
Quote
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/_\

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

  • Guest
Re: how to asemble several objects as one
« Reply #4 on: June 12, 2003, 05:26:06 am »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: how to asemble several objects as one
« Reply #5 on: June 12, 2003, 05:48:02 pm »
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?

Offline urd

  • byte
  • *
  • Posts: 8
    • View Profile
how to asemble several objects as one
« Reply #6 on: June 13, 2003, 06:41:37 am »
i guess i got it..what dummy mean  is a "unseen skeleton".it can assemble objects with an "unseen skeleton"is my thought correct? ^^||

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
how to asemble several objects as one
« Reply #7 on: June 13, 2003, 05:17:16 pm »
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

  • Guest
how to asemble several objects as one
« Reply #8 on: December 20, 2003, 10:57:25 pm »
So the dummy object is a null point, correct?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
how to asemble several objects as one
« Reply #9 on: December 21, 2003, 01:10:31 pm »
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.