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

3D objects offset

(1/2) > >>

deqleos:
Hi,

I have a question regarding a weird offset I get with 3D objects.
I receive a camera preview with faces on it. I want to show 3d objects on these faces, think about masks etc.
What I do is get the position of the face on the 2d preview and translate it to the 3d space with Interact2D.reproject2D3DWS().
I get a very weird offset though, where i can't seem to get the 3d object on the position that I want it to be. For example, I have the top left coordinates of the face but the 3d object will appear significantly to the left side.

What would the ideal circumstances be for a 2dto3d translation, in terms of the z axes, 3d model itself etc.

EDIT: I'm kinda confused now how reproject2dto3dWS() works now. If i put the object at x, y=100, the object barely moves on the x axis on screen and is like halfway they axis.

EDIT2: The idea that I want to implement is very simple but I'm having a really hard time with it. See the image for a simple illustration.
I have the face's positions and just want to overlay it with a 3d model.
The code that should give me the correct world space position is:
SimpleVector simpleVector = Interact2D.reproject2D3DWS(world.getCamera(), GLFrameBuffer, (int) faceRect.tl().x, (int) faceRect.tl().y, 20);



EgonOlsen:
Depending on your screen setup, the coordinates in 2D on screen might not match the ones that the FrameBuffer uses. This can be caused by a bar at the top or something. Make sure that (0,0) in 2D really corresponds to (0,0) in the FB. You can simply blit something at (0,0) to the FB and see if it appears at the right position.

deqleos:
Are there any other common causes? I don't have any bars on screen, just the camera preview.

EDIT: When debugging the reprojected object from 2d to 3d, I found out that projecting it back to 2d gives correct coordinates. I guess it's safe to assume the coordinates form screen match the framebuffer ones. Could my 3d model be the reason for this problem?

Edit2: See picture for what actually happens with the 3d object's position. In code I set it to be at the top left of the light grey square.
When the face moves closer, the 3d object moves more to the left of the set position, when the face moves further, the 3d objects moves more to the right of the set position.

EgonOlsen:
Might be that object isn't exactly centered around the orgin in object space, but I'm not sure if that would explain the increasing offset...it might, though.

What does Object3D.getCenter(); returns on your object?

deqleos:
.getCenter() returns this: (-3.552497,1.6156462,-6.28337).
I guess your thought is then correct otherwise it would be (0,0)?
When I use a library model(primitives.getCube), .getCenter() returns (-1.4901161E-8,0.0,-1.4901161E-8). With this model the visual offset I get is a little less.
Do I manually have to manipulate the object center in different software (like Meshlab) ?

Navigation

[0] Message Index

[#] Next page

Go to full version