# D3DXVec3Unproject Problems

## Recommended Posts

I have asked questions about the D3DXVec3Unproject method before, but that was embedded into another thread so I think Ill ask the question in a fresh thread. I am trying to make a very simple, rotating cube move to a position in 3d-space from a users mouse click. I can do 90% of this, but when I try to convert the users mouse click into 3D-space, I get strange values (or at least I think they are strange). I have placed a cube at and around the -3 to +3 vertex positions in 3D space. Then I setup the camera, etc... and I can see the cube in the middle of the black screen. Then when I click the mouse, I call a self-defined method called
SetupLocalMousePoints(IDirect3DDevice9* p_d3dDevice)


The method is defined as:
D3DXVECTOR3* GameEntity::SetupLocalMousePoints(IDirect3DDevice9
* p_d3dDevice)
{
if (m_mousePoint)
{
D3DXVECTOR3 result;
D3DXVECTOR3 screenPoint;
D3DVIEWPORT9 viewport;
D3DXMATRIX matProjection;
D3DXMATRIX matView;
D3DXMATRIX matWorld;

screenPoint.x = m_mousePoint->x;
screenPoint.y = m_mousePoint->y;
screenPoint.z = 0.0f;
m_mousePoint = 0;

p_d3dDevice->GetViewport(&viewport);
p_d3dDevice->GetTransform( D3DTS_PROJECTION, &matProjection );
p_d3dDevice->GetTransform( D3DTS_VIEW, &matView );
p_d3dDevice->GetTransform( D3DTS_WORLD, &matWorld );

//transform the mouse clicked location
D3DXVec3Unproject( &result, &screenPoint, &viewport, &matProjection, &matView, &matWorld );
return &result;
}
return NULL;
}


m_mousePoint is a private class member variable:
POINTS* m_mousePoint


The rest should be pretty obvious. Now, the issue is when I click in the TOP RIGHT corner of the screen, I am getting. X: -23, Y:8 and Z:0.44 (ish). Why on earth would X be a negative number??? I am having real trouble here and would appreciate any help at all! Thanks Mark

##### Share on other sites
Because what you're doing is dangerous. Your compiler should generate a warning about this - you're returning a pointer to a local variable.

When your function exits, your result variable goes out of scope, and is destroyed. Your pointer now points to rubbish, because the thing it was pointing to is now gone. To solve this, either return by value, or have an extra parameter in your function like this:
void GameEntity::SetupLocalMousePoints(IDirect3DDevice9* p_d3dDevice, D3DXVECTOR3& return){    /*...*/    D3DXVec3Unproject(&return, &screenPoint, &viewport, &matProjection, &matView, &matWorld);    /*...*/}

##### Share on other sites
Quote:
 Original post by Sc4FreakBecause what you're doing is dangerous. Your compiler should generate a warning about this - you're returning a pointer to a local variable.When your function exits, your result variable goes out of scope, and is destroyed. Your pointer now points to rubbish, because the thing it was pointing to is now gone. To solve this, either return by value, or have an extra parameter in your function like this:...

Well thats a good point. I got so caught up in the 3D stuff that I forgot about basic c++...

But anyways, my breakpoints were actually set in that method, so the values that I was checking were the correct ones, but still wrong.

Any more thoughts on the issue here?

Thanks
Mark

P.S. I am happy to attach the project to this thread, or email it, or whatever, to anyone who wants it :)

##### Share on other sites
The usual suspects:

Are you mayhaps using a pure device?
In that case the GetTransform and GetViewport calls will fail. You should check the result codes from them.

It might be a good idea to store the matrices and viewport when you set them anyway to save the getter calls.

##### Share on other sites
Quote:
 Original post by EndurionThe usual suspects:Are you mayhaps using a pure device? In that case the GetTransform and GetViewport calls will fail. You should check the result codes from them.It might be a good idea to store the matrices and viewport when you set them anyway to save the getter calls.

Thanks,

the Getters are all working ok, I have just checked them and they all return S_OK. It seems that maybe I am getting the correct values, but maybe my view is all wrong.

Below is my render method that I use:

void GameEntity::Render(IDirect3DDevice9* p_d3dDevice){	// select which vertex format we are using    p_d3dDevice->SetFVF(CUSTOMFVF);    // set the view transform    D3DXMATRIX matView;    // the view transform matrix    D3DXMatrixLookAtLH(&matView,    &D3DXVECTOR3 (0.0f, 8.0f, 25.0f),					// the camera position    &D3DXVECTOR3 (0.0f, 0.0f, 0.0f),					// the look-at position    &D3DXVECTOR3 (0.0f, 1.0f, 0.0f));					// the up direction    p_d3dDevice->SetTransform(D3DTS_VIEW, &matView);    // set the world transform    static float index = 0.0f; index += 0.03f;				// an ever-increasing float value    D3DXMATRIX matRotateY;									// a matrix to store the rotation    D3DXMatrixRotationY(&matRotateY, index);				// the rotation matrix	    // set the projection transform    D3DXMATRIX matProjection;						// the projection transform matrix    D3DXMatrixPerspectiveFovLH(&matProjection,                               D3DXToRadian(45),    // the horizontal field of view                               640.0f / 480.0f,		// aspect ratio                               1.0f,				// the near view-plane                               100.0f);				// the far view-plane    p_d3dDevice->SetTransform(D3DTS_PROJECTION, &matProjection);	//convert clicked positions into 3D space positions if user has	//clicked the mouse...	this->SetupLocalMousePoints(p_d3dDevice, &m_xOffset, &m_yOffset);	//Remember...Scaling, Translation, Rotation	//translate the X and Y of needed	D3DXMATRIX matTranslate;	D3DXMatrixTranslation(&matTranslate, m_xOffset, m_yOffset, m_zOffset);	//ALWAYS, Rotate before Translate    p_d3dDevice->SetTransform(D3DTS_WORLD, &(matRotateY * matTranslate));  // set the world transform    // select the vertex buffer to display    p_d3dDevice->SetStreamSource(0, this->GetVertexBuffer(), 0, sizeof(CUSTOMVERTEX));    // set the texture    p_d3dDevice->SetTexture(0, m_triangleTexture);    // draw the textured square    p_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);    p_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 4, 2);    p_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 8, 2);    p_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 12, 2);    p_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 16, 2);    p_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 20, 2); }

and the SetupLocalMousePoints method (yes it is different than the original post, as I am simply try new things :))

void GameEntity::SetupLocalMousePoints(IDirect3DDevice9* p_d3dDevice, float* m_xOffset, float* m_yOffset){	if (m_mousePoint)	{		D3DXVECTOR3 screenPoint;		D3DVIEWPORT9 viewport;		D3DXMATRIX matProjection;		D3DXMATRIX matView;		D3DXMATRIX matWorld;		D3DXVECTOR3 screenVector;		screenPoint.x = m_mousePoint->x;		screenPoint.y = m_mousePoint->y;		screenPoint.z = 0.0f;		HRESULT viewportRes = p_d3dDevice->GetViewport(&viewport);		HRESULT projRes = p_d3dDevice->GetTransform( D3DTS_PROJECTION, &matProjection );		HRESULT viewRes = p_d3dDevice->GetTransform( D3DTS_VIEW, &matView );		HRESULT worldRes = p_d3dDevice->GetTransform( D3DTS_WORLD, &matWorld );		//transform the mouse clicked location		D3DXVec3Unproject( &screenVector, &screenPoint, &viewport, &matProjection, &matView, &matWorld );		*m_xOffset = screenVector.x;		*m_yOffset = screenVector.y;		m_mousePoint = 0;	}}

Mark

##### Share on other sites
You're setting the world transform after the call to SetupLocalMousePoints, that might end up using an old world transform matrix.

Also, with one Unproject call with z=0 you get the 3d coordinate on the near plane. You should do two Unproject calls, one with z=0, one with z=1.

Use the resulting line to do intersection tests on your cube.

##### Share on other sites
Quote:
 Original post by EndurionYou're setting the world transform after the call to SetupLocalMousePoints, that might end up using an old world transform matrix.Also, with one Unproject call with z=0 you get the 3d coordinate on the near plane. You should do two Unproject calls, one with z=0, one with z=1.Use the resulting line to do intersection tests on your cube.

Yes, I thought that is what I would have to do, setup the X and Y transformation, which is what SetupLocalMousePoints does, then call the D3DTS_WORLD transformation with the altered X and Y offsets. Isn't that be the way it should be done?

If I did it afterwards, the translation of the X, Y and Z values would be done too late wouldn't they? Although, the next time the Render() method is called, they will be altered correctly, but surely that shouldn't matter, should it??

Also, what is the reasoning behind needing to do the z=0 and z=1 calls?

Thanks for the help!
Mark

##### Share on other sites
Think about why you're making the Unproject call.

What you see on the screen is a 2D projection of objects in a world-space volume that's a truncated pyramid. A point on the 2D screen is the projection of a line in world space. In screen-space the points on that line are ( mouseX, mouseY, some-Z-value ).

Looking down from the top:
+----------------*--+    far plane ( z=1 ) \              /  /  \...........[/]./   \          /  /    \        /  /     +------*--+   near plane ( z=0 )

Your mouse point on the screen is the line between the two asterisks in world space. The place you want to place the cube is somewhere on that line at some z value between 0 ( the near plane ) and 1 ( the far plane ).

You have to decide where on that line, what z value in screen-space, you want the cube to be. Use that z-value in the Unproject call to get the world-space position.

One way to determine that screen-space z-value is to choose the plane (
  ......
in the diagram above ) where you want the cube to be. Pick a point (any point) in world-space in that plane. If you want to move the cube within the same plane all the time, you can use the point at the center of the cube in world-space. Use a Project call to get the screen-space Z-value for that plane and use that Z-value in your Unproject call with your mouse points.

##### Share on other sites
Ok so correct me if I am wrong, but you are saying that I need to setup the Z value because the line that moves back through the 3D space projection, is NOT a strait line, rather, it moves away as a diagonal line. So at different values of Z will give different values of X and Y?

I think Im getting you.

Therefor, if you want to keep the cube on the SAME Z plane, you need to get the current Z position of the center of the cube and use that in the Unproject call.

Correct?

If so, could I please ask you to help me GET the Z corrds from the D3DXVec3Project call? If it converts a Vector from 3D space into screen space, Im not too sure on the best way of getting that Vector...

Thanks so much for the help, I appreciate it greatly.

##### Share on other sites
Yep. The line "behind" the mouse point is a diagonal line (it is straight, by the way ) and the world-space x,y,z values vary along the screen-space line as the screen-space z-value changes.

For the project call, use a world-space D3DXVECTOR3 at the center of your cube. Then use the pOut z-value from the Project call in your Unproject pIn vector.

##### Share on other sites
Quote:
 Original post by BuckeyeYep. The line "behind" the mouse point is a diagonal line (it is straight, by the way ) and the world-space x,y,z values vary along the screen-space line as the screen-space z-value changes.For the project call, use a world-space D3DXVECTOR3 at the center of your cube. Then use the pOut z-value from the Project call in your Unproject pIn vector.

Sorry, I should have said diagonal, not "not strait".

When I "use a world-space D3DXVECTOR3 at the center of your cube", how exactly do I get that? I know it a bit of a basic question, but I want to make sure I am using the correct techniques for this type of call.

Cheers,
Mark

##### Share on other sites
I don't know how you construct the mesh ( or vertex buffer ) for your cube but you have to know "where it is" to set the transform before you draw it.

If you locate the cube by translating to it's center position, that's the 3D location from which to make the D3DXVECTOR3 pIn for the Project call.

If you locate the cube by a corner, add in half of the x, y and z values of each side to move from the corner of the cube to its center.

The Project call for that location returns a screen-space vector with the x,y values of the cube's center screen position and a z value for the plane where the cube is in screen-space.

Just for education's sake, that's the z-value that goes in the Z-buffer, by the way.

The pIn for the Unproject call is ( mouseX, mouseY, cubeZ ) in screen space. The pOut from that call is the position in world-space for the new center of the cube which (hopefully) will appear under the mouse.

If you position the cube by its corner rather than its center, then you have to subtract from the Unproject pOut the half x,y,z values you added in originally .

[Edited by - Buckeye on March 24, 2008 7:25:32 AM]

##### Share on other sites
Quote:
 Original post by BuckeyeI don't know how you construct the mesh ( or vertex buffer ) for your cube but you have to know "where it is" to set the transform before you draw it.If you locate the cube by translating to it's center position, that's the 3D location from which to make the D3DXVECTOR3 pIn for the Project call.If you locate the cube by a corner, add in half of the x, y and z values of each side to move from the corner of the cube to its center.

Ok, well I construct the vertex buffer for my cube by creating a vector of my CUSTOMVERTEX's, then copying them to my vertex buffer.

I think that using the "top left front" corner of the cube would be sufficient to find the center like you said. I can do simple calculations to find it.

Quote:
 The Project call for that location returns a screen-space vector with the x,y values of the cube's center screen position and a z value for the plane where the cube is in screen-space.Just for education's sake, that's the z-value that goes in the Z-buffer, by the way.The pIn for the Unproject call is ( mouseX, mouseY, cubeZ ) in screen space. The pOut from that call is the position in world-space for the new center of the cube which (hopefully) will appear under the mouse.If you position the cube by its corner rather than its center, then you have to subtract from the Unproject pOut the half x,y,z values you added in originally .

Thanks for the education, I do understand now what to do, and what I am/was doing wrong.

Although I was thinking, in real life situations (where you don't have just boring old cubes), how (if at all) is the center of a 3D object usually calculated? Or does it completely depend on the object?

Thanks again!
Mark

##### Share on other sites
Quote:
 how (if at all) is the center of a 3D object usually calculated? Or does it completely depend on the object?

It depends on the object, as you surmise.

In my earlier responses, I assumed that if the user clicked on the screen in your application, the user would expect that to be where the center, rather than a corner, would be.

For the center of a cube with the lower left front corner at ( x, y, z ) and a side of (say) 16, the center will be at ( x+8, y+8, z+8 ), "8" being 1/2 of the side (the middle), and each side being the same. "Cube," right?

That's in world coordinates with +x to the right, +y up and +z "away from you."

For rectangular objects with different lengths along each side, the center would be ( x+xside/2, y+yside/2, z+zside/2 ).

You may want to choose another way of positioning the object.

For instance, when I construct an object, I specifically select coordinates for the vertices thinking ahead of time how I want to position it in the world.

For a tree mesh, for instance, I construct it so that a world translation transform of the tree's position ( say (tx, ty, tz) ) results in the tree with the bottom center of the trunk being at (tx,ty,tz) and it extends up and to the sides from there. So, the vertices would be at y=0 and above, x values running from -TREERADIUS to +TREERADIUS and the same for z values.

For a building, I might choose to position it by it's front left lower corner. All the y values would be >= 0, x would run from 0 to the length of the side in the x direction and z would run from 0 to the length of the side in the z direction.

If you have an "unknown" object, you can guess at the "center" by calculating the average of all the vertex x-values, y-values and z-values. The "center" would be at ( avgX, avgY, avgZ ).

Does that help?

##### Share on other sites
Yes that does make sense, and now that I think about it, its pretty obvious that all different types of world object will operate and be defined differently.

I think for now, I will assume that the center of the cube will be where the movement will be defined. (I plan on making the cube move freely around the viewable space soon).

Thanks very much for the help on these topics everyone, I do appreciate the help.

I'm sure you'll be hearing from me again soon on this forum!

##### Share on other sites
So, guess what... im having trouble getting the center point of my cube. :(

This is very frustrating so bare with me.

As this thread has been leading to, when I click the mouse on the screen I do a number of things:

A) Get the center vector of the cube (initially 0,0,0)

B) Use that center vector to get the z value, using D3DXVec3Project

C) Call D3DXVec3Unproject with the X, Y and (just found) Z values to get the screen positions for the X, Y and Z offsets for my cube to move to.

Here is the code I have:

The Render() Method of the cube:

void GameEntity::Render(IDirect3DDevice9* p_d3dDevice){	// select which vertex format we are using    p_d3dDevice->SetFVF(CUSTOMFVF);    // set the view transform    D3DXMATRIX matView;    // the view transform matrix    D3DXMatrixLookAtLH(&matView,    &D3DXVECTOR3 (0.0f, 8.0f, 25.0f),					// the camera position    &D3DXVECTOR3 (0.0f, 0.0f, 0.0f),					// the look-at position    &D3DXVECTOR3 (0.0f, 1.0f, 0.0f));					// the up direction    p_d3dDevice->SetTransform(D3DTS_VIEW, &matView);    // set the world transform    static float index = 0.0f; index += 0.03f;				// an ever-increasing float value    //D3DXMATRIX matRotateY;									// a matrix to store the rotation    //D3DXMatrixRotationY(&matRotateY, index);				// the rotation matrix	    // set the projection transform    D3DXMATRIX matProjection;						// the projection transform matrix    D3DXMatrixPerspectiveFovLH(&matProjection,                               D3DXToRadian(45),    // the horizontal field of view                               640.0f / 480.0f,		// aspect ratio                               1.0f,				// the near view-plane                               100.0f);				// the far view-plane    p_d3dDevice->SetTransform(D3DTS_PROJECTION, &matProjection);	//convert clicked positions into 3D space positions if user has	//clicked the mouse...	this->SetupLocalMousePoints(p_d3dDevice);	//Remember...Scaling, Translation, Rotation	//translate the X and Y of needed	D3DXMATRIX matTranslate;	D3DXMatrixTranslation(&matTranslate, m_xOffset, m_yOffset, m_zOffset);	//ALWAYS, Rotate before Translate    p_d3dDevice->SetTransform(D3DTS_WORLD, &(matTranslate));  // set the world transform    // select the vertex buffer to display    p_d3dDevice->SetStreamSource(0, this->GetVertexBuffer(), 0, sizeof(CUSTOMVERTEX));    // set the texture    p_d3dDevice->SetTexture(0, m_triangleTexture);    // draw the textured square    p_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);    p_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 4, 2);    p_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 8, 2);    p_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 12, 2);    p_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 16, 2);    p_d3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 20, 2); }

Here is the SetupLocalMousePoints method

void GameEntity::SetupLocalMousePoints(IDirect3DDevice9* p_d3dDevice){	if (m_mousePoint)	{		D3DXVECTOR3 screenPoint;		D3DVIEWPORT9 viewport;		D3DXMATRIX matProjection;		D3DXMATRIX matView;		D3DXMATRIX matWorld;		D3DXVECTOR3 screenVector;		HRESULT viewportRes = p_d3dDevice->GetViewport(&viewport);		HRESULT projRes = p_d3dDevice->GetTransform( D3DTS_PROJECTION, &matProjection );		HRESULT viewRes = p_d3dDevice->GetTransform( D3DTS_VIEW, &matView );		HRESULT worldRes = p_d3dDevice->GetTransform( D3DTS_WORLD, &matWorld );		D3DXVECTOR3 projectVector;		D3DXVECTOR3* p_centerVector = 0;		p_centerVector = this->GetCenterPointOfEntity();		D3DXVec3Project(&projectVector, p_centerVector ,&viewport, &matProjection, &matView, &matWorld );		delete p_centerVector;		p_centerVector = 0;		screenPoint.x = m_mousePoint->x;		screenPoint.y = m_mousePoint->y;		screenPoint.z = projectVector.z;		//transform the mouse clicked location		D3DXVec3Unproject( &screenVector, &screenPoint, &viewport, &matProjection, &matView, &matWorld );		m_xOffset = screenVector.x;		m_yOffset = screenVector.y;		m_zOffset = projectVector.z;		m_mousePoint = 0;	}}

Here is the GetCenterPointOfEntity method

D3DXVECTOR3* GameEntity::GetCenterPointOfEntity(){	//5th element in the vector is the top left front corner of the cube	CUSTOMVERTEX cv = this->GetVertices()[4];	float x = cv.X - m_xOffset;	float y = cv.Y + m_yOffset;	float z = cv.Z + m_zOffset;	x += CUBE_WIDTH / 2;	y -= CUBE_HEIGHT / 2;	z -= CUBE_DEPTH / 2;	D3DXVECTOR3* centerVector = new D3DXVECTOR3(x, y, z);	return centerVector;}

The first click of the mouse is always perfect! I think this is because the center point of the cube is (0,0,0) nice and easy! But from then on I just get crazy positions.

Thanks a lot for any help

Mark (struggling...)

##### Share on other sites
You have the right idea about saving the Unprojected center position.

However, you only need to initialize the center position of the cube once.

Assuming you initialize m_*Offset to (0,0,0), the first time through GetCenter you return the world center position of the cube. Now that you have it, you don't need to use GetCenter again.

You project that world center position to get the screen position using the center position z-value. Good, so far.

Then you unproject the screen position to get the new world center position. That's good, too.

At this point, you have the world center position and don't need to recalculate it using GetCenter! By calling GetCenter again on the next mouse-click, it get's changed. Not good.

##### Share on other sites
Quote:
 Original post by BuckeyeYou have the right idea about saving the Unprojected center position.However, you only need to initialize the center position of the cube once.Assuming you initialize m_*Offset to (0,0,0), the first time through GetCenter you return the world center position of the cube. Now that you have it, you don't need to use GetCenter again.You project that world center position to get the screen position using the center position z-value. Good, so far.Then you unproject the screen position to get the new world center position. That's good, too.At this point, you have the world center position and don't need to recalculate it using GetCenter! By calling GetCenter again on the next mouse-click, it get's changed. Not good.

Thanks Buckeye.

So I get the center (0,0,0) like you did mention, then in order to calculate the positition that the cube should move to, I only need to keep that center vector, then apply the new m_*Offset to the transformation?

In other words, perhaps I should calculate the center vector in the constructor and store it in a member variable, then simply apply the m_*Offset's like normal?

Is this because what we are really doing is when the user clicks the mouse, we want to move the cube from its "initial origin" x and y positions, not from where it "last" was?

##### Share on other sites
You've got it!

As you say, you're going to move the cube from its inital position to the new mouse-click position every time before you draw it.

##### Share on other sites
Quote:
 Original post by BuckeyeYou've got it!As you say, you're going to move the cube from its inital position to the new mouse-click position every time before you draw it.

Great, so Ive got it sort of working, but if I click in the EXACT same position over and over, Im actually getting different results!

Do you have any idea why?

From the code listed, it seems that:

projectVector.z

is constantly changing, I think this is the culprit. But im unsure how to figure out how to fix it... any ideas?

##### Share on other sites
I have just made some debug output for some help:

Mouse X: 460
Mouse Y: 386
projectVector.z: 0.971619
Mouse X: 460
Mouse Y: 386
projectVector.z: 0.974242
Mouse X: 460
Mouse Y: 386
projectVector.z: 0.972081

Which gets outputted right after:

D3DXVECTOR3 projectVector;D3DXVec3Project(&projectVector, m_centerVector ,&viewport, &matProjection, &matView, &matWorld );screenPoint.x = m_mousePoint->x;screenPoint.y = m_mousePoint->y;screenPoint.z = projectVector.z;

as posted earlier.

So as you can see, the mouse doesn't move, but the D3DXVec3Project is creating a different Z value each time...

##### Share on other sites
Usually, math functions are pretty constant. So, if the output is changing, the inputs must be changing between calls. Check the inputs to the Unproject and Project calls.

##### Share on other sites
Quote:
 Original post by BuckeyeUsually, math functions are pretty constant. So, if the output is changing, the inputs must be changing between calls. Check the inputs to the Unproject and Project calls.

Ok will do, I had a thought last night while in bed thinking about it, and should I be storing the screen space Z value on the object rather than calculating it each time the render call is being made?

Considering that I dont want to move the Z value at any time (except for when the user scrolls the mouse wheel), should I just calculate the Z-Offset when I initiate the object, and then re-calculate it only when it changes?

##### Share on other sites
The only time you need to change the z-value is when (or if) any of the viewport, projection or view matrices change.

##### Share on other sites
Quote:
 Original post by BuckeyeThe only time you need to change the z-value is when (or if) any of the viewport, projection or view matrices change.

Ok, well good news on that front, the only matrix that get affected by the m_zOffset member is D3DTS_WORLD.

So obviously, if the Z-index changes so frequently on mouse clicks, the world transformation that applies the translation on the x, y and z axis, will be affected.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627642
• Total Posts
2978354

• 10
• 12
• 22
• 13
• 33