PDA

Click to See Complete Forum and Search --> : 1 or 2 directX questions(should be easy)...


VBD
Sep 16th, 2002, 11:57 AM
Hi, I am wondering how to do double culling in DirectX. Can anyone answer that for me? Also, how can I rotate an object(IE Polygon) without rotating the rest of the DirectX world(If I had 2 triangles and I wanted triangle A to rotate on its X axis and Triangle B to rotate on Its Y axis?). Thanx in advance...

Zaei
Sep 16th, 2002, 12:30 PM
Double culling? Whazzat?

You DO rotate the entire world when you use matrices. For the first triangle, set its rotation matrix, and render it. Set the matrix for the second triangle, and render it. The triangles are rendered With the current matrices, and change the matrices after you render has NO effect on what has been already rendered.

Z.

danday1974
Sep 16th, 2002, 01:10 PM
Just confirming what Z said. Here are the steps.

1) Reset Matrix
2) Apply a rotation to the matrix
3) Set the matrix transformation to the world view
4) Render shape 1
5) Reset Matrix
6) Applay a rotation to the matrix
7) Set the matrix transformation to the world view
8) Render shape 2

If u need function names they are something similar to this (I cant be bothered to look them up but these should be roughly right, I know they arent spot on though)

Reset matrix = d3dxmatrixidentity MatrixName
Apply Rotation = d3dxmatirxrotatey MatrixName (axis y rotation)
Set transformation = d3ddevice.settransform SOMETHING_WORLD, MatrixName
Render = DrawPrimitive bla bla bla

Hope this helps

Dan

VBD
Sep 16th, 2002, 01:12 PM
That helps fix my transformation junk. About double culling, what I mean is that if you rotate a triangle you can only see the front side. What if you want to see the front and back side?

danday1974
Sep 16th, 2002, 02:25 PM
TO SEE BOTH SIDES USE THIS 1 LINE OF CODE

D3DDEVICE.SETRENDERSTATE D3DRS_CULLMODE,1

This following code is the actual function names I mentioned in my last post

D3DXMatrixIdentity matWorld '//Reset our world matrix

' ROTATION

D3DXMatrixIdentity matTemp
D3DXMatrixRotationY matTemp, RotateAngle * (pi / 180)
D3DXMatrixMultiply matWorld, matWorld, matTemp

' SCALING

D3DXMatrixIdentity matTemp
D3DXMatrixScaling matTemp, TileCurrScale, TileCurrScale, TileCurrScale
D3DXMatrixMultiply matWorld, matWorld, matTemp

' TRANSLATION (MOVING)

D3DXMatrixIdentity matTemp
D3DXMatrixTranslation matTemp, TileCurrPos.X, TileCurrPos.Y, TileCurrPos.Z
D3DXMatrixMultiply matWorld, matWorld, matTemp

D3DDevice.SetTransform D3DTS_WORLD, matWorld

Render '//Update the frame...

That should sort u out

Dan

PS In this example he has applied 3 transformations at the same time and then rendered all geometry (shapes n stuff) to be rotated,scaled,etc.

Zaei
Sep 16th, 2002, 03:03 PM
Originally posted by danday1974
D3DDEVICE.SETRENDERSTATE D3DRS_CULLMODE,1


0.0!! Evil! NEVER use values like that =).


D3DDevice.SetRenderState D3DRS_CULLMODE, D3DCULL_NONE


Z.

danday1974
Sep 16th, 2002, 03:23 PM
Z

lol sorry i was thinking that myself but couldnt be assed to write another post which I have ended up doing anyway lol

Dan