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); }
public Vertex(Vector modelPosition, Vector normal, Point textureMapping, Color color) { _position = modelPosition; _normal = normal; _mapping = textureMapping; _color = color; }
public Camera(Vector pos, Vector forward, Vector up, float fieldOfView) { _position = pos; _forward = forward.Normalize(); _up = up.Normalize(); _fieldOfView = fieldOfView; }
public Camera() { _position = new Vector(0, 0, 0); _forward = new Vector(0, 0, 1); _up = new Vector(0, 1, 0); _fieldOfView = .5f; }
public SkyBox() { _position = new Vector(0, 0, 0); _scale = new Vector(100, 100, 100); if (_gpuVertexBufferHandle == 0) GenerateVertexBuffer(); if (_gpuTextureMappingBufferHandle == 0) GenerateTextureCoordinateBuffer(); }
/// <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; }
/// <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; }
/// <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; }
/// <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(); }
/// <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); }
/// <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; }
/// <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; }
/// <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; }
public void RotateY(float angle) { Vector Haxis = yAxis.CrossProduct(_forward.Normalize()); _forward = _forward.RotateBy(angle, 0, 1, 0).Normalize(); _up = _forward.CrossProduct(Haxis.Normalize()); }
public void Move(Vector direction, float ammount) { _position = _position + (direction * ammount); }
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); }
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(); }
public Vector Subtract(Vector right) { return Vector.Subtract(this, right); }
public Vector Slerp(Vector right, float blend) { return Vector.InterpolateSphereical(this, right, blend); }
public static Vector Subtract(Vector left, Vector right) { return new Vector( left.X - right.X, left.Y - right.Y, left.Z - right.Z); }
public bool Equals(Vector right, float leniency) { return Vector.Equals(this, right, leniency); }
public bool Equals(Vector right) { return Vector.Equals(this, right); }
public float DotProduct(Vector right) { return Vector.DotProduct(this, right); }
public Vector CrossProduct(Vector right) { return Vector.CrossProduct(this, right); }
public Vector Add(Vector right) { return Vector.Add(this, right); }
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); }
public static float[,] ToFloats(Vector vector) { return new float[,] { { vector.X }, { vector.Y }, { vector.Z } }; }
public Vector Lerp(Vector right, float blend) { return Vector.InterpolateLinear(this, right, blend); }
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; }
public static Vector RotateBy(Vector vector, Quaternion rotation) { Quaternion answer = (rotation * vector) * Quaternion.Conjugate(rotation); return new Vector(answer.X, answer.Y, answer.Z); }