Page 1 of 1

Automatically rotate the camera when there is not a command

Posted: Wed Mar 21, 2012 10:39 pm
by Psychophanta
Is there a way to tell Ogre to not rotate cameras when there is no explicit command for it?

This tip shows that a generic created Ogre camera automatically turns 180º over its own Z axis everywhen it is being "forced" to invert the 'world' floor (ie. the XZ plane).
In other words:
When you record video with your real cam in your real world, you can turn 180º your cam and the world you get is a 180º rotated world.
Well, the Ogre cameras just seem to not be able to see a 180º rotated world, that's all.
And that is definitely not a good for serious purposes in 3D, that behaviour is undesirable under certain serious 3D stuff.


Check the code please, it is ilustrative.

Code: Select all

;This tip shows that a generic created Ogre camera automatically turns 180º over its own Z axis everywhen it is being "forced" to invert the world floor (ie. the XZ plane)
;At the main loop, probe yourself to test only one of the 3 Macros below
;Tip made 20120318 For PB4.60 by Psychophanta

InitEngine3D():InitSprite():InitKeyboard():InitMouse()
ExamineDesktops()
bitplanes.b=DesktopDepth(0):RX.w=DesktopWidth(0):RY.w=DesktopHeight(0)
scr.l=OpenScreen(RX.w,RY.w,bitplanes.b,"CameraLookAtBug")
Add3DArchive("..\sources\",#PB_3DArchive_FileSystem)
CreateCube(0,40)
UsePNGImageDecoder():LoadTexture(0,"PureBasicLogoNew.png"); <- Use any squared picture (64x64, 128x128, 256x256, 512x512...)
CreateMaterial(0,TextureID(0)) ; Material
CreateEntity(0,MeshID(0),MaterialID(0),0,0,0)
CreateCamera(0,0,0,100,100)
AmbientColor($fafafa); <- Essential for clarity
Macro TurnCameraOverXaxis
  CamLocateX.f=0:CamLocateY.f=0:CamLocateZ.f=100:CamLocateDistance.f=100; <- start looking at the body from back (100 units lenght from XY plane, ie. display monitor surface plane)
  CamAngleX.f+MouseDeltaY()/600
  CamLocateY.f=CamLocateDistance.f*Sin(CamAngleX)
  CamLocateZ.f=CamLocateDistance.f*Cos(CamAngleX)-MouseWheel()*4
EndMacro
Macro TurnCameraOverYaxis
  CamLocateX.f=0:CamLocateY.f=0:CamLocateZ.f=100:CamLocateDistance.f=100; <- start looking at the body from back (100 units lenght from XY plane, ie. display monitor surface plane)
  CamAngleY.f+MouseDeltaX()/600
  CamLocateX.f=CamLocateDistance.f*Sin(CamAngleY)
  CamLocateZ.f=CamLocateDistance.f*Cos(CamAngleY)-MouseWheel()*4
EndMacro
Macro TurnCameraOverZaxis
  CamLocateX.f=0:CamLocateY.f=-100:CamLocateZ.f=0:CamLocateDistance.f=100; <- start looking at the body from upside
  CamAngleZ.f+MouseDeltaX()/600
  CamLocateX.f=CamLocateDistance.f*Sin(CamAngleZ)
  CamLocateY.f=CamLocateDistance.f*Cos(CamAngleZ)-MouseWheel()*4
EndMacro
Repeat
  ExamineKeyboard():ExamineMouse()
;   TurnCameraOverXaxis; <- camera does rotate 180º over itself when it surpass the XY plane
;   TurnCameraOverYaxis; <- the only one in which the camera do not rotate over itself
  TurnCameraOverZaxis; <- camera does rotate 180º over itself when it surpass the YZ plane
  CameraLocate(0,CamLocateX.f,CamLocateY.f,CamLocateZ.f)
  CameraLookAt(0,0,0,0); <- this function does rotate camera over its own z axis, why?
  RenderWorld()
  FlipBuffers():Delay(3)
Until KeyboardPushed(#PB_Key_Escape)

Re: Automatically rotate the camera when there is not a comm

Posted: Sat Mar 24, 2012 10:49 am
by PMV
When i understand you right, the real problem for you is CameraLookAt().
Well, if you don't like the behaviour of CameraLookAt(), don't use it. :wink:

You can rotate the camera by yourself with CameraRotate(). :)

MFG PMV

Re: Automatically rotate the camera when there is not a comm

Posted: Sat Mar 24, 2012 11:48 am
by Psychophanta
PMV wrote:When i understand you right, the real problem for you is CameraLookAt().
Well, if you don't like the behaviour of CameraLookAt(), don't use it. :wink:

You can rotate the camera by yourself with CameraRotate(). :)

MFG PMV
Nope, you have not understood

Re: Automatically rotate the camera when there is not a comm

Posted: Tue Mar 27, 2012 9:56 am
by HeX0R
You surely get more attention (and less wrong answers) if you make your example Copy&Paste&Run-Ready.
Changing those three lines of code e.g.:

Code: Select all

Add3DArchive(#PB_Compiler_Home + "Examples\Sources\Data\", #PB_3DArchive_FileSystem)
CreateCube(0, 40)
LoadTexture(0, "Geebee2.bmp")
You know, the world is full of lazy guys ;)

Re: Automatically rotate the camera when there is not a comm

Posted: Tue Mar 27, 2012 7:08 pm
by PMV
Just by the way ... my answer wasn't wrong.
After he answered i have tested his sniped to
get, what he means ... of course he means the
functionality of CameraLookAt() ... but i have
no time and tendency to make a working
example with a self-made CameraLookAt().
:oops:

OGRE3D is able to show a 180° rotated world,
CameraLookAt() is not designed for his sniped.


MFG PMV

Re: Automatically rotate the camera when there is not a comm

Posted: Tue Mar 27, 2012 8:07 pm
by Psychophanta
@PMV, RotateCamera() does not work properly :!:
PB's ogre implementation is a Pure CRAP!
I forgot it definitely and returned to Dreamotion3D ver 5 (btw, much faster than any version of N3xtD)

Re: Automatically rotate the camera when there is not a comm

Posted: Tue Mar 27, 2012 11:10 pm
by PMV
RotateCamera() is one of the few commands, where i have no problems with :lol:
But yes ... it has many bugs and all of them are readable in the bug-forum ;-)
Still not usefull for serious projects, even though the 3D part is going into the right
direction. I have managed to get a working game-engine with PureBasic and OGRE3D,
but it is still massive limited by the possibilities. I have to change the 3D engine if it
will not get better with the next release ... and of course i don't expect an update
there. :cry: