Jump to content
  • Advertisement
Sign in to follow this  

Picking MeshFVF ?

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

this things makes my head blow.... i have try picking using D3DXIntersect to select mesh.... if the mesh is load from .x file, the picking just can sometime select a part of the mesh. and the main problem: i used D3DXCreateMeshFVF to create my terrain, but I can't select the terrain.... Can someone show me example to select triangle of my terrain mesh... i heard that we must check every triangle vertices in vertex buffer of mesh? is it true...? how to do that..? PLEASE HELP ME .... this is the ray techniques i used, i took it from book: Introduction to Game Programming using Direct X 9.0, Frank Luna
//ray structure
namespace d3d{
struct Ray  //digunakan untuk intersect
		D3DXVECTOR3 _origin;
		D3DXVECTOR3 _direction;
d3d::Ray CalcPickingRay(int x, int y,IDirect3DDevice9* Device)
	float px = 0.0f;
	float py = 0.0f;


	Device->GetTransform(D3DTS_PROJECTION, &proj);

	px = ((( 2.0f*x) / vp.Width)  - 1.0f) / proj(0, 0);
	py = (((-2.0f*y) / vp.Height) + 1.0f) / proj(1, 1);

	d3d::Ray ray;
	ray._origin    = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	ray._direction = D3DXVECTOR3(px, py, 1.0f);

	return ray;

// after calculate ray, the ray and the Inverse of view matrix passing through this function

void TransformRay(d3d::Ray* ray, D3DXMATRIX* T)
	// transform the ray's origin, w = 1.

	// transform the ray's direction, w = 0.

	// normalize the direction
	D3DXVec3Normalize(&ray->_direction, &ray->_direction);
after that i use D3DXintersect...

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.

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!