Log in or register to post comments

Creating New Object in Target Images

March 7, 2013 - 11:06am #1

I have followed the tutorials and am able to replace the teapot with the banana, but I would like to make a new object instead of replacing an existing object.

My understanding so far of the banana tutorials is that, when you replace the obj3D variables, you are pointing to an object that is actually defined in AR_EAGLVIEW.mm. Is this correct?

If so, how do I define my own new object, so that I can have both a banana and a teapot next to eachother

Thanks

Creating New Object in Target Images

March 8, 2013 - 10:27pm #6

Great!

Creating New Object in Target Images

March 8, 2013 - 4:05pm #5

I managed to solve my problem. I had re-ordered some things in the get trackables for loop. Sorted now

Creating New Object in Target Images

March 7, 2013 - 3:00pm #4

Ok I thought I had it, but I must be getting this very wrong. I've tried to create teapot and banana objects by doing the following:

    for (int i=0; i < 3; i++)
    {
        Object3D *obj3D = [[Object3D alloc] init];
        
        obj3D.numVertices = NUM_TEAPOT_OBJECT_VERTEX;
        obj3D.vertices = teapotVertices;
        obj3D.normals = teapotNormals;
        obj3D.texCoords = teapotTexCoords;
        
        obj3D.numIndices = NUM_TEAPOT_OBJECT_INDEX;
        obj3D.indices = teapotIndices;
        
        obj3D.texture = [textures objectAtIndex:i];
        
        [objects3D addObject:obj3D];
        [obj3D release];
    }

    for (int i=3; i < 4; i++)
    {
        Object3D *obj3D = [[Object3D alloc] init];
        
        obj3D.numVertices = bananaNumVerts;
        obj3D.vertices = bananaVerts;
        obj3D.normals = bananaNormals;
        obj3D.texCoords = bananaTexCoords;
        
        obj3D.texture = [textures objectAtIndex:i];
        
        [objects3D addObject:obj3D];
        [obj3D release];
    }

 

I then tried to call them later to render them like this

        Object3D *obj3D = [objects3D objectAtIndex:1];
        Object3D *banana = [objects3D objectAtIndex:3];

 

They work if I do them individually, but when I try to do them together it only does the banana. I can show you the full code if you like, but I didn't want to just throw it all at you in one go. Perhaps you'll know if I'm already doing the first part wrong

 

Creating New Object in Target Images

March 7, 2013 - 12:30pm #3

Thanks very much AlessendroB, I will have a go with that and let you know how I get on. I'm ok with moving things around and all that jazz, scaling, rotating etc. So it shouldn't be a problem to get them in view once its working hopefully

Creating New Object in Target Images

March 7, 2013 - 12:18pm #2

Hi, if you go inside the "for loop" that iterates through the trackable results, then for each trackable result (and thus for each trackable Pose)  you just need to "duplicate" the OpenGL code (the one that you use to render the banana vertices, etc.) so that it renders two meshes instead of one (once using the banana, and once using another mesh).

Also, if you want to make the model sit next to each other (i;e. slightly translated), you need to adjust the translation to use different values ( see this function SampleUtils::translatePoseMatrix() )

It should be quite simple to do.
        

 

Log in or register to post comments