Direct3D 메시의 회전

Posted 2007/02/02 14:05 by J2L

private Mesh RotationZ(Mesh mesh, float angle)
        {
            device.RenderState.Lighting = false;
            int[] ranks = new int[1];
            ranks[0] = mesh.NumberVertices;
            device.Lights.Reset();
            Mesh dumi = mesh.Clone(MeshFlags.SystemMemory, CustomVertex.PositionNormalTextured.Format, device);
            System.Array arr = dumi.VertexBuffer.Lock(0, typeof(CustomVertex.PositionNormalTextured), LockFlags.None, ranks);

            for (int x = 0; x < arr.Length; x++)
            {
                CustomVertex.PositionNormalTextured cpt = (CustomVertex.PositionNormalTextured)arr.GetValue(x);
                //cpt.Position = Vector3.TransformCoordinate(cpt.Position, Matrix.Translation(0, 0, 0) * Matrix.RotationZ(angle));
                cpt.Position = Vector3.TransformCoordinate(cpt.Position,Matrix.RotationAxis(new Vector3(0,0,1),angle));
                cpt.Normal = Vector3.TransformCoordinate(cpt.Normal, Matrix.RotationAxis(new Vector3(0, 0, 1), angle));
                arr.SetValue(cpt, x);
            }
          
            dumi.SetVertexBufferData(arr, LockFlags.None);
            dumi.VertexBuffer.Unlock();
            arr.Initialize();
            return dumi;
        }

크리에이티브 커먼즈 라이선스
Creative Commons License

'C#' 카테고리의 다른 글

Direct3D 메시의 크기 설정  (0) 2007/02/14
C# 이미지에 글쓰기..  (0) 2007/02/13
Direct3D 메시의 회전  (0) 2007/02/02
3D 렌더링...  (0) 2007/01/31
XNA GAME Studio Express 1.0  (0) 2007/01/26
MyPlayer  (0) 2007/01/25

Tag : , , ,

« PREV : 1 : ... 71 : 72 : 73 : 74 : 75 : 76 : 77 : 78 : 79 : ... 85 : NEXT »