Jump to content
  • Advertisement
Sign in to follow this  

trying to show the ray D3DXintersect creates

This topic is 3935 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

i have set the RayPos , to the bottom far left corner of the bounding box and RayDir to top far corner of the bounding box , then draw a line to represent the ray but when i move the mesh with the bounding box around in to the another mesh , it dosent say intersected screenshot http://img352.imageshack.us/my.php?image=bblinehi0.jpg here is the intersect code this code is inside the draw primitive function btw
        D3DXVECTOR3 RayPos;
	BOOL pHit = false;
	DWORD FaceIndex;
	float u;
	float v;
	float distance;

	RayDir.x = minBounds.x;
	RayDir.y = maxBounds.y;
	RayDir.z = minBounds.z;

	RayPos.x = minBounds.x;
    RayPos.y = minBounds.y;
	RayPos.z = maxBounds.z;
      	hr = D3DXIntersect(meshSpaceship2 ,
		         &RayPos , 
				 &RayDir ,
				 &pHit , 
				 &FaceIndex , 
				 &u , 
				 &v , 

		       sprintf(data , "%s\n" , "intersecting");
               WriteConsole(Console,data, sizeof(data) , &written, NULL);


Share this post

Link to post
Share on other sites
I think what you meant for the RayDir is:
TopFarCorner - BottomFarLeftCorner

Setting a position vector as a RayDirection only works if the source of the ray is the origin.

A direction vector in 3D space is the result of PositionA - PositionB. Only when PositionB is the origin (0, 0, 0), can we then simplify the direction to PositionA.

If you doing collision testing, I thinking using separating axis therom(SAT) test is more robust. For more information on the method, you can check out:


Share this post

Link to post
Share on other sites
yeh i was thinking of creating 4 rays going upwards for each corner but i know the other way of testing collision with bounding box , is the intersect function better when you its a first person type game where you move the camera to move the player ,

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!