[Problem] Tilted camera at BSP maps

jintal

14-11-2006 15:54:29

As the title says. I already researched and found that the coordinate sys of quake doesn't match ogre (or d3d). So when i load a BSP map in ogre, it would display the map's walls as the floor.

Supposedly, these line of code would fix this (found at the bottom part of http://grotsnik.ogre3d.org/wiki/index.p ... GtkRadiant , just translated for pyogre)
self.camera.setFixedYawAxis(True, ogre.Vector3.UNIT_Z)
self.camera.pitch(ogre.Degree(90).valueRadians())


This should work perfectly, but the weird thing is, the camera is tilted a bit.

I browsed through the cpp codes of the ogre sdk demos and translated a part of the BSP.cpp:
#ViewPoint vp = mSceneMgr->getSuggestedViewpoint(true);
vp = self.sceneManager.getSuggestedViewpoint(True)
#mCamera->setPosition(vp.position);
self.camera.position = vp.position
#mCamera->pitch(Degree(90)); // Quake uses X/Y horizon, Z up
self.camera.pitch(ogre.Degree(90).valueRadians())
#mCamera->rotate(vp.orientation);
self.camera.rotate(vp.orientation)
# Don't yaw along variable axis, causes leaning
#mCamera->setFixedYawAxis(true, Vector3::UNIT_Z);


similar to the previous code, this results in a tilted camera/world also.

as for now, i've just brute-forcibly adjusted the camera with this to fix the problem:
self.camera.roll(ogre.Degree(7).valueRadians())

i'd like to know if there're any others using pyogre who've encountered the same problem?... and for the guru's, do you know any proper way to solve this?

thanks in advanced! :)

dermont

21-11-2006 17:38:55

Don't really use BSP, but I think this is just your camera settings, try using "camera.lookAt". Here's the code for the example you mentioned above.


# This code is in the public domain
from pyogre import ogre
import SampleFramework as sf

class BSPApplication(sf.Application):
def _chooseSceneManager(self):
self.sceneManager = self.root.createSceneManager("BspSceneManager")


def _createScene(self):
sceneManager = self.sceneManager
camera = self.camera
sceneManager.AmbientLight = (0.5, 0.5, 0.5)

sceneManager.setWorldGeometry("ogretestmap.bsp")

# modify camera for close work
camera.nearClipDistance = 10
camera.farClipDistance = 20000

# Get random player start point
vp = self.sceneManager.getSuggestedViewpoint(True)

camera.position = vp.position
camera.pitch(ogre.Degree(90).valueRadians()) # // Quake uses X/Y horizon, Z up
camera.rotate(vp.orientation)
# Don't yaw along variable axis, causes leaning
camera.setFixedYawAxis(True, ogre.Vector3.UNIT_Z)
# Look at the boxes
camera.lookAt(-150,40,30)

def _createFrameListener(self):
self.frameListener = BSPListener(self.renderWindow, self.camera, self.sceneManager)
self.root.addFrameListener(self.frameListener)

class BSPListener(sf.FrameListener):
def __init__(self, renderWindow, camera, sceneManager):
sf.FrameListener.__init__(self, renderWindow, camera)
self.sceneManager = sceneManager

def frameStarted(self, frameEvent):
return sf.FrameListener.frameStarted(self, frameEvent)


if __name__ == '__main__':
try:
application = BSPApplication()
application.go()
except ogre.OgreException, e:
print e