Log in or register to post comments

How to modify the size of the banana?

December 9, 2011 - 9:10am #1

Hi,all.
I followed Heiko Behrens's obj2opengl solution of banana, and I got the banana.But the size of banana is so small that I can hardly see it. So, do I need to modify something in 'banana.h'or 'ImageTargets.cpp'?
Thanks in advance~~

Re: How to modify the size of the banana?

February 7, 2012 - 9:12pm #11

Try flipping the texture image vertically, that's a common problem.

- Kim

Re: How to modify the size of the banana?

February 7, 2012 - 8:02pm #10
ksiva wrote:

Hmm, that shouldn't happen. The texture should be mapped to the vertices regardless of their location in world space. Are you using a custom shader? Are you sure the texture was applied correctly before the rotation?

- Kim

Hi Kim,

Yes you are right - the texture was applied wrongly even before the rotation! No I wasn't using the custom shader. What I did was:
1. get a 3d car model in obj format from the internet
2. run the Perl script to generate the *.h file
3. Do the necessary changes to replace the teapot with this car model.

But I find that the texture was applied wrongly, irregardless of the rotation. I am really not sure why that's the case. I've noticed the same thing even for the banana.h file - seems like the texture isn't at its right place either.

Re: How to modify the size of the banana?

February 6, 2012 - 6:56pm #9

Hmm, that shouldn't happen. The texture should be mapped to the vertices regardless of their location in world space. Are you using a custom shader? Are you sure the texture was applied correctly before the rotation?

- Kim

Re: How to modify the size of the banana?

February 4, 2012 - 11:34pm #8
ksiva wrote:

You need to adjust the translation and rotation of the modelview matrix. See the renderFrame method. You can add a rotate like this:

        SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale,
                                         &modelViewMatrix.data[0]);
        SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale,
                                     &modelViewMatrix.data[0]);
        SampleUtils::rotatePoseMatrix(90.0f, 1.0f, 0.0f, 0.0f,
                                      &modelViewMatrix.data[0]);
        SampleUtils::multiplyMatrix(&projectionMatrix.data[0],
                                    &modelViewMatrix.data[0] ,
                                    &modelViewProjection.data[0]);

That rotates 90 degrees around the X axis, then scales by kObjectScale, and then translates up the Z axis by kObjectScale.

- Kim

Hi Kim,

I followed the above method to render a car 3d model. If I did not do the rotation around x-axis, the car got rendered correctly, only that it lies sideway and in the middle of the air. If I did do the rotation around x-axis (as per your code up there), I get the car object rendered at the right orientation, but however, the texture is still binded in the old orientation (pre-rotation), and hence I get a car with its sideview rendered on the car roof etc. How I solve this problem?

Rgds,
tapiocaflash

Re: How to modify the size of the banana?

January 24, 2012 - 1:47am #7

Have a look at http://ar.qualcomm.at/node/2000880 thread.

Re: How to modify the size of the banana?

January 3, 2012 - 12:00am #6

Hello,

I'm also trying to get the banana object out from the Heiko Behrens's project but to no avail.

May I know how do you render out the banana in opengl ? (I'm using the ImageTarget as a framework)

Thanks

Re: How to modify the size of the banana?

December 11, 2011 - 7:33am #5

You need to adjust the translation and rotation of the modelview matrix. See the renderFrame method. You can add a rotate like this:

        SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale,
                                         &modelViewMatrix.data[0]);
        SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale,
                                     &modelViewMatrix.data[0]);
        SampleUtils::rotatePoseMatrix(90.0f, 1.0f, 0.0f, 0.0f,
                                      &modelViewMatrix.data[0]);
        SampleUtils::multiplyMatrix(&projectionMatrix.data[0],
                                    &modelViewMatrix.data[0] ,
                                    &modelViewProjection.data[0]);

That rotates 90 degrees around the X axis, then scales by kObjectScale, and then translates up the Z axis by kObjectScale.

- Kim

Re: How to modify the size of the banana?

December 9, 2011 - 11:43pm #4

Hi,Kim.
Thanks,I got a big banana with setting the kObjectScale.
The new problem is the banana is vertical and float in the air now, But I want a horizontal one and close to the image. So, what should I do ?:confused:
many thanks~~

ksiva wrote:

Try setting the kObjectScale in ImageTargets.cpp to something larger.

- Kim

Re: How to modify the size of the banana?

December 9, 2011 - 12:07pm #3

Try setting the kObjectScale in ImageTargets.cpp to something larger.

- Kim

Re: How to modify the size of the banana?

December 9, 2011 - 11:43am #2

I didn't test this but I think you can tweak the size values in config.xml

Log in or register to post comments