Sign in to follow this  
chillypacman

D3DTS_WORLD transform not working..

Recommended Posts

chillypacman    100
void mesh::RenderMesh(ID3DXEffect* mFX)
{
	D3DXHANDLE   mWhiteTex;
	D3DXHANDLE   mhTex;
	D3DXHANDLE   mhMtrl;

	D3DXMATRIX pos;
	D3DXMatrixTranslation(&pos, 78, 50, 69);
	dev->SetTransform(D3DTS_WORLD, &pos);
	

	for(UINT j = 0; j < mSceneMtrls.size(); ++j)
	{
		HR(mFX->SetValue(mhMtrl, &mSceneMtrls[j], sizeof(Mtrl)));
	
		// If there is a texture, then use.
		if(mSceneTextures[j] != 0)
		{
			HR(mFX->SetTexture(mhTex, mSceneTextures[j]));
		}

		// But if not, then set a pure white texture.  When the texture color
		// is multiplied by the color from lighting, it is like multiplying by
		// 1 and won't change the color from lighting.
		else
		{
			HR(mFX->SetTexture(mhTex, mSceneTextures[j]));
		}
	
		//HR(mFX->SetTexture(mhNormalMap, mSceneNormalMaps[j]));

		HR(mFX->CommitChanges());
		dev->SetTransform(D3DTS_WORLD, &pos);
		HR(model->DrawSubset(j));
	}
}
basically I want the model to render at pos, though no matter what pos is set to the transform isn't working, it's always placed at the origin for some reason.

Share this post


Link to post
Share on other sites
chillypacman    100
Quote:
Original post by Kiryn
Are you calling

dev->SetTransform(D3DTS_WORLD, &pos);

Twice on purpose or is that a mistake?


well I don't think it matters, though I've tried calling it once inside the loop, once outside the loop and inside and outside the loop. If it doesn't work once it isn't going to work any other way but it's wortha shot regardless :P

Share this post


Link to post
Share on other sites
Nik02    4348
Does your effect/technique use a vertex shader? The fixed-function transforms (Dev::SetTransform()) and lighting are disabled if a vertex shader is enabled.

Share this post


Link to post
Share on other sites
chillypacman    100
Quote:
Original post by Nik02
Does your effect/technique use a vertex shader? The fixed-function transforms (Dev::SetTransform()) and lighting are disabled if a vertex shader is enabled.


oh ok, I see.

Yes it is, I'm still new to shaders so it was a pretty obvious mistake.

I just went through the DX sdk and it looks like I should use something along the lines of mFX->SetMatrix(), if I don't get this to work I'll come back though I have a strong hunch it's what I'm supposed to use.

Share this post


Link to post
Share on other sites
Nik02    4348
Effect::SetMatrix is a good choice here. In your vertex shader function, you can use that matrix to transform the geometry.

Do note that you have to communicate your view and projection transforms to the shader too, in order to achieve similar results to the fixed pipeline.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this