### 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.

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 / Re: Problem with depth and blending (and alpha)
« on: February 11, 2014, 05:00:18 pm »
Hi again!!!

Thanks EgonOlsen and AGP for your responses. AGP, I try your solution, but it didn't work for me. I change configuration and transparency, but the object didn't get completely transparent, I don't know why.

EgonOlsen, your solution with 2 worlds and clearColorBufferOnly worked for me. Thus, I attach the code  if it could be useful for anyone.

Thanks !!!

3
##### Support / Re: Problem with depth and blending (and alpha)
« on: February 10, 2014, 09:05:20 pm »
Hi,

Thank you for your fast answer. First of all, I do not want to use gl commands, I try to explain what I wanted to do with gl commands, that is how I did it before. Indeed, I do not know in jpct the opengl configuration (I didn't know that depth test was enable, and I do not know which blending mode is enable, if anyone).

I'll try to explain better what I want. I have added an image. What I have, is a white background, then a red square and then a circle yellow (ordered by distance). What I want is that the yellow circle to create a hole in the square and to see the white background through the circle. I hope that now it could be a bit more clear

About your recomendations, I have seen IRenderHook, but I do not know anything about shaders (perhaps I should learn). Anyway, I would like to know if there is a way to make an object transparent without shaders. About your other propositions, I'm not sure if your solution of making another world would work (because the circle and the square could intersect part of them, and I suppose they cannot intersect if they are in different worlds).

On the other hand, In the case of switching visibility, I suppose that I should change the plane to setVisibility(OBJ_INVISIBLE), but in which moment. After world.addObject(plane);?

Thanks,
P.

4
##### 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.build();

Object3D plane = Primitives.getPlane(1, 10);
plane.rotateX(3.141596f/4.0f);
plane.build();