Tested with what you proposed. No luck, but there is a difference.
The mast falls like before (sliding), but when touches the ground, it starts to..... perhaps a video will better explain.
http://www.youtube.com/watch?v=Y9yxjOCTJgY
Nice looking pseudo destruction
-
robagar
- Posts: 48
- Joined: Fri May 21, 2010 1:49 am
Re: Nice looking pseudo destruction
well that looks about right when it hits the floor (apart from the bounciness
), so the body itself is probably OK. So it's just not getting any / enough torque when you give it a push. Where are you applying the force now? Have you tried just applying a torque directly?
-
ca$per
- Posts: 35
- Joined: Fri May 21, 2010 2:48 pm
Re: Nice looking pseudo destruction
Yeap. I tried:
applyImpulse with different impulse and rel_Pos settings;
applyTorque/applyTorqueImpulse with different torque settings;
And many other things, but it's just not working like it should.
Have you seen how other masts behaive on video? It's strange! And with different settings of impulses they behaive more strangely, like bouncing from an invisible obstacle or just moving in weird directions. I've changed constructor to look like this:
Tried rel_Pos with rigidBody->getCenterOfMassPosition() and shifting it in a direction. Nothing helped.
I guess there is something really small that i'm missing. But i don't know what and where to look.
applyImpulse with different impulse and rel_Pos settings;
applyTorque/applyTorqueImpulse with different torque settings;
And many other things, but it's just not working like it should.
Have you seen how other masts behaive on video? It's strange! And with different settings of impulses they behaive more strangely, like bouncing from an invisible obstacle or just moving in weird directions. I've changed constructor to look like this:
Code: Select all
BreakableMast::BreakableMast(Node *node, const float *vertices, const unsigned long vertexCount):
mastNode(node)
{
convexShape = new btConvexHullShape(vertices, vertexCount, 12);
btVector3 inertia(0.0f, 0.0f, 0.0f);
convexShape->calculateLocalInertia(1.0f, inertia);
rigidBody = new btRigidBody(1.0f, this, convexShape, inertia);
TheBulletMgr->AddRigidBody(rigidBody);
rigidBody->getWorldTransform().setFromOpenGLMatrix(node->GetNodeTransform().Get());
//rigidBody->applyImpulse(btVector3(10.0f, 0.0f, 0.0f), btVector3(0.0f, 0.0f, 0.0f));
//rigidBody->applyTorque(btVector3(10.0f, 10.0f, 10.0f));
//rigidBody->applyTorqueImpulse(btVector3(10.0f, 10.0f, 10.0f));
}I guess there is something really small that i'm missing. But i don't know what and where to look.
-
ca$per
- Posts: 35
- Joined: Fri May 21, 2010 2:48 pm
Re: Nice looking pseudo destruction
Any other ideas about this?
-
robagar
- Posts: 48
- Joined: Fri May 21, 2010 1:49 am
Re: Nice looking pseudo destruction
strange.. is your btMotionState implementation right? I mean, what happens if you take out everything apart from the mast and apply a force - does it move as you expect? Something must be wrong if an off axis impulse doesn't make it rotate at all...
-
ca$per
- Posts: 35
- Joined: Fri May 21, 2010 2:48 pm
Re: Nice looking pseudo destruction
Here is how my class looks like (taken from previous page):robagar wrote:strange.. is your btMotionState implementation right? I mean, what happens if you take out everything apart from the mast and apply a force - does it move as you expect? Something must be wrong if an off axis impulse doesn't make it rotate at all...
Code: Select all
class BreakableMast:
public btMotionState
{
private:
Node *mastNode;
btConvexHullShape convexShape;
btRigidBody rigidBody;
void setWorldTransform(const btTransform &worldTrans)
{
Transform4D transform;
worldTrans.getOpenGLMatrix(static_cast<btScalar*>(transform.Get()));
mastNode->SetNodeTransform(transform);
mastNode->Invalidate();
};
void getWorldTransform(btTransform &worldTrans) const
{
Transform4D transform(mastNode->GetNodeTransform());
worldTrans.setFromOpenGLMatrix(static_cast<btScalar*>(transform.Get()));
};
public:
BreakableMast(Node *node, const float *vertices, const unsigned long vertexCount);
~BreakableMast();
};Are there any small tutorials with a simple falling.... emm.... wall? For example how to make it fall nicely? A box, stretched by one of it's sides (a wall as it is). I would compare everything line by line and perhaps there is some small typo in my code somewhere.