I've been messign around with camera rotation but I think what I really need is to rotate the entire scene by -90 degrees (for landscape on mobile device).
How do I do this?
thanks!
Rotate the scene -90 degrees
use an empty scene node as parent for all nodes and rotate it...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
check this code out :
After you create a node for your mesh you can do any operation on it (move, rotate, scale). the "setrotation" line is the one that interests you, just make sure to adapt the code according to your paths and files, and change the angle from 180 to 90.
regards,
Alvaro
Code: Select all
//load b3d scene
IAnimatedMesh* mapMesh = smgr->getMesh("./data/maps/interior/interior_01.b3d");
IAnimatedMeshSceneNode* mapnode = smgr->addAnimatedMeshSceneNode( mapMesh );
mapnode->setScale(core::vector3df(150,150,150));
mapnode->setRotation( irr::core::vector3df(0,180,0) );
mapnode->setMaterialFlag(EMF_LIGHTING, false);
regards,
Alvaro
Thanks. It doesn't seem to be working though.afecelis wrote:check this code out :After you create a node for your mesh you can do any operation on it (move, rotate, scale). the "setrotation" line is the one that interests you, just make sure to adapt the code according to your paths and files, and change the angle from 180 to 90.Code: Select all
//load b3d scene IAnimatedMesh* mapMesh = smgr->getMesh("./data/maps/interior/interior_01.b3d"); IAnimatedMeshSceneNode* mapnode = smgr->addAnimatedMeshSceneNode( mapMesh ); mapnode->setScale(core::vector3df(150,150,150)); mapnode->setRotation( irr::core::vector3df(0,180,0) ); mapnode->setMaterialFlag(EMF_LIGHTING, false);
regards,
Alvaro
I am working with example 12 terrain (possibly something
I'm doing after cancels it out?):
Code: Select all
// add terrain scene node
terrain = smgr->addTerrainSceneNode(
MakeIntoResourcePath("terrain-heightmap.bmp"),
0, // parent node
-1, // node id
core::vector3df(0.f, 0.f, 0.f), // position
core::vector3df(0.f, 0.f, 0.f), // rotation
core::vector3df(40.f, 4.4f, 40.f), // scale
video::SColor ( 255, 255, 255, 255 ), // vertexColor
5, // maxLOD
scene::ETPS_17, // patchSize
4 // smoothFactor
);
terrain->setMaterialFlag(video::EMF_LIGHTING, false);
terrain->setMaterialTexture(0,
driver->getTexture(MakeIntoResourcePath("terrain-texture.jpg")));
terrain->setMaterialTexture(1,
driver->getTexture(MakeIntoResourcePath("detailmap3.jpg")));
terrain->setMaterialType(video::EMT_DETAIL_MAP);
terrain->scaleTexture(1.0f, 20.0f);
//terrain->setDebugDataVisible ( true );
#ifdef FORCE_LANDSCAPE
terrain->setRotation(core::vector3df(0, -90, 0));
#endif
scene::ITriangleSelector* selector
= smgr->createTerrainTriangleSelector(terrain, 0);
terrain->setTriangleSelector(selector);
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(60,100,60),
core::vector3df(0,0,0),
core::vector3df(0,50,0));
selector->drop();
camera->addAnimator(anim);
anim->drop();
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
scene::ISceneNode* skybox=smgr->addSkyBoxSceneNode(
driver->getTexture(MakeIntoResourcePath("irrlicht2_up.jpg")),
driver->getTexture(MakeIntoResourcePath("irrlicht2_dn.jpg")),
driver->getTexture(MakeIntoResourcePath("irrlicht2_lf.jpg")),
driver->getTexture(MakeIntoResourcePath("irrlicht2_rt.jpg")),
driver->getTexture(MakeIntoResourcePath("irrlicht2_ft.jpg")),
driver->getTexture(MakeIntoResourcePath("irrlicht2_bk.jpg")));
scene::ISceneNode* skydome=smgr->addSkyDomeSceneNode(driver->getTexture("skydome.jpg"),16,8,0.95f,2.0f);
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
// create event receiver
MyEventReceiver receiver(terrain, skybox, skydome);
device->setEventReceiver(&receiver);
Re: Rotate the scene -90 degrees
I'm fairly certain that this isn't really what you want to do. If you want landscape mode, you just create a window that is taller than it is wide and then tell the camera about the new aspect ratio.tracerx wrote:I've been messign around with camera rotation but I think what I really need is to rotate the entire scene by -90 degrees (for landscape on mobile device).
Travis
Re: Rotate the scene -90 degrees
Thanks.vitek wrote:I'm fairly certain that this isn't really what you want to do. If you want landscape mode, you just create a window that is taller than it is wide and then tell the camera about the new aspect ratio.tracerx wrote:I've been messign around with camera rotation but I think what I really need is to rotate the entire scene by -90 degrees (for landscape on mobile device).
Travis
I'm doing that, but what happens is it renders it in portrait mode with the
left and right sides cutoff. I need the engine to think that the bottom left
of the screen is the top left of the screen.
In my old 2D OpenGLES code I just swap the vertices coordinates to
draw my one quad with a different orientation.
I'm starting to think this is something that needs to be done at the
driver level.
Re: Rotate the scene -90 degrees
OK, I'm trying messing with the aspect ratio directly now, usingvitek wrote:I'm fairly certain that this isn't really what you want to do. If you want landscape mode, you just create a window that is taller than it is wide and then tell the camera about the new aspect ratio.tracerx wrote:I've been messign around with camera rotation but I think what I really need is to rotate the entire scene by -90 degrees (for landscape on mobile device).
Travis
Code: Select all
core::dimension2d<u32> size(480, 320);
m_pDriver->OnResize(size);
f32 oldAspectRatio = m_pCamera->getAspectRatio();
m_pCamera->setAspectRatio(1.f * 480 / 320);
f32 oldFieldOfView = m_pCamera->getFOV();
m_pCamera->setFOV(oldFieldOfView * 480 / (480 - 2));
But its now just pushed the 480 wide scene to the bottom, so the top half
of the screen is black, and the bottom half has the 480 wide scene (I
think) just cutoff on the side(s).
Somehow I need to tell it that the bottom left corner if the top left
corner. Can SetTranform do this? HOw would I tell it to rotate -90
degrees?