We've gotten several inquiries on how to cause a model to be rendered in a static pose after its target has initially been detected, such that it does not follow the target. Some devs have referred to this operation as disabling Tracking, but this is typically not actually what they are attempting - rendering a model in relation to the pose of a Trackable is distinct from the process of Tracking the target. Here the conventional use of 'tracking' is not technically correct.
The following demonstrates a simple method for rendering a model in a static pose once an associated Trackable has been detected. This is based on the Android ImageTargets sample, and will cause the Teapot model to be rendered in the original pose at which the target is detected and to maintain that pose while the target it is in view regardless of the subsequent position of the target.
In ImageTargets.cpp @ ln 75, under the definition of the projectionMatrix, add the following..
// The projection matrix used for rendering virtual objects:
QCAR::Matrix44F projectionMatrix;
// The ModelView Projection Matrix that stores the original pose of the model
QCAR::Matrix44F stableModelViewProjection;
// a boolean flag indicating whether to render the model in a static pose
bool modelPoseIsStatic = false;
and then copy the following code to lines 386 - 402
if( !modelPoseIsStatic ){
SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale,
&modelViewMatrix.data[0]);
SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale,
&modelViewMatrix.data[0]);
SampleUtils::multiplyMatrix(&projectionMatrix.data[0],
&modelViewMatrix.data[0] ,
&modelViewProjection.data[0]);stableModelViewProjection = modelViewProjection;
modelPoseIsStatic = true;}else{
modelViewProjection = stableModelViewProjection;
}
You're simply wrapping the original section, which updates the modelViewProjection with a conditional statement that incorporates a branch in which the projection is assigned from a copy of the original model pose. You'll notice that stableModelViewProjection is defined in the first instance from the original modelViewProjection generated by multiplying the projectionMatrix, which is based on the camera's intrinsic calibration parameters, and the modelViewMatrix from the Trackable's pose. After this occurs, the modelPoseIsStatic flag is set to true, which prevents the stableModelViewProjection from being subsequently redefined, and forces the modelViewProjection used for rendering to be defined from stableModelViewProjection. You can set modelPoseIsStatic elsewhere (e.g. an event handler ) to customize this behavior.
* this example assumes that you are using OpenGL ES 2.0
I realize this is an Android specific solution (in the Android forums, no less) but what would be the best way to approach this in the Unity project, in particular for use with FrameMarkers? I'm guessing that it's not nearly as simple due to the nature of the camera position updates, but does that mean that Unity is rendering the objects based on the camera positioning by QCAR?