private void timer1_Tick(object sender, EventArgs e) { IWorldSpace node = this.node; if (node != null) { node.RotationAngle += 1; } }
private void timer1_Tick(object sender, EventArgs e) { IWorldSpace renderer = this.scene.RootElement; if (renderer != null) { renderer.RotationAngle += 1; } }
private void timer1_Tick(object sender, EventArgs e) { IWorldSpace node = this.scene.RootElement; if (node != null) { node.RotationAngle += 1.3f; } }
private void timer1_Tick(object sender, EventArgs e) { IWorldSpace node = this.scene.RootNode; if (node != null) { node.RotationAngle += 1.3f; } UpdateText(this.trvScene.Nodes[0]); }
private void timer1_Tick(object sender, EventArgs e) { if (this.operationState == OperationState.Rotating) { IWorldSpace node = this.scene.RootNode; if (node != null) { node.RotationAngle += 1; } } }
/// <summary> /// Gets max and min position of the AABB box that wraps specified <paramref name="model"/>. /// </summary> /// <param name="model"></param> /// <param name="maxPosition"></param> /// <param name="minPosition"></param> public static void GetMaxMinPosition(this IWorldSpace model, out vec3 maxPosition, out vec3 minPosition) { if (model == null) { throw new System.ArgumentNullException(); } vec3 lengths = model.ModelSize * model.Scale; maxPosition = model.WorldPosition + lengths / 2.0f; minPosition = model.WorldPosition - lengths / 2.0f; }
/// <summary> /// Copy <see cref="IWorldSpace"/> state from specified <paramref name="source"/>. /// </summary> /// <param name="dest"></param> /// <param name="source"></param> public static void CopyModelSpaceStateFrom(this IWorldSpace dest, IWorldSpace source) { if (dest == null || source == null) { throw new System.ArgumentNullException(); } dest.ModelSize = source.ModelSize; dest.RotationAngle = source.RotationAngle; dest.RotationAxis = source.RotationAxis; dest.Scale = source.Scale; dest.WorldPosition = source.WorldPosition; }
///// <summary> ///// Get model matrix. ///// </summary> ///// <param name="model"></param> ///// <returns></returns> //public static mat4 GetModelMatrix(this IWorldSpace model) //{ // mat4 matrix = glm.translate(mat4.identity(), model.WorldPosition); // matrix = glm.scale(matrix, model.Scale); // matrix = glm.rotate(matrix, model.RotationAngle, model.RotationAxis); // var node = model as RendererBase; // if (node != null) // { // var parent = node.Parent as RendererBase; // if (parent != null) // { // matrix = parent.modelMat * matrix; // } // node.modelMat = matrix; // } // return matrix; //} /// <summary> /// Rotate this model based on all previous rotation actions. /// Thus all rotations will take part in model's rotation result. /// <para>在目前的旋转状态下继续旋转一次,即所有的旋转操作都会(按照发生顺序)生效。</para> /// </summary> /// <param name="model"></param> /// <param name="angleDegree">Angle in Degree.</param> /// <param name="axis"></param> public static void Rotate(this IWorldSpace model, float angleDegree, vec3 axis) { mat4 currentRotationMatrix = glm.rotate(model.RotationAngle, model.RotationAxis); mat4 newRotationMatrix = glm.rotate(angleDegree, axis); mat4 latestRotationMatrix = newRotationMatrix * currentRotationMatrix; Quaternion quaternion = latestRotationMatrix.ToQuaternion(); float latestAngle; vec3 latestAxis; quaternion.Parse(out latestAngle, out latestAxis); model.RotationAngle = latestAngle; model.RotationAxis = latestAxis; }
private static int AppendWorldStates(RealmPacketOut packet, IWorldSpace space) { var count = 0; if (space.ParentSpace != null) { count += AppendWorldStates(packet, space.ParentSpace); } if (space.WorldStates != null) { count += space.WorldStates.FieldCount; packet.Write(space.WorldStates.CompiledState); } return count; }
public WorldStateCollection(IWorldSpace area, WorldState[] states) { Area = area; States = states; CompiledState = new byte[8 * States.Length]; // init default states for (var i = 0; i < States.Length; i++) { var state = States[i]; Array.Copy(BitConverter.GetBytes((uint)state.Key), 0, CompiledState, i * 8, 4); Array.Copy(BitConverter.GetBytes(state.DefaultValue), 0, CompiledState, 4 + i * 8, 4); } }
public WorldStateCollection(IWorldSpace area, WorldState[] states) { Area = area; States = states; CompiledState = new byte[8 * States.Length]; // init default states for (var i = 0; i < States.Length; i++) { var state = States[i]; Array.Copy(BitConverter.GetBytes((uint)state.Key), 0, CompiledState, i * 8, 4); Array.Copy(BitConverter.GetBytes(state.DefaultValue), 0, CompiledState, 4 + i * 8, 4); } }
public WorldStateCollection(IWorldSpace area, WorldState[] states) { this.Area = area; this.States = states; this.CompiledState = new byte[8 * this.States.Length]; for (int index = 0; index < this.States.Length; ++index) { WorldState state = this.States[index]; Array.Copy((Array)BitConverter.GetBytes((uint)state.Key), 0, (Array)this.CompiledState, index * 8, 4); Array.Copy((Array)BitConverter.GetBytes(state.DefaultValue), 0, (Array)this.CompiledState, 4 + index * 8, 4); } }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public static BoundingBox GetBoundingBox(this IWorldSpace model) { vec3 max, min; { vec3 position = model.WorldPosition + model.ModelSize * model.Scale / 2; max = position; } { vec3 position = model.WorldPosition - model.ModelSize * model.Scale / 2; min = position; } return(new BoundingBox(min, max)); }
static int AppendWorldStates(RealmPacketOut packet, IWorldSpace space) { var count = 0; if (space.ParentSpace != null) { count += AppendWorldStates(packet, space.ParentSpace); } if (space.WorldStates != null) { count += space.WorldStates.FieldCount; packet.Write(space.WorldStates.CompiledState); } return(count); }
private static int AppendWorldStates(RealmPacketOut packet, IWorldSpace space) { int num = 0; if (space.ParentSpace != null) { num += WorldStateHandler.AppendWorldStates(packet, space.ParentSpace); } if (space.WorldStates != null) { num += space.WorldStates.FieldCount; packet.Write(space.WorldStates.CompiledState); } return(num); }
private void timer1_Tick(object sender, EventArgs e) { if (this.rotateRect) { IWorldSpace node = this.rectangle; if (node != null) { node.RotationAngle += 1; } } if (this.rotateTeapot) { IWorldSpace node = this.teapot; if (node != null) { node.RotationAngle += 10; } } }
/// <summary> /// Run legacy model transform.(from model space to world space) /// </summary> /// <param name="model"></param> public static void LegacyTransform(this IWorldSpace model) { GL.Instance.Translatef(model.WorldPosition.x, model.WorldPosition.y, model.WorldPosition.z); GL.Instance.Scalef(model.Scale.x, model.Scale.y, model.Scale.z); GL.Instance.Rotatef(model.RotationAngle, model.RotationAxis.x, model.RotationAxis.y, model.RotationAxis.z); }