If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
DarkScythe
Posts: 11 Joined: Mon Feb 20, 2006 3:50 am
Contact:
Post
by DarkScythe » Tue Feb 28, 2006 1:49 am
Anonymous wrote: okay yea i got it all compiled now.
but it's still not scaling it.
this is what i have:
Code: Select all
NewtonCollision* myShape = NewtonCreateBox(nWorld, size2.X, size2.Y, size2.Z, NULL);
NewtonCollision* collision;
collision = NewtonCreateConvexHullModifier(nWorld,myShape);
dMatrix pMatrix;
NewtonConvexHullModifierGetMatrix(collision, &pMatrix[0][0]);
pMatrix.m_up.m_x *= 0.4;
pMatrix.m_up.m_y *= 2;
pMatrix.m_up.m_z *= 0.4;
NewtonConvexHullModifierSetMatrix(collision, &pMatrix[0][0]);
am i doing it right?
changing the numbers didn't seem to have any effects...
???
where is your body?
Guest
Post
by Guest » Tue Feb 28, 2006 3:00 am
oh sorry..here's a better chunk of the code
Code: Select all
node = Core->getSceneMngr()->addAnimatedMeshSceneNode(mesh);
camera = new ThirdCamera(node,Core->getSceneMngr()->addCameraSceneNode(),camOffset);
node->setMaterialTexture (0, Core->getVideo()->getTexture(texture));
//newton for player
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setPosition(playerPosition); //wtf
//node->setRotation(vector3df(0,0,0));
//node->setScale(vector3df(0.1,0.1,0.1));
}
//size the box in Newton units
aabbox3d<f32> sbox = mesh->getMesh(0)->getBoundingBox();
vector3df size2 = sbox.getExtent();
NewtonCollision* myShape = NewtonCreateBox(nWorld, size2.X, size2.Y, size2.Z, NULL);
NewtonCollision* collision = NewtonCreateConvexHullModifier(nWorld,myShape);
NewtonReleaseCollision(nWorld,myShape);
NewtonBody* myBody = NewtonCreateBody(nWorld, myShape);
NewtonBodySetUserData((const NewtonBody *) myBody, (void *) node); //with this you are sending your graphic pointer to Newton.
NewtonBodySetMassMatrix(myBody, 1.0f, 1.0f, 1.0f, 1.0f);
NewtonBodySetForceAndTorqueCallback(myBody, Physics::setForceAndTorque);
NewtonBodySetTransformCallback(myBody, Physics::setTransform);
matrix4 mat2;
mat2.setTranslation(node->getPosition());
NewtonBodySetMatrix(myBody, &mat2.M[0]);
NewtonJoint* upVector;
vector3df upDirection (0.0f, 1.0f, 0.0f);
upVector = NewtonConstraintCreateUpVector (nWorld, &upDirection.X, myBody);
score = 0;
speed = 0;
dMatrix pMatrix;
NewtonConvexHullModifierGetMatrix(collision, &pMatrix[0][0]);
pMatrix.m_up.m_x += 40;
pMatrix.m_up.m_y += 40;
pMatrix.m_up.m_z += 40;
NewtonConvexHullModifierSetMatrix(myShape, &pMatrix[0][0]);
thanks
DarkScythe
Posts: 11 Joined: Mon Feb 20, 2006 3:50 am
Contact:
Post
by DarkScythe » Tue Feb 28, 2006 4:04 am
Code: Select all
NewtonReleaseCollision(nWorld,myShape);
NewtonBody* myBody = NewtonCreateBody(nWorld, myShape);
i did not look at all but first i saw this , you release "myShape" and create the body with it, you should create the body with the collision you've created:
Code: Select all
NewtonCollision* collision = NewtonCreateConvexHullModifier(nWorld,myShape);
DarkScythe
Posts: 11 Joined: Mon Feb 20, 2006 3:50 am
Contact:
Post
by DarkScythe » Tue Feb 28, 2006 4:07 am
and again:
Code: Select all
dMatrix pMatrix;
NewtonConvexHullModifierGetMatrix(collision, &pMatrix[0][0]);
pMatrix.m_up.m_x += 40;
pMatrix.m_up.m_y += 40;
pMatrix.m_up.m_z += 40;
NewtonConvexHullModifierSetMatrix(myShape, &pMatrix[0][0]);
you've released "myShape" , you should only deal with "collision" , be careful with it, you may release "collision" at the end.
Guest
Post
by Guest » Tue Feb 28, 2006 5:06 am
oh..those mistakes i was just fooling around with the codes before.
but after i fixed it back,
Code: Select all
NewtonCollision* myShape = NewtonCreateBox(nWorld, size2.X, size2.Y, size2.Z, NULL);
NewtonCollision* collision = NewtonCreateConvexHullModifier(nWorld,myShape);
NewtonBody* myBody = NewtonCreateBody(nWorld, collision);
dMatrix pMatrix;
NewtonConvexHullModifierGetMatrix(collision, &pMatrix[0][0]);
pMatrix.m_up.m_x += 0.04;
pMatrix.m_up.m_y += 0.04;
pMatrix.m_up.m_z += 0.04;
NewtonConvexHullModifierSetMatrix(collision, &pMatrix[0][0]);
NewtonReleaseCollision(nWorld,collision);
still no changes to the model...
Guest
Post
by Guest » Tue Feb 28, 2006 5:23 am
oh again...
pMatrix.m_up.m_x += 0.04;
should have been
pMatrix.m_up.m_x *= 0.04;
Acki
Posts: 3496 Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:
Post
by Acki » Tue Feb 28, 2006 6:28 pm
Well, creating a new body would be more easy....
Guest
Post
by Guest » Tue Feb 28, 2006 7:52 pm
Acki wrote: Well, creating a new body would be more easy....
could you give me some example to illustrate your suggestion? i'm a little bit confused...
thanks
Acki
Posts: 3496 Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:
Post
by Acki » Tue Feb 28, 2006 9:19 pm
Use NewtonDestroyBody(const NewtonWorld* newtonWorld, const NewtonBody* bodyPtr) to delete the current body and create a new body as desired...
Guest
Post
by Guest » Tue Feb 28, 2006 9:50 pm
ok thanks, but i meant, when creating new body, how's the scaling part takes place?
Acki
Posts: 3496 Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:
Post
by Acki » Wed Mar 01, 2006 12:50 am
Well, try something like this:
Code: Select all
vector3df size2 = mesh->getMesh(0)->getBoundingBox().getExtent() * node->getScale();
NewtonCollision* myShape = NewtonCreateBox(nWorld, size2.X, size2.Y, size2.Z, NULL);
Guest
Post
by Guest » Wed Mar 01, 2006 5:49 am
ok yea. it kind a works. just for clarification, the above method is to scale the bounding box right? but right now, for some reason when i scale the node player itself, it messes up the mesh...like it's being stretched all over the place.
(this is being done by playernode->setScale(vector3df(..,..,..)); )
anyone knows why it's happening like this?
thanks
Guest
Post
by Guest » Wed Mar 01, 2006 6:01 am
sorry...after further testing, i found out i was inside the model and that's why it looked like it's messed up.
now it seems doing anything to the model did not do anything (ie rotating it)
i'm going to test some things first..
thanks guys for the help