How to set a relative parent-child relationship?

View previous topic View next topic Go down

How to set a relative parent-child relationship?

Post  sgreenwalt on Thu Jun 11, 2009 10:30 pm

Is this code supposed to make the child's transform RELATIVE to the parent?

Child->_SIO2transform->_SIO2parent = Parent->_SIO2transform;

That is . . . will Child->_SIO2transform->loc be rendered RELATIVE to Parent->SIO2transform->loc?

I tried this and . . . I have child objects rendering completely out of place . . . not how they were designed in Blender.

Thanks for your help.

sgreenwalt

Posts : 18
Join date : 2009-04-24
Location : Layton, Utah

View user profile

Back to top Go down

Re: How to set a relative parent-child relationship?

Post  sio2interactive on Thu Jun 11, 2009 10:54 pm

The position that is exported from blender is the world position not relative to the parent... If you want the relative position you have to calculate the relative position manually.

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

What I am really asking . . .

Post  sgreenwalt on Fri Jun 12, 2009 11:16 am

What I am really asking is:

What is the purpose of _SIO2parent?

Does the engine have the ability to adjust the child objects location (relative to the parent) if the parent's location changes?

sgreenwalt

Posts : 18
Join date : 2009-04-24
Location : Layton, Utah

View user profile

Back to top Go down

Re: How to set a relative parent-child relationship?

Post  uprise78 on Fri Jun 12, 2009 11:33 am

I'm not sure if this is an option or if it would work but could you offset your objects center then use _SIO2parent to get the effect you are looking for?

uprise78

Posts : 228
Join date : 2008-10-31

View user profile

Back to top Go down

Re: How to set a relative parent-child relationship?

Post  sgreenwalt on Fri Jun 12, 2009 3:18 pm

I am headed in that direction.

I was just hoping that, by simply specifying the parent->child relationship . . . that the engine would handle the rest (i.e. . . . move the parent and the children move with it).

I will have to write that.

I am not complaining.

From what I see so far, this engine is really excellent.

sgreenwalt

Posts : 18
Join date : 2009-04-24
Location : Layton, Utah

View user profile

Back to top Go down

Re: How to set a relative parent-child relationship?

Post  Francescu on Fri Jun 12, 2009 5:00 pm

You could use a bullet 6DOF hinge constraint to achieve this I think...

If you search on the forums you should find some examples I believe.

An example was posted in this thread recently:
http://sio2interactive.forumotion.net/sio2-engine-f3/sio2-architecture-and-bullet-physics-integration-t669.htm

Francescu

Posts : 136
Join date : 2009-03-18

View user profile

Back to top Go down

Re: How to set a relative parent-child relationship?

Post  _-MADMAN-_ on Sat Jun 13, 2009 12:45 pm

First- set the location of child object. Bind matrix.
Second - bind parent-child chierarchy (more than two object chain have strange issues) - bind matrix.
Third - move Your parent - bind matrix.

First transformation will set Your child object position and rotation relative to child. So, if child have to be same as parent just set all to 0.0. I'm using parenting for my emitters (both emitter with sparkles and engine effect, first is set -1 in x, second 1 in x, and third -2 in y etc etc) binded to player.

Sometimes child object disappear - just force his rendering (I think this is problem with calculation child object matrix and actual child matrix, so culling system disables it).

_-MADMAN-_

Posts : 52
Join date : 2009-04-23

View user profile

Back to top Go down

Update

Post  sgreenwalt on Mon Jun 15, 2009 5:46 pm

Followed Francescu's advice:

Some variant of the Bullet 6DOF hinge constraint seems to be the way to go.

I am new to Bullet . . . so I am still figuring things out . . . when I have something working I will post my findings.

Thanks everyone for your help.

sgreenwalt

Posts : 18
Join date : 2009-04-24
Location : Layton, Utah

View user profile

Back to top Go down

Re: How to set a relative parent-child relationship?

Post  _-MADMAN-_ on Mon Jun 15, 2009 6:07 pm

Have You tested your app with constraints on device? Maybe I'm doing something wrong, but with simple two joint constraint I had about 10fps - without it about 25, so bullet and real physic are really expensive for iphone. If You have better performance - just give me a sign Wink

_-MADMAN-_

Posts : 52
Join date : 2009-04-23

View user profile

Back to top Go down

Re: How to set a relative parent-child relationship?

Post  Francescu on Mon Jun 15, 2009 6:22 pm

_-MADMAN-_ wrote:Have You tested your app with constraints on device? Maybe I'm doing something wrong, but with simple two joint constraint I had about 10fps - without it about 25, so bullet and real physic are really expensive for iphone. If You have better performance - just give me a sign Wink
That interesting - are you meshes convexhull ones? Just asking as when I tried with simple meshes from tutorial06 I did not see drop in FPS at all...I have not tried with the monkey though ;-)

Francescu

Posts : 136
Join date : 2009-03-18

View user profile

Back to top Go down

Re: How to set a relative parent-child relationship?

Post  _-MADMAN-_ on Tue Jun 16, 2009 1:36 am

Actually I'm using only rigid body spheres. Never tried convex or triangle mesh as physic object in sio2.

Oh, but important thing - constraint was with six limiters and hinge values for each of them. FPS drop stared of course after adding limits etc. In fact I can't find the reason for using real physic for simply behaviors, I have played with physic only in case of my player and vehicles.

Other fact is that actually I have objects controlled by about 10 forces, it is duplicated five times and forces aren't the same, which gives us about 50 forces at same time - so any next "physic things" in my app make it sloooooowwwww Wink

But maybe I'm doing something wrong Wink

Regards,
Mad

_-MADMAN-_

Posts : 52
Join date : 2009-04-23

View user profile

Back to top Go down

Re: How to set a relative parent-child relationship?

Post  Francescu on Tue Jun 16, 2009 2:26 am

Yes I bet - that's a lot of forces.

Are you using a separate thread for the physics?

Francescu

Posts : 136
Join date : 2009-03-18

View user profile

Back to top Go down

Re: How to set a relative parent-child relationship?

Post  _-MADMAN-_ on Tue Jun 16, 2009 2:35 am

Unfortunately not - I left that for last part of my work. I'm not sure how to make properly work thread - I divided app to four threads - one for physic, one for stats and time calculation, next for rendering and the last for other game variables. And only one thread crushes app - physic thread... no idea why. In tut we can read, that render physic call have to be before rendering process, but thread crushed no matter where rendering was.

_-MADMAN-_

Posts : 52
Join date : 2009-04-23

View user profile

Back to top Go down

Re: How to set a relative parent-child relationship?

Post  Francescu on Tue Jun 16, 2009 10:33 am

_-MADMAN-_ wrote:Unfortunately not - I left that for last part of my work. I'm not sure how to make properly work thread - I divided app to four threads - one for physic, one for stats and time calculation, next for rendering and the last for other game variables. And only one thread crushes app - physic thread... no idea why. In tut we can read, that render physic call have to be before rendering process, but thread crushed no matter where rendering was.
Did you check where time was spent the most with Shark? You could also use the activity / CPU sampler instrument tool...It's very likely bullet but it would be interesting to see where it is happening since you don't have convexhull meshes...

Francescu

Posts : 136
Join date : 2009-03-18

View user profile

Back to top Go down

Re: How to set a relative parent-child relationship?

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum