samrad / android-packaging

Augmented reality application for packaging (Java, C++)
3 stars 3 forks source link

Mapping the model to 3D geometry #1

Open TheMaggieSimpson opened 8 years ago

TheMaggieSimpson commented 8 years ago

Hello there, can you please point me to the code in which you mapped your 3D model to the 3D geometry? Or in another words, how you put the 3D model relative to the image target.

I understand that renderFrame() does the image tracking, and I can see that the 3D model is loaded in ImageTargetsRenderer class. But I don't really understand where and when you actually mapped the 3D model into the whole scene.

Thanks in advance.

samrad commented 8 years ago

Most of the heavy lifting is done at the native code. Have a look at ImageTargets.cpp#L307. There are few native functions in ImageTargetsRederer.java that are used in native code. To have the big picture you can read 4.4 Code chapter. The code is really messy but I think I explained in a simpler way in that PDF file. Basically you need ModelView and Projection matrices.

Please note that, this code is almost 5 years old. A lot might have been changed in Vuforia and jPCT-AE since then.

TheMaggieSimpson commented 8 years ago

Yes, I do aware of that. I also have read your thesis doc. I just thought that you implemented something like Structure-from-Motion (not exactly that one, but something like that, a simpler technique which can be manually done even with single image reference), to estimate where to put the virtual 3D model relative to the image reference.

But anw, I realized lately that you don't need such calculation for this project, do you?

samrad commented 8 years ago

Apologies, I don't quite understand your question. Can you elaborate?

TheMaggieSimpson commented 8 years ago

Sorry for the confusion :D What I was trying to say is, I thought you were reconstructing the actual packaging-box by mapping the 2D-image-target-coordinate to 3D-object-coordinate, and made it as the object target. But after read your codes and doc thoroughly, I realized this project only deal with 2D image target. Am I right?

samrad commented 8 years ago

That's correct. AFAIK, the algorithm used to implement Vuforia are planar meaning that they are not 3D-aware. I'm not sure if there is any 3D tracking system available since what you get from camera is just a rectangle of pixels and there is no depth in it.

Regarding the 3D model, it's actually a 3D MD2 file. The texture is mapped to that 3D model but that has nothing to do with the code. It's all done in 3Ds Max. If you have any software that reads MD2 files you can just open the file along with its texture and see it rendered.

Hope this helps.

TheMaggieSimpson commented 8 years ago

Thanks. Sure it helps.