public override void Start() { base.Start(); _other = ElementManager.Instance.Enemy(TeamIndex); CamController = GameObject.FindGameObjectWithName("camera_" + PlayerIndex).GetComponent <CameraController>(); //CamController.Start(); // why is start called on this? //subcomponents (shorten) pA = gameObject.GetComponent <PlayerAttack>(); pM = gameObject.GetComponent <PlayerMovement>(); pI = gameObject.GetComponent <PlayerInventory>(); pP = gameObject.GetComponent <PlayerPowerup>(); pS = gameObject.GetComponent <PlayerStamina>(); MovingRigidBody mrb = gameObject.GetComponent <MovingRigidBody>(); _steerableCollider = mrb.SteerableCollider; // Reset start position transform.position = startPosition; transform.rotation = Quaternion.Identity; if (_steerableCollider != null) { _steerableCollider.Speed = JVector.Zero; _steerableCollider.RotationY = 0; _steerableCollider.Position = Conversion.ToJitterVector(startPosition); _steerableCollider.Orientation = JMatrix.CreateRotationY(0); } }
/// <summary> /// Randomizes the orientation of a die /// </summary> /// <param name="die">Die body</param> public void RandomizeDieOrientation(RigidBody die) { float xRot = -MathHelper.Pi + ((float)random.NextDouble() * MathHelper.TwoPi); float yRot = -MathHelper.Pi + ((float)random.NextDouble() * MathHelper.TwoPi); float zRot = -MathHelper.Pi + ((float)random.NextDouble() * MathHelper.TwoPi); die.Orientation = JMatrix.CreateRotationX(xRot) * JMatrix.CreateRotationY(yRot) * JMatrix.CreateRotationZ(zRot); }
/// <summary> /// Functionality which is applied after the physics is updated /// </summary> /// <param name="timestep"></param> public override void PostStep(float timestep) { //AddForce(Speed); //LinearVelocity = Speed; Position = new JVector(Position.X, HeightHalf + 0.1f, Position.Z); Orientation = JMatrix.CreateRotationY(RotationY); base.PostStep(timestep); }
protected override void rotate() { if (gameInput.keyboard[Key.Q]) { if (selectedMod != null && mConst == null) { JMatrix rotMatA = JMatrix.CreateRotationY(gameInput.move.X * cameraRotSpeed); JMatrix rotMatB = GenericMethods.FromOpenTKMatrix(Matrix4.CreateFromAxisAngle(-Parent.rightVec, gameInput.move.Y * cameraRotSpeed)); JMatrix rotMatFinal = JMatrix.Multiply(rotMatA, rotMatB); selectedBody.Orientation = JMatrix.Multiply(selectedBody.Orientation, rotMatFinal); } } else { base.rotate(); } }
public override void Draw() { G.PushMatrix(); G.SetTransform(Body.Position, Body.Orientation); G.Translate(0, -0.3f, -0.2f); G.Scale(0.032f, 0.032f, 0.032f); sc.Draw(); G.PopMatrix(); for (int i = 0; i < ((DefaultCar)Body).Wheels.Length; i++) { G.PushMatrix(); Wheel wheel = ((DefaultCar)Body).Wheels[i]; G.SetTransform(wheel.GetWorldPosition(), Body.Orientation); G.SetTransform(JVector.Zero, JMatrix.CreateRotationY(wheel.SteerAngle * (float)Math.PI / 180)); G.SetTransform(JVector.Zero, JMatrix.CreateRotationX(-wheel.WheelRotation * (float)Math.PI / 180)); G.Scale(whRadius * 1.3f, whRadius * 1.3f, whRadius * 1.3f); wc.Draw(); G.PopMatrix(); } }
public void InitBody(ref RigidBody body, TransformComponent transform, int entity) { body.Shape = new BoxShape(0.2f, 0.2f, 0.2f); body.Position = new JVector(transform.X, transform.Y, transform.Z); body.Orientation = JMatrix.CreateRotationX(transform.RotationX) * JMatrix.CreateRotationY(transform.RotationY) * JMatrix.CreateRotationZ(transform.RotationZ); body.SetMassProperties(); body.Update(); body.IsActive = true; // TODO body.IsStatic = !OwnerApp.EntityManager.HasComponent <MovableComponent>(entity); body.Mass = 1.0f; // TODO body.Material = new Material() { Restitution = 0.2f, StaticFriction = 0.8f, KineticFriction = 0.8f }; // TODO _world.AddBody(body); }