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


C# Transformation.Translate方法代码示例

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


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

示例1: CreateFace


//.........这里部分代码省略.........
            }

            // Now that we have the min/max sizes in the x-y plane
            // Construct the quad vertices based on the resolution.  
            // Start from the bottom (negative y) and go up
            // Move from left (negative x) to right
            float xDiff = maxX - minX;
            float yDiff = maxY - minY;
            float xIncr = xDiff / res.Columns;
            float yIncr = yDiff / res.Rows;
            int vIndex = 0;

            for (int row = 0; row < res.Rows; row++)
            {
                for (int column = 0; column < res.Columns; column++)
                {
                    Vector3f vertex1 = new Vector3f(minX + column * xIncr, minY + row * yIncr, 0);
                    Vector3f vertex2 = new Vector3f(minX + (column + 1) * xIncr, minY + row * yIncr, 0);
                    Vector3f vertex3 = new Vector3f(minX + (column + 1) * xIncr, minY + (row + 1) * yIncr, 0);
                    Vector3f vertex4 = new Vector3f(minX + column * xIncr, minY + (row + 1) * yIncr, 0);

                    // Set the vertices for the quad
                    vertices[vIndex + 0] = vertex1;
                    vertices[vIndex + 1] = vertex2;
                    vertices[vIndex + 2] = vertex3;
                    vertices[vIndex + 3] = vertex4;

                    // Set the indices for the quad
                    indices[vIndex + 0] = vIndex;
                    indices[vIndex + 1] = vIndex + 1;
                    indices[vIndex + 2] = vIndex + 2;
                    indices[vIndex + 3] = vIndex + 3;

                    // Set the texture coords for the quad
                    texCoords[vIndex + 0].Set(0.0f, 0.0f);
                    texCoords[vIndex + 1].Set(1.0f, 0.0f);
                    texCoords[vIndex + 2].Set(1.0f, 1.0f);
                    texCoords[vIndex + 3].Set(0.0f, 1.0f);

                    vIndex += 4;
                }
            }

            // assign all the attributes to the mesh object
            // and return it.
            wall.SetIndices(indices);
            wall.SetVertices(vertices);
            wall.SetTextureCoordinates(texCoords);
            wall.Texture = texture;

            
            // Now transform the vertices based on which wall it is we are constructing
            minX = roomSize.X / -2;
            maxX = roomSize.X / 2;

            minY = roomSize.Y / -2;
            maxY = roomSize.Y / 2;

            float minZ = roomSize.Z / -2;
            float maxZ = roomSize.Z / 2;
            Transformation transform = new Transformation();

            switch (whichWall)
            {
                case AABBFace.Front:
                    transform.Translate(new float3(0, 0, minZ));
                    break;

                case AABBFace.Back:
                    transform.SetRotate(float3x3.Rotate((float)Math.PI, new float3(0, 1, 0)));
                    transform.Translate(new float3(0, 0, maxZ));
                    break;

                case AABBFace.Left:
                    transform.SetRotate(float3x3.Rotate((float)Math.PI/2, new float3(0, 1, 0)));
                    transform.Translate(new float3(minX, 0, 0));

                    break;

                case AABBFace.Right:
                    transform.SetRotate(float3x3.Rotate((float)-Math.PI/2, new float3(0, 1, 0)));
                    transform.Translate(new float3(maxX, 0, 0));
                    break;

                case AABBFace.Ceiling:
                    transform.SetRotate(float3x3.Rotate((float)-Math.PI/2, new float3(1, 0, 0)));
                    transform.Translate(new float3(0, maxY, 0));
                    break;

                case AABBFace.Floor:
                    transform.SetRotate(float3x3.Rotate((float)Math.PI/2, new float3(1, 0, 0)));
                    transform.Translate(new float3(0, minY, 0));
                    break;
            }

            wall.ApplyTransform(transform);


            return wall;
        }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:101,代码来源:AABBFaceMesh.cs


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