A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Executor » Fri Sep 04, 2009 7:21 am
I use convex cast. There is no problem with basic single collision objects (NewtonCreateSphere, NewtonCreateBox, NewtonCreateCone, etc), but it doesnt work with compound objects (NewtonCreateSphere, NewtonCreateBox, NewtonCreateCone + NewtonCreateCompoundCollision). What is problem?
If offsetMatrix is identity - all ok.
-
Executor
-
- Posts: 25
- Joined: Fri Sep 04, 2009 7:01 am
by Julio Jerez » Fri Sep 04, 2009 8:27 am
I do not think it works with compound shapes.
what are you doing?
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Executor » Fri Sep 04, 2009 12:22 pm
Object placement like in tutorial Tutorial_104_RayCastAndConvexCast.
ConvexCast dont work with compounds?
-
Executor
-
- Posts: 25
- Joined: Fri Sep 04, 2009 7:01 am
by Julio Jerez » Fri Sep 04, 2009 1:18 pm
There is a work around.
If I was going to write a funtion liek that I woudl just call convex cast in a loop.
- Code: Select all
Collisioninfo Info;
NewtonGetCollisionInfo (coll, info)
if (info.type == compount)
for ( i = 0; i < compoungCount; i ++) {
calacualte the matrix for shape [i]
convex cast (shape[i], matrix[i])
}
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Executor » Fri Sep 04, 2009 2:13 pm
And if I want the opposite, simple box put on compound mesh?
-
Executor
-
- Posts: 25
- Joined: Fri Sep 04, 2009 7:01 am
by Julio Jerez » Fri Sep 04, 2009 2:25 pm
if you cast a simple shape it will work on everything.
Actuatly on a secund thought, I have to verify if convex cast work on compound meshes at all.
I beleive it will not work because I do not remember making tah funtion recurse on child shapes,
I will verify tonigh and let you know. It sopdul be eassy to add tha piece of code if it is missing, and the it will work
what are you doing?
do you have a test to make it easier for me to test it?
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Executor » Fri Sep 04, 2009 4:56 pm
-
Executor
-
- Posts: 25
- Joined: Fri Sep 04, 2009 7:01 am
by Julio Jerez » Sat Sep 05, 2009 7:40 am
Ok I checked the convex cast code and teh infomation i gave you before was incorrect,
convex cast should work on all shapes, including compound collision, convex cast uses the funtion
- Code: Select all
dgInt32 dgWorld::CollideContinue (
dgCollision* collisionA,
const dgMatrix& matrixA,
const dgVector& velocA,
const dgVector& omegaA,
dgCollision* collisionB,
const dgMatrix& matrixB,
const dgVector& velocB,
const dgVector& omegaB,
dgFloat32& retTimeStep,
dgTriplex* points,
dgTriplex* normals,
dgFloat32* penetration,
dgInt32 maxSize,
dgInt32 threadIndex)
wich teh funtiosn used bu teh engien do do all type of collisions
so if it does not work for compound the it will fail on collison as well.
make sure you are making the compound shape corrently, you need to postion the shape just adding then at the origin of the shape is no enought
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Executor » Sat Sep 05, 2009 10:27 am
I use rotate in offsetMatrix. This used in tutorials for simple meshes too. But if rotate in offsetMatrix for compound shapes, then not work convexcast, but collision work perfect.
I can not use rotation in offsetMatrix for compound???
-
Executor
-
- Posts: 25
- Joined: Fri Sep 04, 2009 7:01 am
by Julio Jerez » Sat Sep 05, 2009 11:05 am
That does no make sence.
if collision works then convex cast will also work, because they both use the same function to calculate contacts.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Executor » Sat Sep 05, 2009 11:58 am
Have you watched my example demonstrates the problem? (upper in my post)
Code from sample:
- Code: Select all
NewtonCollision* MyCreateNewtonBox (NewtonWorld* world, Entity *ent, int shapeId)
{
dVector minBox;
dVector maxBox;
ent->GetBBox (minBox, maxBox);
dVector size (maxBox - minBox);
dVector origin ((maxBox + minBox).Scale (0.5f));
size.m_w = 1.0f;
origin.m_w = 1.0f;
// make and offset Matrix for this collision shape.
dMatrix offset = dRollMatrix(M_PI / 2); <------------------------------- if identity (NO rotate) then ok
offset.m_posit = origin;
// now create a collision Box for this entity
return NewtonCreateBox (world, size.m_x, size.m_y, size.m_z, shapeId, &offset[0][0]);
}
Collision work fine with rotation and without rotation! Convexcast not!
Problem stay if compound mesh have one shape. In sample i create two shapes (boxes).
See sample please...
-
Executor
-
- Posts: 25
- Joined: Fri Sep 04, 2009 7:01 am
by Julio Jerez » Sat Sep 05, 2009 1:31 pm
Tha code does not make a compound shape is just rotate the shape, but i lieabe in teh sam epal;ce.
I check the code and it works.
you are making a compound collision of two boxes that are rotated but in the same place.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Executor » Sat Sep 05, 2009 1:43 pm
Julio Jerez wrote:Tha code does no make a compound shape is just rotate the shape, but i lieabe in teh sam epal;ce.
My code does make compound shape:
- Code: Select all
// create compound
Entity* smilly2;
NewtonBody* smillyBody2;
smilly2 = sceneManager->CreateEntity();
smilly2->LoadMesh ("Smilly.dat");
smilly2->m_curPosition.m_x = 0.0f;
smilly2->m_curPosition.m_z = 0;
smilly2->m_curPosition.m_y = 1;
smilly2->m_prevPosition = smilly2->m_curPosition;
#if 1
// some stupid compound
NewtonCollision* shapedArray[2];
shapedArray[0] = MyCreateNewtonBox (world, smilly2, 0);
shapedArray[1] = MyCreateNewtonBox (world, smilly2, 0);
shape = NewtonCreateCompoundCollision (world, 2, shapedArray, 0);
smillyBody2 = CreateRigidBody (world, smilly2, shape, 0.0f);
NewtonReleaseCollision (world, shape);
NewtonReleaseCollision (world, shapedArray[0]);
NewtonReleaseCollision (world, shapedArray[1]);
#else
// simple box - cast ok
shape = MyCreateNewtonBox (world, smilly2, 0);
smillyBody2 = CreateRigidBody (world, smilly2, shape, 0.0f);
NewtonReleaseCollision (world, shape);
#endif
You see code in archive or not???
I check the code and it works.
My code work for you!?!? Why not work for me?
Newton 2.08, VS2008
you are making a compound collision of two boxes that are rotated but in the same place.
And that this is not correct? Why?
Last edited by
Executor on Sat Sep 05, 2009 1:56 pm, edited 2 times in total.
-
Executor
-
- Posts: 25
- Joined: Fri Sep 04, 2009 7:01 am
by Julio Jerez » Sat Sep 05, 2009 1:55 pm
This will make two boxes in the exat same place.
- Code: Select all
NewtonCollision* shapedArray[2];
shapedArray[0] = MyCreateNewtonBox (world, smilly2, 0);
shapedArray[1] = MyCreateNewtonBox (world, smilly2, 0);
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Executor » Sat Sep 05, 2009 1:56 pm
Boxes in same place - this is for simple. This matter what does not affect. Do not make me a complex scene for a simple example.
If you want:
- Code: Select all
// some stupid compound
NewtonCollision* shapedArray[1];
shapedArray[0] = MyCreateNewtonBox (world, smilly2, 0);
shape = NewtonCreateCompoundCollision (world, 1, shapedArray, 0);
smillyBody2 = CreateRigidBody (world, smilly2, shape, 0.0f);
NewtonReleaseCollision (world, shape);
NewtonReleaseCollision (world, shapedArray[0]);
Result identicaly.
My example in archive does not show the problem? I have to make another example?
-
Executor
-
- Posts: 25
- Joined: Fri Sep 04, 2009 7:01 am
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 54 guests