Example #1
0
        public void RotateX(int degrees)
        {
            List <Vector3> posPom = new List <Vector3>();

            foreach (var point in vertices)
            {
                posPom.Add(Vector3.Transform(point.Position, Matrix.CreateRotationX(MathHelper.ToRadians(degrees))));
            }
            int i = 0;

            foreach (var point in posPom)
            {
                vertices[i] = new VertexPositionNormalColor(point, vertices[i].Normal, vertices[i].Color);
                i++;
            }
        }
Example #2
0
        public void Scale(float scaleFactor)
        {
            List <Vector3> posPom = new List <Vector3>();

            foreach (var point in vertices)
            {
                posPom.Add(Vector3.Transform(point.Position, Matrix.CreateScale(scaleFactor)));
            }
            int i = 0;

            foreach (var point in posPom)
            {
                vertices[i] = new VertexPositionNormalColor(point, vertices[i].Normal, vertices[i].Color);
                i++;
            }
        }
Example #3
0
        public void Translate(Vector3 translation)
        {
            List <Vector3> posPom = new List <Vector3>();

            foreach (var point in vertices)
            {
                posPom.Add(Vector3.Transform(point.Position, Matrix.CreateTranslation(translation)));
            }
            int i = 0;

            foreach (var point in posPom)
            {
                vertices[i] = new VertexPositionNormalColor(point, vertices[i].Normal, vertices[i].Color);
                i++;
            }
        }
Example #4
0
        private void CreateSphereVertices()
        {
            vertices = new VertexPositionNormalColor[nvertices];
            Vector3 center = new Vector3(0, 0, 0);
            Vector3 rad    = new Vector3((float)Math.Abs(radius), 0, 0);

            for (int x = 0; x < m; x++) //90 circles, difference between each is 4 degrees
            {
                float difx = 360.0f / m;
                for (int y = 0; y <= m / 2; y++) //90 veritces, difference between each is 4 degrees
                {
                    float   dify  = 360.0f / m;
                    Matrix  zrot  = Matrix.CreateRotationZ(MathHelper.ToRadians(y * dify)); //rotate vertex around z
                    Matrix  yrot  = Matrix.CreateRotationY(MathHelper.ToRadians(x * difx)); // rotate circle around y
                    Vector3 point = Vector3.Transform(Vector3.Transform(rad, zrot), yrot);  //transformation

                    vertices[x + y * m] = new VertexPositionNormalColor(point, GetNormal(point), color);
                }
            }
        }