- Sort Posts
- 10 replies
- Last post
Re: How to modify the size of the banana?
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?
Re: How to modify the size of the banana?
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?
Re: How to modify the size of the banana?
Re: How to modify the size of the banana?
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?
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~~
Try setting the kObjectScale in ImageTargets.cpp to something larger.
- Kim
Try flipping the texture image vertically, that's a common problem.
- Kim