I'm developer on iOS(FrameMarkers). I would like to display 2D picture(JPG) or 3D model in each FrameMarker.For example FM1 shows 3D ,FM2 shows 2D, FM3 shows 2D. Now I can display only 3D model but I don't know how to display 2D picture. Do Anyone know how to solve this problem or adapt code from sample?
- Sort Posts
- 6 replies
- Last post
How to display 2d image when FrameMarkers is detected.
February 15, 2013 - 1:20am #6
OK, that is pretty easy to do:
first, you need to render a "quad" instead of the classic "teapot"; the texture of your picture is applied on the quad; you can find the full code to render a textured quad in the VideoPlayback sample for instance (see the quadVertices, quadNormals, quadTexCoords variables and how they are used in the OpenGL code)
second, you will need to adjust the pose matrix so that it behaves like a Billboard, i.e. by resetting (clearing) the rotational part of the matrix and only keeping the translational one; in practice this can be done with this simple code:
QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(result->getPose()); // reset the rotational part of the pose matrix modelViewMatrix.data[0] = 1.0f; modelViewMatrix.data[1] = 0.0f; modelViewMatrix.data[2] = 0.0f; modelViewMatrix.data[3] = 0.0f; modelViewMatrix.data[4] = 0.0f; modelViewMatrix.data[5] = 1.0f; modelViewMatrix.data[6] = 0.0f; modelViewMatrix.data[7] = 0.0f; modelViewMatrix.data[8] = 0.0f; modelViewMatrix.data[9] = 0.0f; modelViewMatrix.data[10] = 1.0f; modelViewMatrix.data[11] = 0.0f;
This should do the trick.
This is exactly what I would like to know, i.e. how to add 2D image/texture when a frame marker is recognised. I have asked this question here: https://developer.vuforia.com/forum/ios/dynamic-image-not-rendered-correctly-ipad
The problem I'm facing is that if I add a 3D Plane game object in Unity Editor at design time my image is rendered correctly when deployed to iPad. If I add 3D Plane game object programmatically at run-time, then when deployed to iPad it is rendered as pink/magenta rectangle. Of course it works in Unity Player.
My question what is the difference between Plane and Quad? Would it make any difference to my problem?