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 }
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 }