瀏覽代碼

Removed useless stuff from the Camera class

Marko Pintera 13 年之前
父節點
當前提交
042e831042

+ 1 - 1
CamelotGLRenderer/Source/GLSL/include/CmGLSLParamParser.h

@@ -283,7 +283,7 @@ namespace CamelotEngine
 				}
 				else
 				{
-					gpuParam.gpuMemOffset = glGetUniformLocationARB(glProgram, uniformName);
+					gpuParam.gpuMemOffset = glGetUniformLocation(glProgram, uniformName);
 					gpuParam.paramBlockSlot = 0;
 					gpuParam.cpuMemOffset = globalBlockDesc.blockSize;
 

+ 0 - 97
CamelotRenderer/Include/CmCamera.h

@@ -504,38 +504,8 @@ namespace CamelotEngine {
         /// Small constant used to reduce far plane projection to avoid inaccuracies
         static const float INFINITE_FAR_PLANE_ADJUST;
     protected:
-        /// Rendering type
-        PolygonMode mSceneDetail;
-
-        /** Viewing window. 
-        @remarks
-        Generalize camera class for the case, when viewing frustum doesn't cover all viewport.
-        */
-        float mWLeft, mWTop, mWRight, mWBottom;
-        /// Is viewing window used.
-        bool mWindowSet;
-        /// Windowed viewport clip planes 
-        mutable vector<Plane>::type mWindowClipPlanes;
-        // Was viewing window changed.
-        mutable bool mRecalcWindow;
-        /** Whether aspect ratio will automatically be recalculated 
-            when a viewport changes its size
-        */
-        bool mAutoAspectRatio;
-		/// Whether or not the rendering distance of objects should take effect for this camera
-		bool mUseRenderingDistance;
-
 		Viewport* mViewport;
 
-        /** Do actual window setting, using parameters set in SetWindow call
-        @remarks
-            The method will called on demand.
-        */
-        void setWindowImpl(void) const;
-
-		/** Helper function for forwardIntersect that intersects rays with canonical plane */
-		vector<Vector4>::type getRayForwardIntersect(const Vector3& anchor, const Vector3 *dir, float planeOffset) const;
-
     public:
         /** Standard destructor.
         */
@@ -548,73 +518,6 @@ namespace CamelotEngine {
 
 		Viewport* getViewport() { return mViewport; }
 
-        /** 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;
-
-        /** 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);
-
-        /** 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(float screenx, float 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(float screenx, float screeny, Ray* outRay) const;
-
-        /** 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 (float Left, float Top, float Right, float 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
-        const vector<Plane>::type& getWindowPlanes(void) const;
-
-        /** If set to true a viewport that owns this frustum will be able to 
-            recalculate the aspect ratio whenever the frustum is resized.
-        @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.
-        */    
-        void setAutoAspectRatio(bool autoratio);
-
-        /** Retrieves if AutoAspectRatio is currently set or not
-        */
-        bool getAutoAspectRatio(void) const;
-
-		/** Forward projects frustum rays to find forward intersection with plane.
-		 @remarks
-		    Forward projection may lead to intersections at infinity.
-		*/
-		void forwardIntersect(const Plane& worldPlane, vector<Vector4>::type* intersect3d) const;
-
 		/************************************************************************/
 		/* 						COMPONENT OVERRIDES                      		*/
 		/************************************************************************/

+ 0 - 280
CamelotRenderer/Source/CmCamera.cpp

@@ -63,9 +63,6 @@ namespace CamelotEngine {
 		mCustomViewMatrix(false),
 		mCustomProjMatrix(false),
 		mFrustumExtentsManuallySet(false),
-		mSceneDetail(PM_SOLID),
-		mWindowSet(false),
-		mAutoAspectRatio(false),
 		mViewport(nullptr)
     {
 		updateView();
@@ -663,20 +660,17 @@ namespace CamelotEngine {
 		}
 
 	}
-
 	//-----------------------------------------------------------------------
 	float Camera::getAspectRatio(void) const
 	{
 		return mAspect;
 	}
-
 	//-----------------------------------------------------------------------
 	void Camera::setAspectRatio(float r)
 	{
 		mAspect = r;
 		invalidateFrustum();
 	}
-
 	//-----------------------------------------------------------------------
 	const AxisAlignedBox& Camera::getBoundingBox(void) const
 	{
@@ -944,139 +938,13 @@ namespace CamelotEngine {
 		outtop = mTop;
 		outbottom = mBottom;
 	}
-    //-----------------------------------------------------------------------
-    void Camera::setPolygonMode(PolygonMode sd)
-    {
-        mSceneDetail = sd;
-    }
-
-    //-----------------------------------------------------------------------
-    PolygonMode Camera::getPolygonMode(void) const
-    {
-        return mSceneDetail;
-    }
     // -------------------------------------------------------------------
     void Camera::invalidateFrustum(void) const
     {
-        mRecalcWindow = true;
-		mRecalcFrustum = true;
 		mRecalcFrustumPlanes = true;
 		mRecalcWorldSpaceCorners = true;
 		mRecalcVertexData = true;
     }
-    //-----------------------------------------------------------------------
-    void Camera::_renderScene(Viewport *vp, bool includeOverlays)
-    {
-		// TODO PORT - I'm not going to be rendering the scene like this (yet), but I think I will do it eventually
-        //mSceneMgr->_renderScene(this, vp, includeOverlays);
-	}
-    //-----------------------------------------------------------------------
-	Ray Camera::getCameraToViewportRay(float screenX, float screenY) const
-	{
-		Ray ret;
-		getCameraToViewportRay(screenX, screenY, &ret);
-		return ret;
-	}
-	//---------------------------------------------------------------------
-    void Camera::getCameraToViewportRay(float screenX, float screenY, Ray* outRay) const
-    {
-		Matrix4 inverseVP = (getProjectionMatrix() * getViewMatrix()).inverse();
-
-		float nx = (2.0f * screenX) - 1.0f;
-		float ny = 1.0f - (2.0f * screenY);
-		Vector3 nearPoint(nx, ny, -1.f);
-		// Use midPoint rather than far point to avoid issues with infinite projection
-		Vector3 midPoint (nx, ny,  0.0f);
-
-		// Get ray origin and ray target on near plane in world space
-		Vector3 rayOrigin, rayTarget;
-		
-		rayOrigin = inverseVP * nearPoint;
-		rayTarget = inverseVP * midPoint;
-
-		Vector3 rayDirection = rayTarget - rayOrigin;
-		rayDirection.normalise();
-
-		outRay->setOrigin(rayOrigin);
-		outRay->setDirection(rayDirection);
-    } 
-    // -------------------------------------------------------------------
-    void Camera::setWindow (float Left, float Top, float Right, float Bottom)
-    {
-        mWLeft = Left;
-        mWTop = Top;
-        mWRight = Right;
-        mWBottom = Bottom;
-
-        mWindowSet = true;
-        mRecalcWindow = true;
-    }
-    // -------------------------------------------------------------------
-    void Camera::resetWindow ()
-    {
-        mWindowSet = false;
-    }
-    // -------------------------------------------------------------------
-    void Camera::setWindowImpl() const
-    {
-        if (!mWindowSet || !mRecalcWindow)
-            return;
-
-        // Calculate general projection parameters
-        float vpLeft, vpRight, vpBottom, vpTop;
-        calcProjectionParameters(vpLeft, vpRight, vpBottom, vpTop);
-
-        float vpWidth = vpRight - vpLeft;
-        float vpHeight = vpTop - vpBottom;
-
-        float wvpLeft   = vpLeft + mWLeft * vpWidth;
-        float wvpRight  = vpLeft + mWRight * vpWidth;
-        float wvpTop    = vpTop - mWTop * vpHeight;
-        float wvpBottom = vpTop - mWBottom * vpHeight;
-
-        Vector3 vp_ul (wvpLeft, wvpTop, -mNearDist);
-        Vector3 vp_ur (wvpRight, wvpTop, -mNearDist);
-        Vector3 vp_bl (wvpLeft, wvpBottom, -mNearDist);
-        Vector3 vp_br (wvpRight, wvpBottom, -mNearDist);
-
-        Matrix4 inv = mViewMatrix.inverseAffine();
-
-        Vector3 vw_ul = inv.transformAffine(vp_ul);
-        Vector3 vw_ur = inv.transformAffine(vp_ur);
-        Vector3 vw_bl = inv.transformAffine(vp_bl);
-        Vector3 vw_br = inv.transformAffine(vp_br);
-
-		mWindowClipPlanes.clear();
-        if (mProjType == PT_PERSPECTIVE)
-        {
-            Vector3 position = gameObject()->getWorldPosition();
-            mWindowClipPlanes.push_back(Plane(position, vw_bl, vw_ul));
-            mWindowClipPlanes.push_back(Plane(position, vw_ul, vw_ur));
-            mWindowClipPlanes.push_back(Plane(position, vw_ur, vw_br));
-            mWindowClipPlanes.push_back(Plane(position, vw_br, vw_bl));
-        }
-        else
-        {
-            Vector3 x_axis(inv[0][0], inv[0][1], inv[0][2]);
-            Vector3 y_axis(inv[1][0], inv[1][1], inv[1][2]);
-            x_axis.normalise();
-            y_axis.normalise();
-            mWindowClipPlanes.push_back(Plane( x_axis, vw_bl));
-            mWindowClipPlanes.push_back(Plane(-x_axis, vw_ur));
-            mWindowClipPlanes.push_back(Plane( y_axis, vw_bl));
-            mWindowClipPlanes.push_back(Plane(-y_axis, vw_ur));
-        }
-
-        mRecalcWindow = false;
-
-    }
-    // -------------------------------------------------------------------
-    const vector<Plane>::type& Camera::getWindowPlanes(void) const
-    {
-        updateView();
-        setWindowImpl();
-        return mWindowClipPlanes;
-    }
     // -------------------------------------------------------------------
     float Camera::getBoundingRadius(void) const
     {
@@ -1085,154 +953,6 @@ namespace CamelotEngine {
         return mNearDist * 1.5f;
 
     }
-    //-----------------------------------------------------------------------
-    bool Camera::getAutoAspectRatio(void) const
-    {
-        return mAutoAspectRatio;
-    }
-    //-----------------------------------------------------------------------
-    void Camera::setAutoAspectRatio(bool autoratio)
-    {
-        mAutoAspectRatio = autoratio;
-    }
-	//-----------------------------------------------------------------------
-	//_______________________________________________________
-	//|														|
-	//|	getRayForwardIntersect								|
-	//|	-----------------------------						|
-	//|	get the intersections of frustum rays with a plane	|
-	//| of interest.  The plane is assumed to have constant	|
-	//| z.  If this is not the case, rays					|
-	//| should be rotated beforehand to work in a			|
-	//| coordinate system in which this is true.			|
-	//|_____________________________________________________|
-	//
-	vector<Vector4>::type Camera::getRayForwardIntersect(const Vector3& anchor, const Vector3 *dir, float planeOffset) const
-	{
-		vector<Vector4>::type res;
-
-		if(!dir)
-			return res;
-
-		int infpt[4] = {0, 0, 0, 0}; // 0=finite, 1=infinite, 2=straddles infinity
-		Vector3 vec[4];
-
-		// find how much the anchor point must be displaced in the plane's
-		// constant variable
-		float delta = planeOffset - anchor.z;
-
-		// now set the intersection point and note whether it is a 
-		// point at infinity or straddles infinity
-		unsigned int i;
-		for (i=0; i<4; i++)
-		{
-			float test = dir[i].z * delta;
-			if (test == 0.0) {
-				vec[i] = dir[i];
-				infpt[i] = 1;
-			}
-			else {
-				float lambda = delta / dir[i].z;
-				vec[i] = anchor + (lambda * dir[i]);
-				if(test < 0.0)
-					infpt[i] = 2;
-			}
-		}
-
-		for (i=0; i<4; i++)
-		{
-			// store the finite intersection points
-			if (infpt[i] == 0)
-				res.push_back(Vector4(vec[i].x, vec[i].y, vec[i].z, 1.0));
-			else
-			{
-				// handle the infinite points of intersection;
-				// cases split up into the possible frustum planes 
-				// pieces which may contain a finite intersection point
-				int nextind = (i+1) % 4;
-				int prevind = (i+3) % 4;
-				if ((infpt[prevind] == 0) || (infpt[nextind] == 0))
-				{
-					if (infpt[i] == 1)
-						res.push_back(Vector4(vec[i].x, vec[i].y, vec[i].z, 0.0));
-					else
-					{
-						// handle the intersection points that straddle infinity (back-project)
-						if(infpt[prevind] == 0) 
-						{
-							Vector3 temp = vec[prevind] - vec[i];
-							res.push_back(Vector4(temp.x, temp.y, temp.z, 0.0));
-						}
-						if(infpt[nextind] == 0)
-						{
-							Vector3 temp = vec[nextind] - vec[i];
-							res.push_back(Vector4(temp.x, temp.y, temp.z, 0.0));
-						}
-					}
-				} // end if we need to add an intersection point to the list
-			} // end if infinite point needs to be considered
-		} // end loop over frustun corners
-
-		// we end up with either 0, 3, 4, or 5 intersection points
-
-		return res;
-	}
-
-	//_______________________________________________________
-	//|														|
-	//|	forwardIntersect									|
-	//|	-----------------------------						|
-	//|	Forward intersect the camera's frustum rays with	|
-	//| a specified plane of interest.						|
-	//| Note that if the frustum rays shoot out and would	|
-	//| back project onto the plane, this means the forward	|
-	//| intersection of the frustum would occur at the		|
-	//| line at infinity.									|
-	//|_____________________________________________________|
-	//
-	void Camera::forwardIntersect(const Plane& worldPlane, vector<Vector4>::type* intersect3d) const
-	{
-		if(!intersect3d)
-			return;
-
-		Vector3 trCorner = getWorldSpaceCorners()[0];
-		Vector3 tlCorner = getWorldSpaceCorners()[1];
-		Vector3 blCorner = getWorldSpaceCorners()[2];
-		Vector3 brCorner = getWorldSpaceCorners()[3];
-
-		// need some sort of rotation that will bring the plane normal to the z axis
-		Plane pval = worldPlane;
-		if(pval.normal.z < 0.0)
-		{
-			pval.normal *= -1.0;
-			pval.d *= -1.0;
-		}
-		Quaternion invPlaneRot = pval.normal.getRotationTo(Vector3::UNIT_Z);
-
-		// get rotated light
-		Vector3 lPos = invPlaneRot * gameObject()->getWorldPosition();
-		Vector3 vec[4];
-		vec[0] = invPlaneRot * trCorner - lPos;
-		vec[1] = invPlaneRot * tlCorner - lPos; 
-		vec[2] = invPlaneRot * blCorner - lPos; 
-		vec[3] = invPlaneRot * brCorner - lPos; 
-
-		// compute intersection points on plane
-		vector<Vector4>::type iPnt = getRayForwardIntersect(lPos, vec, -pval.d);
-
-
-		// return wanted data
-		if(intersect3d) 
-		{
-			Quaternion planeRot = invPlaneRot.Inverse();
-			(*intersect3d).clear();
-			for(unsigned int i=0; i<iPnt.size(); i++)
-			{
-				Vector3 intersection = planeRot * Vector3(iPnt[i].x, iPnt[i].y, iPnt[i].z);
-				(*intersect3d).push_back(Vector4(intersection.x, intersection.y, intersection.z, iPnt[i].w));
-			}
-		}
-	}
 
 	RTTITypeBase* Camera::getRTTIStatic()
 	{

+ 8 - 0
CamelotRenderer/TODO.txt

@@ -96,6 +96,12 @@ Keeping a list of all render targets in RenderSystem shouldn't be needed (and ca
 Make CommandQueue not use mutexes and use atomics instead??
 Make sure that the simulation can't run faster then the render thread! (Block the main thread until previous render finishes)
 Figure out how to handle accessing texture from a non-render thread?
+
+Issue of setting individual parameters on a material
+ - Material can contain multiple techniques
+ - How do I ensure parameters are valid for all techniques?
+ - Require user to create a Material parameter specification?
+ - Also need a way to avoid displaying internal parameters used by the active renderer
 /////
 
 
@@ -107,6 +113,7 @@ RenderSystem needed modifications
 	- Setting UAV for both buffers and textures (Need to add a special flag for texture creation)
   - Generic buffers (Normal/Structured/Raw/Append/Consume/Indirect)
   - Texture buffers 
+   - Just add a special texture type? OpenGL doesn't support getting offset from within a texture buffer anyway
   - Stream out (write vertex buffers) (DX11 and GL)
   - Static/Dynamic usage for GpuParamBlocks
   - GpuParams need to support bools, buffers & structs (void*)
@@ -115,6 +122,7 @@ RenderSystem needed modifications
    - Also make DepthStencilBuffer share common features with RenderTexture
   
  - Low priority
+  - OpenGL provides image load/store which seems to be GL UAV equivalent (http://www.opengl.org/wiki/Image_Load_Store)
   - Single and dual channel textures (especially render textures, which are very important for effects like SSAO)
   - Compute pipeline
   - Instancing (DrawInstanced) (DX11 and GL)