本文整理汇总了C++中qcar::State::getActiveTrackable方法的典型用法代码示例。如果您正苦于以下问题:C++ State::getActiveTrackable方法的具体用法?C++ State::getActiveTrackable怎么用?C++ State::getActiveTrackable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qcar::State
的用法示例。
在下文中一共展示了State::getActiveTrackable方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
JNIEXPORT jobject JNICALL
Java_org_ronhuang_vistroller_Vistroller_getMarker(JNIEnv *env, jobject)
{
//LOG("Java_org_ronhuang_vistroller_Vistroller_getMarker");
jobject result = NULL;
QCAR::State state = QCAR::Renderer::getInstance().begin();
for (int i = 0; i < state.getNumActiveTrackables(); i++) {
const QCAR::Trackable *trackable = state.getActiveTrackable(i);
assert(trackable->getType() == QCAR::Trackable::MARKER);
const QCAR::Marker *marker = static_cast<const QCAR::Marker*>(trackable);
result = newMarker(env, marker->getMarkerId(), marker->getPose().data, marker->getSize().data);
break; // FIXME: return only the first one for now.
}
if (NULL == result) {
// Make sure always return an instance of Trackable.
// Return invalid one.
float pose[3 * 4] = {
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0
};
float size[2] = {0, 0};
result = newMarker(env, -1, pose, size);
}
QCAR::Renderer::getInstance().end();
return result;
}
示例2:
JNIEXPORT jstring JNICALL
Java_com_robopeak_EasyQCAR_EasyQCAR_getName(JNIEnv* env, jobject, jint tIdx)
{
if (!qcar_begun)
return NULL;
const QCAR::Trackable* trackable = g_state.getActiveTrackable(tIdx);
const char* name = trackable->getName();
return env->NewStringUTF(name);
}
示例3: glClear
JNIEXPORT void JNICALL
Java_edu_pugetsound_vichar_ar_ARGameRenderer_renderFrame(JNIEnv * env, jobject obj, jboolean updated, jfloatArray test, jint objSize)
{
bool update;
update = (bool) updated; //so we know whether or not to update the drawlist.
float testScale = 0.3f;
// here is an example of how to pull the elements out of the jfloatArray. I think c++ will implicitly handle the type casting of jfloats as floats,
// but if you are getting errors, you can always explicitly type cast them like so (assuming you have jfloats in the array):
// float x;
// x = (float) posData[i];
if(update){
int i = 0;
int j = 0;
jsize len = env->GetArrayLength(test);
jfloat* posData = env->GetFloatArrayElements(test, 0);
while(i<len && posData[(i/objSize)*objSize] != 0){
LOG("JSON to JNI test. Pos. %d : %f", i, posData[i]); //print the elements of the array.
interpList[i/objSize][i%objSize]= (float) posData[i] * testScale;
i++;
}
interpLength=(i)/objSize;
LOG("%i", interpLength);
env->ReleaseFloatArrayElements(test, posData, 0); //release memory
}
//LOG("Java_edu_pugetsound_vichar_ar_GLRenderer_renderFrame");
// Clear color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Get the state from QCAR and mark the beginning of a rendering section
QCAR::State state = QCAR::Renderer::getInstance().begin();
// Explicitly render the Video Background
QCAR::Renderer::getInstance().drawVideoBackground();
#ifdef USE_OPENGL_ES_1_1
// Set GL11 flags:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
#endif
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
// Did we find any trackables this frame?
for(int tIdx = 0; tIdx < state.getNumActiveTrackables(); tIdx++)
{
// Get the trackable:
const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx);
QCAR::Matrix44F modelViewMatrix =
QCAR::Tool::convertPose2GLMatrix(trackable->getPose());
//Begin additions by Erin================================================================================
QCAR::Matrix34F test; //gets inverse pos matrix
QCAR::Matrix34F pos; //Gets positional data
pos = trackable->getPose();
//Get inverse
test = SampleMath::phoneCoorMatrix(trackable->getPose());
//Print results
// LOG("Poisiton:");
// LOG("%f %f %f %f",pos.data[0], pos.data[1], pos.data[2], pos.data[3]);
// LOG("%f %f %f %f",pos.data[4], pos.data[5], pos.data[6], pos.data[7]);
// LOG("%f %f %f %f",pos.data[8], pos.data[9], pos.data[10],pos.data[11]);
// LOG("Inverse:");
// LOG("%f %f %f %f",test.data[0], test.data[1], test.data[2], test.data[3]);
// LOG("%f %f %f %f",test.data[4], test.data[5], test.data[6], test.data[7]);
// LOG("%f %f %f %f",test.data[8], test.data[9], test.data[10], test.data[11]);
// LOG("=========================");
phoneLoc[0] = 1.0f;
phoneLoc[1] = test.data[3];
phoneLoc[2] = test.data[7];
phoneLoc[3] = test.data[11];
//End============================================================================================
// Assign Textures according in the texture indices defined at the beginning of the file, and based
// on the loadTextures() method in ARGameActivity.java.
const Texture* const tower_shellTexture = textures[tower_shellIndex];
const Texture* const tower_topTexture = textures[tower_topIndex];
const Texture* const bananaTexture = textures[banana180Index];
#ifdef USE_OPENGL_ES_1_1
// Load projection matrix:
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(projectionMatrix.data);
// Load model view matrix:
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(modelViewMatrix.data);
glTranslatef(0.f, 0.f, kObjectScale);
//.........这里部分代码省略.........
示例4: screenPoint
JNIEXPORT jboolean JNICALL
Java_com_snda_sdar_ImageTargetsRenderer_renderFrame(JNIEnv *env, jobject obj)
{
//LOG("Java_com_snda_sdar_ImageTargets_GLRenderer_renderFrame");
// Clear color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
jboolean isDetected = false;
// Render video background:
QCAR::State state = QCAR::Renderer::getInstance().begin();
// Explicitly render the Video Background
QCAR::Renderer::getInstance().drawVideoBackground();
#ifdef USE_OPENGL_ES_1_1
// Set GL11 flags:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
#endif
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
// Did we find any trackables this frame?
for(int tIdx = 0; tIdx < state.getNumActiveTrackables(); tIdx++)
{
isDetected = true;
// Get the trackable:
const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx);
QCAR::Matrix44F modelViewMatrix =
QCAR::Tool::convertPose2GLMatrix(trackable->getPose());
// Choose the texture based on the target name:
//int textureIndex = (!strcmp(trackable->getName(), "stones")) ? 0 : 1;
const Texture* const thisTexture = textures[textureIndex];
const Texture* const tagTexture = textures[textureCount - 1];
#ifdef USE_OPENGL_ES_1_1
// Load projection matrix:
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(projectionMatrix.data);
// Load model view matrix:
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(modelViewMatrix.data);
glTranslatef(0.f, 0.f, kObjectScale);
glScalef(kObjectScale, kObjectScale, kObjectScale);
// Draw object:
glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID);
glTexCoordPointer(2, GL_FLOAT, 0, (const GLvoid*) &planeTexCoords[0]);
glVertexPointer(3, GL_FLOAT, 0, (const GLvoid*) &planeVertices[0]);
glNormalPointer(GL_FLOAT, 0, (const GLvoid*) &planeNormals[0]);
glDrawElements(GL_TRIANGLES, NUM_PLANE_OBJECT_INDEX, GL_UNSIGNED_SHORT,
(const GLvoid*) &planeIndices[0]);
// // Load model view matrix:
// glMatrixMode(GL_MODELVIEW);
// glLoadMatrixf(modelViewMatrix.data);
// glTranslatef(50.f, 50.f, kObjectScale);
// glScalef(1, 1, 1);
//
// // Draw object:
// glBindTexture(GL_TEXTURE_2D, tagTexture->mTextureID);
// glTexCoordPointer(2, GL_FLOAT, 0, (const GLvoid*) &planeTexCoords[0]);
// glVertexPointer(3, GL_FLOAT, 0, (const GLvoid*) &planeVertices[0]);
// glNormalPointer(GL_FLOAT, 0, (const GLvoid*) &planeNormals[0]);
// glDrawElements(GL_TRIANGLES, NUM_PLANE_OBJECT_INDEX, GL_UNSIGNED_SHORT,
// (const GLvoid*) &planeIndices[0]);
#else
QCAR::Matrix44F modelViewMatrix2;
for (int i = 0; i < 16; i++)
{
modelViewMatrix2.data[i] = modelViewMatrix.data[i];
}
QCAR::Matrix44F modelViewProjection;
QCAR::Matrix44F modelViewProjection2;
SampleUtils::translatePoseMatrix(translateX, translateY, kObjectScale,
&modelViewMatrix.data[0]);
SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale,
&modelViewMatrix.data[0]);
SampleUtils::rotatePoseMatrix(angleX, 0, 1, 0,
&modelViewMatrix.data[0]);
SampleUtils::rotatePoseMatrix(angleY, 1, 0, 0,
&modelViewMatrix.data[0]);
//.........这里部分代码省略.........
示例5: if
// Does all the rendering stuff
JNIEXPORT void JNICALL
Java_edu_ethz_s3d_S3DRenderer_renderFrame(JNIEnv *, jobject)
{
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
// Clear color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Get the state from QCAR and mark the beginning of a rendering section
QCAR::State state = QCAR::Renderer::getInstance().begin();
// Explicitly render the Video Background
QCAR::Renderer::getInstance().drawVideoBackground();
#ifdef USE_OPENGL_ES_1_1
// Set GL11 flags:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
#endif
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
// TODO: Only work, when there is exactly one trackable
// Did we find any trackables this frame?
for(int tIdx = 0; tIdx < state.getNumActiveTrackables(); tIdx++)
{
// Get the trackable:
const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx);
QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(trackable->getPose());
// Choose the texture based on the target name:
int textureIndex;
if (strcmp(trackable->getName(), "chips") == 0)
{
textureIndex = 0;
}
else if (strcmp(trackable->getName(), "stones") == 0)
{
textureIndex = 1;
}
else
{
textureIndex = 2;
}
const Texture* const thisTexture = textures[textureIndex];
#ifdef USE_OPENGL_ES_1_1
// Load projection matrix:
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(projectionMatrix.data);
// Load model view matrix:
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(modelViewMatrix.data);
glTranslatef(0.f, 0.f, kObjectScale);
glScalef(kObjectScale, kObjectScale, kObjectScale);
// Draw object:
glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID);
glTexCoordPointer(2, GL_FLOAT, 0, (const GLvoid*) &teapotTexCoords[0]);
glVertexPointer(3, GL_FLOAT, 0, (const GLvoid*) &teapotVertices[0]);
glNormalPointer(GL_FLOAT, 0, (const GLvoid*) &teapotNormals[0]);
glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
(const GLvoid*) &teapotIndices[0]);
#else
// Calculate the projection matrix
QCAR::Matrix44F modelViewProjection;
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]);
// Calculate the camera position
QCAR::Matrix44F inverseModelView = SampleMath::Matrix44FTranspose(SampleMath::Matrix44FInverse(modelViewMatrix));
QCAR::Vec3F cameraPosition(inverseModelView.data[12], inverseModelView.data[13], inverseModelView.data[14]);
// Select the shader program
glUseProgram(shaderProgramID);
// Load the vertex attributes
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotVertices[0]);
glVertexAttribPointer(vertexColorHandle,3,GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &color[0]);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotNormals[0]);
// Enable the vertex attributes
glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(normalHandle);
glEnableVertexAttribArray(vertexColorHandle);
// Load the reconstruction data
if (reconstructionHandler != NULL) {
//.........这里部分代码省略.........
示例6: glClear
JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv *, jobject)
{
//LOG("Java_com_qualcomm_QCARSamples_ImageTargets_GLRenderer_renderFrame");
// Clear color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render video background:
QCAR::State state = QCAR::Renderer::getInstance().begin();
#ifdef USE_OPENGL_ES_1_1
// Set GL11 flags:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
#endif
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
// Did we find any trackables this frame?
for(int tIdx = 0; tIdx < state.getNumActiveTrackables(); tIdx++)
{
// Get the trackable:
const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx);
QCAR::Matrix44F modelViewMatrix =
QCAR::Tool::convertPose2GLMatrix(trackable->getPose());
// Choose the texture based on the target name:
int textureIndex = (!strcmp(trackable->getName(), "stones")) ? 0 : 1;
const Texture* const thisTexture = textures[textureIndex];
#ifdef USE_OPENGL_ES_1_1
// Load projection matrix:
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(projectionMatrix.data);
// Load model view matrix:
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(modelViewMatrix.data);
glTranslatef(0.f, 0.f, kObjectScale);
glScalef(kObjectScale, kObjectScale, kObjectScale);
// Draw object:
glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID);
glTexCoordPointer(2, GL_FLOAT, 0, (const GLvoid*) &teapotTexCoords[0]);
glVertexPointer(3, GL_FLOAT, 0, (const GLvoid*) &teapotVertices[0]);
glNormalPointer(GL_FLOAT, 0, (const GLvoid*) &teapotNormals[0]);
glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
(const GLvoid*) &teapotIndices[0]);
#else
QCAR::Matrix44F modelViewProjection;
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]);
glUseProgram(shaderProgramID);
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &teapotVertices[0]);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &teapotNormals[0]);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &teapotTexCoords[0]);
glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(normalHandle);
glEnableVertexAttribArray(textureCoordHandle);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
(GLfloat*)&modelViewProjection.data[0] );
glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
(const GLvoid*) &teapotIndices[0]);
SampleUtils::checkGlError("ImageTargets renderFrame");
#endif
}
glDisable(GL_DEPTH_TEST);
#ifdef USE_OPENGL_ES_1_1
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#else
//.........这里部分代码省略.........
示例7: glClear
JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_VirtualButtons_VirtualButtonsRenderer_renderFrame(JNIEnv *, jobject)
{
//LOG("Java_com_qualcomm_QCARSamples_VirtualButtons_GLRenderer_renderFrame");
// Clear color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render video background:
QCAR::State state = QCAR::Renderer::getInstance().begin();
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
// Did we find any trackables this frame?
if (state.getNumActiveTrackables())
{
// Get the trackable:
const QCAR::Trackable* trackable = state.getActiveTrackable(0);
QCAR::Matrix44F modelViewMatrix =
QCAR::Tool::convertPose2GLMatrix(trackable->getPose());
// The image target:
assert(trackable->getType() == QCAR::Trackable::IMAGE_TARGET);
const QCAR::ImageTarget* target =
static_cast<const QCAR::ImageTarget*>(trackable);
// Set transformations:
QCAR::Matrix44F modelViewProjection;
SampleUtils::multiplyMatrix(&projectionMatrix.data[0],
&modelViewMatrix.data[0],
&modelViewProjection.data[0]);
// Set the texture used for the teapot model:
int textureIndex = 0;
GLfloat vbVertices[96];
unsigned char vbCounter=0;
// Iterate through this targets virtual buttons:
for (int i = 0; i < target->getNumVirtualButtons(); ++i)
{
const QCAR::VirtualButton* button = target->getVirtualButton(i);
// If the button is pressed, than use this texture:
if (button->isPressed())
{
// Run through button name array to find texture index
for (int j = 0; j < NUM_BUTTONS; ++j)
{
if (strcmp(button->getName(), virtualButtonColors[j]) == 0)
{
textureIndex = j+1;
break;
}
}
}
const QCAR::Area* vbArea = &button->getArea();
assert(vbArea->getType() == QCAR::Area::RECTANGLE);
const QCAR::Rectangle* vbRectangle = static_cast<const QCAR::Rectangle*>(vbArea);
// We add the vertices to a common array in order to have one single
// draw call. This is more efficient than having multiple glDrawArray calls
vbVertices[vbCounter ]=vbRectangle->getLeftTopX();
vbVertices[vbCounter+ 1]=vbRectangle->getLeftTopY();
vbVertices[vbCounter+ 2]=0.0f;
vbVertices[vbCounter+ 3]=vbRectangle->getRightBottomX();
vbVertices[vbCounter+ 4]=vbRectangle->getLeftTopY();
vbVertices[vbCounter+ 5]=0.0f;
vbVertices[vbCounter+ 6]=vbRectangle->getRightBottomX();
vbVertices[vbCounter+ 7]=vbRectangle->getLeftTopY();
vbVertices[vbCounter+ 8]=0.0f;
vbVertices[vbCounter+ 9]=vbRectangle->getRightBottomX();
vbVertices[vbCounter+10]=vbRectangle->getRightBottomY();
vbVertices[vbCounter+11]=0.0f;
vbVertices[vbCounter+12]=vbRectangle->getRightBottomX();
vbVertices[vbCounter+13]=vbRectangle->getRightBottomY();
vbVertices[vbCounter+14]=0.0f;
vbVertices[vbCounter+15]=vbRectangle->getLeftTopX();
vbVertices[vbCounter+16]=vbRectangle->getRightBottomY();
vbVertices[vbCounter+17]=0.0f;
vbVertices[vbCounter+18]=vbRectangle->getLeftTopX();
vbVertices[vbCounter+19]=vbRectangle->getRightBottomY();
vbVertices[vbCounter+20]=0.0f;
vbVertices[vbCounter+21]=vbRectangle->getLeftTopX();
vbVertices[vbCounter+22]=vbRectangle->getLeftTopY();
vbVertices[vbCounter+23]=0.0f;
vbCounter+=24;
}
// We only render if there is something on the array
if (vbCounter>0)
{
// Render frame around button
glUseProgram(vbShaderProgramID);
//.........这里部分代码省略.........
示例8: if
JNIEXPORT void JNICALL
Java_name_nailgun_irrlichtvuforia_Renderer_renderFrame(JNIEnv *, jobject)
{
QCAR::State state = QCAR::Renderer::getInstance().begin();
QCAR::Renderer::getInstance().drawVideoBackground();
#ifndef DONT_SAVE_STATE
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
//glEnable(GL_CULL_FACE);
#endif
// Did we find any trackables this frame?
for(int tIdx = 0; tIdx < state.getNumActiveTrackables(); tIdx++)
{
// Get the trackable:
const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx);
QCAR::Matrix44F modelViewMatrix =
QCAR::Tool::convertPose2GLMatrix(trackable->getPose());
// Choose the texture based on the target name:
int textureIndex;
if (strcmp(trackable->getName(), "chips") == 0)
{
textureIndex = 0;
}
else if (strcmp(trackable->getName(), "stones") == 0)
{
textureIndex = 1;
}
else
{
textureIndex = 2;
}
if (!mDevice->run()) {
// TODO: error
}
irr::core::matrix4& cameraMatrix = mTransformationNode->getRelativeTransformationMatrix();
cameraMatrix.setM(modelViewMatrix.data);
mDriver->beginScene(false, true);
mSceneManager->drawAll();
mDriver->endScene();
}
#ifndef DONT_SAVE_STATE
glDisable(GL_DEPTH_TEST);
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
QCAR::Renderer::getInstance().end();
}
示例9: glClear
JNIEXPORT void JNICALL
Java_com_mx_ipn_escom_ars_recorrido_ArsRenderer_renderFrame2(JNIEnv *env, jobject obj)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
QCAR::State state = QCAR::Renderer::getInstance().begin();
QCAR::Renderer::getInstance().drawVideoBackground();
#ifdef USE_OPENGL_ES_1_1
// Set GL11 flags:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
// glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
glEnable(GL_LIGHTING);
// glDisable(GL_LIGHTING);
#endif
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
// Did we find any trackables this frame?
for(int tIdx = 0; tIdx < state.getNumActiveTrackables(); tIdx++)
{
// Get the trackable:
const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx);
QCAR::Matrix44F modelViewMatrix =
QCAR::Tool::convertPose2GLMatrix(trackable->getPose());
#ifdef USE_OPENGL_ES_1_1
// Load projection matrix:
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(projectionMatrix2.data);
// Load model view matrix:
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(modelViewMatrix.data);
glTranslatef(0.f, 0.f, kObjectScale);
glScalef(kObjectScale, kObjectScale, kObjectScale);
jclass javaClass = env->GetObjectClass(obj);
char *buf = (char*)malloc(10);
strcpy(buf, trackable->getName());
jstring jstrBuf = env->NewStringUTF(buf);
jmethodID method1 = env->GetMethodID(javaClass, "prueba2", "(Ljava/lang/String;)V");
env->CallVoidMethod(obj, method1,jstrBuf);
env->DeleteLocalRef(jstrBuf);
#endif
}
glDisable(GL_DEPTH_TEST);
#ifdef USE_OPENGL_ES_1_1
// glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
#endif
QCAR::Renderer::getInstance().end();
}