当前位置: 首页>>代码示例>>C#>>正文


C# Matrix4.mutiply方法代码示例

本文整理汇总了C#中Matrix4.mutiply方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix4.mutiply方法的具体用法?C# Matrix4.mutiply怎么用?C# Matrix4.mutiply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix4的用法示例。


在下文中一共展示了Matrix4.mutiply方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddTrianglesGroupDoodads

        void AddTrianglesGroupDoodads(TriangleCollection s, ModelInstance mi, Vec3D world_dir, Vec3D world_off, float rot)
        {
            float dx = mi.pos.x;
            float dy = mi.pos.y;
            float dz = mi.pos.z;

            rotate(dx, dz, rot + 90f, out dx, out dz);

            dx += world_off.x;
            dy += world_off.y;
            dz += world_off.z;

            Quaternion q;
            q.x = mi.dir.z;
            q.y = mi.dir.x;
            q.z = mi.dir.y;
            q.w = mi.w;
            Matrix4 rotMatrix = new Matrix4();
            rotMatrix.makeQuaternionRotate(q);

            Model m = mi.model;

            if (m.boundingTriangles == null)
            {

            }
            else
            {

                // We got boiuding stuff, that is better
                int nBoundingVertices = m.boundingVertices.Length / 3;
                int[] vertices = new int[nBoundingVertices];

                for (uint i = 0; i < nBoundingVertices; i++)
                {
                    uint off = i * 3;
                    float x = m.boundingVertices[off];
                    float y = m.boundingVertices[off + 2];
                    float z = m.boundingVertices[off + 1];
                    x *= mi.sc;
                    y *= mi.sc;
                    z *= -mi.sc;

                    Vector pos;
                    pos.x = x;
                    pos.y = y;
                    pos.z = z;
                    Vector new_pos = rotMatrix.mutiply(pos);
                    x = pos.x;
                    y = pos.y;
                    z = pos.z;

                    float dir_x = world_dir.z;
                    float dir_y = world_dir.y - 90;
                    float dir_z = -world_dir.x;

                    rotate(z, y, dir_x, out z, out y);
                    rotate(x, y, dir_z, out x, out y);
                    rotate(x, z, dir_y, out x, out z);

                    float xx = x + dx;
                    float yy = y + dy;
                    float zz = -z + dz;

                    float finalx = ChunkReader.ZEROPOINT - zz;
                    float finaly = ChunkReader.ZEROPOINT - xx;
                    float finalz = yy;
                    vertices[i] = s.AddVertex(finalx, finaly, finalz);
                }

                int nBoundingTriangles = m.boundingTriangles.Length / 3;
                for (uint i = 0; i < nBoundingTriangles; i++)
                {
                    uint off = i * 3;
                    int v0 = vertices[m.boundingTriangles[off]];
                    int v1 = vertices[m.boundingTriangles[off + 1]];
                    int v2 = vertices[m.boundingTriangles[off + 2]];
                    s.AddTriangle(v0, v2, v1, ChunkedTriangleCollection.TriangleFlagModel);
                }

            }
        }
开发者ID:iwaitu,项目名称:babbot,代码行数:82,代码来源:MPQTriangleSupplier.cs

示例2: AddTrianglesGroupDoodads

        void AddTrianglesGroupDoodads(TriangleCollection s, ModelInstance mi, Vec3D world_dir, Vec3D world_off, float rot)
        {
            float dx = mi.pos.x;
            float dy = mi.pos.y;
            float dz = mi.pos.z;

            rotate(dx, dz, rot +90f, out dx, out dz);

            dx += world_off.x;
            dy += world_off.y;
            dz += world_off.z;

            Quaternion q;
            q.x = -mi.dir.z; q.y = mi.dir.x; q.z = mi.dir.y; q.w = mi.w;
            Matrix4 rotMatrix = new Matrix4();
            rotMatrix.makeQuaternionRotate(q);

            Model m = mi.model;

            if (m.boundingTriangles == null)
            {
                /*
                // /cry no bouding info, revert to normal vertices

                ModelView mv = m.view[0]; // View number 1 ?!?!
                int[] vertices = new int[m.vertices.Length / 3];
                for (uint i = 0; i < m.vertices.Length / 3; i++)
                {
                    float x = m.vertices[i * 3];
                    float y = m.vertices[i * 3 + 2];
                    float z = m.vertices[i * 3 + 1];
                    x *= mi.sc;
                    y *= mi.sc;
                    z *= -mi.sc;

                    Vector pos; pos.x = x; pos.y = y; pos.z = z;
                    Vector new_pos = rotMatrix.mutiply(pos);
                    x = pos.x; y = pos.y; z = pos.z;

                    rotate(x, z, (world_dir.y - 90), out x, out z);
                    rotate(y, z, -world_dir.x, out y, out z);
                    rotate(x, y, world_dir.z, out x, out y);

                    float xx = x + dx;
                    float yy = y + dy;
                    float zz = -z + dz;

                    float finalx = ChunkReader.ZEROPOINT - zz;
                    float finaly = ChunkReader.ZEROPOINT - xx;
                    float finalz = yy;

                    vertices[i] = s.AddVertex(finalx, finaly, finalz);
                }

                for (int i = 0; i < mv.triangleList.Length / 3; i++)
                {
                    int off = i * 3;
                    UInt16 vi0 = mv.triangleList[off];
                    UInt16 vi1 = mv.triangleList[off + 1];
                    UInt16 vi2 = mv.triangleList[off + 2];

                    int ind0 = mv.indexList[vi0];
                    int ind1 = mv.indexList[vi1];
                    int ind2 = mv.indexList[vi2];

                    int v0 = vertices[ind0];
                    int v1 = vertices[ind1];
                    int v2 = vertices[ind2];
                    s.AddTriangle(v0, v1, v2, ChunkedTriangleCollection.TriangleFlagModel);
                }
                */
            }
            else
            {

                // We got boiuding stuff, that is better
                int nBoundingVertices = m.boundingVertices.Length / 3;
                int[] vertices = new int[nBoundingVertices];

                for (uint i = 0; i < nBoundingVertices; i++)
                {
                    uint off = i * 3;
                    float x = m.boundingVertices[off];
                    float y = m.boundingVertices[off + 2];
                    float z = m.boundingVertices[off + 1];
                    x *= mi.sc;
                    y *= mi.sc;
                    z *= -mi.sc;

                    Vector pos; pos.x = x; pos.y = y; pos.z = z;
                    Vector new_pos = rotMatrix.mutiply(pos);
                    x = pos.x; y = pos.y; z = pos.z;

                    rotate(x, z, (world_dir.y - 90), out x, out z);
                    rotate(y, z, -world_dir.x, out y, out z);
                    rotate(x, y, world_dir.z, out x, out y);

                    float xx = x + dx;
                    float yy = y + dy;
                    float zz = -z + dz;
//.........这里部分代码省略.........
开发者ID:icaca,项目名称:boogiebot,代码行数:101,代码来源:MPQTriangleSupplier.cs


注:本文中的Matrix4.mutiply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。