make collision only use CollisionTools

li574000

14-03-2009 03:27:17

i want to make raycast and collision detect between entitys .but I only want to use OgreNewt::Collision ,don't want to use OgreNewt::Body. now i meet some problem.
1,how to set the OgreNewt::Collision position and oriention?
for example ,CollisionPrimitives::Box,ConvexHull or TreeCollision.
2,when i scale a entiy,how to simultaneity scale its collision
m_collison=new OgreNewt::CollisionPrimitives::ConvexHull(m_world,chanode);
chanode->scale(5,5,5);
when i have down this ,i found the ConvexHull collision don't scale ,why?how can i make them scale simultaneously

sorry for my poor english ,i hope i speak clearly.

li574000

14-03-2009 07:30:18

i only want to use CollisionTools to make collision detect,but i meet thoese problem.

melven

14-03-2009 14:25:05

What version of newton do you use?

for 1.53 and 2.0:
1. You can use the collision-tools functions to determine contacts between collisions. Have a look at OgreNewt_Tools. You can test with the functions CollisionCollideContinue and CollisionCollide if two collisions interact. They allow you to set a position and orientation. In order to get all contacts you would need to iterate through all collisions like this:

for(int i = 0; i < numCol; i++)
for(int j = i+1; j < numCol; j++)
// test if there is a contact between collision i and collision j

2. In Order to scale a collision, you can use the ConvexModifierCollision. I think you need to apply the scale to the collision by yourself, if the node is scaled...


for 2.0:
You can use the library as usual, but only call World::collisionUpdate instead of of World::update.

li574000

16-03-2009 03:36:40

thanks melven ,but i still can't scaled the collision .i have try a lost of ways .
for example,
m_collison=new OgreNewt::CollisionPrimitives::ConvexHull(m_world,mynode);
mynode->scale(3,3,3);
mynode->rotate(Ogre::Vector3(0,1,0),Ogre::Radian(1));
mynode->translate(Ogre::Vector3(50,10,0),Ogre::Node::TS_LOCAL);
//it does't wrok infact
OgreNewt::ConvexModifierCollision* col=new OgreNewt::ConvexModifierCollision(m_world,m_collison);
col->setScalarMatrix(Ogre::Matrix4::getScale(mynode->_getDerivedScale()));
the second way i try is:
//infact the _getFullTransform() function has include scale information ,but it still does't work.
OgreNewt::Converters::Matrix4ToMatrix(view.m_mynode->_getFullTransform(),firstmatrix);
OgreNewt::Converters::Matrix4ToMatrix(view.m_secnode->_getFullTransform(),secondmatrix);
ret2=NewtonCollisionCollide(view.m_world->getNewtonWorld(),5,view.m_collison->getNewtonCollision(),firstmatrix,
view.m_seccolli->getNewtonCollision(),secondmatrix,dpos,dnormal,dpry);
i really don't know how to scale a collision,any help will be very appreciate

melven

16-03-2009 09:57:05

I think it doesn't transform the original collision, so you need to use col instead of m_collision afterwards!
I don't use ConvexModifierCollisions, so I'm not shure...

li574000

17-03-2009 00:37:14

yes,you are right,i need use col to instead m_collison,but i found it only take effect to ConvexHull,not to TreeCollision.