Newton physics displays good movement and collision of objects:
[img]http://cat-.front.ru/Screen.jpg[/img]
Need help in solving such problems:
1 Definition of the coordinates of the collision object (bullet) with the surface or other objects to display the
explosion.
2 How to distinguish between different objects (soil, water, concrete) to display various types of explosions?
Demo and code (3.7Mb) here: http://uploadbox.com/files/5deeac1434/
Control:
Fire - left mouse
F3-F4 - optical sight
==============================================
Newton physics bullet example + code + need help
Re: Newton physics bullet example + code + need help
1 Point of collision object and terrain
...
f32 p0[3];
f32 p1[3];
core::vector3df pos=cubes[total-1]->node->getAbsolutePosition();
p0[0]=pos.X;
p0[1]=pos.Y;
p0[2]=pos.Z;
NewtonBodyGetVelocity(cubes[total-1]->body, p1);
p1[0]=p1[0]*0.05f+p0[0];
p1[1]=p1[1]*0.05f+p0[1];
p1[2]=p1[2]*0.05f+p0[2];
f32 normal[3]={0,0,0};
int attribute=2;
rez=NewtonCollisionRayCast(g_newtonmap,p0,p1,normal,&attribute) ;
if(rez<1.2f) { //if collision
test->setPosition(core::vector3df(p0[0],p0[1],p0[2]));
swprintf(text, 255, L"Collision point on terrain %f %f %f %f",rez,p0[0],p0[1],p0[2]);
font->draw(text, core::rect<s32>(30,60,500,80),video::SColor(25,25,25,25));
}
...
...
f32 p0[3];
f32 p1[3];
core::vector3df pos=cubes[total-1]->node->getAbsolutePosition();
p0[0]=pos.X;
p0[1]=pos.Y;
p0[2]=pos.Z;
NewtonBodyGetVelocity(cubes[total-1]->body, p1);
p1[0]=p1[0]*0.05f+p0[0];
p1[1]=p1[1]*0.05f+p0[1];
p1[2]=p1[2]*0.05f+p0[2];
f32 normal[3]={0,0,0};
int attribute=2;
rez=NewtonCollisionRayCast(g_newtonmap,p0,p1,normal,&attribute) ;
if(rez<1.2f) { //if collision
test->setPosition(core::vector3df(p0[0],p0[1],p0[2]));
swprintf(text, 255, L"Collision point on terrain %f %f %f %f",rez,p0[0],p0[1],p0[2]);
font->draw(text, core::rect<s32>(30,60,500,80),video::SColor(25,25,25,25));
}
...