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 - kkl

Pages: 1 ... 18 19 [20]
286
Support / Re: Interact2D issue after camera transformation
« on: January 01, 2013, 11:16:31 am »
Haha... Yaya... We were talking in different context... In the first reply you were saying about returning a coordinate, I took it as actual position in world space. Now I got what you mean. Thank alot for the help ;) 

287
Support / Re: Interact2D issue after camera transformation
« on: January 01, 2013, 09:22:04 am »
hi thanks for reply.

I tried again with reproject2D3DWS.

The results are as followed:

No camera movement yet
touch = (45, 340), vector result = (-0.5078125, -0.057291668, 0.0)

After camera.moveCamera(camera.getXAxis(), -0.3f)
touch = (45, 340), vector result = (-0.5078125, -0.057291668, 0.0)

I got both the same values at 2 cases. It should be different since the camera has moved. Did I miss anything yet?

Here's the new code:
Code: [Select]
frame = new FrameBuffer(gl, width, height);
world = new World();
world.setAmbientLight(10, 10, 10);

sun = new Light(world);
sun.setIntensity(255, 255, 255);

Texture texture = new Texture(BitmapHelper.convert(context.getResources().getDrawable(R.drawable.test3)), true);
TextureManager.getInstance().addTexture("texture", texture);
texture.setClamping(true);

plane = Primitives.getPlane(1, 0.08f);
plane.calcTextureWrapSpherical();
plane.setTexture("texture");
plane.setTransparency(0);
plane.build();

world.addObject(plane);

Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 1f);
cam.lookAt(plane.getTransformedCenter());

Code: [Select]
public void onTouch(MotionEvent e) {
Camera cam = world.getCamera();
SimpleVector rayTemp = Interact2D.reproject2D3DWS(cam, frame, (int)e.getX(), (int)e.getY());
rayTemp.z = plane.getOrigin().z;
Log.v("kkl", (int)e.getX() + ", " + (int)e.getY() + ": " + rayTemp.toString());
plane.setOrigin(rayTemp);
}

Btw, I'm using RENDERMODE_WHEN_DIRTY for rendering mode in GLSurfaceView. It only renders after onTouch() function. I reckon it's quite safe to do so since rendering is called after modifying objects.

288
Support / Re: Interact2D issue after camera transformation
« on: December 29, 2012, 03:32:03 pm »
I tried the reproject2D3DWS, it gives the same values as reproject2D3D does. Since we get a vector from reproject2D3DWS, do we have to calculate the coordinates along that vector by a given Z-value by ourself instead of treating the vector as actual coordinates?

I also tried this way and it got the correct values, but I don't think it's the proper way to do it.
Code: [Select]
public void onTouch(MotionEvent e) {
Camera cam = world.getCamera();
SimpleVector rayTemp = Interact2D.reproject2D3D(cam, frame, (int)e.getX(), (int)e.getY(), 50f);
SimpleVector camPos = cam.getPosition();
rayTemp.x += camPos.x;
rayTemp.y += camPos.y;
rayTemp.z = 0;
plane.setOrigin(rayTemp);
}

289
Support / Interact2D issue after camera transformation
« on: December 29, 2012, 08:30:23 am »
Hi I'm working on object following finger touch by Interact2D in android. The reproject2D3D gave unexpected value after I translated the camera. I know the reproject2D3D doesn't take account of camera transformation. Is there any way to get correct location after camera transformation?

Here's the code

Happens when finger touching:
Code: [Select]
public void onTouch(MotionEvent e) {
Camera cam = world.getCamera();
SimpleVector rayTemp = Interact2D.reproject2D3D(cam, frame, (int)e.getX(), (int)e.getY(), 50f);
rayTemp.z = 0;
plane.setOrigin(rayTemp);
}

Move the camera along X axis:
Code: [Select]
Camera cam = renderer.getWorld().getCamera();
cam.moveCamera(cam.getXAxis(), 1);

Creating objects and world:
Code: [Select]
frame = new FrameBuffer(gl, width, height);
world = new World();
world.setAmbientLight(10, 10, 10);

sun = new Light(world);
sun.setIntensity(255, 255, 255);

Texture texture = new Texture(BitmapHelper.convert(context.getResources().getDrawable(R.drawable.test3)), true);
TextureManager.getInstance().addTexture("texture", texture);
texture.setClamping(true);

plane = Primitives.getPlane(20, 2);
//cube.calcTextureWrapSpherical();
plane.setTexture("texture");
plane.setTransparency(0);
plane.build();

world.addObject(plane);

Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.lookAt(plane.getTransformedCenter());

290
Support / Re: Blending issue
« on: December 25, 2012, 03:50:50 pm »
Wow... Got it ;) Damn, you guys are efficient! Love the fast reply... Thanks alot haha

291
Support / Blending issue
« on: December 25, 2012, 03:43:39 pm »
Hi I'm new to opengl and JCPT android. I tried putting in a texture with tranparency, and it shows up in an unexpected way. Did I miss anything? Could anyone show me the proper way to do it?


The code is as followed:


Code: [Select]
Config.glTransparencyMul = 1f;
Config.glTransparencyOffset = 1f;

frame = new FrameBuffer(gl, width, height);
world = new World();
world.setAmbientLight(20, 20, 20);


sun = new Light(world);
sun.setIntensity(250, 250, 250);
// Create a texture out of the icon...:-)
Texture texture = new Texture(BitmapHelper.rescale(BitmapHelper.convert(context.getResources().getDrawable(R.drawable.ic_launcher)), 64, 64));
TextureManager.getInstance().addTexture("texture", texture);
texture.setClamping(true);


plane = Primitives.getPlane(3, 10);
// cube.calcTextureWrapSpherical();
plane.setTexture("texture");
plane.setTransparency(0);
plane.strip();
plane.build();

Thanks for help ;)

[attachment deleted by admin]

Pages: 1 ... 18 19 [20]