[Solved] Camera view messed up?

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
panto
Posts: 22
Joined: Thu Mar 17, 2011 5:44 pm

[Solved] Camera view messed up?

Post by panto »

I'm trying to create a camera by writing this before the main loop.

ICameraSceneNode *cam;
cam = sceneManager->addCameraSceneNode();


It does create the camera.. however, the camera only displays half of the screen. The upper half is completely gray. Why is this so?
Last edited by panto on Sun Mar 20, 2011 9:47 pm, edited 1 time in total.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

Well, what are you trying to display on-screen? Can you provide a screenshot of wat your output is?
panto
Posts: 22
Joined: Thu Mar 17, 2011 5:44 pm

Post by panto »

I've traced the error to these lines:

Code: Select all

	vector3df rootPos = rootNode->getPosition();
	camera->setTarget( rootPos );
	camera->setPosition( rootPos + offset );
	rootNode->setRotation( vector3df( 0, cameraDirection, 0 ) );
If I uncomment those lines of codes, then there's no graphical glitches. Btw, even if "camera" is not the actual active camera, the output is glitched.. I can't see anything wrong with those lines?
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

Again, could you provide a screenshot and could you tell what you are trying to draw? We can't magically predict what's wrong with your application ;)
panto
Posts: 22
Joined: Thu Mar 17, 2011 5:44 pm

Post by panto »

Click me!

All I'm drawing is a IAnimatedMesh and a ILight.
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

This is called 'background' ;)
The grey area is just the color you specify in beginScene(). If you don't want it to be grey you either have to use a different color for clearing the color buffer or draw something into it like a skybox.
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
panto
Posts: 22
Joined: Thu Mar 17, 2011 5:44 pm

Post by panto »

When I comment that snippet of code, then it renders fine...

This is what I exactly do.

1) Create "Player" class before main loop.
2) In the main loop, I call player->Rotate(), which is basically this:

Code: Select all

//offset is a vector3df.
//cameraDirection is f32.

	vector3df rootPos = rootNode->getPosition();
	camera->setTarget( rootPos );
	camera->setPosition( rootPos + offset );
	rootNode->setRotation( vector3df( 0, cameraDirection, 0 ) );
Now.. even if the "camera" which is in player->Rotate() function ISN'T the currently active camera, I still get those glitches.

After some rotation.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

What does your complete drawing loop look like? Do you have any problems running any examples provided by irrlicht, or do the glitches disappear when using a different video driver?

Could you maybe provide a minimal compilable codesample which reproduces the problem?
panto
Posts: 22
Joined: Thu Mar 17, 2011 5:44 pm

Post by panto »

I tried to reproduce it, but I can't. It seems the problems root is deeper within my code.. :/

Here's what I'm basically doing, though. (pastebin links).
main.cpp
BugCulprit.h
BugCulprit.cpp
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

I don't see anything wrong with your code after a quick look

Do these problems occur when running in OpenGL?
panto
Posts: 22
Joined: Thu Mar 17, 2011 5:44 pm

Post by panto »

Yeah, and then the FPS also drops drastically for some reason.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

Maybe this could be a driver error? Your code seems fine to me (although it'd be a good idea to clamp your Y-rotation to a maximum of 360.f to maintain precision), unless I'm overlooking something major
Post Reply