D3DXVec3Unproject in irrlicht - UERGENT

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
castefani
Posts: 4
Joined: Sun Apr 22, 2007 11:14 pm

D3DXVec3Unproject in irrlicht - UERGENT

Post 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);
}
}
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post 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.
If you don't have anything nice to say, don't say anything at all.
Post Reply