private GeometryNode ObstModel; //Geometry Node und Model #endregion #region Constructor public Game_Weapon(PrimitiveModel BulletModel, Material BulletMaterial, MarkerNode GrdMarkerNode) { FOV = NORMAL_FOV; DeltaGiro = DELTA_THETA; Active = true; ActAngle = 0; InitAngle = 0; MaxAng = 360; RadActAngle = 0; GirDir = RotDirection.RECHS; RotaMode = RotMode.CONTINUE; this.BulletModel = BulletModel; BulletMat = BulletMaterial; GMarkerNode = GrdMarkerNode; WBullets = new List <Bullet>(); //Config type of Shoot WaitBullet = WAIT_SHOOT; CountToShoot = WaitBullet; ReloadTime = WAIT_RELOAD; CountToReload = 0; CountOfBullets = 0; NumBullets = Game_Logic.MAX_BULLET; RadOffset = Math.PI * (95) / 180.0; BulletOffset = new Vector3(0, 10, 30); }
public void SetMode(RotMode newMode) { if (newMode == CurrentRotMode) { return; } switch (newMode) { case RotMode.STABLE: targetAngle = joint.jointAngle - joint.jointAngle % 360.0f + stableAngle; break; case RotMode.FLOP: break; case RotMode.FRONT_FLIP: { float initialOffset = joint.jointAngle % 360.0f; if (initialOffset< 180.0f) { initialOffset += 360.0f; } targetAngle = joint.jointAngle - initialOffset; JointMotor2D motor = joint.motor; motor.motorSpeed = -flipSpeed; motor.maxMotorTorque = flipTorque; joint.motor = motor; break; } case RotMode.BACK_FLIP: { float initialOffset = joint.jointAngle % 360.0f; if (initialOffset>180.0f) { initialOffset -= 360.0f; } initialOffset = 360.0f - initialOffset; targetAngle = joint.jointAngle + initialOffset - 90f; JointMotor2D motor = joint.motor; motor.motorSpeed = flipSpeed * 0.75f; motor.maxMotorTorque = flipTorque; joint.motor = motor; break; } } if (newMode == RotMode.FLOP) { joint.useMotor = false; } else { joint.useMotor = true; } CurrentRotMode = newMode; }
private List<Bullet> WBullets; //Bullets For Weapon #endregion Fields #region Constructors public Game_Weapon(PrimitiveModel BulletModel, Material BulletMaterial, MarkerNode GrdMarkerNode) { FOV = NORMAL_FOV; DeltaGiro = DELTA_THETA; Active = true; ActAngle = 0; InitAngle = 0; MaxAng = 360; RadActAngle = 0; GirDir = RotDirection.RECHS; RotaMode = RotMode.CONTINUE; this.BulletModel = BulletModel; BulletMat = BulletMaterial; GMarkerNode = GrdMarkerNode; WBullets = new List<Bullet>(); //Config type of Shoot WaitBullet = WAIT_SHOOT; CountToShoot = WaitBullet; ReloadTime = WAIT_RELOAD; CountToReload = 0; CountOfBullets = 0; NumBullets = Game_Logic.MAX_BULLET; RadOffset = Math.PI * (95) / 180.0; BulletOffset = new Vector3(0, 10, 30); }
/// <summary> /// Sets the matrix to perform rotation about Euler angles X/Y/Z, with a /// configurable order. /// </summary> /// <param name="xdeg">Rotation about the X axis, in degrees.</param> /// <param name="ydeg">Rotation about the Y axis, in degrees.</param> /// <param name="zdeg">Rotation about the Z axis, in degrees.</param> public void SetRotationEuler(int xdeg, int ydeg, int zdeg, RotMode mode) { const double degToRad = Math.PI / 180.0; double xrad = xdeg * degToRad; double yrad = ydeg * degToRad; double zrad = zdeg * degToRad; double cx = Math.Cos(xrad); double sx = Math.Sin(xrad); double cy = Math.Cos(yrad); double sy = Math.Sin(yrad); double cz = Math.Cos(zrad); double sz = Math.Sin(zrad); double sycx = sy * cx; double sysx = sy * sx; switch (mode) { case RotMode.ZYX_RRR: // R = Rz * Ry * Rx, right-handed Val[0, 0] = cz * cy; Val[0, 1] = sz * cy; Val[0, 2] = -sy; Val[1, 0] = cz * sysx - sz * cx; Val[1, 1] = sz * sysx + cz * cx; Val[1, 2] = cy * sx; Val[2, 0] = cz * sycx + sz * sx; Val[2, 1] = sz * sycx - cz * sx; Val[2, 2] = cy * cx; break; case RotMode.ZYX_LLL: // R = Rz * Ry * Rx, left-handed Val[0, 0] = cz * cy; Val[0, 1] = -sz * cy; Val[0, 2] = sy; Val[1, 0] = cz * sysx + sz * cx; Val[1, 1] = -sz * sysx + cz * cx; Val[1, 2] = -cy * sx; Val[2, 0] = -cz * sycx + sz * sx; Val[2, 1] = sz * sycx + cz * sx; Val[2, 2] = cy * cx; break; case RotMode.XYZ_RRR: // R = Rx * Ry * Rz Val[0, 0] = cz * cy; Val[0, 1] = -sz * cy; Val[0, 2] = sy; Val[1, 0] = cz * sysx + sz * cx; Val[1, 1] = -sz * sysx + cz * cx; Val[1, 2] = -cy * sx; Val[2, 0] = -cz * sycx + sz * sx; Val[2, 1] = sz * sycx + cz * sx; Val[2, 2] = cy * cx; break; case RotMode.ZXY_RRR: // R = Rz * Rx * Ry double cysx = cy * sx; Val[0, 0] = cz * cy + sz * sysx; Val[0, 1] = -sz * cy + cz * sysx; Val[0, 2] = sy * cx; Val[1, 0] = sz * cx; Val[1, 1] = cz * cx; Val[1, 2] = -sx; Val[2, 0] = -cz * sy + sz * cysx; Val[2, 1] = sz * sy + cz * cysx; Val[2, 2] = cy * cx; break; } }