Page 1 of 1

D3DXVec3Unproject in irrlicht - UERGENT

Posted: Tue May 01, 2007 4:10 am
by castefani
sorry my english.

I needed to convert a mouse point to world space.
In directx I use D3DXVec3Unproject to make this.
How to implement this fueature in irrlicht?

I make this implementation but not work.
Help please

----------------------------------------------

vector3df v(event.MouseInput.X, event.MouseInput, 0);
Engine3D* engine;

engine->Unproject(v);
.
.
.

void Engine3D::Unproject(vector3df& vector)
{
matrix4 Mat;
Mat = driver->getTransform(ETS_WORLD) * driver->getTransform(ETS_VIEW) * driver->getTransform(ETS_PROJECTION);
if (Mat.makeInverse())
{
Mat.transformVect(vector);
}
}

Posted: Tue May 01, 2007 5:48 pm
by Luben

Code: Select all

		//! Returns a 3d ray which would go through the 2d screen coodinates.
		//! \param pos: Screen coordinates in pixels.
		//! \param camera: Camera from which the ray starts. If null, the
		//! active camera is used. 
		//! \return Returns a ray starting from the position of the camera
		//! and ending at a length of the far value of the camera at a position
		//! which would be behind the 2d screen coodinates.
		virtual core::line3d<f32> getRayFromScreenCoordinates(
			core::position2d<s32> pos, ICameraSceneNode* camera = 0) = 0;
This is a member function of the class ISceneCollisionManager. You can get a pointer to it trough the scene manager. Note that it returns a line, since your 2d-position is of undefined depth.