Sign in to follow this  
roni_game

3D Object Rotation VB 6

Recommended Posts

I have a problem with direct3d programming in VB 6...I wish you can help me my problem is how to Rotate 3D object, i'm already create several cylinder, but my cylinder position in along of Y axis....I want to rotate my cylinder position in along of X axis. I wish you can help me...thanx this is of my script section.... '----------------------- ' Create cylinder mesh: '----------------------- Set Mesh = m_D3DX8.CreateCylinder(m_D3DDevice8, m_Radius, m_Radius2, m_length, 36, 12, AdjBuffer) Set m_BallMesh = Mesh.CloneMeshFVF(ByVal 0, D3DFVF_BALLVERTEX, m_D3DDevice8) numVertices = m_BallMesh.GetNumVertices ReDim VArray(numVertices - 1) Set VBuffer = m_BallMesh.GetVertexBuffer D3DVertexBuffer8GetData VBuffer, 0, numVertices * Len(VArray(0)), 0, VArray(0) For i = 0 To numVertices - 1 SignZ = Sgn(VArray(i).XYZ.z) VArray(i).Tex1.x = (-SignZ * VArray(i).XYZ.x + m_Radius) / (2 * m_Radius) VArray(i).Tex1.y = (VArray(i).XYZ.y + m_Radius) / (2 * m_Radius) * -1 Next i D3DVertexBuffer8SetData VBuffer, 0, numVertices * Len(VArray(0)), 0, VArray(0) '----------------------------------------------------------------------------- ' Render: Draws the scene '----------------------------------------------------------------------------- Friend Sub Render() Dim matBlack As D3DMATERIAL8 Dim mTranslation As D3DMATRIX If m_D3DDevice8 Is Nothing Then Exit Sub With m_D3DDevice8 .SetRenderState D3DRS_WRAP0, D3DWRAP_U .SetRenderState D3DRS_ALPHABLENDENABLE, 0 .SetVertexShader D3DFVF_BALLVERTEX .SetMaterial m_matWhite For i = 0 To m_numBalls - 1 If m_Balls(i).numFramesSpentInPocket <= m_maxFramesSpentInPocket Then ' Set the world transformation matrix: .SetTransform D3DTS_WORLD, m_Balls(i).mGenerator ' and the texture for this subset: .SetTexture 0, m_Balls(i).Texture ' Draw the mesh subset m_BallMesh.DrawSubset 0 End If Next i [Edited by - roni_game on May 24, 2007 1:20:44 AM]

Share this post


Link to post
Share on other sites
So your question is how to rotate your object by 90 degrees along the z axis? (Making a vertical cylinder horizontal?) If so, you need to multiply the world matrix for the cylinder with a rotation matrix. Some VB6 code from an earlier project of mine:

D3DXMatrixIdentity matTemp 
D3DXMatrixRotationZ matTemp, msngRotZ
D3DXMatrixMultiply mWorldMatrix, mWorldMatrix, matTemp 'mWorldMatrix corresponds to your "m_Balls(i).mGenerator"


Is this the type of thing you are looking for?

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