示例#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);
 }
示例#2
0
 public Vertex(Vector modelPosition, Vector normal, Point textureMapping, Color color)
 {
     _position = modelPosition;
       _normal = normal;
       _mapping = textureMapping;
      _color = color;
 }
示例#3
0
 public Camera(Vector pos, Vector forward, Vector up, float fieldOfView)
 {
     _position = pos;
       _forward = forward.Normalize();
       _up = up.Normalize();
       _fieldOfView = fieldOfView;
 }
示例#4
0
        public Camera()
        {
            _position = new Vector(0, 0, 0);
              _forward = new Vector(0, 0, 1);
              _up = new Vector(0, 1, 0);

              _fieldOfView = .5f;
        }
示例#5
0
 public SkyBox()
 {
     _position = new Vector(0, 0, 0);
       _scale = new Vector(100, 100, 100);
       if (_gpuVertexBufferHandle == 0)
     GenerateVertexBuffer();
       if (_gpuTextureMappingBufferHandle == 0)
     GenerateTextureCoordinateBuffer();
 }
示例#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;
 }
示例#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;
 }
示例#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;
 }
示例#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();
 }
示例#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);
 }
示例#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;
 }
示例#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;
 }
示例#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;
        }
示例#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());
 }
示例#15
0
 public void Move(Vector direction, float ammount)
 {
     _position = _position + (direction * ammount);
 }
示例#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);
 }
示例#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();
 }
示例#18
0
 public Vector Subtract(Vector right)
 {
     return Vector.Subtract(this, right);
 }
示例#19
0
 public Vector Slerp(Vector right, float blend)
 {
     return Vector.InterpolateSphereical(this, right, blend);
 }
示例#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);
 }
示例#21
0
 public bool Equals(Vector right, float leniency)
 {
     return Vector.Equals(this, right, leniency);
 }
示例#22
0
 public bool Equals(Vector right)
 {
     return Vector.Equals(this, right);
 }
示例#23
0
 public float DotProduct(Vector right)
 {
     return Vector.DotProduct(this, right);
 }
示例#24
0
 public Vector CrossProduct(Vector right)
 {
     return Vector.CrossProduct(this, right);
 }
示例#25
0
 public Vector Add(Vector right)
 {
     return Vector.Add(this, right);
 }
示例#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);
 }
示例#27
0
 public static float[,] ToFloats(Vector vector)
 {
     return new float[,] { { vector.X }, { vector.Y }, { vector.Z } };
 }
示例#28
0
 public Vector Lerp(Vector right, float blend)
 {
     return Vector.InterpolateLinear(this, right, blend);
 }
示例#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;
 }
示例#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);
 }