Log in or register to post comments

How to change the teapot to another 3D model for the user defined target demo

January 27, 2013 - 5:20pm #1

HI,

How can I change the teapot model with another 3d model in the user defined target demo ?

thanks

Regis

How to change the teapot to another 3D model for the user define

January 29, 2013 - 5:59am #12

Glad to hear that!

How to change the teapot to another 3D model for the user define

January 29, 2013 - 3:46am #11

Thanks that did the work!

Regis

How to change the teapot to another 3D model for the user define

January 28, 2013 - 9:54am #10

Thanks for the update; that confirms that the glBindTexture() code is wrong;

as I was saying in my previous post, you should have a "texture ID" as argument of glBindTexture(); a texture ID is just an integer, it is not a string like "banana.jpg";

please use the same code that is in the original sample (and if you need to adapt it, please try first to understand what the existing sample code does, as OpenGL is a very strict API, so if you modify any of the OpenGL function, you need to be fully aware of what you are doing, otherwise you will break it, like in this case...)

 

 

How to change the teapot to another 3D model for the user define

January 28, 2013 - 9:44am #9

Hi,

 

*textureFilenames[0] = "babana.jpg"

 

thanks

 

 

How to change the teapot to another 3D model for the user define

January 28, 2013 - 9:40am #8

Hi, if you see a black banana model, it means you have a problem with the texture;

one strange thing I see in your code is:

glBindTexture(GL_TEXTURE_2D, *textureFilenames[0]);

not quite sure what textureFilenames is; could you compare this code with the original one in ImageTargets sample ?

glBindTexture requires that you pass a texture ID there.

 

Also, the texture issue has been addresses already several time in this Forum (if you search the Forum you can find many threads about it), plus in addition you can also take a look at this FAQ:

https://developer.vuforia.com/forum/faq/android-how-do-i-add-textures-my-model

That article has been written for Android, but you will find general tips that can help in iOS too.

 

How to change the teapot to another 3D model for the user define

January 28, 2013 - 9:25am #7

Hi,

 

Ok i see them they are black !

 

I have 3 files babana.h, banana.jpg, banana.obj

 

please advise.

 

thanks

 

Regis

How to change the teapot to another 3D model for the user define

January 28, 2013 - 9:05am #6

OK, it could be that it is just too small;

have you changed the objectScale to something larger (I think by default it is around 3.0 in the sample, try increasing it to 100 or so...)?

This might fix the problem.

 

How to change the teapot to another 3D model for the user define

January 28, 2013 - 9:03am #5

I do not see the 3d nodel ie the banana

 

Regis

How to change the teapot to another 3D model for the user define

January 28, 2013 - 9:01am #4

Hi, can you be more specific ?

it does not work because you don't see the 3D model ? or do you see a mesh which is looking erroneous / black / non textured, other ?

 

How to change the teapot to another 3D model for the user define

January 28, 2013 - 8:54am #3

hi,

 

sorry I need a bit more help it does nor work:

 

 

// modify renderFrameQCAR here if you want a different 3D rendering model

////////////////////////////////////////////////////////////////////////////////

// Draw the current frame using OpenGL

//

// This method is called by QCAR when it wishes to render the current frame to

// the screen.

//

// *** QCAR will call this method on a single background thread ***

- (void)renderFrameQCAR

{

    

    [self setFramebuffer];

    

    // Clear colour and depth buffers

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    

    // Render video background and retrieve tracking state

    QCAR::State state = QCAR::Renderer::getInstance().begin();

    QCAR::Renderer::getInstance().drawVideoBackground();

    

    //NSLog(@"active trackables: %d", state.getNumActiveTrackables());

    

    if (QCAR::GL_11 & qUtils.QCARFlags) {

        glEnable(GL_TEXTURE_2D);

        glDisable(GL_LIGHTING);

        glEnableClientState(GL_VERTEX_ARRAY);

        glEnableClientState(GL_NORMAL_ARRAY);

        glEnableClientState(GL_TEXTURE_COORD_ARRAY);

    }

    

    glEnable(GL_DEPTH_TEST);

    // We must detect if background reflection is active and adjust the culling direction.

    // If the reflection is active, this means the pose matrix has been reflected as well,

    // therefore standard counter clockwise face culling will result in "inside out" models.

    glEnable(GL_CULL_FACE);

    glCullFace(GL_BACK);

    if(QCAR::Renderer::getInstance().getVideoBackgroundConfig().mReflection == QCAR::VIDEO_BACKGROUND_REFLECTION_ON)

        glFrontFace(GL_CW);  //Front camera

    else

        glFrontFace(GL_CCW);   //Back camera

    

    // Render the RefFree UI elements depending on the current state

    refFreeFrame.render();

    

    for (int i = 0; i < state.getNumTrackableResults(); ++i) {

        // Get the trackable

        const QCAR::TrackableResult* trackableResult = state.getTrackableResult(i);

        QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(trackableResult->getPose());

        

        int targetIndex = 1;

        

        //Object3D *obj3D = [objects3D objectAtIndex:targetIndex];

        

        QCAR::Matrix44F modelViewProjection;

        

        ShaderUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale, &modelViewMatrix.data[0]);

        ShaderUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, &modelViewMatrix.data[0]);

        ShaderUtils::multiplyMatrix(&qUtils.projectionMatrix.data[0], &modelViewMatrix.data[0], &modelViewProjection.data[0]);

        

        glUseProgram(shaderProgramID);

        

        glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bananaVerts[0]);

        glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bananaNormals[0]);

        glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bananaTexCoords[0]);

        

        glEnableVertexAttribArray(vertexHandle);

        glEnableVertexAttribArray(normalHandle);

        glEnableVertexAttribArray(textureCoordHandle);

        

        glActiveTexture(GL_TEXTURE0);

        glBindTexture(GL_TEXTURE_2D, *textureFilenames[0]);

        glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (const GLfloat*)&modelViewProjection.data[0]);

        glDrawArrays(GL_TRIANGLES, 0, bananaNumVerts);

        

        ShaderUtils::checkGlError("EAGLView renderFrameQCAR");

    }

    

    glDisable(GL_DEPTH_TEST);

    glDisable(GL_CULL_FACE);

    

    glDisableVertexAttribArray(vertexHandle);

    glDisableVertexAttribArray(normalHandle);

    glDisableVertexAttribArray(textureCoordHandle);

    

    QCAR::Renderer::getInstance().end();

    [self presentFramebuffer];

}

 

thanks

 

Regis

How to change the teapot to another 3D model for the user define

January 28, 2013 - 1:00am #2

Hi, you can have a look here:

https://developer.vuforia.com/forum/faq/android-how-do-i-replace-teapot

This is explaining how to do that for the Image Targets sample, but you can basically follow the same steps and logic to do it in User Defined Target sample too.

 

Log in or register to post comments