public void Reset() { for (int i = 0; i < verticesDefault.Count; i++) { var c = vertices[i].Color; var n = vertices[i].Normal; vertices[i] = new VertexPositionColorNormal(verticesDefault[i].Position, c, n); } }
public void Transform(Matrix transformationMatrix) { for (int i = 0; i < vertices.Count; i++) { var v = vertices[i].Position; var c = vertices[i].Color; var n = vertices[i].Normal; vertices[i] = new VertexPositionColorNormal(Vector3.Transform(v, transformationMatrix), c, n); } }
//in deg public void Rotate(float x, float y, float z) { var rotation = Matrix.CreateRotationX(MathHelper.ToRadians(x)) * Matrix.CreateRotationY(MathHelper.ToRadians(y)) * Matrix.CreateRotationZ(MathHelper.ToRadians(z)); for (int i = 0; i < vertices.Count; i++) { var v = vertices[i].Position; var c = vertices[i].Color; var n = vertices[i].Normal; vertices[i] = new VertexPositionColorNormal(Vector3.Transform(v, rotation), c, n); //vertices[i].SetNewPosition(Vector3.Transform(v, rotation)); } }
public void Translate(Vector3 translationVector) { var translation = Matrix.CreateTranslation(translationVector.X, translationVector.Y, translationVector.Z); for (int i = 0; i < vertices.Count; i++) { var v = vertices[i].Position; var c = vertices[i].Color; var n = vertices[i].Normal; vertices[i] = new VertexPositionColorNormal(Vector3.Transform(v, translation), c, n); //vertices[i].SetNewPosition(v+translationVector); } }
public void Rotate(Vector3 rotationVector) { float a = MathHelper.ToRadians(rotationVector.X); float b = MathHelper.ToRadians(rotationVector.Y); float c = MathHelper.ToRadians(rotationVector.Z); var rotation = Matrix.CreateRotationY(MathHelper.ToRadians(-rotationVector.X)) * Matrix.CreateRotationZ(MathHelper.ToRadians(-rotationVector.Y)) * Matrix.CreateRotationX(MathHelper.ToRadians(-rotationVector.Z)); for (int i = 0; i < vertices.Count; i++) { var v = vertices[i].Position; var col = vertices[i].Color; var n = vertices[i].Normal; vertices[i] = new VertexPositionColorNormal(Vector3.Transform(v, rotation), col, n); //vertices[i].SetNewPosition(Vector3.Transform(v, rotation)); } }
public void QuaterionRotation(Quaternion quaternion) { //change z with y to correct display in xna //double z = quaternion.Z; //quaternion.Z = -quaternion.Y; //quaternion.Y = z; //quaternion.X = -quaternion.X; //quaternion.Y = quaternion.Y; //quaternion.Z = -quaternion.Y; Quaternion q = new Quaternion(-quaternion.X, -quaternion.Y, quaternion.Z, quaternion.W); var rotation = Matrix.CreateFromQuaternion(q); for (int i = 0; i < vertices.Count; i++) { var v = vertices[i].Position; var c = vertices[i].Color; var n = vertices[i].Normal; vertices[i] = new VertexPositionColorNormal(Vector3.Transform(v, rotation), c, n); } }