Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Guest Anonymous Poster

Collision detection

This topic is 6902 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Example 7 shows spherical collision detection between entities. If you are scaling the entities at all, you'll need to adjust the radius stored in the bounding box to match.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Thanks.. you were real fast.., but, i saw example7, and i'm making exactly as in example7, but it's not working.
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

Share this post


Link to post
Share on other sites
It's stored in entity->shape->bbox.radius.
You'll need to multiply this by the amount you scaled the entity.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanks..
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

Share this post


Link to post
Share on other sites
I've already given examples that do collision detection with polytopes. Look at the collide example that uses a set of volumes for collision.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I've already been in the collide example, but i don't understand it , anyway i've been tryng another aproach..
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

Share this post


Link to post
Share on other sites
If you use reset transform on the object in 3dsmax the scaling will be reset, Alternatively you could calc the radius:


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;

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thank you very much

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!