Exemplo n.º 1
0
        public CubieMesh(CubieFace face, Point3[] vertexes, CColor color)
        {
            _face              = face;
            _mesh              = new MeshGeometry3D();
            _geometry          = new GeometryModel3D();
            _geometry.Geometry = _mesh;
            SetColor(MapToColor(color));


            Point3DCollection positions = PositionsToPoint3DCollection(vertexes);

            //positions.Freeze();
            _mesh.Positions = positions;

            Int32Collection indices = new Int32Collection(2 * 3);

            indices.Add(0);
            indices.Add(1);
            indices.Add(2);

            indices.Add(2);
            indices.Add(3);
            indices.Add(0);

            //indices.Freeze();
            _mesh.TriangleIndices = indices;
        }
Exemplo n.º 2
0
        private Color MapToColor(CColor meshColor)
        {
            Color color = new Color();

            color.A = meshColor.A;
            color.B = meshColor.B;
            color.G = meshColor.G;
            color.R = meshColor.R;

            return(color);
        }
Exemplo n.º 3
0
        public Mesh(CubieFace face, Point3[] vertexes, CColor meshColor)
        {
            _face = face;
            GraphicsDevice gd = Factory.GraphicsDevice;

            Debug.Assert(vertexes.Count() == 4);

            _basicEffect       = new BasicEffect(gd, null);
            _basicEffect.Alpha = 1.0F;
            _basicEffect.VertexColorEnabled = true;

            _vertexDeclaration = new VertexDeclaration(gd, VertexPositionColor.VertexElements);
            int vertexCount = vertexes.Count();                                                                    // 4;// 24;

            _vertexBuffer = new VertexBuffer(gd, typeof(VertexPositionColor), vertexCount, BufferUsage.WriteOnly); // ResourceUsage.WriteOnly, ResourceManagementMode.Automatic);
            _vertexArray  = new VertexPositionColor[vertexCount];

            Color color = MapToColor(meshColor);

            for (int i = 0; i < vertexCount; i++)
            {
                _vertexArray[i].Position = new Vector3((float)vertexes[i].X, (float)vertexes[i].Y, (float)vertexes[i].Z);
                _vertexArray[i].Color    = color;
            }

            _vertexBuffer.SetData <VertexPositionColor>(_vertexArray);

            short[] vertexIndices = new short[2 * 3 * 2];

            vertexIndices[0] = (short)0;
            vertexIndices[1] = (short)1;
            vertexIndices[2] = (short)2;
            vertexIndices[3] = (short)0;
            vertexIndices[4] = (short)2;
            vertexIndices[5] = (short)3;

            vertexIndices[6]  = (short)2;
            vertexIndices[7]  = (short)1;
            vertexIndices[8]  = (short)0;
            vertexIndices[9]  = (short)3;
            vertexIndices[10] = (short)2;
            vertexIndices[11] = (short)0;

            _indexBuffer = new IndexBuffer(gd, sizeof(short) * vertexIndices.Length,
                                           BufferUsage.None, IndexElementSize.SixteenBits);

            _indexBuffer.SetData <short>(vertexIndices);
        }
Exemplo n.º 4
0
 public IMesh CreateMesh(CubieFace face, Point3[] vertexes, CColor color)//(Axis axis, Position center, MeshSize size, double edgeWidth, MeshColor color)
 {
     //return new CubieMesh(axis, center, size, edgeWidth, color);
     return(new CubieMesh(face, vertexes, color));
 }
Exemplo n.º 5
0
 public IMesh CreateMesh(CubieFace face, Point3[] vertexes, CColor color)
 {
     return(new Mesh(face, vertexes, color));
 }