2D rendering of NRRD volume slicing direction reversed? - xtk

In the example given at http://jsfiddle.net/gh/get/library/pure/xtk/lessons/tree/gh-pages/13/#run, the Z orientation shows a mirror view of the 3D view. Is there a way to make them the same direction?
Thanks

It is the same for the red view, and probably for the yellow no ?
I think it's coming from the camera 'position' (0,0,-100). Is that enough for you to rotate the renderer's camera of 180°, i.e. to use myrenderer.camera.rotate([900,0]); or myrenderer.camera.rotate([0,900]) (I don't remember what is the good one) ?
The issue is the camera is behind the object, not in front of.

Related

Vehicle control in opengl?

I have trouble in opengl. I want to rotate my vehicle while moving forward/backward. Here's a picture which shows exactly my problem. Effects of current code are in blue - after moving the car rotates over the starting location and not the current one. I want to have situation in red - in which my vehicle will rotate over current position and later move forward/backward correctly.
My current code:
lxr=sin(angle);
lzr=cos(angle);
xr+=speed*lxr;
zr+=speed*lzr;
totalangle+=angle
glRotatef(totalangle,0.0,1.0,0.0);
glTranslatef(0.0,0.0,xr);
drawVehicle();
You can try to call translate before rotate. glRotatef rotate view matrix and it affects on current view and also matrix glTranslatef.
From the image, I thought you are translating and then rotating, but looking at the code, I see it is not true.
So, it is obvious that you are in the drawVehicle(); function not rendering your object in the center (0,0). You need to render it in the center, rotate and then translate.
Also, your translation is bogus. You are just translating in z direction, not in y :
glTranslatef(0.0,0.0,xr);
You need to do something like this :
glRotatef(totalangle,0.0,1.0,0.0);
glTranslatef(0.0,yOffset,0.0);
drawVehicle(); // render around [0,0]
you have to move the origin of the coordinate system too, in order to rotate your car as you wish.

OpenGL flow camera in a stadium, how?

I have a scene, that is an arena (so basically this is a cube space)
What is the best way to simulate a fly camera in this cube?
(lets say the scene is an arena, or stadium with an origo point)
I have the gluLookat to change the camera view.
What do you mean exactly?
If I understood you correctly, you could let the camera look at a fixed point (e.g. the center of the arena) and then using sin/cos trickery rotate the camera around it.

About Cocos2d Camera?

I am try to figure out the zoom in/out effect. I am using tile-mapping background.
[self.Camera setEyeX:eyeY:eyeZ:]
[self.Camera setCenterX:centerY:centerZ:]
[self.Camera setUpX:upY:upZ:]
I don't know what differences among these methods and what these coordinate arguments represents.
Can someone help me please.
Thanks and sorry for my English.
It'll be a lot easier to just set tilemap.scale rather than using CCCamera.
The eye coordinates are the vector pointing in the direction the camera "looks at". The center coordinates are nothing more than the position of the camera in space. You can ignore the up vector, unless you want to rotate the camera's view. If I'm not mistaken, setting the up vector to (0, 1, 0) will ensure that the camera is not rotated and the coordinate system is what it should be (X extends to the right, Y extends upwards).

Zooming in and out in Direct3D

I have a 3D scene and I want to be able to zoom in and out. What implementations are good, and which has some flaws? Will I be changing viewport, clipping panes? I totally don't know.
Thanks
If you want a camera-like zoom, just change the camera viewing angle. This is usually set to around 45 degrees, but making it smaller will zoom into the image.
I think "zooming" refers to adjusting the view of a 2d image.
In a 3d scene I do not know what you mean with zooming. Probably moving the camera is what you are looking for? http://www.toymaker.info/Games/html/camera.html

Proper way to pan and move camera in OpenGL?

Right now I'm panning by glRotating before rendering everything, and i'm moving the camera by gltranslating. I feel as if this is wrong since im essentially moving the scene, not the camera. What is the proper way to move the camera?
Thanks
Actually 'moving the scene around the camera' is the proper way in OpenGL.
This is due to the fact that OpenGL combines the view and model matrices into the modelview matrix. (look here for more details)
Obvious the lookat function (as mentioned above) is an easy way to move a (virtual) camera but i found that it doesn't work for OpenGL3.
I'd suggest to use the excellent glm library to setup the transformation matrices for OpenGL3.
Kind Regards,
Florian
Moving the scene and the camera is essentially the same thing. One being the negative of the other.
The usual way of implementing it is to have a camera class with absolute coordinates and direction, then you just put
glTranslate(-camera)
glRotate(-camera)
at the top in your display function.
gluLookAt is how you move the camera.