Automatically rotate the camera when there is not a command

Everything else that doesn't fall into one of the other PB categories.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Automatically rotate the camera when there is not a command

Post 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)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

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

Post 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
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

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

Post 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
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
HeX0R
Addict
Addict
Posts: 1258
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

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

Post 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 ;)
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

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

Post 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
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

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

Post 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)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

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

Post 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:
Post Reply