Jump to content
  • Advertisement
Sign in to follow this  
chillypacman

D3DTS_WORLD transform not working..

This topic is 4024 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
Are you calling

dev->SetTransform(D3DTS_WORLD, &pos);

Twice on purpose or is that a mistake?

Share this post


Link to post
Share on other sites
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
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!