In case someone would like to know, QCAR's initial far plane is set to 2500, near plane to 2, which are larger than the default values of jPCT (1 & 1000). They have to be unified to solve the depth problem as I mentioned along Z direction.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
glEnable (GL_DEPTH_TEST);
glEnable (GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// prepare the cylinder
SampleUtils::scalePoseMatrix(kCylinderScaleX, kCylinderScaleY,
kCylinderScaleZ, &modelViewMatrix.data[0]);
SampleUtils::multiplyMatrix(&projectionMatrix.data[0],
&modelViewMatrix.data[0], &modelViewProjection.data[0]);
SampleUtils::checkGlError("CylinderTargets prepareCylinder");
glUseProgram(shaderProgramID);
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) mCylinderModel.ptrVertices());
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) mCylinderModel.ptrNormals());
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) mCylinderModel.ptrTexCoords());
glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(normalHandle);
glEnableVertexAttribArray(textureCoordHandle);
glActiveTexture (GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textures[0]->mTextureID);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
(GLfloat*) &modelViewProjection.data[0]);
glUniform1i(texSampler2DHandle, 0 /*GL_TEXTURE0*/);
glDrawElements(GL_TRIANGLES, mCylinderModel.nbIndices(),
GL_UNSIGNED_SHORT, (const GLvoid*) mCylinderModel.ptrIndices());
Quote
modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(result->getPose());
SampleUtils::multiplyMatrix(&projectionMatrix.data[0],
&modelViewMatrix.data[0], &modelViewProjection.data[0]);
jfloatArray modelviewArray = env->NewFloatArray(16);
env->SetFloatArrayRegion(modelviewArray, 0, 16, modelViewMatrix.data);
env->CallVoidMethod(obj, updateMatrixMethod, modelviewArray);
env->DeleteLocalRef(modelviewArray);
env->CallVoidMethod(obj, fovMethod, fovRadians);
env->CallVoidMethod(obj, fovyMethod, fovyRadians);
public void updateModelviewMatrix(float mat[]) {
modelViewMat = mat;
}
public void onDrawFrame(GL10 gl) {
if (!mIsActive)
return;
// Update render view (projection matrix and viewport) if needed:
mActivity.updateRenderView();
// Call our native function to render content
modelViewMat = null;
cylinderModelViewMat = null;
renderFrame(); //here call the QCAR native code so that JPCT receives the new matrix
updateCamera();
world.renderScene(fb);
world.draw(fb);
fb.display();
}
public void updateCamera() {
Matrix m = new Matrix();
if (modelViewMat != null) {
firstObj.setVisibility(true);
m.setDump(modelViewMat);
cam.setBack(m);
return;
}
firstObj.setVisibility(false);
cam.setBack(originalMatrix);
}
glEable(GL_DEPTH_TEST);
...
...
...
...
glDisable(GL_DEPTH_TEST);
//translation
firstObj.translate(400.0f, 0.0f, 0.0f);
firstObj.rotateZ(90.0f);
firstObj.rotateY(90.0f);
tester.translate(-400.0f, 0.0f, 0.0f);
tester.rotateZ(90.0f);
tester.rotateY(90.0f);
world.addObject(firstObj);
world.addObject(tester);
cam = world.getCamera();
originalMatrix = cam.getBack();
m.setDump(modelViewMat);
cam.setBack(m);
Page created in 0.051 seconds with 13 queries.