/** * @param margin Collision margin * @param switchingMode Determine the state of the camera when switching to this camera mode from another */ public FreeCameraMode(CameraControlSystem cam , Vector3 initialPosition , Degree initialRotationX , Degree initialRotationY , SwitchingMode switchingMode = SwitchingMode.CurrentState , float margin = 0.1f) : base(cam) { CameraCS = cam; Margin = margin; _fixedAxis = Vector3.UNIT_Y; _moveFactor = 1; _rotationFactor = 0.13f; _rotX = initialRotationX; _rotY = initialRotationY; _initialPosition = initialPosition; _initialRotationX = initialRotationX; _initialRotationY = initialRotationY; _lastRotationX = initialRotationX; _lastRotationY = initialRotationY; _lastPosition = initialPosition; _switchingMode = switchingMode; CameraPosition = initialPosition; this.CollisionFunc = this.DefaultCollisionDetectionFunction; }
/** * @param relativePositionToCameraTarget Default camera position with respecto to camera target * @param autoResetTime If greater than zero the camera will be resetted to its initial position after the amount of seconds specified. * @param resetDistance true for correcting the camera distance to the target when resetting. If false, the camera will maintaing the current distance to target. * @param resetRotationFactor Speed factor for correcting the camera rotation when resetting. * @param offset Offset applied to the center of the sphere. */ public SphericCameraMode(CameraControlSystem cam , Vector3 relativePositionToCameraTarget , float outerSphereRadius , Vector3 offset , Vector3 fixedAxis, float innerSphereRadius = 0.0f , float autoResetTime = 3.0f , bool resetDistance = true , float resetRotationFactor = 1.0f) : base(cam) { _relativePositionToCameraTarget = relativePositionToCameraTarget; _outerSphereRadius = outerSphereRadius; _innerSphereRadius = innerSphereRadius; _autoResetTime = autoResetTime; _resetDistance = resetDistance; _resetRotationFactor = resetRotationFactor; _offset = offset; _fixedAxis = fixedAxis; _resseting = false; _LastRessetingDiff = new Radian(2.0f * Mogre.Math.PI); if (innerSphereRadius > outerSphereRadius) { throw new Exception("Inner radious greater than outer radious"); } if (innerSphereRadius > relativePositionToCameraTarget.Length || outerSphereRadius < relativePositionToCameraTarget.Length) { throw new Exception("relativePositionToCameraTarget param value not valid."); } }
public FixedCameraMode(CameraControlSystem cam, Vector3 fixedAxis) : base(cam) { _fixedAxis = fixedAxis; _lastPosition = Vector3.ZERO; _lastOrientation = Quaternion.IDENTITY; }
public OrbitalWithMouseCameraMode(CameraControlSystem cam , MOIS.MouseButtonID activateButton , Radian initialHorizontalRotation , Radian initialVerticalRotation, float initialZoom = 1) : base(cam, initialHorizontalRotation, initialVerticalRotation, initialZoom) { _activateButton = activateButton; }
public ClosestToTargetCameraMode(CameraControlSystem cam, Vector3 fixedAxis, float timeInterval = 1) : base(cam, fixedAxis) { _timeInterval = timeInterval; _time = timeInterval; _positionsList = new List <Vector3>(); }
public ClosestToTargetCameraMode(CameraControlSystem cam, Vector3 fixedAxis, float timeInterval = 1) : base(cam, fixedAxis) { _timeInterval = timeInterval; _time = timeInterval; _positionsList=new List<Vector3>(); }
public PlaneBindedCameraMode(CameraControlSystem cam, Plane plane, Vector3 fixedAxis) : base(cam) { _fixedAxis = fixedAxis; _plane = plane; CameraTightness = 1; }
public ThroughTargetCameraMode(CameraControlSystem cam, float margin, Vector3 focusPos, Vector3 fixedAxis, bool inverse = false) : base(cam) { _fixedAxis = fixedAxis; _margin = margin; _inverse = inverse; _focusPos = focusPos; }
public FixedDirectionCameraMode(CameraControlSystem cam, Vector3 direction, float distance, Vector3 fixedAxis) : base(cam) { _fixedAxis = fixedAxis; _direction = direction.NormalisedCopy; _distance = distance; CameraTightness = 1; }
public ChaseCameraMode(CameraControlSystem cam, Vector3 relativePositionToCameraTarget, Vector3 fixedAxis, float margin = 0.1f, bool fixedStep = false, float delta = 0.001f) : base(cam) { Margin = margin; CameraCS = cam; _fixedAxis = fixedAxis; _relativePositionToCameraTarget = relativePositionToCameraTarget; _fixedStep = fixedStep; _delta = delta; CameraTightness = 0.01f; _remainingTime = 0; }
public OrbitalCameraMode(CameraControlSystem cam, Radian initialHorizontalRotation, Radian initialVerticalRotation, float initialZoom = 1 , bool resetToInitialPosition = true, float collisionmargin = 0.1f) : base(cam, Vector3.ZERO, new Radian(0), new Radian(0), new Radian(0), collisionmargin) { _zoomFactor = 1; _rotationFactor = 0.13f; _initialRotHorizontal = initialHorizontalRotation; _initialRotVertical = initialVerticalRotation; _initialZoom = initialZoom; _zoom = initialZoom; _rotHorizontal = 0; _rotVertical = 0; _zoomDisplacement = 0; _resetToInitialPosition = resetToInitialPosition; this.CameraTightness = 1; }
public RTSCameraMode(CameraControlSystem cam, Vector3 initialPosition, Vector3 upAxis, Vector3 leftAxis, Radian cameraPitch, float minZoom = 0, float maxZoom = 0) : base(cam) { _upAxis = upAxis.NormalisedCopy; _leftAxis = leftAxis.NormalisedCopy; _moveFactor = 1; _cameraPitch = cameraPitch; _minZoom = minZoom; _maxZoom = maxZoom; _zoom = 0; _rotation = new Quaternion(cameraPitch, leftAxis); _heightAxis = -upAxis.CrossProduct(leftAxis).NormalisedCopy; CameraPosition = initialPosition; _heightDisplacement = 0; _lateralDisplacement = 0; _verticalDisplacement = 0; }
public AttachedCameraMode(CameraControlSystem cam, Vector3 relativePositionToCameraTarget, Radian roll, Radian yaw, Radian pitch) : this(cam, relativePositionToCameraTarget, new Quaternion(roll, Vector3.UNIT_Z) * new Quaternion(yaw, Vector3.UNIT_Y) * new Quaternion(pitch, Vector3.UNIT_X)) { }
public FirstPersonCameraMode(CameraControlSystem cam, Vector3 relativePositionToCameraTarget, Radian roll, Radian yaw, Radian pitch) : base(cam, relativePositionToCameraTarget, roll, yaw, pitch) { _isCharacterVisible = true; }
public DummyCameraMode(CameraControlSystem cam, float speed = 1) : base(cam) { _speed = speed; _directionWhenStopped = 1; }
public FirstPersonCameraMode(CameraControlSystem cam, Vector3 relativePositionToCameraTarget, Quaternion rotation) : base(cam, relativePositionToCameraTarget, rotation) { _isCharacterVisible = true; }
private void setupCameraControlSystem() { // Ogre::camera points to -Z by default // Create the camera system using the previously created ogre camera. mCameraCS = new CameraControlSystem(sceneMgr, "CameraControlSystem", camera); // ------------------------------------------------------------------------------------- // Register a "Fixed" camera mode. In this mode the camera position and orientation // never change. FixedCameraMode camMode1; camMode1 = new FixedCameraMode(mCameraCS, Vector3.UNIT_Y); //mCameraCS->registerCameraMode("Fixed (2)",camMode1); mCameraCS.RegisterCameraMode("Fixed", camMode1); cameraModeNames.Add("Fixed"); camMode1.CameraPosition=new Vector3(-500, 0, -500); float roll = 0; float yaw = 225; float pitch = 10; camMode1.CameraOrientation=new Quaternion(new Radian(new Degree(roll)), Vector3.UNIT_Z) * new Quaternion(new Radian(new Degree(yaw)), Vector3.UNIT_Y) * new Quaternion(new Radian(new Degree(pitch)), Vector3.UNIT_X); // ------------------------------------------------------------------------------------- // Register a "FixedTracking" camera mode. In this mode the camera position is fixed // and the camera always points to the target. FixedTrackingCameraMode camMode2; camMode2 = new FixedTrackingCameraMode(mCameraCS, Vector3.UNIT_Y); mCameraCS.RegisterCameraMode("FixedTracking", camMode2); cameraModeNames.Add("FixedTracking"); camMode2.CameraPosition=new Vector3(500, 0, -100); // ------------------------------------------------------------------------------------- // Register a "Chase" camera mode with default tightness (0.01). In // this mode the camera follows the target. The second parameter is the relative position // to the target. The orientation of the camera is fixed by a yaw axis (UNIT_Y by default). ChaseCameraMode camMode3; camMode3 = new ChaseCameraMode(mCameraCS, new Vector3(0, 0, -200), Vector3.UNIT_Y); //mCameraCS.registerCameraMode("Chase(0.01 tightness)",camMode3); mCameraCS.RegisterCameraMode("Chase", camMode3); cameraModeNames.Add("Chase"); // ------------------------------------------------------------------------------------- // Register a "ChaseFreeYawAxis" camera mode with max tightness. This mode is // similar to "Chase" camera mode but the camera orientation is not fixed by // a yaw axis. The camera orientation will be the same as the target. camMode3 = new ChaseFreeYawAxisCameraMode(mCameraCS, new Vector3(0, 0, -200) , new Radian(0), new Radian(new Degree(180)), new Radian(0)); mCameraCS.RegisterCameraMode("ChaseFreeYawAxis", camMode3); cameraModeNames.Add("ChaseFreeYawAxis"); camMode3.CameraTightness = 0.05f; // ------------------------------------------------------------------------------------- // Register a "FirstPerson" camera mode. //FirstPersonCameraMode* camMode4 = new FirstPersonCameraMode(mCameraCS,Vector3(0,17,-16) FirstPersonCameraMode camMode4 = new FirstPersonCameraMode(mCameraCS, new Vector3(0, 6, -20) , new Radian(0), new Radian(new Degree(180)), new Radian(0)); mCameraCS.RegisterCameraMode("FirstPerson", camMode4); cameraModeNames.Add("FirstPerson"); camMode4.IsCharacterVisible = false; // ------------------------------------------------------------------------------------- // Register a "PlaneBinded" camera mode. In this mode the camera is constrained to the // limits of a plane. The camera always points to the target, perpendicularly to the plane. Plane mPlane = new Plane(Vector3.UNIT_Z, new Vector3(0, 0, -200)); PlaneBindedCameraMode camMode5 = new PlaneBindedCameraMode(mCameraCS, mPlane, Vector3.UNIT_Y); mCameraCS.RegisterCameraMode("PlaneBinded (XY)", camMode5); cameraModeNames.Add("PlaneBinded (XY)"); // ------------------------------------------------------------------------------------- // Register another "PlaneBinded" camera mode using a top point of view. // mPlane = new Plane(Vector3.UNIT_Y, new Vector3(0, 1000, 0)); // camMode5 = new PlaneBindedCameraMode(mCameraCS, mPlane, Vector3.UNIT_Z); // mCameraCS.registerCameraMode("PlaneBinded (XZ)", camMode5); // cameraModeNames.Add("PlaneBinded (XZ)"); // ------------------------------------------------------------------------------------- // Register a "ThroughTarget" camera mode. In this mode the camera points to a given // position (the "focus") throuh the target. The camera orientation is fixed by a yaw axis. ThroughTargetCameraMode camMode6 = new ThroughTargetCameraMode(mCameraCS, 400, Vector3.ZERO, Vector3.UNIT_Y); mCameraCS.RegisterCameraMode("ThroughTarget", camMode6); cameraModeNames.Add("ThroughTarget"); //camMode6.CameraFocusPosition=atheneNode._getDerivedPosition() - Vector3(0,100,0); camMode6.CameraFocusPosition=atheneNode._getDerivedPosition() + new Vector3(0, 100, 0); // ------------------------------------------------------------------------------------- // Register a "ClosestToTarget" camera mode. In this camera mode the position of the // camera is chosen to be the closest to the target of a given list. The camera // orientation is fixed by a yaw axis. ClosestToTargetCameraMode camMode7 = new ClosestToTargetCameraMode(mCameraCS, Vector3.UNIT_Y); mCameraCS.RegisterCameraMode("ClosestToTarget", camMode7); cameraModeNames.Add("ClosestToTarget"); Vector3 camPos1 = new Vector3(-400, 0, -400); Vector3 camPos2 = new Vector3(-400, 0, 1400); Vector3 camPos3 = new Vector3(1400, 0, 1400); camMode7.AddCameraPosition(camPos1); camMode7.AddCameraPosition(camPos2); camMode7.AddCameraPosition(camPos3); // ------------------------------------------------------------------------------------- // Register an "Attached" camera mode. In this mode the camera node is attached to the // target node as a child. AttachedCameraMode camMode8 = new AttachedCameraMode(mCameraCS, new Vector3(200, 0, 0) , new Radian(0), new Radian(new Degree(90)), new Radian(0)); //mCameraCS.registerCameraMode("Attached (lateral)",camMode8); mCameraCS.RegisterCameraMode("Attached", camMode8); cameraModeNames.Add("Attached"); // ------------------------------------------------------------------------------------- // Register a "Free" camera mode. In this mode the camera is controlled by the user. // The camera orientation is fixed to a yaw axis. yaw = 225; pitch = -10; FreeCameraMode camMode9 = new FreeCameraMode(mCameraCS, Vector3.ZERO, new Degree(yaw), new Degree(pitch) , SwitchingMode.CurrentState); mCameraCS.RegisterCameraMode("Free", camMode9); cameraModeNames.Add("Free"); camMode9.MoveFactor=30; // ------------------------------------------------------------------------------------- // Register a "FixedDirection" camera mode. In this mode the // target is always seen from the same point of view. FixedDirectionCameraMode camMode10 = new FixedDirectionCameraMode(mCameraCS, new Vector3(-1, -1, -1), 1000, Vector3.UNIT_Y); mCameraCS.RegisterCameraMode("Fixed direction", camMode10); cameraModeNames.Add("Fixed direction"); camMode10.CameraTightness=0.01f; // ------------------------------------------------------------------------------------- // Register an "Orbital" camera mode. This is basically an attached camera mode where the user // can mofify the camera position. If the scene focus is seen as the center of a sphere, the camera rotates arount it. // The last parameter indicates if the camera should be reset to its initial position when this mode is selected. OrbitalCameraMode camMode12 = new OrbitalCameraMode(mCameraCS, new Radian(0), new Radian(0), 200, false); mCameraCS.RegisterCameraMode("Orbital", camMode12); cameraModeNames.Add("Orbital"); camMode12.ZoomFactor=100; camMode12.RotationFactor=50; //camMode12.CollisionsEnabled = true; //camMode12.collisionDelegate = camMode12.DefaultCollisionDetectionFunction; // ** Uncomment for custom collisions calculation. By default the collisions are based on ogre basic raycast feature ** //camMode12.collisionDelegate = CollidableCamera::newCollisionDelegate(this // , &CameraControlSystemDemo::CustomCollisionDetectionFunction); // ------------------------------------------------------------------------------------- // Register a RTS camera mode. // RTSCameraMode camMode13 = new RTSCameraMode(mCameraCS, new Vector3(500, 1300, 1000) , Vector3.NEGATIVE_UNIT_Z , Vector3.NEGATIVE_UNIT_X , new Radian(new Degree(70)) , 0, 1000); mCameraCS.RegisterCameraMode("RTS", camMode13); cameraModeNames.Add("RTS"); camMode13.MoveFactor=20; // ------------------------------------------------------------------------------------- // Register the custom "Dummy" camera mode defined previously. It basically goes forward // and backward constantly DummyCameraMode camMode14 = new DummyCameraMode(mCameraCS, 400); mCameraCS.RegisterCameraMode("Dummy", (CameraMode)camMode14); cameraModeNames.Add("Dummy"); // ------------------------------------------------------------------------------------- // Register an "OrbitalWithMouse" camera mode. OrbitalWithMouseCameraMode camMode15 = new OrbitalWithMouseCameraMode(mCameraCS, MOIS.MouseButtonID.MB_Left, new Radian(0), new Radian(0), 200); mCameraCS.RegisterCameraMode("Orbital + mouse", camMode15); cameraModeNames.Add("Orbital + mouse"); camMode15.ZoomFactor=3; camMode15.RotationFactor=10; // ------------------------------------------------------------------------------------- // Register a spheric camera mode. Vector3 relativePositionToCameraTarget = new Vector3(0, 50, -300); // THIS IS NOT NECESSARY. just needed for the demo showing integer values in the sliders relativePositionToCameraTarget = relativePositionToCameraTarget.NormalisedCopy * 300; SphericCameraMode camMode16 = new SphericCameraMode(mCameraCS, relativePositionToCameraTarget, 700, Vector3.ZERO, Vector3.UNIT_Y); // outer radious = inner radious = relativePositionToCameraTarget.length() for a perfect sphere camMode16.HeightOffset = 50; mCameraCS.RegisterCameraMode("Spherical", camMode16); cameraModeNames.Add("Spherical"); // Set the camera target mCameraCS.TargetNode = headNode; //mCameraCS.CurrentCameraMode=camMode1;// fixed camera of cause works //mCameraCS.CurrentCameraMode=camMode2;//fixed tracking camera works //mCameraCS.CurrentCameraMode=camMode3;//chase camera works //mCameraCS.CurrentCameraMode=camMode4;//first person camera works //mCameraCS.CurrentCameraMode=camMode5;// plane binded (XY) (YZ) camera works //mCameraCS.CurrentCameraMode=camMode6;// through target camera works, cs game //mCameraCS.CurrentCameraMode=camMode7;// closest target camera works //mCameraCS.CurrentCameraMode=camMode8;// attached camera works //mCameraCS.CurrentCameraMode=camMode9;// free camera works //mCameraCS.CurrentCameraMode=camMode10;// fix direction camera works //mCameraCS.CurrentCameraMode = camMode12;// orbital camera works, but the head entity flickered //mCameraCS.CurrentCameraMode=camMode13;// RTS camera works? //mCameraCS.CurrentCameraMode=camMode14;// dummy camera works mCameraCS.CurrentCameraMode=camMode15;// orbital with mouse camera works //mCameraCS.CurrentCameraMode=camMode16;// spherical camera works }
public AttachedCameraMode(CameraControlSystem cam, Vector3 relativePositionToCameraTarget, Quaternion rotation) : base(cam) { _rotation = rotation; _relativePositionToCameraTarget = relativePositionToCameraTarget; }
public ChaseFreeYawAxisCameraMode(CameraControlSystem cam, Vector3 relativePositionToCameraTarget, Radian roll, Radian yaw, Radian pitch, float collisionMargin = 0.1f) : base(cam, relativePositionToCameraTarget, Vector3.UNIT_Y, collisionMargin) { _rotationOffset = new Quaternion(roll, Vector3.UNIT_Z) * new Quaternion(yaw, Vector3.UNIT_Y) * new Quaternion(pitch, Vector3.UNIT_X); }
public NodeListener(CameraControlSystem cam) { cameraCS = cam; }
public FixedTrackingCameraMode(CameraControlSystem cam, Vector3 fixedAxis) : base(cam, fixedAxis) { }
public CameraMode(CameraControlSystem cam) { CameraCS = cam; _cameraPos = Vector3.ZERO; _cameraOrient = Quaternion.IDENTITY; }