天天看點

ogre 1.8.1 camera 類

想用ogre的camera類設定成可以将觀察平面設定到遠近剪切面之間,是以整理一下相機類,部分參考自http://blog.csdn.net/w1635610/article/details/5446058

隻整理public函數:

<span style="white-space:pre">	</span>/** Standard constructor.
        */
        Camera( const String& name, SceneManager* sm);

        /** Standard destructor.
        */
        virtual ~Camera();

		/// Add a listener to this camera
		virtual void addListener(Listener* l);
		/// Remove a listener to this camera
		virtual void removeListener(Listener* l);

        /** Returns a pointer to the SceneManager this camera is rendering through.
		獲得場景管理器
        */
        SceneManager* getSceneManager(void) const;

        /** Sets the level of rendering detail required from this camera.
			設定該相機要求的渲染細節
            @remarks
                Each camera is set to render at full detail by default, that is
                with full texturing, lighting etc. This method lets you change
                that behaviour, allowing you to make the camera just render a
                wireframe view, for example.
				每個相機預設渲染所有細節,包含了紋理,燈光等。該函數讓你可以改變情況,
				例如允許你設定相機隻渲染線框。
        */
        void setPolygonMode(PolygonMode sd);

        /** Retrieves the level of detail that the camera will render.
        */
        PolygonMode getPolygonMode(void) const;

        /** Sets the camera's position.
        */
        void setPosition(Real x, Real y, Real z);

        /** Sets the camera's position.
        */
        void setPosition(const Vector3& vec);

        /** Retrieves the camera's position.
        */
        const Vector3& getPosition(void) const;

        /** Moves the camera's position by the vector offset provided along world axes.
		移動相機(世界坐标軸)
        */
        void move(const Vector3& vec);

        /** Moves the camera's position by the vector offset provided along it's own axes (relative to orientation).
		移動相機(相機自身坐标軸)
        */
        void moveRelative(const Vector3& vec);

        /** Sets the camera's direction vector.
		設定相機指向的向量
            @remarks
                Note that the 'up' vector for the camera will automatically be recalculated based on the
                current 'up' vector (i.e. the roll will remain the same).
				相機向上的方向會自動根據目前向上的向量改變,向右的向量保持不變
        */
        void setDirection(Real x, Real y, Real z);

        /** Sets the camera's direction vector.
        */
        void setDirection(const Vector3& vec);

        /* Gets the camera's direction.
        */
        Vector3 getDirection(void) const;

        /** Gets the camera's up vector.
        */
        Vector3 getUp(void) const;

        /** Gets the camera's right vector.
        */
        Vector3 getRight(void) const;

        /** Points the camera at a location in worldspace.
			使相機盯住世界坐标系中的某點。
            @remarks
                This is a helper method to automatically generate the
                direction vector for the camera, based on it's current position
                and the supplied look-at point.
            @param
                targetPoint A vector specifying the look at point.
        */
        void lookAt( const Vector3& targetPoint );
        /** Points the camera at a location in worldspace.
            @remarks
                This is a helper method to automatically generate the
                direction vector for the camera, based on it's current position
                and the supplied look-at point.
            @param
                x
            @param
                y
            @param
                z Co-ordinates of the point to look at.
        */
        void lookAt(Real x, Real y, Real z);

        /** Rolls the camera anticlockwise, around its local z axis.
        */
        void roll(const Radian& angle);

        /** Rotates the camera anticlockwise around it's local y axis.
        */
        void yaw(const Radian& angle);

        /** Pitches the camera up/down anticlockwise around it's local z axis.
        */
        void pitch(const Radian& angle);

        /** Rotate the camera around an arbitrary axis.
        */
        void rotate(const Vector3& axis, const Radian& angle);

        /** Rotate the camera around an arbitrary axis using a Quaternion.
        */
        void rotate(const Quaternion& q);

        /** Tells the camera whether to yaw around it's own local Y axis or a 
			fixed axis of choice.
			相機偏轉軸設定,采用它自身(Y軸)的還是你修改後的。
            @remarks
                This method allows you to change the yaw behaviour of the camera
				- by default, the camera yaws around a fixed Y axis. This is 
				often what you want - for example if you're making a first-person 
				shooter, you really don't want the yaw axis to reflect the local 
				camera Y, because this would mean a different yaw axis if the 
				player is looking upwards rather than when they are looking
                straight ahead. You can change this behaviour by calling this 
				method, which you will want to do if you are making a completely
				free camera like the kind used in a flight simulator. 
            @param
                useFixed If true, the axis passed in the second parameter will 
				always be the yaw axis no matter what the camera orientation. 
				If false, the camera yaws around the local Y.
            @param
                fixedAxis The axis to use if the first parameter is true.
        */
        void setFixedYawAxis( bool useFixed, const Vector3& fixedAxis = Vector3::UNIT_Y );


        /** Returns the camera's current orientation.
        */
        const Quaternion& getOrientation(void) const;

        /** Sets the camera's orientation.
        */
        void setOrientation(const Quaternion& q);

        /** Tells the Camera to contact the SceneManager to render from it's viewpoint.
		告訴相機将場景管理器同視口渲染聯系起來
        @param vp The viewport to render to
        @param includeOverlays Whether or not any overlay objects should be included
        */
        void _renderScene(Viewport *vp, bool includeOverlays);

        /** Function for outputting to a stream.
        */
        _OgreExport friend std::ostream& operator<<(std::ostream& o, const Camera& c);

        /** Internal method to notify camera of the visible faces in the last render.
        */
        void _notifyRenderedFaces(unsigned int numfaces);

        /** Internal method to notify camera of the visible batches in the last render.
        */
        void _notifyRenderedBatches(unsigned int numbatches);

        /** Internal method to retrieve the number of visible faces in the last render.
        */
        unsigned int _getNumRenderedFaces(void) const;

        /** Internal method to retrieve the number of visible batches in the last render.
        */
        unsigned int _getNumRenderedBatches(void) const;

        /** Gets the derived orientation of the camera, including any
            rotation inherited from a node attachment and reflection matrix.
			獲得相機派生方位,包括了任何繼承自節點連接配接和反射矩陣的旋轉資訊*/
        const Quaternion& getDerivedOrientation(void) const;
        /** Gets the derived position of the camera, including any
            translation inherited from a node attachment and reflection matrix. */
        const Vector3& getDerivedPosition(void) const;
        /** Gets the derived direction vector of the camera, including any
            rotation inherited from a node attachment and reflection matrix. */
        Vector3 getDerivedDirection(void) const;
        /** Gets the derived up vector of the camera, including any
            rotation inherited from a node attachment and reflection matrix. */
        Vector3 getDerivedUp(void) const;
        /** Gets the derived right vector of the camera, including any
            rotation inherited from a node attachment and reflection matrix. */
        Vector3 getDerivedRight(void) const;

        /** Gets the real world orientation of the camera, including any
            rotation inherited from a node attachment */
        const Quaternion& getRealOrientation(void) const;
        /** Gets the real world position of the camera, including any
            translation inherited from a node attachment. */
        const Vector3& getRealPosition(void) const;
        /** Gets the real world direction vector of the camera, including any
            rotation inherited from a node attachment. */
        Vector3 getRealDirection(void) const;
        /** Gets the real world up vector of the camera, including any
            rotation inherited from a node attachment. */
        Vector3 getRealUp(void) const;
        /** Gets the real world right vector of the camera, including any
            rotation inherited from a node attachment. */
        Vector3 getRealRight(void) const;

        /** Overridden from Frustum/Renderable */
        void getWorldTransforms(Matrix4* mat) const;

        /** Overridden from MovableObject */
        const String& getMovableType(void) const;

        /** Enables / disables automatic tracking of a SceneNode.
			激活或關閉自動跟蹤場景節點功能。
        @remarks
            If you enable auto-tracking, this Camera will automatically rotate to
            look at the target SceneNode every frame, no matter how 
            it or SceneNode move. This is handy if you want a Camera to be focused on a
            single object or group of objects. Note that by default the Camera looks at the 
            origin of the SceneNode, if you want to tweak this, e.g. if the object which is
            attached to this target node is quite big and you want to point the camera at
            a specific point on it, provide a vector in the 'offset' parameter and the 
            camera's target point will be adjusted.
			如果你啟動了自動跟蹤功能,無論相機或節點怎麼移動,相機都會盯着節點。
			如果相機想要盯一個大的物體上的某點,需要設定偏移量(offset)
        @param enabled If true, the Camera will track the SceneNode supplied as the next 
            parameter (cannot be null). If false the camera will cease tracking and will
            remain in it's current orientation.
        @param target Pointer to the SceneNode which this Camera will track. Make sure you don't
            delete this SceneNode before turning off tracking (e.g. SceneManager::clearScene will
            delete it so be careful of this). Can be null if and only if the enabled param is false.
        @param offset If supplied, the camera targets this point in local space of the target node
            instead of the origin of the target node. Good for fine tuning the look at point.
        */
        void setAutoTracking(bool enabled, SceneNode* const target = 0, 
            const Vector3& offset = Vector3::ZERO);


		/** Sets the level-of-detail factor for this Camera.
			設定相機細節等級因素
		@remarks
			This method can be used to influence the overall level of detail of the scenes 
			rendered using this camera. Various elements of the scene have level-of-detail
			reductions to improve rendering speed at distance; this method allows you 
			to hint to those elements that you would like to adjust the level of detail that
			they would normally use (up or down). 
		@par
			The most common use for this method is to reduce the overall level of detail used
			for a secondary camera used for sub viewports like rear-view mirrors etc.
			Note that scene elements are at liberty to ignore this setting if they choose,
			this is merely a hint.
		@param factor The factor to apply to the usual level of detail calculation. Higher
			values increase the detail, so 2.0 doubles the normal detail and 0.5 halves it.
		*/
		void setLodBias(Real factor = 1.0);

		/** Returns the level-of-detail bias factor currently applied to this camera. 
		@remarks
			See Camera::setLodBias for more details.
		*/
		Real getLodBias(void) const;

		/** Get a pointer to the camera which should be used to determine 
			LOD settings. 
			從另一個相機copy一個細節設定到本相機。
		@remarks
			Sometimes you don't want the LOD of a render to be based on the camera
			that's doing the rendering, you want it to be based on a different
			camera. A good example is when rendering shadow maps, since they will 
			be viewed from the perspective of another camera. Therefore this method
			lets you associate a different camera instance to use to determine the LOD.
		@par
			To revert the camera to determining LOD based on itself, call this method with 
			a pointer to itself. 
		*/
		virtual void setLodCamera(const Camera* lodCam);

		/** Get a pointer to the camera which should be used to determine 
			LOD settings. 
		@remarks
			If setLodCamera hasn't been called with a different camera, this
			method will return 'this'. 
		*/
		virtual const Camera* getLodCamera() const;


        /** Gets a world space ray as cast from the camera through a viewport position.
			獲得從相機出發穿過視口位置的世界坐标系的射線。
        @param screenx, screeny The x and y position at which the ray should intersect the viewport, 
            in normalised screen coordinates [0,1]
        */
        Ray getCameraToViewportRay(Real screenx, Real screeny) const;
        /** Gets a world space ray as cast from the camera through a viewport position.
        @param screenx, screeny The x and y position at which the ray should intersect the viewport, 
            in normalised screen coordinates [0,1]
		@param outRay Ray instance to populate with result
        */
        void getCameraToViewportRay(Real screenx, Real screeny, Ray* outRay) const;

		/** Gets a world-space list of planes enclosing a volume based on a viewport
			rectangle. 
		@remarks
			Can be useful for populating a PlaneBoundedVolumeListSceneQuery, e.g. 
			for a rubber-band selection. 
		@param screenLeft, screenTop, screenRight, screenBottom The bounds of the
			on-screen rectangle, expressed in normalised screen coordinates [0,1]
		@param includeFarPlane If true, the volume is truncated by the camera far plane, 
			by default it is left open-ended
		*/
		PlaneBoundedVolume getCameraToViewportBoxVolume(Real screenLeft, 
			Real screenTop, Real screenRight, Real screenBottom, bool includeFarPlane = false);

		/** Gets a world-space list of planes enclosing a volume based on a viewport
			rectangle. 
		@remarks
			Can be useful for populating a PlaneBoundedVolumeListSceneQuery, e.g. 
			for a rubber-band selection. 
		@param screenLeft, screenTop, screenRight, screenBottom The bounds of the
			on-screen rectangle, expressed in normalised screen coordinates [0,1]
		@param outVolume The plane list to populate with the result
		@param includeFarPlane If true, the volume is truncated by the camera far plane, 
			by default it is left open-ended
		*/
		void getCameraToViewportBoxVolume(Real screenLeft, 
			Real screenTop, Real screenRight, Real screenBottom, 
			PlaneBoundedVolume* outVolume, bool includeFarPlane = false);

		/** Internal method for OGRE to use for LOD calculations. */
		Real _getLodBiasInverse(void) const;


        /** Internal method used by OGRE to update auto-tracking cameras. */
        void _autoTrack(void);


        /** Sets the viewing window inside of viewport.
			設定視口内的觀察視窗
        @remarks
        This method can be used to set a subset of the viewport as the rendering
		可以用來設定渲染時一個視口内的小集合
        target. 
        @param Left Relative to Viewport - 0 corresponds to left edge, 1 - to right edge (default - 0).
        @param Top Relative to Viewport - 0 corresponds to top edge, 1 - to bottom edge (default - 0).
        @param Right Relative to Viewport - 0 corresponds to left edge, 1 - to right edge (default - 1).
        @param Bottom Relative to Viewport - 0 corresponds to top edge, 1 - to bottom edge (default - 1).
        */
        virtual void setWindow (Real Left, Real Top, Real Right, Real Bottom);
        /// Cancel view window.
        virtual void resetWindow (void);
        /// Returns if a viewport window is being used
        virtual bool isWindowSet(void) const { return mWindowSet; }
        /// Gets the window clip planes, only applicable if isWindowSet == true
		/// 獲得剪切面們,隻有當isWindowSet == true時有效
        const vector<Plane>::type& getWindowPlanes(void) const;

        /** Overridden from MovableObject */
        Real getBoundingRadius(void) const;
		/** Get the auto tracking target for this camera, if any. */
        SceneNode* getAutoTrackTarget(void) const { return mAutoTrackTarget; }
		/** Get the auto tracking offset for this camera, if it is auto tracking. */
		const Vector3& getAutoTrackOffset(void) const { return mAutoTrackOffset; }
		
        /** Get the last viewport which was attached to this camera. 
        @note This is not guaranteed to be the only viewport which is
        using this camera, just the last once which was created referring
        to it.
		獲得相機綁定的最後一個視口。不保證獲得的是獲得的視口唯一使用該相機,隻是最後一次建立的關于該相機的視口。
        */
        Viewport* getViewport(void) const {return mLastViewport;}
        /** Notifies this camera that a viewport is using it.*/
        void _notifyViewport(Viewport* viewport) {mLastViewport = viewport;}

        /** If set to true a viewport that owns this frustum will be able to 
            recalculate the aspect ratio whenever the frustum is resized.
			如果設定成true,當視錐改變時,觀察縱橫比将會自動改變
        @remarks
            You should set this to true only if the frustum / camera is used by 
            one viewport at the same time. Otherwise the aspect ratio for other 
            viewports may be wrong.
			隻能在視錐/相機同時隻被一個視口使用的時候設定成true。
        */    
        void setAutoAspectRatio(bool autoratio);

        /** Retrieves if AutoAspectRatio is currently set or not
        */
        bool getAutoAspectRatio(void) const;

		/** Tells the camera to use a separate Frustum instance to perform culling.
		告訴相機分别使用視錐執行個體執行剪切(剔除)
		@remarks
			By calling this method, you can tell the camera to perform culling
			against a different frustum to it's own. This is mostly useful for
			debug cameras that allow you to show the culling behaviour of another
			camera, or a manual frustum instance. 
		@param frustum Pointer to a frustum to use; this can either be a manual
			Frustum instance (which you can attach to scene nodes like any other
			MovableObject), or another camera. If you pass 0 to this method it
			reverts the camera to normal behaviour.
		*/
		void setCullingFrustum(Frustum* frustum) { mCullFrustum = frustum; }
		/** Returns the custom culling frustum in use. */
		Frustum* getCullingFrustum(void) const { return mCullFrustum; }

		/** Forward projects frustum rays to find forward intersection with plane.
		 @remarks
		    Forward projection may lead to intersections at infinity.
		*/
		virtual void forwardIntersect(const Plane& worldPlane, vector<Vector4>::type* intersect3d) const;
		繼承自Frustum類的函數,判斷是否在視錐内,設定遠近剪切面,投影圓?
		/// @copydoc Frustum::isVisible
		bool isVisible(const AxisAlignedBox& bound, FrustumPlane* culledBy = 0) const;
		/// @copydoc Frustum::isVisible
		bool isVisible(const Sphere& bound, FrustumPlane* culledBy = 0) const;
		/// @copydoc Frustum::isVisible
		bool isVisible(const Vector3& vert, FrustumPlane* culledBy = 0) const;
		/// @copydoc Frustum::getWorldSpaceCorners
		const Vector3* getWorldSpaceCorners(void) const;
		/// @copydoc Frustum::getFrustumPlane
		const Plane& getFrustumPlane( unsigned short plane ) const;
		/// @copydoc Frustum::projectSphere
		bool projectSphere(const Sphere& sphere, 
			Real* left, Real* top, Real* right, Real* bottom) const;
		/// @copydoc Frustum::getNearClipDistance
		Real getNearClipDistance(void) const;
		/// @copydoc Frustum::getFarClipDistance
		Real getFarClipDistance(void) const;
		/// @copydoc Frustum::getViewMatrix
		//觀察矩陣的獲得
		const Matrix4& getViewMatrix(void) const;
		/** Specialised version of getViewMatrix allowing caller to differentiate
			whether the custom culling frustum should be allowed or not. 
		@remarks
			The default behaviour of the standard getViewMatrix is to delegate to 
			the alternate culling frustum, if it is set. This is expected when 
			performing CPU calculations, but the final rendering must be performed
			using the real view matrix in order to display the correct debug view.
		*/
		const Matrix4& getViewMatrix(bool ownFrustumOnly) const;
		/** Set whether this camera should use the 'rendering distance' on
			objects to exclude distant objects from the final image. The
			default behaviour is to use it.
			設定相機是否使用渲染距離排除遠距離的物體。預設使用
		@param use True to use the rendering distance, false not to.
		*/
		virtual void setUseRenderingDistance(bool use) { mUseRenderingDistance = use; }
		/** Get whether this camera should use the 'rendering distance' on
			objects to exclude distant objects from the final image.
		*/
		virtual bool getUseRenderingDistance(void) const { return mUseRenderingDistance; }

		/** Synchronise core camera settings with another.
			同步主相機設定同另一個相機
		@remarks
			Copies the position, orientation, clip distances, projection type, 
			FOV, focal length and aspect ratio from another camera. Other settings like query flags, 
			reflection etc are preserved.
			複制位置,方位,剪切距離,投影方式,視角,長度,觀察比等從另一個相機。
		*/
		virtual void synchroniseBaseSettingsWith(const Camera* cam);

		/** Get the derived position of this frustum. */
		const Vector3& getPositionForViewUpdate(void) const;
		/** Get the derived orientation of this frustum. */
		const Quaternion& getOrientationForViewUpdate(void) const;

		/** @brief 
				Sets whether to use min display size calculations 
			When active objects who's size on the screen is less then a given number will not
			be rendered.
		*/
		void setUseMinPixelSize(bool enable) { mUseMinPixelSize = enable; }
		/** Returns whether to use min display size calculations 
			@see Camera::setUseMinDisplaySize
		*/
		bool getUseMinPixelSize() const { return mUseMinPixelSize; }

		/** Returns an estimated ratio between a pixel and the display area it represents.
			For orthographic cameras this function returns the amount of meters covered by
			a single pixel along the vertical axis. For perspective cameras the value
			returned is the amount of meters covered by a single pixel per meter distance 
			from the camera.
		@note
			This parameter is calculated just before the camera is rendered
		@note
			This parameter is used in min display size calculations.
		*/
		Real getPixelDisplayRatio() const { return mPixelDisplayRatio; }
           
上一篇: ogre配置檔案
下一篇: ogre3d git位址

繼續閱讀