Page 1 of 1

Isometric camera

Posted: Mon May 05, 2008 5:08 pm
by Magus_Stragus
Hey there. Is there any way to create an isometric camera? I'm just starting using cameras and such, so I really don't know of an easy way to create a fixed isometric camera. Thanks.

Re: Isometric camera

Posted: Mon May 05, 2008 11:31 pm
by rogerborg
Magus_Stragus wrote:Hey there. Is there any way to create an isometric camera? I'm just starting using cameras and such, so I really don't know of an easy way to create a fixed isometric camera. Thanks.
matrix4::buildProjectionMatrixOrthoLH()

ICameraSceneNode::setProjectionMatrix()

Magus_Stragus wrote:Proud member of the Online Campaign for Real English.
Sentence fragment.

Posted: Tue May 06, 2008 4:20 am
by Ion Dune
This topic made my day.

Posted: Tue May 06, 2008 6:57 am
by aheymann
does

Code: Select all

pCamera->setIsOrthogonal(true);
not do the same?

Posted: Tue May 06, 2008 10:36 am
by rogerborg
aheymann wrote:does

Code: Select all

pCamera->setIsOrthogonal(true);
not do the same?
You'd think, wouldn't you?

Unfortunately:

Code: Select all

Find all "IsOrthogonal", Match case, Whole word, Subfolders, Find Results 1, "Entire Solution"
  C:\dev\irrlicht-svn\include\ICameraSceneNode.h(32):			: ISceneNode(parent, mgr, id, position, rotation, scale), IsOrthogonal(false) {}
  C:\dev\irrlicht-svn\include\ICameraSceneNode.h(126):			return IsOrthogonal;
  C:\dev\irrlicht-svn\include\ICameraSceneNode.h(137):			IsOrthogonal = orthogonal;
  C:\dev\irrlicht-svn\include\ICameraSceneNode.h(142):		bool IsOrthogonal;
  Matching lines: 4    Matching files: 1    Total files searched: 623
It does somewhat less than you might hope.

Posted: Tue May 06, 2008 1:56 pm
by rogerborg
It's a method of matrix4.

Code: Select all

void buildProjectionMatrixOrthoLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar);
I'm assuming that by isometric camera you mean one that doesn't have perspective effects. That's an orthographic camera, which in turn is just a camera with an orthographic (rather than perspective) projection matrix.

Posted: Tue May 06, 2008 1:57 pm
by Magus_Stragus
matrix4::buildProjectionMatrixOrthoLH()
Could you please explain me a bit more about this function? I was trying to use it, but I don't know how :?: .

Ah, and thanks for pointing that out in my sig. However, IIRC, sentence fragments don't represent grammatical error in informal speech.

Edited: My last edition came out too late.

Thank you. That will do more than enough.

Posted: Wed Jul 23, 2008 11:20 pm
by torleif
Should someone take setIsOrthogonal(true); out of the SVN build or is it going to be used for something in the future?

Posted: Thu Jul 24, 2008 12:18 am
by piiichan
It is already being used by ISceneCollisionManager.

For instance, getRayFromScreenCoordinates() will give you correct results with an orthographic camera only if setIsOrthogonal(true) has been called on that camera (and if your camera projection matrix is orthogonal as well).

Posted: Thu Jul 24, 2008 10:25 am
by rogerborg
Would it be clearer if it was a parameter to setProjectionMatrix()? It seems to make sense to set them both together, since that's the only circumstance under which IsOrthogonal should change.

Code: Select all

Index: include/ICameraSceneNode.h
===================================================================
--- include/ICameraSceneNode.h	(revision 1412)
+++ include/ICameraSceneNode.h	(working copy)
@@ -39,8 +39,10 @@
 		to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH.
 		Note that the matrix will only stay as set by this method until one of
 		the following Methods are called: setNearValue, setFarValue, setAspectRatio, setFOV.
-		\param projection: The new projection matrix of the camera. */
-		virtual void setProjectionMatrix(const core::matrix4& projection) = 0;
+		\param projection: The new projection matrix of the camera.
+		\param isOrthogonal: Set this to true if the matrix is an orthogonal one (e.g. 
+							 from matrix4::buildProjectionMatrixOrthoLH(). */
+		virtual void setProjectionMatrix(const core::matrix4& projection, bool isOrthogonal = false) = 0;
 
 		//! Gets the current projection matrix of the camera.
 		/** \return Returns the current projection matrix of the camera. */
@@ -126,19 +128,8 @@
 			return IsOrthogonal;
 		}
 
-		//! Sets if this camera should return that it is orthogonal.
-		/** This setting does not change anything of the view or
-			projection matrix. However, the kind of camera
-			influences how collision detection and picking is done
-			and thus can be useful to query.
-		*/
-		void setIsOrthogonal( bool orthogonal )
-		{
-			IsOrthogonal = orthogonal;
-		}
+	protected:
 
-	private:
-
 		bool IsOrthogonal;
 	};
 
Index: source/Irrlicht/CCameraSceneNode.cpp
===================================================================
--- source/Irrlicht/CCameraSceneNode.cpp	(revision 1412)
+++ source/Irrlicht/CCameraSceneNode.cpp	(working copy)
@@ -70,8 +70,9 @@
 //! Sets the projection matrix of the camera. The core::matrix4 class has some methods
 //! to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH
 //! \param projection: The new projection matrix of the camera. 
-void CCameraSceneNode::setProjectionMatrix(const core::matrix4& projection)
+void CCameraSceneNode::setProjectionMatrix(const core::matrix4& projection, bool isOrthogonal)
 {
+	IsOrthogonal = isOrthogonal;
 	ViewArea.Matrices [ video::ETS_PROJECTION ] = projection;
 	ViewArea.setTransformState ( video::ETS_PROJECTION );
 }
Index: source/Irrlicht/CCameraSceneNode.h
===================================================================
--- source/Irrlicht/CCameraSceneNode.h	(revision 1412)
+++ source/Irrlicht/CCameraSceneNode.h	(working copy)
@@ -25,10 +25,15 @@
 		//! destructor
 		virtual ~CCameraSceneNode();
 
-		//! Sets the projection matrix of the camera. The core::matrix4 class has some methods
-		//! to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH
-		//! \param projection: The new projection matrix of the camera. 
-		virtual void setProjectionMatrix(const core::matrix4& projection);
+		//! Sets the projection matrix of the camera.
+		/** The core::matrix4 class has some methods
+		to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH.
+		Note that the matrix will only stay as set by this method until one of
+		the following Methods are called: setNearValue, setFarValue, setAspectRatio, setFOV.
+		\param projection: The new projection matrix of the camera.
+		\param isOrthogonal: Set this to true if the matrix is an orthogonal one (e.g. 
+							 from matrix4::buildProjectionMatrixOrthoLH(). */
+		virtual void setProjectionMatrix(const core::matrix4& projection, bool isOrthogonal = false);
 
 		//! Gets the current projection matrix of the camera
 		//! \return Returns the current projection matrix of the camera.

Posted: Fri Jul 25, 2008 12:40 am
by piiichan
I agree with you rogerborg.

I spent quite a long time debugging my app before realizing I didn't call setIsOrthogonal().

So there must be a clearer and more obvious way of setting that parameter, as you suggest.

Posted: Fri Jul 25, 2008 8:00 am
by rogerborg