### Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

### Topics - paulados

Pages: [1]
1
##### Support / Order for applying rotations to camera correctly
« on: March 30, 2014, 03:20:30 am »
Hi !!!

I've been trying and trying for a week, I have read in the forum some similar questions, and I'm not sure how to apply rotations to the camera for getting a normal behavior in the scene. The movement that I want to make is to simulate that I have a mobile phone, and rotate it to the left (y axis) and then rotate up and down (x axis).

First of all, I try this code:

Camera camera = world.getCamera();
camera.setPosition( new SimpleVector(0.0f, 0.0f, -20.0f) );  // Set camera position
camera.lookAt( new SimpleVector(0.0f, 0.0f, 1.0f) );  // Set direction to see. In positive Z axis
camera.getBack().setIdentity();  // clears rotation matrix
camera.rotateCameraX(-PI / 12.0f);  // rotates in X axis
camera.rotateCameraY(PI / 6.0f);  // Rotates in Y axis

And I get an strange rotation in the scene when moving the camera up and down (varying the angle in rotateCameraY). Then, I realize that when I was rotating the camera in Y axis, it was Y axis relative to the camera after X rotation. Thus, I try this:

Camera camera = world.getCamera();
camera.setPosition( new SimpleVector(0.0f, -2.0f, -20.0f) );
camera.lookAt( new SimpleVector(0.0f, 0.0f, 1.0f) );
camera.getBack().setIdentity();
SimpleVector yaxis = camera.getYAxis();
camera.rotateCameraX(-PI / 12.0f);
camera.rotateCameraAxis( yaxis, PI / 6.0f);

In this way, I though that Y axis should be the absolute Y axis of the camera before rotating in X axis, but behavior was the same that before.

Finally, I try this:

Camera camera = world.getCamera();
camera.setPosition( new SimpleVector(0.0f, -2.0f, -20.0f) );
camera.lookAt( new SimpleVector(0.0f, 0.0f, 1.0f) );
camera.getBack().setIdentity();
camera.rotateCameraY(PI / 6.0f);
camera.rotateCameraX(-PI / 12.0f);

This order for rotations seems to be ok, but, I'm not very sure why this order works, and no my last solution, and which is really the normal rotation order if I just want to move the camera in JPCT as if I where moving a camera in real world (rotating Right/Left, Up/down). I know this is a really basic question, but I've been stucked with it for this week and I'm getting crazy!!!!

Thanks in advance. If I have not explain correctly my doubt, please tell me and I'll explain again and I'll put some images showing the weird scene rotations.

2
##### Support / Problem with depth and blending (and alpha)
« on: February 10, 2014, 07:20:52 pm »
Hi everybody,

First of all, I'm new with JPCT (I've been testing it for a week). I'm trying to create an invisible object that should make objects after it invisible too. But I do not know how to make an object transparent (If played with setTransparency but it does not work as I want).

I will explain what I want to do with an example:

Object3D cono = Primitives.getCone(90, 4, 1.5f);
cono.setAdditionalColor(new Color(100, 0, 0, 100));
cono.build();

Object3D plane = Primitives.getPlane(1, 10);
plane.rotateX(3.141596f/4.0f);
plane.setAdditionalColor(new Color(0, 100, 0, 100));
plane.build();