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.


Messages - FredAxis

Pages: [1]
1
Support / Re: camera rotation on own X axis
« on: November 13, 2013, 04:00:30 pm »
Simple but effective. I changed the order of rotations and it did the trick.  ;D

2
Support / camera rotation on own X axis
« on: November 13, 2013, 03:42:34 pm »
I have a skybox and I want to rotate the camera when my tablet is tilted on the X axis. It works but when I rotate the Y axis the X axis gets rotated too and so the camera does not tilt but it is rotating (like on its Z axis).

My code ..
Code: [Select]
[code]
cam.rotateCameraX((tilt+90)*rad2bogFac);
cam.rotateCameraY(yaw*rad2bogFac);
[/code]      

How would I tilt the camera the right way?

3
Support / Re: Keep the camera view
« on: November 08, 2013, 05:48:32 pm »
Yes it is. When I remove the setScale (1f) the scaling gets a bit confuzing.


Code: [Select]

float sc = cube.getScale();

// fix scaling
cube.setScale(1f);

Matrix rotMat = cube.getRotationMatrix();

Matrix rotToMat = new Matrix();

// degree to radian
rotToMat.rotateX(rotAim[0] * rad);
rotToMat.rotateY(rotAim[1] * rad);

// factor calculated from the click time
float f = Math.min(1,(float) (time (startAiming)/450) );
rotMat.interpolate(rotMat, rotToMat,f );

cube.setRotationMatrix(rotMat);

cube.setScale( (sc*11 + 4f) /12   );


4
Support / Re: Keep the camera view
« on: November 08, 2013, 11:04:43 am »
You were right. Saving the scale and putting it to one before interpolate did work. Scale 1 gives me the size that it was before. Thanks.

5
Support / Re: Keep the camera view
« on: November 07, 2013, 11:18:54 pm »
I checked it with getScale but the displayed object looks 6 times smaller than it was before is the same when it was scaled at 6. Is there something else that scales the view?

I took the HelloWorld example and added (bigger) quads by getPlane to each side of the cube (rotate them and use addChild)  then saved the scale by getScale and it was 1. At click I scaled it up to 20 scale, rotate the cube to the quad direction with matrix.interpolate and after another click scaled it back to 6 which is displayed the same size as it was before (that was scale 1. If I scale to that it is a more tiny cube).

Do I have to wait a frame until the object is updated or something? Is there something to care about when using the interpolate function?

6
Support / Keep the camera view
« on: November 07, 2013, 05:55:40 pm »
In my project I use a a camera on a cube. When the cube is clicked it is scaled up until one surface fills all the camera view. When clicked again it zooms back. But now the cube looks smaller so the camera seems to have changed.

I guess it has something to do with camera collision but did't find how to fix it. I put the position and fov of the camera in a textfield but it had not changed.

My camera definition looks like this.
Code: [Select]
cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 22);

cam.lookAt(cube.getTransformedCenter());
        // tried this to fix it but it didn't
cam.setEllipsoidMode(Camera.ELLIPSOID_ALIGNED);


7
Support / Re: Cube rolling
« on: November 04, 2013, 05:42:56 pm »
Found out ..
The animating by using the interpolate function of Matrix works nice.

8
Support / Cube rolling
« on: November 03, 2013, 10:36:50 pm »
Hi everybody!

I am just starting in jpct with a basic project. So I came here for some basic questions I guess.

I want to roll a cube to the side that is touched by the user to the front. I managed to create a cube with 4 plane objects added as child to an object at the center. I put each orientation of a side in an array to move to when it was clicked. Works fine but at the moment but with no interpolation. It just switch to the orientation and that's it.

1.) Is there a common way to interpolate the positions to the next best rotation point? w/o rotating to the wrong way and turning around too much

2.) The sides of the cube are now only colors. So it may look strange when the cube rotates more than necessary. I am not sure how to manage this at the moment. Any ideas about that would be much appreciated.

3.) It seems to me that not all clicks are giving the right side/color of the cube. I guess the boundary box is used to get the clicked object. Is there an more accurate way? I put my code next here ...

Code: [Select]
// code at touch event

 SimpleVector dir = Interact2D.reproject2D3DWS(world.getCamera(), fb, Math.round(me.getX()) , Math.round(me.getY())) .normalize();
 
 Object[] res=world.calcMinDistanceAndObject3D(world.getCamera().getPosition(), dir, 10000 /*or whatever*/);
 
 float f = world.calcMinDistance(world.getCamera().getPosition(), dir, 1000);
 
 if (f != Object3D.COLLISION_NONE ){

Object3D picked = (Object3D)res[1];

TextView tv = (TextView) findViewById(R.id.textHit);

String nam = picked.getName();

tv.setText( nam);

int idx = indexOf ( nam, colorNames);


if (idx>-1){
rotAim = rotAims[idx];

cube.clearRotation();
cube.rotateX(rotAim[0] * rad );
cube.rotateY(rotAim[1] * rad );
}
}



It would be nice see any advice.

thanks in advance!

Fred

Pages: [1]