A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by ellorenz » Sat Mar 14, 2009 7:30 am
Hi, i'm new on Newton and i need help to create a object during execution of the program like a bullet or ball and not on of program initializizing, like tutorial .
Example
i fire the bullet (a sphere) hit a box react correctly with newton world
Thank's
-
ellorenz
-
- Posts: 5
- Joined: Sat Sep 27, 2008 7:45 am
by VeT » Sat Mar 14, 2009 2:48 pm
-
VeT
-
- Posts: 84
- Joined: Thu Jul 31, 2008 11:31 am
by ellorenz » Sun Mar 15, 2009 7:35 pm
Thank'you very much
Now i'm looking with irrlicht to give the direction
i'm studing the argument on newton velocity

-
ellorenz
-
- Posts: 5
- Joined: Sat Sep 27, 2008 7:45 am
by ellorenz » Tue Mar 17, 2009 6:35 pm
Hi i'm back because a need help to give speed on my fired object, i saw the example with lite c but i use irrlicht.
Now i understand how to fire the object in the cam direction but i can't give speed to the object can u help me on
NewtonBodySetVelocity function?
-
ellorenz
-
- Posts: 5
- Joined: Sat Sep 27, 2008 7:45 am
by ellorenz » Wed Mar 18, 2009 6:09 pm
i don't how i can rotate the velocity vector, somebody can help me?
This is the code:
- Code: Select all
dMatrix location (GetIdentityMatrix());
dVector size (0.5f, 0.5f, 0.5f);
core::vector3df nstart = mystart;
//irr::f64 rotazione = cam->getRotation().X * (180.0/3.1416);
//nstart.rotateXZBy(rotazione,nstart);
nstart *=IRRTONEWTON;
location.m_posit.m_y = nstart.Y;
location.m_posit.m_x = nstart.X;
location.m_posit.m_z = nstart.Z;
float irrSize = size.m_x*NEWTONTOIRR;
scene::ISceneNode* billnode = smgr->addSphereSceneNode(irrSize,16,0,-1, start,cam->getRotation());
//billnode->setRotation(cam->getRotation());
billnode->setDebugDataVisible(irr::scene::EDS_FULL);
f32 length = (f32)(end - start).getLength();
const f32 speed = 0.6f;
u32 time = (u32)(length / speed);
scene::ITriangleSelector* billselector = 0;
billselector = smgr->createTriangleSelectorFromBoundingBox(billnode);
Selectors.push_back(billselector);
scene::ISceneNodeAnimator* anim = 0;
imp.shootednode = billnode;
if (imp.when)
{
// create impact note
imp.when = device->getTimer()->getTime() + (time - 100);
Impacts.push_back(imp);
}
float inertia[3];
float centerofmass[3];
float mass = 10;
imp.shootednode->setMaterialFlag(video::EMF_LIGHTING, true);
imp.shootednode->setMaterialFlag(video::EMF_WIREFRAME,true);
core::vector3df position (location.m_posit.m_x, location.m_posit.m_y, location.m_posit.m_z);
collision = NewtonCreateSphere (nWorld, size.m_x, size.m_y, size.m_z, NULL);
imp.shootedBody = NewtonCreateBody (nWorld, collision);
NewtonConvexCollisionCalculateInertialMatrix(collision, inertia, centerofmass);
NewtonBodySetMassMatrix(imp.shootedBody, mass, mass * inertia[0], mass * inertia[1], mass * inertia[2]);
NewtonBodySetUserData (imp.shootedBody, imp.shootednode);
NewtonBodySetDestructorCallback (imp.shootedBody, PhysicsBodyDestructor);
NewtonBodySetTransformCallback (imp.shootedBody, PhysicsSetTransform);
NewtonBodySetForceAndTorqueCallback (imp.shootedBody, PhysicsApplyForceAndTorque);
NewtonBodySetMatrix (imp.shootedBody, &location[0][0]);
PhysicsSetTransform (imp.shootedBody, &location[0][0]);
dVector vel(-22.0f,0.0f,0.0f);
NewtonBodySetVelocity(imp.shootedBody, &vel[0]);
-
ellorenz
-
- Posts: 5
- Joined: Sat Sep 27, 2008 7:45 am
by ellorenz » Fri Mar 20, 2009 6:05 pm
-
ellorenz
-
- Posts: 5
- Joined: Sat Sep 27, 2008 7:45 am
by ODSTDare » Wed Oct 07, 2009 7:19 pm
Thanks for the link, VeT.
And ellorenz, did you really just quad post?!
*whisper* Edit button *whisper*
-
ODSTDare
-
by Stucuk » Wed Oct 07, 2009 9:06 pm
ODSTDare wrote:And ellorenz, did you really just quad post?!
Last post before yours was March 20th, so he didn't
just do anything.
-

Stucuk
-
- Posts: 801
- Joined: Sat Mar 12, 2005 3:54 pm
- Location: Scotland
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 4 guests