jPCT-AE - a 3d engine for Android > Support

Problem with object picking and modified camera backbuffer matrix

<< < (5/5)

Ok, I'll try to synthetize my code and make it as clear as I can :

object part :

--- Code: ---                ...


--- End code ---

I'm not sure collision optimization and CHECK_SELF are necessary but It works that way so... I keep it.

Camera matrix part :

--- Code: ---
public boolean setCameraMatrix(float[] matrix){

if (_camera != null){

matrix[12] = matrix[13] = matrix[14] = 0;

_cameraMatrix = _cameraMatrix.invert();


return true;

} else {
return false;


--- End code ---

Here, I guess you could invert the matrix before calling setCameraMatrix ( and you would have to change 12/13/14 to 3/7/11) but again, it works that way... So I keep it.

Picking part :

--- Code: --- public Object3D pick(int x,int y){

Log.d("jpctEngine", "Picking...");

SimpleVector dir=Interact2D.reproject2D3DWS(_camera, _frameBuffer, x, y).normalize();
Object[] res=_world.calcMinDistanceAndObject3D(_camera.getPosition(), dir, 10000 /*or whatever*/);

if (res[1] != null){
Log.d("Jpct-Engine","Picking réussi.");
return res[1];

return null;


--- End code ---

In fact, the advices you gave on picking work well.
But somehow, dumping a false(maybe inverted) matrix still gives a nice graphical result and craps the picking. Seeing graphics working, I thought the matrix was OK and looked for the problem elsewhere... Matrices are very tricky...

Well, now that's fixed ^^ thanks again, I hope this comment will help !



[0] Message Index

[*] Previous page

Go to full version