Jump to content


- - - - -

collision normal: rotating obb and particle


  • You cannot reply to this topic
3 replies to this topic

#1 kyuzo

    New Member

  • Members
  • PipPip
  • 29 posts

Posted 05 July 2008 - 11:12 AM

i'm using the slabs based method ( http://www.siggraph....ce/rtinter3.htm )for obb-particle collision detection, and it's working well for moving boxes/particles; my problem is that i cant seem to find the collision normal in case of a still and rotating box and a still particle.
i would appreciate any help.

#2 Dim_Yimma_H

    Member

  • Members
  • PipPip
  • 49 posts

Posted 05 July 2008 - 02:15 PM

If you've computed the particle line, relative to box rotation (do you do like that?), you should be able to get the normal of the "Tnear" plane in box space (since it looks like an axis-aligned box on the page you linked to).
That normal can be rotated in the opposite direction of the box to get the normal in world space.

I haven't used the "slabs" method, but if I understood correctly after skimming through it, that should be possible.

#3 kyuzo

    New Member

  • Members
  • PipPip
  • 29 posts

Posted 07 July 2008 - 07:31 AM

thanks for your reply; i'm not sure i understand what the particle line is.

the problem is that, as the box and the particle are not moving, my code detects the intersection, but the time of collision is always =0, so i dont know wich face of the box collide with the particle.

here's some code, maybe it will help you to help me :)


bool Particle::slabIntersect(float min,float max,float start,float end,float &enter,float &exit){

	float dir=end-start;

	if(fabs(dir)<.0001)//ray paralel to slab

		if(start<min||start>max)return false;//outside the slab planes

		else{

			return true;//inside

		}

	float tsenter=(min-start)/dir;

	float tsexit=(max-start)/dir;

	if(tsenter>tsexit){

		float tmp=tsenter;

		tsenter=tsexit;

		tsexit=tmp;

	}

	if(enter>tsexit||tsenter>exit)return false;

	else{

		enter=enter>tsenter?enter:tsenter;

		exit=exit<tsexit?exit:tsexit;

		return true;

	}

}



bool PEngine::particleIntersectOOBB(Particle *p,OOBB *bbox,float &time,Vector &normal,Vector &point){		

	bbox->X.set(1,0,0);

	bbox->Y.set(0,1,0);

	bbox->Z.set(0,0,1);


	float m[16];

	bbox->m_orientation.toMatrix(m);

	bbox->X.matrixMult(m);

	bbox->Y.matrixMult(m);

	bbox->Z.matrixMult(m);

	float enter=0,exit=1,x=0;						

	Vector axii[]={bbox->X,bbox->Y,bbox->Z};

	

	Vector velocity=p->m_velocity-bbox->m_velocity;		

	for(int i=0;i<3;i++){

		float c=bbox->m_position.dot(axii[i]);

		float min=c-bbox->m_ext[i];

		float max=c+bbox->m_ext[i];

		float s=p->m_position.dot(axii[i]);

		float e=(p->m_position+velocity).dot(axii[i]);

		if(!p->slabIntersect(min,max,s,e,enter,exit))return false;

		if(x<enter){x=enter;normal=axii[i];}

	}

	time=enter;

	point=p->m_position+velocity*time;

	return true;

}



#4 Dim_Yimma_H

    Member

  • Members
  • PipPip
  • 49 posts

Posted 12 July 2008 - 10:12 AM

I see, you define the slabs using the transformed box axes. They're parallell too the normals, but the step-based overlap test makes it difficult to get the normal.

When I did a completely step-based overlap test I iterated through the planes (the planes can be computed from the axes) to find the plane that's closest to the intersecting particle, and that plane is most likely to be the first/recently intersected plane. Maybe you can do something like that, once the intersection has been confirmed to be true?

kyuzo said:

i'm not sure i understand what the particle line is
With particle line I meant the movement line of the particle.

I thought you transformed the particle relatively to the box, and that would've given the particle movement line (in box space). Maybe that's too much of a change from the code as it looks like now.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users