trueaxis.com Forum Index trueaxis.com
True Axis Physics SDK Forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sphere falling through static mesh

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    trueaxis.com Forum Index -> Getting Started
View previous topic :: View next topic  
Author Message
beebs1



Joined: 21 Feb 2007
Posts: 6

PostPosted: Wed Feb 21, 2007 5:26 pm    Post subject: Sphere falling through static mesh Reply with quote

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
View user's profile Send private message
luke
Site Admin


Joined: 15 Oct 2004
Posts: 621

PostPosted: Thu Feb 22, 2007 10:27 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
beebs1



Joined: 21 Feb 2007
Posts: 6

PostPosted: Thu Feb 22, 2007 5:35 pm    Post subject: Reply with quote

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 Smile

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
View user's profile Send private message
beebs1



Joined: 21 Feb 2007
Posts: 6

PostPosted: Thu Feb 22, 2007 6:32 pm    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message
luke
Site Admin


Joined: 15 Oct 2004
Posts: 621

PostPosted: Thu Mar 08, 2007 10:08 am    Post subject: Reply with quote

My best guess is the impulse you are applying is too low.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    trueaxis.com Forum Index -> Getting Started All times are GMT
Page 1 of 1

 
Jump to:  
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