Isometric camera

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Magus_Stragus
Posts: 86
Joined: Wed Aug 29, 2007 10:45 pm

Isometric camera

Post 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.
Proud member of the Online Campaign for Real English. If you believe in capital letters, correct spelling and good sentence structure then copy this into your signature.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Re: Isometric camera

Post 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.
Last edited by rogerborg on Tue May 06, 2008 6:48 am, edited 1 time in total.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

This topic made my day.
aheymann
Posts: 153
Joined: Wed Aug 22, 2007 12:25 pm
Location: England

Post by aheymann »

does

Code: Select all

pCamera->setIsOrthogonal(true);
not do the same?
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Magus_Stragus
Posts: 86
Joined: Wed Aug 29, 2007 10:45 pm

Post 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.
Proud member of the Online Campaign for Real English. If you believe in capital letters, correct spelling and good sentence structure then copy this into your signature.
torleif
Posts: 188
Joined: Mon Jun 30, 2008 4:53 am

Post by torleif »

Should someone take setIsOrthogonal(true); out of the SVN build or is it going to be used for something in the future?
piiichan
Posts: 59
Joined: Thu May 01, 2008 1:20 am
Location: New Caledonia (France - Pacific)
Contact:

Post 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).
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
piiichan
Posts: 59
Joined: Thu May 01, 2008 1:20 am
Location: New Caledonia (France - Pacific)
Contact:

Post 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.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply