 |
trueaxis.com True Axis Physics SDK Forum
|
| View previous topic :: View next topic |
| Author |
Message |
beebs1
Joined: 21 Feb 2007 Posts: 6
|
Posted: Wed Feb 21, 2007 5:26 pm Post subject: Sphere falling through static mesh |
|
|
Hi again,
I have a static ground plane and spawn boxes and spheres over it at random places in a test app. The boxes behave as expected, but the spheres either fall through the ground plane and come to rest a few units underneath, or they perform some very unusual random looping/flying actions if they touch another dynamic object.
Any idea what could be wrong? Here's the code I'm using, if it helps:
| Code: |
TA::DynamicObject *pDynamicObject = TA::DynamicObject::CreateNew();
// i think this may be the problem - does parameter one mean centre of the cube in world or object space?
pDynamicObject->InitialiseAsASphere( TA::Vec3(0.0f, 5.0f, 0.0f);
// place the dynamic object
pDynamicObject->SetPosition( TA::Vec3(0.0f, 5.0f, 0.0f) );
// add the dynamic object to the simulation
m_pPhysics->AddDynamicObject( pDynamicObject );
m_pSphereList->push_back( pDynamicObject );
|
Many thanks for any help.
Last edited by beebs1 on Thu Feb 22, 2007 5:32 pm; edited 1 time in total |
|
| Back to top |
|
 |
luke Site Admin
Joined: 15 Oct 2004 Posts: 621
|
Posted: Thu Feb 22, 2007 10:27 am Post subject: |
|
|
Where is the rest of this function:
| Code: | | pDynamicObject->InitialiseAsASphere( TA::Vec3(0.0f, 5.0f, 0.0f); |
The second parameter is missing.
The first parameter is the ceter of the sphere in object space.
My best guess is that TrueAxis is behaving correctly but that you are actually not rendering the sphere in the correct location. |
|
| Back to top |
|
 |
beebs1
Joined: 21 Feb 2007 Posts: 6
|
Posted: Thu Feb 22, 2007 5:35 pm Post subject: |
|
|
Hi - sorry, my post there had loads of mistakes in it - you'd have thought I'd have managed to copy and paste it correctly, but apparently not
The problem was my own code - it should have been:
| Code: |
// initialize as sphere
pDynamicObject->InitialiseAsSphere( TA::Vec3( 0.0f, 0.0f, 0.0f), 1.0f );
|
Stupid mistake, but thanks for your reply. |
|
| Back to top |
|
 |
beebs1
Joined: 21 Feb 2007 Posts: 6
|
Posted: Thu Feb 22, 2007 6:32 pm Post subject: |
|
|
Would anyone be able to tell me how to apply forces to objects? I'm trying to be able to 'launch' balls from the camera's position. I think I should be doing this:
| Code: |
// pX, pY, pZ is position of sphere to create
// vX, vY, vZ is the direction vector to 'launch' in
TA::DynamicObject *pDynamicObject = TA::DynamicObject::CreateNew();
pDynamicObject->InitialiseAsASphere( TA::Vec3(0.0f, 0.0f, 0.0f), 1.0f );
// place the dynamic object
pDynamicObject->SetPosition( TA::Vec3(pX, pY, pZ) );
pDynamicObject->SetRestitution( 0.3f );
// add the dynamic object to the simulation
m_pPhysics->AddDynamicObject( pDynamicObject );
m_pPhysics->SetDynamicObjectIsMoving( pDynamicObject );
pDynamicObject->ApplyImpulse( TA::Vec3(vX, vY, vZ), TA::Vec3(pX, pY, pZ) );
m_pSphereList->push_back( pDynamicObject );
return pDynamicObject; |
All it does, though is create a sphere at the correct position which then falls straight down. If anyone could suggest what might be wrong it would be much appreciated, thanks.
Fixed - the objects needed mass. I'll be sure to experiment a bit more before posting in future  |
|
| Back to top |
|
 |
luke Site Admin
Joined: 15 Oct 2004 Posts: 621
|
Posted: Thu Mar 08, 2007 10:08 am Post subject: |
|
|
| My best guess is the impulse you are applying is too low. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|