A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Slick » Wed Nov 27, 2013 3:35 pm
I created two boxes and slider joint between them.
- Code: Select all
//////////////////////////////////////////////////////////////////////////
//slider joint
Vector3 size(12.0f,8.0f,12.0f);
dNewtonCollision* col = new dNewtonCollisionBox(m_physicsWorld, size.x, size.y, size.z, m_all);
Entity* ent = mSceneMgr->createEntity(MakeName("box"),"box.mesh");
Matrix4 matrix;
matrix.makeTransform(Vector3(0,15,-50), Vector3::UNIT_SCALE, Quaternion::IDENTITY);
SceneNode* node2 = CreateNode(mSceneMgr,ent,matrix.getTrans(),matrix.extractQuaternion());
node2->setScale(size);
OgreNewtonDynamicBody* basebody = new OgreNewtonDynamicBody(GetPhysics(), 5.0f, col, node2, matrix);
dNewtonCollision* col2 = new dNewtonCollisionBox(m_physicsWorld, 1.0, 1.0, 1.0, m_all);
ent = mSceneMgr->createEntity(MakeName("box"),"box.mesh");
Matrix4 matrix2;
matrix2.makeTransform(Vector3(0,25,-50), Vector3::UNIT_SCALE, Quaternion::IDENTITY);
SceneNode* node3 = CreateNode(mSceneMgr,ent,matrix2.getTrans(),matrix2.extractQuaternion());
OgreNewtonDynamicBody* childbody = new OgreNewtonDynamicBody(GetPhysics(), 5.0f, col2, node3, matrix2);
Matrix4 aligmentMatrix (Quaternion (Radian (3.141592f * 0.5f), Vector3 (0.0f, 1.0f, 0.0f)));
// Matrix4 aligmentMatrix (Quaternion (Radian (3.141592f * 0.0f), Vector3 (0.0f, 1.0f, 0.0f)));
// Matrix4 aligmentMatrix (Quaternion() Quaternion::IDENTITY, Vector3 (0.0f, 0.0f, 1.0f));
Matrix4 baseMatrix((basebody->GetMatrix() * aligmentMatrix).transpose());
m_slider1 = new dNewtonSliderActuator (&baseMatrix[0][0], 0.1f, 1.0f, 2.5f, childbody, basebody);
I don't understand the alignmentmatrix. In my test above I just want the smaller box to slide in Y direction (Up for me) and down when a force is applied. The boxes appear unstable after a short time and zoom off into space.
Is there a simple example with explanations?
What does minposit and maxposit mean? Does it mean the smallest and largest range of the slider?
What does speed mean? Is it the rate the actuator moves to get to a position? What are valid values 0..1 or can you do greater?
The aligmentMatrix confuses me and is tranpose putting it into local coords of the object?
thanks for any help.
A demo with simple joints for each joint would be great I guess.
Last edited by
Slick on Wed Nov 27, 2013 5:04 pm, edited 1 time in total.
-
Slick
-
- Posts: 330
- Joined: Sat Feb 07, 2004 7:24 pm
- Location: LA last and France now
by Julio Jerez » Wed Nov 27, 2013 3:56 pm
where did you get that code fragment form?
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Slick » Wed Nov 27, 2013 4:01 pm
It is my code but using a few pieces from the forklift demo. I just don't understand it well enough I guess. This is what it looks like but the boxes dance around. It is probably from my code - the alignmentmatrix or one of the actuator values?

- 11-27-2013 11-59-50 AM.png (117.63 KiB) Viewed 3029 times
-
Slick
-
- Posts: 330
- Joined: Sat Feb 07, 2004 7:24 pm
- Location: LA last and France now
by Julio Jerez » Wed Nov 27, 2013 4:14 pm
all joints newton have teh same interphase.
basciall you have two bodies, and you and to restrct relative motion alone one or more degree of freedom.
the wat you set the space that teh joint work is by passing and transformation matrix, where the x axis is the principal axis of action
the y is the secund and so on.
for example a slider, the x axis will be the direction along the two body will move relative to each other
I has to transpose the matrix because Ogre use the matrix literally organized as column, newton uses as rows
for the slider actuators, is liek sldier control by a motor, yo uset the position and teh moving part will try to go to the position at teh speed you set.
the limit are self explantory.
had you seen the demo07_standardJoints_d demo. is has exmple of hwo to set slider joints with limits.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Slick » Wed Nov 27, 2013 4:21 pm
I'll take a look at that demo in the Newton demos. hopefully I will realize what i did wrong so that they don't explode.
oh demo7 in the ogrenewton. That is the forklift demo. I have been looking at that but as I said I struggle understanding what the values mean. Also ogre is Y up so adds another level of confusion. I'll keep going.
-
Slick
-
- Posts: 330
- Joined: Sat Feb 07, 2004 7:24 pm
- Location: LA last and France now
by Julio Jerez » Wed Nov 27, 2013 4:26 pm
in ogreNetwon,
this is teh code that creat a slider
- Code: Select all
static OgreNewtonDynamicBody* CreateBox (SceneManager* const sceneMgr, OgreNewtonWorld* const world, const Vector3& location, const Vector3& size)
{
dNewtonCollisionBox shape (world, size.x, size.y, size.z, m_all);
// create a texture for using with this material
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().load("sand1b.jpg", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
// make a material to use with this mesh
MaterialPtr renderMaterial = MaterialManager::getSingleton().create("ramp", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
renderMaterial->getTechnique(0)->getPass(0)->setLightingEnabled(true);
renderMaterial->getTechnique(0)->getPass(0)->createTextureUnitState("sand1b.jpg");
renderMaterial->setAmbient(0.2f, 0.2f, 0.2f);
OgreNewtonMesh boxMesh (&shape);
boxMesh.Triangulate();
int materialId = boxMesh.AddMaterial(renderMaterial);
boxMesh.ApplyBoxMapping (materialId, materialId, materialId);
// create a manual object for rendering
ManualObject* const object = boxMesh.CreateEntity(MakeName ("ramp"));
MeshPtr mesh (object->convertToMesh (MakeName ("ramp")));
//Matrix4 matrix (Matrix4::IDENTITY);
Matrix4 matrix (Matrix4::IDENTITY);
matrix.setTrans (Vector3 (location.x, location.y, location.z));
Entity* const ent = sceneMgr->createEntity(MakeName ("ramp"), mesh);
SceneNode* const node = CreateNode (sceneMgr, ent, matrix.getTrans(), matrix.extractQuaternion());
OgreNewtonDynamicBody* const body = new OgreNewtonDynamicBody (world, 10.0f, &shape, node, matrix);
delete object;
return body;
}
static OgreNewtonDynamicBody* CreateWheel (SceneManager* const sceneMgr, OgreNewtonWorld* const world, const Vector3& location, dFloat radius, dFloat height)
{
dNewtonCollisionChamferedCylinder shape (world, radius, height, m_all);
// create a texture for using with this material
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().load("smilli.tga", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
// make a material to use with this mesh
MaterialPtr renderMaterial = MaterialManager::getSingleton().create("wheel", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
renderMaterial->getTechnique(0)->getPass(0)->setLightingEnabled(true);
renderMaterial->getTechnique(0)->getPass(0)->createTextureUnitState("smilli.tga");
renderMaterial->setAmbient(0.2f, 0.2f, 0.2f);
OgreNewtonMesh boxMesh (&shape);
boxMesh.Triangulate();
int materialId = boxMesh.AddMaterial(renderMaterial);
boxMesh.ApplyCylindricalMapping (materialId, materialId);
// create a manual object for rendering
ManualObject* const object = boxMesh.CreateEntity(MakeName ("ramp"));
MeshPtr mesh (object->convertToMesh (MakeName ("ramp")));
//Matrix4 matrix (Matrix4::IDENTITY);
Matrix4 matrix (Matrix4::IDENTITY);
matrix.setTrans (Vector3 (location.x, location.y, location.z));
Entity* const ent = sceneMgr->createEntity(MakeName ("ramp"), mesh);
SceneNode* const node = CreateNode (sceneMgr, ent, matrix.getTrans(), matrix.extractQuaternion());
OgreNewtonDynamicBody* const body = new OgreNewtonDynamicBody (world, 10.0f, &shape, node, matrix);
delete object;
return body;
}
void AddSlider (SceneManager* const sceneMgr, OgreNewtonWorld* const world, const Vector3& origin)
{
// make a reel static
OgreNewtonDynamicBody* const reel = CreateBox (sceneMgr, world, origin + Vector3 (0.0f, 4.0f, 0.0f), Vector3 (8.0f, 0.25f, 0.25f));
reel->SetMassAndInertia (0.0f, 0.0f, 0.0f, 0.0f);
OgreNewtonDynamicBody* const wheel = CreateWheel (sceneMgr, world, origin + Vector3 (0.0f, 4.0f, 0.0f), 1.0f, 0.5f);
Matrix4 matrix (wheel->GetMatrix());
dNewtonSliderJoint* const slider = new dNewtonSliderJoint (&matrix.transpose()[0][0], wheel, reel);
// enable limit of first axis
slider->EnableLimits(true);
// set limit on second axis
slider->SetLimis (-4.0f, 4.0f);
}
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Slick » Wed Nov 27, 2013 4:56 pm
That worked. Now I need to study it to see where I went wrong.
-
Slick
-
- Posts: 330
- Joined: Sat Feb 07, 2004 7:24 pm
- Location: LA last and France now
by Slick » Wed Nov 27, 2013 5:04 pm
It was actually the dNewtonSliderActuator that I was trying to get working. The slider code is great though and might help me understand the actuator.
-
Slick
-
- Posts: 330
- Joined: Sat Feb 07, 2004 7:24 pm
- Location: LA last and France now
by Julio Jerez » Wed Nov 27, 2013 5:29 pm
later I see if If I add actuators sample as well.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest