Example #1
0
        /// <summary>
        /// Sets the uniform value.
        /// </summary>
        /// <param name="name">The uniform name.</param>
        /// <param name="value">The uniform value.</param>
        /// <returns>Reference to self for method call chaining.</returns>
        IShaderUniform IShaderUniform.SetUniform(string name, Quaternion value)
        {
            int location;

            if (this.uniformLocations.TryGetValue(name, out location))
            {
                gl.Uniform4(location, value.X, value.Y, value.Z, value.W);
            }

            return this;
        }
Example #2
0
		/// <summary>
		/// Accumulate a rotation to this ModelMatrix.
		/// </summary>
		/// <param name="q">
		/// A <see cref="Quaternion"/> representing the rotation.
		/// </param>
		public void Rotate(Quaternion q)
		{
			if (q == null)
				throw new ArgumentNullException("q");

			Set((Matrix4x4)this * (Matrix4x4)q);
		}
Example #3
0
 /// <summary>
 /// Create a new camera object with a certain eye position and orientation.
 /// </summary>
 /// <param name="position">The eye position of the camera.</param>
 /// <param name="orientation">The orientation of the camera.</param>
 public Camera(Vector3 position, Quaternion orientation)
 {
     this.Position = position;
     this.Orientation = orientation;
 }
Example #4
0
 /// <summary>
 /// Rotates the camera by a supplied rotation quaternion.
 /// </summary>
 /// <param name="rotation">The amount to rotate the camera by.</param>
 public void Rotate(Quaternion rotation)
 {
     Orientation = rotation * orientation;
 }
Example #5
0
		/// <summary>
		/// Quaternion constructor from euler rotation axis and rotation angle.
		/// </summary>
		/// <param name="other">
		/// A <see cref="Quaternion"/> representing the rotation axis.
		/// </param>
		public Quaternion(Quaternion other)
		{
			if (other == null)
				throw new ArgumentNullException("other");

			// Set the default rotation axis
			mDefaultVector = other.mDefaultVector;
			// Copy quaternion fields
			mVector = other.mVector;
			mCosAngle = other.mCosAngle;
		}
Example #6
0
        private static void OnKeyboardDown(byte key, int x, int y)
        {
            if (key == 'w') moveforward = true;
            if (key == 's') movebackward = true;
            if (key == 'a') moveleft = true;
            if (key == 'd') moveright = true;
            if (key == ' ') moveup = true;
            if (Glut.glutGetModifiers() == Glut.GLUT_ACTIVE_SHIFT) movedown = true;

            if (key == 'v')
            {
                testViewMatrix = camera.ViewMatrix;
                testPos = camera.Position;
                testOrientation = camera.Orientation;
            }
            if (key == 'f') wireframe = !wireframe;
            if (key == 'c')
            {
                culling = !culling;
                if (culling)
                    Gl.Enable(EnableCap.CullFace);
                else
                    Gl.Disable(EnableCap.CullFace);
            }
            if (key == 27) Glut.glutLeaveMainLoop();
        }