Esempio n. 1
0
 public Vertex()
 {
     _position = new Vector(0, 0, 0);
       _normal = new Vector(0, 0, 0);
       _mapping = new Point(0, 0);
       _color = new Color(0, 0, 0, 0);
 }
Esempio n. 2
0
 public Vertex(Vector modelPosition, Vector normal, Point textureMapping, Color color)
 {
     _position = modelPosition;
       _normal = normal;
       _mapping = textureMapping;
      _color = color;
 }
Esempio n. 3
0
 public Camera(Vector pos, Vector forward, Vector up, float fieldOfView)
 {
     _position = pos;
       _forward = forward.Normalize();
       _up = up.Normalize();
       _fieldOfView = fieldOfView;
 }
Esempio n. 4
0
        public Camera()
        {
            _position = new Vector(0, 0, 0);
              _forward = new Vector(0, 0, 1);
              _up = new Vector(0, 1, 0);

              _fieldOfView = .5f;
        }
Esempio n. 5
0
 public SkyBox()
 {
     _position = new Vector(0, 0, 0);
       _scale = new Vector(100, 100, 100);
       if (_gpuVertexBufferHandle == 0)
     GenerateVertexBuffer();
       if (_gpuTextureMappingBufferHandle == 0)
     GenerateTextureCoordinateBuffer();
 }
Esempio n. 6
0
 /// <summary>Creates a static model out of the parameters.</summary>
 /// <param name="staticModelId">The id of this model for look up purposes.</param>
 /// <param name="meshes">A list of mesh ids, textures, and buffer references that make up this model.</param>
 internal StaticModel(string staticModelId, AvlTree<StaticMesh, string> meshes)
 {
     _id = staticModelId;
       _shaderOverride = null;
       _meshes = meshes;
       _position = new Vector(0, 0, 0);
       _scale = new Vector(1, 1, 1);
       _orientation = Quaternion.FactoryIdentity;
 }
Esempio n. 7
0
 /// <summary>Creates a blank template for a static model (you will have to construct the model yourself).</summary>
 public StaticModel(string id)
 {
     _id = id;
       _shaderOverride = null;
       _meshes = new AvlTreeLinked<StaticMesh, string>(StaticMesh.CompareTo, StaticMesh.CompareTo);
       _position = new Vector(0, 0, 0);
       _scale = new Vector(1, 1, 1);
       _orientation = Quaternion.FactoryIdentity;
 }
Esempio n. 8
0
 /// <summary>Creates a blank template for a static model (you will have to construct the model yourself).</summary>
 public StaticModel()
 {
     _id = "From Scratch";
       _shaderOverride = null;
       _meshes = new List<Link3<string, Texture, StaticMesh>>();
       _position = new Vector(0, 0, 0);
       _scale = new Vector(1, 1, 1);
       _rotationAxis = new Vector(0, 0, 0);
       _rotationAngle = 0;
 }
Esempio n. 9
0
 /// <summary>Creates an instance of a sprite.</summary>
 /// <param name="texture">The texture to have this sprite mapped to.</param>
 public Sprite(Texture texture)
 {
     if (_gpuVertexBufferHandle == 0)
     GenerateVertexBuffer();
       _position = new Vector(0, 0, -10);
       _scale = new Point(1, 1);
       _rotation = 0f;
       _texture = texture;
       GenerateTextureCoordinateBuffer();
 }
Esempio n. 10
0
 /// <summary>Creates an instance of a sprite.</summary>
 /// <param name="texture">The texture to have this sprite mapped to.</param>
 /// <param name="textureMappings">The texture mappings for this sprite.</param>
 public Sprite(Texture texture, float[] textureMappings)
 {
     if (_gpuVertexBufferHandle == 0)
     GenerateVertexBuffer(_verteces);
       _position = new Vector(0, 0, -10);
       _scale = new Point(1, 1);
       _rotation = 0f;
       _texture = texture;
       if (textureMappings.Length != 12)
     throw new Exception("Invalid number of texture coordinates in sprite constructor.");
       GenerateTextureCoordinateBuffer(textureMappings);
 }
Esempio n. 11
0
 /// <summary>Creates a static model from the ids provided.</summary>
 /// <param name="staticModelId">The id to represent this model as.</param>
 /// <param name="textures">An array of the texture ids for each sub-mesh of this model.</param>
 /// <param name="meshes">An array of each mesh id for this model.</param>
 /// <param name="meshNames">An array of mesh names for this specific instanc3e of a static model.</param>
 internal StaticModel(string staticModelId, string[] meshNames, string[] meshes, string[] textures)
 {
     if (textures.Length != meshes.Length && textures.Length != meshNames.Length)
     throw new Exception("Attempting to create a static model with non-matching number of components.");
       _id = staticModelId;
       _meshes = new AvlTreeLinked<StaticMesh, string>(StaticMesh.CompareTo, StaticMesh.CompareTo);
       for (int i = 0; i < textures.Length; i++)
     _meshes.Add(new StaticMesh(meshNames[i], TextureManager.Get(textures[i]), StaticModelManager.GetMesh(meshes[i]).StaticMeshInstance));
       _shaderOverride = null;
       _position = new Vector(0, 0, 0);
       _scale = new Vector(1, 1, 1);
       _orientation = Quaternion.FactoryIdentity;
 }
Esempio n. 12
0
 /// <summary>Creates an instance of a sprite.</summary>
 /// <param name="texture">The texture to have this sprite mapped to.</param>
 public Sprite(Texture texture)
 {
     if (_gpuVertexBufferHandle == 0)
     GenerateVertexBuffer(_verteces);
       _position = new Vector(0, 0, -10);
       _scale = new Point(1, 1);
       _rotation = 0f;
       _texture = texture;
       if (_gpuTextureMappingBufferHandleDefault == 0)
       {
     GenerateTextureCoordinateBuffer(_textureMappingsDefault);
     _gpuTextureMappingBufferHandleDefault = _gpuTextureMappingBufferHandle;
       }
       else
     _gpuTextureMappingBufferHandle = _gpuTextureMappingBufferHandleDefault;
 }
Esempio n. 13
0
        /// <summary>Creates a static model from the ids provided.</summary>
        /// <param name="staticModelId">The id to represent this model as.</param>
        /// <param name="textures">An array of the texture ids for each sub-mesh of this model.</param>
        /// <param name="meshes">An array of each mesh id for this model.</param>
        /// <param name="meshNames">An array of mesh names for this specific instanc3e of a static model.</param>
        internal StaticModel(string staticModelId, string[] textures, string[] meshes, string[] meshNames)
        {
            if (textures.Length != meshes.Length && textures.Length != meshNames.Length)
            throw new Exception("Attempting to create a static model with non-matching number of components.");

              _id = staticModelId;
              //_meshes = new ListArray<Link<Texture, StaticMesh>>(10);
              _meshes = new List<Link3<string, Texture, StaticMesh>>();

              for (int i = 0; i < textures.Length; i++)
            _meshes.Add(meshNames[i], new Link3<string, Texture, StaticMesh>(meshNames[i], TextureManager.Get(textures[i]), StaticModelManager.GetMesh(meshes[i])));

              _shaderOverride = null;
              _position = new Vector(0, 0, 0);
              _scale = new Vector(1, 1, 1);
              _rotationAxis = new Vector(0, 0, 0);
              _rotationAngle = 0;
        }
Esempio n. 14
0
 public void RotateY(float angle)
 {
     Vector Haxis = yAxis.CrossProduct(_forward.Normalize());
       _forward = _forward.RotateBy(angle, 0, 1, 0).Normalize();
       _up = _forward.CrossProduct(Haxis.Normalize());
 }
Esempio n. 15
0
 public void Move(Vector direction, float ammount)
 {
     _position = _position + (direction * ammount);
 }
Esempio n. 16
0
 public Quaternion Multiply(Vector vector)
 {
     return new Quaternion(
     _w * vector.X + _y * vector.Z - _z * vector.Y,
     _w * vector.Y + _z * vector.X - _x * vector.Z,
     _w * vector.Z + _x * vector.Y - _y * vector.X,
     -_x * vector.X - _y * vector.Y - _z * vector.Z);
 }
Esempio n. 17
0
 public static Quaternion FromAxisAngle(Vector axis, float angle)
 {
     if (axis.LengthSquared == 0.0f)
     return IdentityFactory;
       float sinAngleOverAxisLength = Trigonometry.Sin(angle / 2) / axis.Length;
       return new Quaternion(
     axis.X * sinAngleOverAxisLength,
     axis.Y * sinAngleOverAxisLength,
     axis.Z * sinAngleOverAxisLength,
     Trigonometry.Cos(angle / 2)).Normalize();
 }
Esempio n. 18
0
 public Vector Subtract(Vector right)
 {
     return Vector.Subtract(this, right);
 }
Esempio n. 19
0
 public Vector Slerp(Vector right, float blend)
 {
     return Vector.InterpolateSphereical(this, right, blend);
 }
Esempio n. 20
0
 public static Vector Subtract(Vector left, Vector right)
 {
     return new Vector(
     left.X - right.X,
     left.Y - right.Y,
     left.Z - right.Z);
 }
Esempio n. 21
0
 public bool Equals(Vector right, float leniency)
 {
     return Vector.Equals(this, right, leniency);
 }
Esempio n. 22
0
 public bool Equals(Vector right)
 {
     return Vector.Equals(this, right);
 }
Esempio n. 23
0
 public float DotProduct(Vector right)
 {
     return Vector.DotProduct(this, right);
 }
Esempio n. 24
0
 public Vector CrossProduct(Vector right)
 {
     return Vector.CrossProduct(this, right);
 }
Esempio n. 25
0
 public Vector Add(Vector right)
 {
     return Vector.Add(this, right);
 }
Esempio n. 26
0
 public static Vector RotateBy(Vector vector, float angle, float x, float y, float z)
 {
     // Note: the angle is in radians
       float sinHalfAngle = Calc.Sin(angle / 2);
       float cosHalfAngle = Calc.Cos(angle / 2);
       x *= sinHalfAngle;
       y *= sinHalfAngle;
       z *= sinHalfAngle;
       float x2 = cosHalfAngle * vector.X + y * vector.Z - z * vector.Y;
       float y2 = cosHalfAngle * vector.Y + z * vector.X - x * vector.Z;
       float z2 = cosHalfAngle * vector.Z + x * vector.Y - y * vector.X;
       float w2 = -x * vector.X - y * vector.Y - z * vector.Z;
       return new Vector(
     x * w2 + cosHalfAngle * x2 + y * z2 - z * y2,
     y * w2 + cosHalfAngle * y2 + z * x2 - x * z2,
     z * w2 + cosHalfAngle * z2 + x * y2 - y * x2);
 }
Esempio n. 27
0
 public static float[,] ToFloats(Vector vector)
 {
     return new float[,] { { vector.X }, { vector.Y }, { vector.Z } };
 }
Esempio n. 28
0
 public Vector Lerp(Vector right, float blend)
 {
     return Vector.InterpolateLinear(this, right, blend);
 }
Esempio n. 29
0
 public static Matrix ToMatrix(Vector vector)
 {
     return new Matrix(new float[,] { { vector.X }, { vector.Y }, { vector.Z } });
       //Matrix matrix = new Matrix(vector.X, vector.Y, vector.Z);
       //matrix[0, 0] = vector.X;
       //matrix[1, 0] = vector.Y;
       //matrix[2, 0] = vector.Z;
       //return matrix;
 }
Esempio n. 30
0
 public static Vector RotateBy(Vector vector, Quaternion rotation)
 {
     Quaternion answer = (rotation * vector) * Quaternion.Conjugate(rotation);
       return new Vector(answer.X, answer.Y, answer.Z);
 }