Collision detection
You say, if i did any scale on the objects, wich i did, i have to adjust the bounding box??
How do i do that?
thanks
You'll need to multiply this by the amount you scaled the entity.
I've tried with the entity->shape->box.radius as you said, but even like that i can't get this to work. Power render is detecting the colision far away from the objects.
I even tried not to scale any objects, and even like this the detection is far from good.
Can you give me a simple explanation on how to make the collision detection using the collision interface of power render using the PRCL_DistanceToPlane???
I would really apreciate if you could post some example code.
thanks
Ricardo
I'm using the entity->orientation.location.x and y and z, but i need to draw a box with the size of the entity, like if the entity is 50,50,50 size, i will compare the 3dbox of the entity with another 3d box of another entity to detect collision, bu i have a little problem. How do i know the size of the object in pixels??? Is there any structure where this data is saved?? I know it has to be, probably is whre the PR_MoveEntity and other are going to get the info.. Can you tell me, how do i get the info , please?
Thanks
void C3dSimpleObject :: TransformToWorldCoord()
{
for (int seg = 0; seg < m_pObject->num_segments; seg++)
m_pObject->segment_list[seg].flags |=FLAG_ALWAYS_VISIBLE;
/* Transform the object to world space */
PR_MatrixIdentity (PR_ViewMatrix);
PR_TransformEntity (m_pEntity);
/* Restore the transformation to camera space */
PR_SetActiveCamera (PR_CurrentCamera);
}
void C3dSimpleObject :: GetMassCenter(PR_POINT *Center)
{
PR_REAL TotalVertices=0;
TransformToWorldCoord();
Center->x=0; Center->y=0; Center->z=0;
for (int nseg=0; nsegnum_segments; nseg++)
{
TotalVertices+=m_pObject->segment_list[nseg].num_vertices;
for (int nverts=0; nvertssegment_list[nseg].num_vertices; nverts++)
{
Center->x+=m_pObject->segment_list[nseg].vertex_list[nverts].vdata->vx;
Center->y+=m_pObject->segment_list[nseg].vertex_list[nverts].vdata->vy;
Center->z+=m_pObject->segment_list[nseg].vertex_list[nverts].vdata->vz;
}
}
Center->x=Center->x/TotalVertices;
Center->y=Center->y/TotalVertices;
Center->z=Center->z/TotalVertices;
}
PR_REAL C3dSimpleObject :: GetRadius()
{
PR_POINT Center, VertexPoint, Dist;
PR_SEGMENT *seg;
PR_REAL fResult, fRadius;
fRadius=0;
GetMassCenter(&Center);
for (int nseg=0; nsegnum_segments; nseg++)
{
seg=m_pObject->segment_list;
for (int nverts=0; nvertssegment_list[nseg].num_vertices; nverts++)
{
VertexPoint.x=seg->vertex_list[nverts].vdata->vx;
VertexPoint.y=seg->vertex_list[nverts].vdata->vy;
VertexPoint.z=seg->vertex_list[nverts].vdata->vz;
MakeVector(&Center, &VertexPoint, &Dist);
fResult=LengthOfVector(&Dist);
if (fResult > fRadius)
fRadius=fResult;
}
seg++;
}
return fRadius;
I'm new with Power Render, so this is probably very basic, but i would like some help please.
I'm trying to make a simple game, just to practice, but i'm unable to make object collision detection. I'm using Pr_entitycolideradius but it doesn't seem to work. I know Power Render has collision detection routines but i don't know how to work with them. Can someone please tell me how do i detect 2 coliding entities?
Thanks