Exemple #1
0
        public VertexEntity(Vector3 position, Vector3 rotation, PredefinedObject shape, Color color, Vector3 scale)
            : this(position, rotation, PrimitiveType.TriangleList)
        {
            if (shape == PredefinedObject.Plane)
            {
                _vertices = new VertexPositionColorNormal[6];

                _vertices[0].Position = new Vector3(-1.0f, 1.0f, 0.0f) * scale;
                _vertices[1].Position = new Vector3(1.0f, 1.0f, 0.0f) * scale;
                _vertices[2].Position = new Vector3(1.0f, -1.0f, 0.0f) * scale;
                _vertices[3].Position = new Vector3(-1.0f, 1.0f, 0.0f) * scale;
                _vertices[4].Position = new Vector3(1.0f, -1.0f, 0.0f) * scale;
                _vertices[5].Position = new Vector3(-1.0f, -1.0f, 0.0f) * scale;

                _vertices[0].Color = color;
                _vertices[1].Color = color;
                _vertices[2].Color = color;
                _vertices[3].Color = color;
                _vertices[4].Color = color;
                _vertices[5].Color = color;

                _vertices[0].Normal = new Vector3(0, 1, 0);
                _vertices[1].Normal = new Vector3(0, 1, 0);
                _vertices[2].Normal = new Vector3(0, 1, 0);
                _vertices[3].Normal = new Vector3(0, 1, 0);
                _vertices[4].Normal = new Vector3(0, 1, 0);
                _vertices[5].Normal = new Vector3(0, 1, 0);

                _indices = new int[] {0, 1, 2, 3, 4, 5};
                _primCount = 2;

                InitBuffers();
            }
        }
        public TexturedVertexEntity(Vector3 position, Vector3 rotation, PredefinedObject shape, Color color, Vector3 scale, Texture2D texture)
            : base(position, rotation, PrimitiveType.TriangleList)
        {
            _effect = new BasicEffect(GameUtils.GetUtil<GraphicsDevice>());

            if (shape == PredefinedObject.Plane)
            {
                _texture = texture;
                _vertices = new VertexPositionNormalTexture[6];

                _vertices[0].Position = new Vector3(-1.0f, 1.0f, 0.0f) * scale;
                _vertices[1].Position = new Vector3(1.0f, 1.0f, 0.0f) * scale;
                _vertices[2].Position = new Vector3(1.0f, -1.0f, 0.0f) * scale;
                _vertices[3].Position = new Vector3(-1.0f, 1.0f, 0.0f) * scale;
                _vertices[4].Position = new Vector3(1.0f, -1.0f, 0.0f) * scale;
                _vertices[5].Position = new Vector3(-1.0f, -1.0f, 0.0f) * scale;

                _vertices[0].TextureCoordinate = new Vector2(0, 0);
                _vertices[1].TextureCoordinate = new Vector2(1, 0);
                _vertices[2].TextureCoordinate = new Vector2(1, 1);
                _vertices[3].TextureCoordinate = new Vector2(0, 0);
                _vertices[4].TextureCoordinate = new Vector2(1, 1);
                _vertices[5].TextureCoordinate = new Vector2(0, 1);

                _vertices[0].Normal = new Vector3(0, 1, 0);
                _vertices[1].Normal = new Vector3(0, 1, 0);
                _vertices[2].Normal = new Vector3(0, 1, 0);
                _vertices[3].Normal = new Vector3(0, 1, 0);
                _vertices[4].Normal = new Vector3(0, 1, 0);
                _vertices[5].Normal = new Vector3(0, 1, 0);

                _indices = new int[] {0, 1, 2, 3, 4, 5};
                _primCount = 2;

                InitBuffers();
            }
        }