Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


davepl1968

Member Since 08 Mar 2013
Offline Last Active Sep 04 2013 11:28 AM

#5085971 What on earth is wrong with this really basic rotation?

Posted by davepl1968 on 14 August 2013 - 06:09 PM

I have a nice little fireworks demo running, and I thought for the heck of it I'd spin the "ball of particles" that comprises the fireworks.  To do this, I assumed that the steps were:

 

- Translate back to origin from where it lives in space

- Apply rotation matrices for X, Y, Z

- Translate back to where object lived in space

- Set that as the World matrix before drawing the object (leaving projection and view completely alone)

 

It does not work as I would expect (or at all, really).  It just jumps around a bunch but largely stays put (no rotation).  I'm placing that new world matrix into the shader before drawing the instance.  I know all that works, as it draws them without rotation exactly as I'd hoped.  It's just my application of rotation that has broken everything...

 

Either I've got a really ugly bug or a very poor grasp of how to compose such a matrix.  A prod in either direction would be very much appreciated!

D3DXMATRIX matrixTranslateBefore;
D3DXMATRIX matrixRotationX;
D3DXMATRIX matrixRotationY;
D3DXMATRIX matrixRotationZ;
D3DXMATRIX matrixTranslateAfter;

float rads = fElapsedTime * 50.0f;

D3DXMatrixTranslation(&matrixTranslateBefore,  -pExplosion->_centerPosition.x, 
                      -pExplosion->_centerPosition.y, -pExplosion->_centerPosition.z);
D3DXMatrixRotationX(&matrixRotationX, rads);
D3DXMatrixRotationY(&matrixRotationY, rads);
D3DXMatrixRotationZ(&matrixRotationZ, rads);
D3DXMatrixTranslation(&matrixTranslateAfter, pExplosion->_centerPosition.x,
pExplosion->_centerPosition.y, pExplosion->_centerPosition.z);

pCameraManager->_worldMatrix = matrixTranslateBefore * matrixRotationX * matrixRotationY * matrixRotationZ * matrixTranslateAfter; 

 




#5083052 Using FX files without -shipping- my FX shader files

Posted by davepl1968 on 04 August 2013 - 12:22 PM

My solution was to compile them to .cso and then do this:

 

V_RETURN( D3DXCreateEffectFromFile(pd3dDevice, strPath.c_str(), 0, 0, D3DXSHADER_DEBUG, 0, &_ptrEffect, &pBuffer) );
V_RETURN( pd3dDevice->CreateVertexDeclaration(particleVertexDeclarations, &_ptrVertexDeclaration) );
 
// Get the technique, pass, and shaders we need
 
D3DXHANDLE hTechnique = _ptrEffect->GetTechniqueByName("ExplosionTechnique");
if (!hTechnique)
return E_FAIL;
 
D3DXHANDLE hPass = _ptrEffect->GetPassByName(hTechnique, "Pass0");
if (!hPass)
return E_FAIL;
 
// Get the vertex and pixel shaders 
 
D3DXPASS_DESC desc;
V_RETURN( _ptrEffect->GetPassDesc(hPass, &desc) );
V_RETURN( pd3dDevice->CreateVertexShader(desc.pVertexShaderFunction, &_ptrVertexShader) );
V_RETURN( pd3dDevice->CreatePixelShader (desc.pPixelShaderFunction,  &_ptrPixelShader) );



#5082608 Given an effect-technique-pass handle, how to get the PixelShader

Posted by davepl1968 on 02 August 2013 - 05:22 PM

I'll answer my own question since I've seen it asked a number of times but never answered:  this appears to work.

 

 

 

D3DXPASS_DESC desc;

V_RETURN( _pEffect->GetPassDesc(hPass, &desc) );

V_RETURN( pd3dDevice->CreateVertexShader(desc.pVertexShaderFunction, &_pVertexShader) );

V_RETURN( pd3dDevice->CreatePixelShader (desc.pPixelShaderFunction, &_pPixelShader) );




PARTNERS