Main Menu
Menu

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.

Show posts Menu

Messages - Vi_O

#1
Support / Re: OpenGL matrix to Camera
March 09, 2012, 11:12:07 AM
If that's still distortion you are after, I think that it is your hardware camera distortion parameters that are inadequate. Try to see if Vuforia lets you change it and calibrate your camera.
#2
Support / Re: Camera Matrix
February 10, 2012, 11:31:58 AM
camera.getBack() ?
#3
Support / Re: ClearRotation resets the scale
February 09, 2012, 05:53:26 PM
I've lost a lot of time because of this scale problem this week... Maybe you could make this post sticky or write the issue on the setScale()'s javadoc... I'm sure this would help a lot :)
#4
try to set "landscape" from the AndroidManifest, It's cleaner and could even fix your problem.

here's the line :
android:screenOrientation="landscape"

Edit : put it in the activity proterty.
#5
First, check that your OntouchEvent() always return true or it will only get the ACTION_DOWN event.

If it's not this, the problem is that ActionEvents only fire when there is a change. (You can't check a NO_ACTION event then)
So maybe you could use a Timer...
#6
Yeah, calcCross with a constant_vector (that would be, in fact, your sphere/planet axis) should give you a usable tangent vector. (I don't know if you can have a better one with just rotating the normal of 90°)

For the positioning, I've done something like this :


camera.setOrientation(_normalVector, _tangentVector);
camera.rotateAxis(_normalVector, _leftRightAngle);
camera.rotateAxis(_tangentVector, _upDownAngle);


where upDownAngle and leftRightAngle should be your angles gotten by the mouse events (I'm not sure how mouse works as I'm using jpct on android)


#7
Yes, that's right, the vector between the camera and the sphere center would be better. But has it to be a reversed sphere ? Why not just inversing the vector and make the ray origin from the camera ?

BTW, if the field is a sphere, isn't the UpVector just the Ray direction ?
#8
You have to make it in 2 steps :

first, set your sphere object collision type to CHECK_OTHERS and set it's collision listener to whatever you want (for your case, I guess it's the camera)
then, when you want to check the polygon under the camera it's :

World.calcMinDistance(Camera.getPosition(),Camera.getUpVector(), someDistance);

It will fire a CollisionEvent on your listener with the id of your polygon that you can check within the polygon manager of your object.

Something like this :

public void collision(final CollisionEvent ce) {
if (ce.getAlgorithm() == CollisionEvent.ALGORITHM_RAY) {
if (ce.getPolygonIDs().length > 0) {
_normalVector.normalize(ce.getTargets()[0].getPolygonManager()
.getTransformedNormal(ce.getPolygonIDs()[0]));
_tangentVector = _normalVector.calcCross(CROSS_PROD_VECTOR);
}
}
}


Hope it helps...

Edit :
Btw, I think it would be nice if the calcMinDistance would return the normal or id of the polygon reached (or maybe event the CollisionEvent ?) that would make the code easier ^^
#9
Support / Re: world position of a child object
January 26, 2012, 02:08:22 PM
did you try Object.getWorldTransformation() ?
#10
Ok, I'll try to synthetize my code and make it as clear as I can :

object part :


                ...
_object.strip();
_object.build();

_object.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS|Object3D.COLLISION_CHECK_SELF);
_object.setCollisionOptimization(true);


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

Camera matrix part :



public boolean setCameraMatrix(float[] matrix){

if (_camera != null){

_cameraPosition.set(matrix[12],matrix[13],matrix[14]);
matrix[12] = matrix[13] = matrix[14] = 0;

_cameraMatrix.setDump(matrix);
_cameraMatrix = _cameraMatrix.invert();

_camera.setBack(_cameraMat);
_camera.setPosition(_cameraPosition);

return true;

} else {
return false;
}

}


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 :


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;

}


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 !

Bye.
#11
That was a backside picking problem, I have flipped the plan and now it works !

Thanks a lot !
#12
I have check my code, and after adjusting some tranformation matrices, it works ! Thanks !

One problem still remains : I don't know why, it doesn't pick planes... Is there a special settings to apply in order to pick planes ?
#13
Hello,

I am having the same issue than redfalcon and indeed, separating doesn't work.

I made a bit of code to see the difference between normal and rotation/translation separated :



_cameraMat.setDump(matrix);
_camera.setBack(_cameraMat);

Log.d("JpctEngine", "Valeur camera : " + _camera.getPosition().x + ";" + _camera.getPosition().y +
";" + _camera.getPosition().z);
Log.d("JpctEngine", "Valeur camera : " + _camera.getXAxis().x + ";" + _camera.getYAxis().x +
";" + _camera.getZAxis().x);

float x = matrix[12]; float y = matrix[13]; float z = matrix[14];
matrix[12] = matrix[13] = matrix[14] = 0;
_cameraMat.setDump(matrix);
_camera.setBack(_cameraMat);
_camera.setPosition(x, y, z);

Log.d("JpctEngine", "Valeur camera : " + _camera.getPosition().x + ";" + _camera.getPosition().y +
";" + _camera.getPosition().z);
Log.d("JpctEngine", "Valeur camera : " + _camera.getXAxis().x + ";" + _camera.getYAxis().x +
";" + _camera.getZAxis().x);


It is strange because getPosition and get*Axis give the same results for both but the separated one doesn't place the camera well... And still no picking...

From what you were writing there, it is a problem with the getPosition that returns {0.0,0.0,0.0}.

Would it be possible then to extends Camera and Overriding setPosition/getPosition to make the reproject2D3DWS and calcMinDistanceAndObject3D works (assuming it uses getPosition to work) ?

I can't test it now as I don't have my source right now, but i'll try tomorrow if you don't tell me it is useless before :)

#14
Ok, I've separated the two threads more clearly and now it works perfectly ^^
It wasn't about the serializer after all... My apologizes...

Thanks a lot for the quick response, that will be very helpful

Have a nice day !
#15
Well, the 3DOBjects and world are loaded from the onSurfaceCreated of the OpenGLSurface Renderer.

Besides, by replacing :
Object3D objLoader = Loader.loadSerializedObject(new ByteArrayInputStream(serializedObject));
by
Object3D objLoader = Primitives.cube(1);

I've got a properly rendered cube and no warning...

I will check if the server/client thread doesn't interfere with the renderer somehow.