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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

思依_xuni

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值