problems with picking method

Started by
9 comments, last by Stowelly 17 years, 10 months ago
ive implemented the method demonstrated on the toymaker site and am having a problem with the capture area, it seems to respond about halfway up the object and abit further past it, im using the following method http://img518.imageshack.us/img518/4554/00337gc.jpg http://img148.imageshack.us/img148/6505/00349ao.jpg
D3DVIEWPORT9 mainViewport;
m_pd3dDevice->GetViewport( &mainViewport );
m_pd3dDevice->GetTransform(D3DTS_PROJECTION,&matProj);



D3DXVECTOR3 v;
v.x =  ( ( ( 2.0f * mouseX ) / mainViewport.Width ) - 1 ) / matProj._11;
v.y = -( ( ( 2.0f * mouseY ) / mainViewport.Height ) - 1 ) / matProj._22;
v.z =  1.0f;
mousePos = v;

D3DXMATRIX view;
TheCamera->getViewMatrix(&view);
D3DXMatrixInverse( &m, NULL, &view );
// Transform the screen space pick ray into 3D space
rayDir.x = v.x*m._11 + v.y*m._21 + v.z*m._31;
rayDir.y = v.x*m._12 + v.y*m._22 + v.z*m._32;
rayDir.z = v.x*m._13 + v.y*m._23 + v.z*m._33;
rayOrigin.x = m._41;
rayOrigin.y = m._42;
rayOrigin.z = m._43;

// Use inverse of matrix
D3DXMATRIX matInverse;

D3DXMatrixInverse(&matInverse,NULL,&xFiles[0].entityWorld);

// Transform ray origin and direction by inv matrix
D3DXVECTOR3 rayObjOrigin,rayObjDirection;

D3DXVec3TransformCoord(&rayObjOrigin,&rayOrigin,&matInverse);
D3DXVec3TransformNormal(&rayObjDirection,&rayDir,&matInverse);
D3DXVec3Normalize(&rayObjDirection,&rayObjDirection);
float distanceToCollision = 0;

BOOL intersect;
rayIntersect(&xFiles[0],&rayObjOrigin,&rayObjDirection,&distanceToCollision,&intersect);
stringstream ss;
ss << distanceToCollision;
string dist = ss.str();

if (intersect)
{
MessageBox(0,dist.c_str(),"Error",MB_OK);
}
}


void objMan::rayIntersect(CXFileEntity * mesh,D3DXVECTOR3 *rayObjOrigin,D3DXVECTOR3 * rayObjDirection,float *distanceToCollision, BOOL *hit)
{
D3DXIntersect(mesh->xMesh, rayObjOrigin, rayObjDirection,hit, NULL,NULL, NULL, distanceToCollision, NULL, NULL);


}
cheers
http://stowelly.co.uk/
Advertisement
You might want to try: D3DXVec3Unproject
cheers does D3DXVec3Unproject return the ray origin or the ray direction?
http://stowelly.co.uk/
bump

sorry im not too clued up on this
http://stowelly.co.uk/
You get a point in 3d space with D3DXVec3Unproject.

To get something usable you simply call it two times with different z values. This gets you simply two points in world space. You can use one as the ray origin and use the difference as the ray direction for intersection tests.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

So as not to duplicate a thread with a similar problem I'll post my problem with picking here. Hope thats the right thing to do.

Anyway I am using Managed DirectX with C++ 2003 .Net 1.1 with the April version of DirectX 9c.

I have a plane drawn 36x36 grids and using examples on various sites on the net I managed to get a picking piece of code up and running but for some reason it is not working. Heres the segments of code involved.

void DXForm::OnMouseDown(Object*  sender, MouseEventArgs*  pArgs){	Viewport vp;	Matrix world;	Matrix view;	Matrix projection;	vp = m_dxbase->Device->Viewport;	world = m_dxbase->Device->Transform->World;	projection = m_dxbase->Device->Transform->Projection;	view = m_dxbase->Device->Transform->View;	Vector3 RayPos;	RayPos = Vector3();	RayPos.X = (float)pArgs->X;	RayPos.Y = (float)pArgs->Y;	Vector3 Near;	Vector3 Far;	Near = Vector3::Unproject(Vector3(RayPos.X,RayPos.Y,0),__box(vp),world,view,projection);	Far = Vector3::Unproject(Vector3(RayPos.X,RayPos.Y,1),__box(vp),world,view,projection);	Vector3 RayDir;	RayDir = Vector3::Subtract(Far,Near);	IntersectInformation* ii = m_plane->PickVertex(RayPos,RayDir);}


IntersectInformation* DXPlane::PickVertex(Vector3 RayPos,Vector3 RayDir){	return m_primitives->PickVertex(RayPos,RayDir);}


IntersectInformation* DXPrimitive::PickVertex(Vector3 RayPos,Vector3 RayDir){	Vector3 tempV3a;	Vector3 tempV3b;	Vector3 tempV3c;	IntersectInformation ii;	FileStream* fs;	StreamWriter* sw;	fs = __gc new FileStream("PickVertex.txt",FileMode::CreateNew);	sw = __gc new StreamWriter(fs);	sw->WriteLine(String::Format("RayPos = {0}, RayDir = {1}",__box(RayPos),__box(RayDir)));	for (int i = 0; i < m_vertexCount-2; i+=3)	{		if (m_cvt == DXBase::CustomVertexType::NormalisedColored)		{			ii = IntersectInformation();			tempV3a = Vector3(m_PNCVerts.X,m_PNCVerts.Y,m_PNCVerts.Z);			tempV3b = Vector3(m_PNCVerts[i+1].X,m_PNCVerts[i+1].Y,m_PNCVerts[i+1].Z);			tempV3c = Vector3(m_PNCVerts[i+2].X,m_PNCVerts[i+2].Y,m_PNCVerts[i+2].Z);			sw->WriteLine(String::Format("i={0}",__box(i)));			sw->WriteLine(String::Format("V3a={0},{1},{2}",__box(tempV3a.X),__box(tempV3a.Y),__box(tempV3a.Z)));			sw->WriteLine(String::Format("V3b={0},{1},{2}",__box(tempV3b.X),__box(tempV3b.Y),__box(tempV3b.Z)));			sw->WriteLine(String::Format("V3c={0},{1},{2}",__box(tempV3c.X),__box(tempV3b.Y),__box(tempV3c.Z)));			bool found = Geometry::IntersectTri(tempV3a,tempV3b,tempV3c,RayPos,RayDir,&ii);			if (found) 			{				sw->WriteLine(String::Format("Found : {0}",__box(found)));				i = m_vertexCount;			}		}	}	sw->Close();	return &ii;}


As you can see I have outputted the values being tested to see why it isn't working. The contents of the file are thus:

RayPos = X: 272,Y: 342,Z: 0 RayDir = X: -0.129,Y: -5.736,Z: 6i=0V3a=-70,0,-100V3b=-65,0,-100V3c=-60,0,-100i=3V3a=-55,0,-100V3b=-50,0,-100V3c=-45,0,-100i=6V3a=-40,0,-100V3b=-35,0,-100V3c=-30,0,-100i=9V3a=-25,0,-100V3b=-20,0,-100V3c=-15,0,-100i=12V3a=-10,0,-100V3b=-5,0,-100V3c=0,0,-100i=15V3a=5,0,-100V3b=10,0,-100V3c=15,0,-100i=18V3a=20,0,-100V3b=25,0,-100V3c=30,0,-100i=21V3a=35,0,-100V3b=40,0,-100V3c=45,0,-100i=24V3a=50,0,-100V3b=55,0,-100V3c=60,0,-100i=27V3a=65,0,-100V3b=70,0,-100V3c=75,0,-100i=30V3a=80,0,-100V3b=85,0,-100V3c=90,0,-100i=33V3a=95,0,-100V3b=100,0,-100V3c=105,0,-100i=36V3a=110,0,-100V3b=-70,0,-95V3c=-65,0,-95i=39V3a=-60,0,-95V3b=-55,0,-95V3c=-50,0,-95i=42V3a=-45,0,-95V3b=-40,0,-95V3c=-35,0,-95i=45V3a=-30,0,-95V3b=-25,0,-95V3c=-20,0,-95i=48V3a=-15,0,-95V3b=-10,0,-95V3c=-5,0,-95i=51V3a=0,0,-95V3b=5,0,-95V3c=10,0,-95i=54V3a=15,0,-95V3b=20,0,-95V3c=25,0,-95i=57V3a=30,0,-95V3b=35,0,-95V3c=40,0,-95i=60V3a=45,0,-95V3b=50,0,-95V3c=55,0,-95i=63V3a=60,0,-95V3b=65,0,-95V3c=70,0,-95i=66V3a=75,0,-95V3b=80,0,-95V3c=85,0,-95i=69V3a=90,0,-95V3b=95,0,-95V3c=100,0,-95i=72V3a=105,0,-95V3b=110,0,-95V3c=-70,0,-90i=75V3a=-65,0,-90V3b=-60,0,-90V3c=-55,0,-90i=78V3a=-50,0,-90V3b=-45,0,-90V3c=-40,0,-90i=81V3a=-35,0,-90V3b=-30,0,-90V3c=-25,0,-90i=84V3a=-20,0,-90V3b=-15,0,-90V3c=-10,0,-90i=87V3a=-5,0,-90V3b=0,0,-90V3c=5,0,-90i=90V3a=10,0,-90V3b=15,0,-90V3c=20,0,-90i=93V3a=25,0,-90V3b=30,0,-90V3c=35,0,-90i=96V3a=40,0,-90V3b=45,0,-90V3c=50,0,-90i=99V3a=55,0,-90V3b=60,0,-90V3c=65,0,-90i=102V3a=70,0,-90V3b=75,0,-90V3c=80,0,-90i=105V3a=85,0,-90V3b=90,0,-90V3c=95,0,-90i=108V3a=100,0,-90V3b=105,0,-90V3c=110,0,-90i=111V3a=-70,0,-85V3b=-65,0,-85V3c=-60,0,-85i=114V3a=-55,0,-85V3b=-50,0,-85V3c=-45,0,-85i=117V3a=-40,0,-85V3b=-35,0,-85V3c=-30,0,-85i=120V3a=-25,0,-85V3b=-20,0,-85V3c=-15,0,-85i=123V3a=-10,0,-85V3b=-5,0,-85V3c=0,0,-85i=126V3a=5,0,-85V3b=10,0,-85V3c=15,0,-85i=129V3a=20,0,-85V3b=25,0,-85V3c=30,0,-85i=132V3a=35,0,-85V3b=40,0,-85V3c=45,0,-85i=135V3a=50,0,-85V3b=55,0,-85V3c=60,0,-85i=138V3a=65,0,-85V3b=70,0,-85V3c=75,0,-85i=141V3a=80,0,-85V3b=85,0,-85V3c=90,0,-85i=144V3a=95,0,-85V3b=100,0,-85V3c=105,0,-85i=147V3a=110,0,-85V3b=-70,0,-80V3c=-65,0,-80i=150V3a=-60,0,-80V3b=-55,0,-80V3c=-50,0,-80i=153V3a=-45,0,-80V3b=-40,0,-80V3c=-35,0,-80i=156V3a=-30,0,-80V3b=-25,0,-80V3c=-20,0,-80i=159V3a=-15,0,-80V3b=-10,0,-80V3c=-5,0,-80i=162V3a=0,0,-80V3b=5,0,-80V3c=10,0,-80i=165V3a=15,0,-80V3b=20,0,-80V3c=25,0,-80i=168V3a=30,0,-80V3b=35,0,-80V3c=40,0,-80i=171V3a=45,0,-80V3b=50,0,-80V3c=55,0,-80i=174V3a=60,0,-80V3b=65,0,-80V3c=70,0,-80i=177V3a=75,0,-80V3b=80,0,-80V3c=85,0,-80i=180V3a=90,0,-80V3b=95,0,-80V3c=100,0,-80i=183V3a=105,0,-80V3b=110,0,-80V3c=-70,0,-75i=186V3a=-65,0,-75V3b=-60,0,-75V3c=-55,0,-75i=189V3a=-50,0,-75V3b=-45,0,-75V3c=-40,0,-75i=192V3a=-35,0,-75V3b=-30,0,-75V3c=-25,0,-75i=195V3a=-20,0,-75V3b=-15,0,-75V3c=-10,0,-75i=198V3a=-5,0,-75V3b=0,0,-75V3c=5,0,-75i=201V3a=10,0,-75V3b=15,0,-75V3c=20,0,-75i=204V3a=25,0,-75V3b=30,0,-75V3c=35,0,-75i=207V3a=40,0,-75V3b=45,0,-75V3c=50,0,-75i=210V3a=55,0,-75V3b=60,0,-75V3c=65,0,-75i=213V3a=70,0,-75V3b=75,0,-75V3c=80,0,-75i=216V3a=85,0,-75V3b=90,0,-75V3c=95,0,-75i=219V3a=100,0,-75V3b=105,0,-75V3c=110,0,-75i=222V3a=-70,0,-70V3b=-65,0,-70V3c=-60,0,-70i=225V3a=-55,0,-70V3b=-50,0,-70V3c=-45,0,-70i=228V3a=-40,0,-70V3b=-35,0,-70V3c=-30,0,-70i=231V3a=-25,0,-70V3b=-20,0,-70V3c=-15,0,-70i=234V3a=-10,0,-70V3b=-5,0,-70V3c=0,0,-70i=237V3a=5,0,-70V3b=10,0,-70V3c=15,0,-70i=240V3a=20,0,-70V3b=25,0,-70V3c=30,0,-70i=243V3a=35,0,-70V3b=40,0,-70V3c=45,0,-70i=246V3a=50,0,-70V3b=55,0,-70V3c=60,0,-70i=249V3a=65,0,-70V3b=70,0,-70V3c=75,0,-70i=252V3a=80,0,-70V3b=85,0,-70V3c=90,0,-70i=255V3a=95,0,-70V3b=100,0,-70V3c=105,0,-70i=258V3a=110,0,-70V3b=-70,0,-65V3c=-65,0,-65i=261V3a=-60,0,-65V3b=-55,0,-65V3c=-50,0,-65i=264V3a=-45,0,-65V3b=-40,0,-65V3c=-35,0,-65i=267V3a=-30,0,-65V3b=-25,0,-65V3c=-20,0,-65i=270V3a=-15,0,-65V3b=-10,0,-65V3c=-5,0,-65i=273V3a=0,0,-65V3b=5,0,-65V3c=10,0,-65i=276V3a=15,0,-65V3b=20,0,-65V3c=25,0,-65i=279V3a=30,0,-65V3b=35,0,-65V3c=40,0,-65i=282V3a=45,0,-65V3b=50,0,-65V3c=55,0,-65i=285V3a=60,0,-65V3b=65,0,-65V3c=70,0,-65i=288V3a=75,0,-65V3b=80,0,-65V3c=85,0,-65i=291V3a=90,0,-65V3b=95,0,-65V3c=100,0,-65i=294V3a=105,0,-65V3b=110,0,-65V3c=-70,0,-60i=297V3a=-65,0,-60V3b=-60,0,-60V3c=-55,0,-60i=300V3a=-50,0,-60V3b=-45,0,-60V3c=-40,0,-60i=303V3a=-35,0,-60V3b=-30,0,-60V3c=-25,0,-60i=306V3a=-20,0,-60V3b=-15,0,-60V3c=-10,0,-60i=309V3a=-5,0,-60V3b=0,0,-60V3c=5,0,-60i=312V3a=10,0,-60V3b=15,0,-60V3c=20,0,-60i=315V3a=25,0,-60V3b=30,0,-60V3c=35,0,-60i=318V3a=40,0,-60V3b=45,0,-60V3c=50,0,-60i=321V3a=55,0,-60V3b=60,0,-60V3c=65,0,-60i=324V3a=70,0,-60V3b=75,0,-60V3c=80,0,-60i=327V3a=85,0,-60V3b=90,0,-60V3c=95,0,-60i=330V3a=100,0,-60V3b=105,0,-60V3c=110,0,-60i=333V3a=-70,0,-55V3b=-65,0,-55V3c=-60,0,-55i=336V3a=-55,0,-55V3b=-50,0,-55V3c=-45,0,-55i=339V3a=-40,0,-55V3b=-35,0,-55V3c=-30,0,-55i=342V3a=-25,0,-55V3b=-20,0,-55V3c=-15,0,-55i=345V3a=-10,0,-55V3b=-5,0,-55V3c=0,0,-55i=348V3a=5,0,-55V3b=10,0,-55V3c=15,0,-55i=351V3a=20,0,-55V3b=25,0,-55V3c=30,0,-55i=354V3a=35,0,-55V3b=40,0,-55V3c=45,0,-55i=357V3a=50,0,-55V3b=55,0,-55V3c=60,0,-55i=360V3a=65,0,-55V3b=70,0,-55V3c=75,0,-55i=363V3a=80,0,-55V3b=85,0,-55V3c=90,0,-55i=366V3a=95,0,-55V3b=100,0,-55V3c=105,0,-55i=369V3a=110,0,-55V3b=-70,0,-50V3c=-65,0,-50i=372V3a=-60,0,-50V3b=-55,0,-50V3c=-50,0,-50i=375V3a=-45,0,-50V3b=-40,0,-50V3c=-35,0,-50i=378V3a=-30,0,-50V3b=-25,0,-50V3c=-20,0,-50i=381V3a=-15,0,-50V3b=-10,0,-50V3c=-5,0,-50i=384V3a=0,0,-50V3b=5,0,-50V3c=10,0,-50i=387V3a=15,0,-50V3b=20,0,-50V3c=25,0,-50i=390V3a=30,0,-50V3b=35,0,-50V3c=40,0,-50i=393V3a=45,0,-50V3b=50,0,-50V3c=55,0,-50i=396V3a=60,0,-50V3b=65,0,-50V3c=70,0,-50i=399V3a=75,0,-50V3b=80,0,-50V3c=85,0,-50i=402V3a=90,0,-50V3b=95,0,-50V3c=100,0,-50i=405V3a=105,0,-50V3b=110,0,-50V3c=-70,0,-45i=408V3a=-65,0,-45V3b=-60,0,-45V3c=-55,0,-45i=411V3a=-50,0,-45V3b=-45,0,-45V3c=-40,0,-45i=414V3a=-35,0,-45V3b=-30,0,-45V3c=-25,0,-45i=417V3a=-20,0,-45V3b=-15,0,-45V3c=-10,0,-45i=420V3a=-5,0,-45V3b=0,0,-45V3c=5,0,-45i=423V3a=10,0,-45V3b=15,0,-45V3c=20,0,-45i=426V3a=25,0,-45V3b=30,0,-45V3c=35,0,-45i=429V3a=40,0,-45V3b=45,0,-45V3c=50,0,-45i=432V3a=55,0,-45V3b=60,0,-45V3c=65,0,-45i=435V3a=70,0,-45V3b=75,0,-45V3c=80,0,-45i=438V3a=85,0,-45V3b=90,0,-45V3c=95,0,-45i=441V3a=100,0,-45V3b=105,0,-45V3c=110,0,-45i=444V3a=-70,0,-40V3b=-65,0,-40V3c=-60,0,-40i=447V3a=-55,0,-40V3b=-50,0,-40V3c=-45,0,-40i=450V3a=-40,0,-40V3b=-35,0,-40V3c=-30,0,-40i=453V3a=-25,0,-40V3b=-20,0,-40V3c=-15,0,-40i=456V3a=-10,0,-40V3b=-5,0,-40V3c=0,0,-40i=459V3a=5,0,-40V3b=10,0,-40V3c=15,0,-40i=462V3a=20,0,-40V3b=25,0,-40V3c=30,0,-40i=465V3a=35,0,-40V3b=40,0,-40V3c=45,0,-40i=468V3a=50,0,-40V3b=55,0,-40V3c=60,0,-40i=471V3a=65,0,-40V3b=70,0,-40V3c=75,0,-40i=474V3a=80,0,-40V3b=85,0,-40V3c=90,0,-40i=477V3a=95,0,-40V3b=100,0,-40V3c=105,0,-40i=480V3a=110,0,-40V3b=-70,0,-35V3c=-65,0,-35i=483V3a=-60,0,-35V3b=-55,0,-35V3c=-50,0,-35i=486V3a=-45,0,-35V3b=-40,0,-35V3c=-35,0,-35i=489V3a=-30,0,-35V3b=-25,0,-35V3c=-20,0,-35i=492V3a=-15,0,-35V3b=-10,0,-35V3c=-5,0,-35i=495V3a=0,0,-35V3b=5,0,-35V3c=10,0,-35i=498V3a=15,0,-35V3b=20,0,-35V3c=25,0,-35i=501V3a=30,0,-35V3b=35,0,-35V3c=40,0,-35i=504V3a=45,0,-35V3b=50,0,-35V3c=55,0,-35i=507V3a=60,0,-35V3b=65,0,-35V3c=70,0,-35i=510V3a=75,0,-35V3b=80,0,-35V3c=85,0,-35i=513V3a=90,0,-35V3b=95,0,-35V3c=100,0,-35i=516V3a=105,0,-35V3b=110,0,-35V3c=-70,0,-30i=519V3a=-65,0,-30V3b=-60,0,-30V3c=-55,0,-30i=522V3a=-50,0,-30V3b=-45,0,-30V3c=-40,0,-30i=525V3a=-35,0,-30V3b=-30,0,-30V3c=-25,0,-30i=528V3a=-20,0,-30V3b=-15,0,-30V3c=-10,0,-30i=531V3a=-5,0,-30V3b=0,0,-30V3c=5,0,-30i=534V3a=10,0,-30V3b=15,0,-30V3c=20,0,-30i=537V3a=25,0,-30V3b=30,0,-30V3c=35,0,-30i=540V3a=40,0,-30V3b=45,0,-30V3c=50,0,-30i=543V3a=55,0,-30V3b=60,0,-30V3c=65,0,-30i=546V3a=70,0,-30V3b=75,0,-30V3c=80,0,-30i=549V3a=85,0,-30V3b=90,0,-30V3c=95,0,-30i=552V3a=100,0,-30V3b=105,0,-30V3c=110,0,-30i=555V3a=-70,0,-25V3b=-65,0,-25V3c=-60,0,-25i=558V3a=-55,0,-25V3b=-50,0,-25V3c=-45,0,-25i=561V3a=-40,0,-25V3b=-35,0,-25V3c=-30,0,-25i=564V3a=-25,0,-25V3b=-20,0,-25V3c=-15,0,-25i=567V3a=-10,0,-25V3b=-5,0,-25V3c=0,0,-25i=570V3a=5,0,-25V3b=10,0,-25V3c=15,0,-25i=573V3a=20,0,-25V3b=25,0,-25V3c=30,0,-25i=576V3a=35,0,-25V3b=40,0,-25V3c=45,0,-25i=579V3a=50,0,-25V3b=55,0,-25V3c=60,0,-25i=582V3a=65,0,-25V3b=70,0,-25V3c=75,0,-25i=585V3a=80,0,-25V3b=85,0,-25V3c=90,0,-25i=588V3a=95,0,-25V3b=100,0,-25V3c=105,0,-25i=591V3a=110,0,-25V3b=-70,0,-20V3c=-65,0,-20i=594V3a=-60,0,-20V3b=-55,0,-20V3c=-50,0,-20i=597V3a=-45,0,-20V3b=-40,0,-20V3c=-35,0,-20i=600V3a=-30,0,-20V3b=-25,0,-20V3c=-20,0,-20i=603V3a=-15,0,-20V3b=-10,0,-20V3c=-5,0,-20i=606V3a=0,0,-20V3b=5,0,-20V3c=10,0,-20i=609V3a=15,0,-20V3b=20,0,-20V3c=25,0,-20i=612V3a=30,0,-20V3b=35,0,-20V3c=40,0,-20i=615V3a=45,0,-20V3b=50,0,-20V3c=55,0,-20i=618V3a=60,0,-20V3b=65,0,-20V3c=70,0,-20i=621V3a=75,0,-20V3b=80,0,-20V3c=85,0,-20i=624V3a=90,0,-20V3b=95,0,-20V3c=100,0,-20i=627V3a=105,0,-20V3b=110,0,-20V3c=-70,0,-15i=630V3a=-65,0,-15V3b=-60,0,-15V3c=-55,0,-15i=633V3a=-50,0,-15V3b=-45,0,-15V3c=-40,0,-15i=636V3a=-35,0,-15V3b=-30,0,-15V3c=-25,0,-15i=639V3a=-20,0,-15V3b=-15,0,-15V3c=-10,0,-15i=642V3a=-5,0,-15V3b=0,0,-15V3c=5,0,-15i=645V3a=10,0,-15V3b=15,0,-15V3c=20,0,-15i=648V3a=25,0,-15V3b=30,0,-15V3c=35,0,-15i=651V3a=40,0,-15V3b=45,0,-15V3c=50,0,-15i=654V3a=55,0,-15V3b=60,0,-15V3c=65,0,-15i=657V3a=70,0,-15V3b=75,0,-15V3c=80,0,-15i=660V3a=85,0,-15V3b=90,0,-15V3c=95,0,-15i=663V3a=100,0,-15V3b=105,0,-15V3c=110,0,-15i=666V3a=-70,0,-10V3b=-65,0,-10V3c=-60,0,-10i=669V3a=-55,0,-10V3b=-50,0,-10V3c=-45,0,-10i=672V3a=-40,0,-10V3b=-35,0,-10V3c=-30,0,-10i=675V3a=-25,0,-10V3b=-20,0,-10V3c=-15,0,-10i=678V3a=-10,0,-10V3b=-5,0,-10V3c=0,0,-10i=681V3a=5,0,-10V3b=10,0,-10V3c=15,0,-10i=684V3a=20,0,-10V3b=25,0,-10V3c=30,0,-10i=687V3a=35,0,-10V3b=40,0,-10V3c=45,0,-10i=690V3a=50,0,-10V3b=55,0,-10V3c=60,0,-10i=693V3a=65,0,-10V3b=70,0,-10V3c=75,0,-10i=696V3a=80,0,-10V3b=85,0,-10V3c=90,0,-10i=699V3a=95,0,-10V3b=100,0,-10V3c=105,0,-10i=702V3a=110,0,-10V3b=-70,0,-5V3c=-65,0,-5i=705V3a=-60,0,-5V3b=-55,0,-5V3c=-50,0,-5i=708V3a=-45,0,-5V3b=-40,0,-5V3c=-35,0,-5i=711V3a=-30,0,-5V3b=-25,0,-5V3c=-20,0,-5i=714V3a=-15,0,-5V3b=-10,0,-5V3c=-5,0,-5i=717V3a=0,0,-5V3b=5,0,-5V3c=10,0,-5i=720V3a=15,0,-5V3b=20,0,-5V3c=25,0,-5i=723V3a=30,0,-5V3b=35,0,-5V3c=40,0,-5i=726V3a=45,0,-5V3b=50,0,-5V3c=55,0,-5i=729V3a=60,0,-5V3b=65,0,-5V3c=70,0,-5i=732V3a=75,0,-5V3b=80,0,-5V3c=85,0,-5i=735V3a=90,0,-5V3b=95,0,-5V3c=100,0,-5i=738V3a=105,0,-5V3b=110,0,-5V3c=-70,0,0i=741V3a=-65,0,0V3b=-60,0,0V3c=-55,0,0i=744V3a=-50,0,0V3b=-45,0,0V3c=-40,0,0i=747V3a=-35,0,0V3b=-30,0,0V3c=-25,0,0i=750V3a=-20,0,0V3b=-15,0,0V3c=-10,0,0i=753V3a=-5,0,0V3b=0,0,0V3c=5,0,0i=756V3a=10,0,0V3b=15,0,0V3c=20,0,0i=759V3a=25,0,0V3b=30,0,0V3c=35,0,0i=762V3a=40,0,0V3b=45,0,0V3c=50,0,0i=765V3a=55,0,0V3b=60,0,0V3c=65,0,0i=768V3a=70,0,0V3b=75,0,0V3c=80,0,0i=771V3a=85,0,0V3b=90,0,0V3c=95,0,0i=774V3a=100,0,0V3b=105,0,0V3c=110,0,0i=777V3a=-70,0,5V3b=-65,0,5V3c=-60,0,5i=780V3a=-55,0,5V3b=-50,0,5V3c=-45,0,5i=783V3a=-40,0,5V3b=-35,0,5V3c=-30,0,5i=786V3a=-25,0,5V3b=-20,0,5V3c=-15,0,5i=789V3a=-10,0,5V3b=-5,0,5V3c=0,0,5i=792V3a=5,0,5V3b=10,0,5V3c=15,0,5i=795V3a=20,0,5V3b=25,0,5V3c=30,0,5i=798V3a=35,0,5V3b=40,0,5V3c=45,0,5i=801V3a=50,0,5V3b=55,0,5V3c=60,0,5i=804V3a=65,0,5V3b=70,0,5V3c=75,0,5i=807V3a=80,0,5V3b=85,0,5V3c=90,0,5i=810V3a=95,0,5V3b=100,0,5V3c=105,0,5i=813V3a=110,0,5V3b=-70,0,10V3c=-65,0,10i=816V3a=-60,0,10V3b=-55,0,10V3c=-50,0,10i=819V3a=-45,0,10V3b=-40,0,10V3c=-35,0,10i=822V3a=-30,0,10V3b=-25,0,10V3c=-20,0,10i=825V3a=-15,0,10V3b=-10,0,10V3c=-5,0,10i=828V3a=0,0,10V3b=5,0,10V3c=10,0,10i=831V3a=15,0,10V3b=20,0,10V3c=25,0,10i=834V3a=30,0,10V3b=35,0,10V3c=40,0,10i=837V3a=45,0,10V3b=50,0,10V3c=55,0,10i=840V3a=60,0,10V3b=65,0,10V3c=70,0,10i=843V3a=75,0,10V3b=80,0,10V3c=85,0,10i=846V3a=90,0,10V3b=95,0,10V3c=100,0,10i=849V3a=105,0,10V3b=110,0,10V3c=-70,0,15i=852V3a=-65,0,15V3b=-60,0,15V3c=-55,0,15i=855V3a=-50,0,15V3b=-45,0,15V3c=-40,0,15i=858V3a=-35,0,15V3b=-30,0,15V3c=-25,0,15i=861V3a=-20,0,15V3b=-15,0,15V3c=-10,0,15i=864V3a=-5,0,15V3b=0,0,15V3c=5,0,15i=867V3a=10,0,15V3b=15,0,15V3c=20,0,15i=870V3a=25,0,15V3b=30,0,15V3c=35,0,15i=873V3a=40,0,15V3b=45,0,15V3c=50,0,15i=876V3a=55,0,15V3b=60,0,15V3c=65,0,15i=879V3a=70,0,15V3b=75,0,15V3c=80,0,15i=882V3a=85,0,15V3b=90,0,15V3c=95,0,15i=885V3a=100,0,15V3b=105,0,15V3c=110,0,15i=888V3a=-70,0,20V3b=-65,0,20V3c=-60,0,20i=891V3a=-55,0,20V3b=-50,0,20V3c=-45,0,20i=894V3a=-40,0,20V3b=-35,0,20V3c=-30,0,20i=897V3a=-25,0,20V3b=-20,0,20V3c=-15,0,20i=900V3a=-10,0,20V3b=-5,0,20V3c=0,0,20i=903V3a=5,0,20V3b=10,0,20V3c=15,0,20i=906V3a=20,0,20V3b=25,0,20V3c=30,0,20i=909V3a=35,0,20V3b=40,0,20V3c=45,0,20i=912V3a=50,0,20V3b=55,0,20V3c=60,0,20i=915V3a=65,0,20V3b=70,0,20V3c=75,0,20i=918V3a=80,0,20V3b=85,0,20V3c=90,0,20i=921V3a=95,0,20V3b=100,0,20V3c=105,0,20i=924V3a=110,0,20V3b=-70,0,25V3c=-65,0,25i=927V3a=-60,0,25V3b=-55,0,25V3c=-50,0,25i=930V3a=-45,0,25V3b=-40,0,25V3c=-35,0,25i=933V3a=-30,0,25V3b=-25,0,25V3c=-20,0,25i=936V3a=-15,0,25V3b=-10,0,25V3c=-5,0,25i=939V3a=0,0,25V3b=5,0,25V3c=10,0,25i=942V3a=15,0,25V3b=20,0,25V3c=25,0,25i=945V3a=30,0,25V3b=35,0,25V3c=40,0,25i=948V3a=45,0,25V3b=50,0,25V3c=55,0,25i=951V3a=60,0,25V3b=65,0,25V3c=70,0,25i=954V3a=75,0,25V3b=80,0,25V3c=85,0,25i=957V3a=90,0,25V3b=95,0,25V3c=100,0,25i=960V3a=105,0,25V3b=110,0,25V3c=-70,0,30i=963V3a=-65,0,30V3b=-60,0,30V3c=-55,0,30i=966V3a=-50,0,30V3b=-45,0,30V3c=-40,0,30i=969V3a=-35,0,30V3b=-30,0,30V3c=-25,0,30i=972V3a=-20,0,30V3b=-15,0,30V3c=-10,0,30i=975V3a=-5,0,30V3b=0,0,30V3c=5,0,30i=978V3a=10,0,30V3b=15,0,30V3c=20,0,30i=981V3a=25,0,30V3b=30,0,30V3c=35,0,30i=984V3a=40,0,30V3b=45,0,30V3c=50,0,30i=987V3a=55,0,30V3b=60,0,30V3c=65,0,30i=990V3a=70,0,30V3b=75,0,30V3c=80,0,30i=993V3a=85,0,30V3b=90,0,30V3c=95,0,30i=996V3a=100,0,30V3b=105,0,30V3c=110,0,30i=999V3a=-70,0,35V3b=-65,0,35V3c=-60,0,35i=1002V3a=-55,0,35V3b=-50,0,35V3c=-45,0,35i=1005V3a=-40,0,35V3b=-35,0,35V3c=-30,0,35i=1008V3a=-25,0,35V3b=-20,0,35V3c=-15,0,35i=1011V3a=-10,0,35V3b=-5,0,35V3c=0,0,35i=1014V3a=5,0,35V3b=10,0,35V3c=15,0,35i=1017V3a=20,0,35V3b=25,0,35V3c=30,0,35i=1020V3a=35,0,35V3b=40,0,35V3c=45,0,35i=1023V3a=50,0,35V3b=55,0,35V3c=60,0,35i=1026V3a=65,0,35V3b=70,0,35V3c=75,0,35i=1029V3a=80,0,35V3b=85,0,35V3c=90,0,35i=1032V3a=95,0,35V3b=100,0,35V3c=105,0,35i=1035V3a=110,0,35V3b=-70,0,40V3c=-65,0,40i=1038V3a=-60,0,40V3b=-55,0,40V3c=-50,0,40i=1041V3a=-45,0,40V3b=-40,0,40V3c=-35,0,40i=1044V3a=-30,0,40V3b=-25,0,40V3c=-20,0,40i=1047V3a=-15,0,40V3b=-10,0,40V3c=-5,0,40i=1050V3a=0,0,40V3b=5,0,40V3c=10,0,40i=1053V3a=15,0,40V3b=20,0,40V3c=25,0,40i=1056V3a=30,0,40V3b=35,0,40V3c=40,0,40i=1059V3a=45,0,40V3b=50,0,40V3c=55,0,40i=1062V3a=60,0,40V3b=65,0,40V3c=70,0,40i=1065V3a=75,0,40V3b=80,0,40V3c=85,0,40i=1068V3a=90,0,40V3b=95,0,40V3c=100,0,40i=1071V3a=105,0,40V3b=110,0,40V3c=-70,0,45i=1074V3a=-65,0,45V3b=-60,0,45V3c=-55,0,45i=1077V3a=-50,0,45V3b=-45,0,45V3c=-40,0,45i=1080V3a=-35,0,45V3b=-30,0,45V3c=-25,0,45i=1083V3a=-20,0,45V3b=-15,0,45V3c=-10,0,45i=1086V3a=-5,0,45V3b=0,0,45V3c=5,0,45i=1089V3a=10,0,45V3b=15,0,45V3c=20,0,45i=1092V3a=25,0,45V3b=30,0,45V3c=35,0,45i=1095V3a=40,0,45V3b=45,0,45V3c=50,0,45i=1098V3a=55,0,45V3b=60,0,45V3c=65,0,45i=1101V3a=70,0,45V3b=75,0,45V3c=80,0,45i=1104V3a=85,0,45V3b=90,0,45V3c=95,0,45i=1107V3a=100,0,45V3b=105,0,45V3c=110,0,45i=1110V3a=-70,0,50V3b=-65,0,50V3c=-60,0,50i=1113V3a=-55,0,50V3b=-50,0,50V3c=-45,0,50i=1116V3a=-40,0,50V3b=-35,0,50V3c=-30,0,50i=1119V3a=-25,0,50V3b=-20,0,50V3c=-15,0,50i=1122V3a=-10,0,50V3b=-5,0,50V3c=0,0,50i=1125V3a=5,0,50V3b=10,0,50V3c=15,0,50i=1128V3a=20,0,50V3b=25,0,50V3c=30,0,50i=1131V3a=35,0,50V3b=40,0,50V3c=45,0,50i=1134V3a=50,0,50V3b=55,0,50V3c=60,0,50i=1137V3a=65,0,50V3b=70,0,50V3c=75,0,50i=1140V3a=80,0,50V3b=85,0,50V3c=90,0,50i=1143V3a=95,0,50V3b=100,0,50V3c=105,0,50i=1146V3a=110,0,50V3b=-70,0,55V3c=-65,0,55i=1149V3a=-60,0,55V3b=-55,0,55V3c=-50,0,55i=1152V3a=-45,0,55V3b=-40,0,55V3c=-35,0,55i=1155V3a=-30,0,55V3b=-25,0,55V3c=-20,0,55i=1158V3a=-15,0,55V3b=-10,0,55V3c=-5,0,55i=1161V3a=0,0,55V3b=5,0,55V3c=10,0,55i=1164V3a=15,0,55V3b=20,0,55V3c=25,0,55i=1167V3a=30,0,55V3b=35,0,55V3c=40,0,55i=1170V3a=45,0,55V3b=50,0,55V3c=55,0,55i=1173V3a=60,0,55V3b=65,0,55V3c=70,0,55i=1176V3a=75,0,55V3b=80,0,55V3c=85,0,55i=1179V3a=90,0,55V3b=95,0,55V3c=100,0,55i=1182V3a=105,0,55V3b=110,0,55V3c=-70,0,60i=1185V3a=-65,0,60V3b=-60,0,60V3c=-55,0,60i=1188V3a=-50,0,60V3b=-45,0,60V3c=-40,0,60i=1191V3a=-35,0,60V3b=-30,0,60V3c=-25,0,60i=1194V3a=-20,0,60V3b=-15,0,60V3c=-10,0,60i=1197V3a=-5,0,60V3b=0,0,60V3c=5,0,60i=1200V3a=10,0,60V3b=15,0,60V3c=20,0,60i=1203V3a=25,0,60V3b=30,0,60V3c=35,0,60i=1206V3a=40,0,60V3b=45,0,60V3c=50,0,60i=1209V3a=55,0,60V3b=60,0,60V3c=65,0,60i=1212V3a=70,0,60V3b=75,0,60V3c=80,0,60i=1215V3a=85,0,60V3b=90,0,60V3c=95,0,60i=1218V3a=100,0,60V3b=105,0,60V3c=110,0,60i=1221V3a=-70,0,65V3b=-65,0,65V3c=-60,0,65i=1224V3a=-55,0,65V3b=-50,0,65V3c=-45,0,65i=1227V3a=-40,0,65V3b=-35,0,65V3c=-30,0,65i=1230V3a=-25,0,65V3b=-20,0,65V3c=-15,0,65i=1233V3a=-10,0,65V3b=-5,0,65V3c=0,0,65i=1236V3a=5,0,65V3b=10,0,65V3c=15,0,65i=1239V3a=20,0,65V3b=25,0,65V3c=30,0,65i=1242V3a=35,0,65V3b=40,0,65V3c=45,0,65i=1245V3a=50,0,65V3b=55,0,65V3c=60,0,65i=1248V3a=65,0,65V3b=70,0,65V3c=75,0,65i=1251V3a=80,0,65V3b=85,0,65V3c=90,0,65i=1254V3a=95,0,65V3b=100,0,65V3c=105,0,65i=1257V3a=110,0,65V3b=-70,0,70V3c=-65,0,70i=1260V3a=-60,0,70V3b=-55,0,70V3c=-50,0,70i=1263V3a=-45,0,70V3b=-40,0,70V3c=-35,0,70i=1266V3a=-30,0,70V3b=-25,0,70V3c=-20,0,70i=1269V3a=-15,0,70V3b=-10,0,70V3c=-5,0,70i=1272V3a=0,0,70V3b=5,0,70V3c=10,0,70i=1275V3a=15,0,70V3b=20,0,70V3c=25,0,70i=1278V3a=30,0,70V3b=35,0,70V3c=40,0,70i=1281V3a=45,0,70V3b=50,0,70V3c=55,0,70i=1284V3a=60,0,70V3b=65,0,70V3c=70,0,70i=1287V3a=75,0,70V3b=80,0,70V3c=85,0,70i=1290V3a=90,0,70V3b=95,0,70V3c=100,0,70i=1293V3a=105,0,70V3b=110,0,70V3c=-70,0,75i=1296V3a=-65,0,75V3b=-60,0,75V3c=-55,0,75i=1299V3a=-50,0,75V3b=-45,0,75V3c=-40,0,75i=1302V3a=-35,0,75V3b=-30,0,75V3c=-25,0,75i=1305V3a=-20,0,75V3b=-15,0,75V3c=-10,0,75i=1308V3a=-5,0,75V3b=0,0,75V3c=5,0,75i=1311V3a=10,0,75V3b=15,0,75V3c=20,0,75i=1314V3a=25,0,75V3b=30,0,75V3c=35,0,75i=1317V3a=40,0,75V3b=45,0,75V3c=50,0,75i=1320V3a=55,0,75V3b=60,0,75V3c=65,0,75i=1323V3a=70,0,75V3b=75,0,75V3c=80,0,75i=1326V3a=85,0,75V3b=90,0,75V3c=95,0,75i=1329V3a=100,0,75V3b=105,0,75V3c=110,0,75i=1332V3a=-70,0,80V3b=-65,0,80V3c=-60,0,80i=1335V3a=-55,0,80V3b=-50,0,80V3c=-45,0,80i=1338V3a=-40,0,80V3b=-35,0,80V3c=-30,0,80i=1341V3a=-25,0,80V3b=-20,0,80V3c=-15,0,80i=1344V3a=-10,0,80V3b=-5,0,80V3c=0,0,80i=1347V3a=5,0,80V3b=10,0,80V3c=15,0,80i=1350V3a=20,0,80V3b=25,0,80V3c=30,0,80i=1353V3a=35,0,80V3b=40,0,80V3c=45,0,80i=1356V3a=50,0,80V3b=55,0,80V3c=60,0,80i=1359V3a=65,0,80V3b=70,0,80V3c=75,0,80i=1362V3a=80,0,80V3b=85,0,80V3c=90,0,80i=1365V3a=95,0,80V3b=100,0,80V3c=105,0,80


As you can see from the output not once does the Ray hit the planes position even though I am clearly hitting a triangle on the plane. I even set it into wireframe mode so that I only picked one triangle and not confuse it.

So the question is. Did I miss something out?

Thank you for sticking with me and reading all this. I am suspecting the problem lies in the XY point and XZ plane needing to work together but I'm not sure how that would work in this example as none of the sites I found had a plane example.

edit:
Okay found this site : http://www.3dkingdoms.com/selection.html#linetri so tried to implement his test in my test code instead to locate which triangle has been selected. Same problem, not match found. Heres the altered code now:

int DXPrimitive::PickVertex(Vector3 RayPos,Vector3 RayDir){	Vector3 tempV3a;	Vector3 tempV3b;	Vector3 tempV3c;	Vector3 tempNorm;	Vector3 tempIntersect;	Vector3 tempHit;	Vector3 tempTest;	bool skiptest = false;	bool hit = true;	FileStream* fs;	StreamWriter* sw;	fs = __gc new FileStream("PickVertex.txt",FileMode::CreateNew);	sw = __gc new StreamWriter(fs);	sw->WriteLine(String::Format("RayPos = {0}, RayDir = {1}",__box(RayPos),__box(RayDir)));	for (int i = 0; i < m_vertexCount-2; i+=3)	{		if (m_cvt == DXBase::CustomVertexType::NormalisedColored)		{			sw->WriteLine(String::Format("i={0}",__box(i)));			tempV3a = Vector3(m_PNCVerts.X,m_PNCVerts.Y,m_PNCVerts.Z);			tempV3b = Vector3(m_PNCVerts[i+1].X,m_PNCVerts[i+1].Y,m_PNCVerts[i+1].Z);			tempV3c = Vector3(m_PNCVerts[i+2].X,m_PNCVerts[i+2].Y,m_PNCVerts[i+2].Z);			sw->WriteLine(String::Format("V3a={0},{1},{2}",__box(tempV3a.X),__box(tempV3a.Y),__box(tempV3a.Z)));			sw->WriteLine(String::Format("V3b={0},{1},{2}",__box(tempV3b.X),__box(tempV3b.Y),__box(tempV3b.Z)));			sw->WriteLine(String::Format("V3c={0},{1},{2}",__box(tempV3c.X),__box(tempV3b.Y),__box(tempV3c.Z)));			tempNorm = Vector3::Cross(tempV3b-tempV3a,tempV3c-tempV3a);			tempNorm.Normalize();			float fDist1 = Vector3::Dot((RayPos - tempV3a),(tempNorm));			float fDist2 = Vector3::Dot((RayDir - tempV3a),(tempNorm));			sw->WriteLine(String::Format("Normal={0},Distance={1},{2}",__box(tempNorm),__box(fDist1),__box(fDist2)));			if ((fDist1 * fDist2) >= 0.0f) skiptest = true;			if (fDist1 == fDist2) skiptest = true;			if (!skiptest)			{				tempIntersect = tempV3a + (tempV3b-tempV3a) * (-fDist1/(fDist2-fDist1));				tempTest = Vector3::Cross(tempNorm,tempV3b-tempV3a);				sw->WriteLine(String::Format("Intersect={0},Test={1}",__box(tempIntersect),__box(tempTest)));				if (Vector3::Dot(tempTest,tempIntersect-tempV3a) < 0.0f) hit = false;				if (Vector3::Dot(tempTest,tempIntersect-tempV3b) < 0.0f) hit = false;				if (Vector3::Dot(tempTest,tempIntersect-tempV3c) < 0.0f) hit = false;				if (hit) 				{					tempHit = tempIntersect;					sw->WriteLine(String::Format("Successful Hit={0}",__box(tempHit)));					return i;				}			}		}	}	sw->Close();	return -1;}


The relevant routines have had their return values altered accordingly to reflect the new value. Now unless I am misunderstanding what of my values are the ones to use based on his code it seems I am never hitting the clearly hittable plane.

edit 2:
Well finally figured it out, well maybe. Had to change the code slightly but now it picks out the same triangles every time instead of different ones that I am selecting.

int DXPrimitive::PickVertex(Vector3 RayPos,Vector3 RayDir){	Vector3 tempV3a;	Vector3 tempV3b;	Vector3 tempV3c;	Vector3 tempNorm;	Vector3 tempIntersect;	Vector3 tempHit;	Vector3 tempTest;	bool skiptest = true;	bool hit = true;	int VertexHit;	for (int i = 0; i < m_vertexCount-2; i+=3)	{		VertexHit = -1;		if (m_cvt == DXBase::CustomVertexType::NormalisedColored)		{			tempV3a = Vector3(m_PNCVerts.X,m_PNCVerts.Y,m_PNCVerts.Z);			tempV3b = Vector3(m_PNCVerts[i+1].X,m_PNCVerts[i+1].Y,m_PNCVerts[i+1].Z);			tempV3c = Vector3(m_PNCVerts[i+2].X,m_PNCVerts[i+2].Y,m_PNCVerts[i+2].Z);			tempNorm = Vector3::Cross(tempV3b-tempV3a,tempV3c-tempV3a);			tempNorm.Normalize();			float fDist1 = Vector3::Dot((RayPos - tempV3a),(tempNorm));			float fDist2 = Vector3::Dot((RayDir - tempV3a),(tempNorm));			float DistTest = fDist1 * fDist2;						skiptest = false;			if ((fDist1 * fDist2) >= 0.0f) skiptest = true;			if (fDist1 == fDist2) skiptest = true;			if (!skiptest)			{				tempIntersect = tempV3a + (tempV3b-tempV3a) * (-fDist1/(fDist2-fDist1));				hit = true;				tempTest = Vector3::Cross(tempNorm,tempV3b-tempV3a);				if (Vector3::Dot(tempTest,tempIntersect-tempV3a) < 0.0f) hit = false;				tempTest = Vector3::Cross(tempNorm,tempV3c-tempV3b);				if (Vector3::Dot(tempTest,tempIntersect-tempV3b) < 0.0f) hit = false;				tempTest = Vector3::Cross(tempNorm,tempV3a-tempV3c);				if (Vector3::Dot(tempTest,tempIntersect-tempV3a) < 0.0f) hit = false;				if (hit) 				{					tempHit = tempIntersect;					VertexHit = i;					i = m_vertexCount;				}			}		}	}	return VertexHit;}


There are over 1300 vertexpoints in this plane and for some strange reason it insists that I am selecting either 36 or 72 even if I am not selecting anything on the grid.

Needless to say this is starting to get on my nerves.

[Edited by - Xrystal on May 30, 2006 12:39:18 PM]
link to a ray picking demo in C++/CLI
Looking at that code example link, thanks by the way, it looks like my ray generating code was almost identical and still not working. I can only assume then that my camera code is wrong .. looking like I may have to take a step back and work out whats missing from the camera code that the ray picking code needs.

edit:

Unfortunately it won't compile for me as it cannot find windows.h and neither can I for visual C++ 2005 compiling.

The unmanaged code int it is clear enough though for me to see if I can work with it with my managed code.
finally came back to this problem and solved it,

i was testing my picking in windowed mode, then realised that the mouse co-ords didnt start at 0,0 in windowed they started at about 60 which left a little offset

but in fullscreen it worked perfectly

sny idea how i cna make the mouse co-ords range from 0,0 to screen width, height in windowed mode rather than what they currently are?
http://stowelly.co.uk/
bump.
http://stowelly.co.uk/

This topic is closed to new replies.

Advertisement