Geometry

Hi everybody,

I am rendering half of an object. I want to duplicate the another half of the geometry. How to do this? For example, I have rendered one half of the ship, By using that half ship geometry data i want to render the another half. I know i have to change the matrix and i can render the another half? But how to change my matrix to get a another half?

[QUOTE=unknown123;1292098]Hi everybody,

I am rendering half of an object. I want to duplicate the another half of the geometry. How to do this? For example, I have rendered one half of the ship, By using that half ship geometry data i want to render the another half. I know i have to change the matrix and i can render the another half? But how to change my matrix to get a another half?[/QUOTE]

Lets say your symmetry axis is the z-axis in Model space and all parts of your ship which lie directly on that axis have a z-value of 0. Then multiplying a matrix like this


| 1  0  0  0 |
| 0  1  0  0 |
| 0  0 -1  0 |
| 0  0  0  1 |

before all other transformations will give you the other half of the ship. It basically just switches the sign of the z-value. But there is one drawback to this: You need to switch the used backface culling winding order before rendering, otherwise you will get the back faces instead of the front faces. I can’t come up with a transformation which does not need this state change. Maybe there is a OGL function for that, but I don’t know it.

If you’re using fixed-function matrix operations, glScalef(1,1,-1) will mirror in the Z=0 plane (similarly for the other two). For other planes, you can surround the scaling with translation and/or rotation calls, or construct the matrix directly. A reflection about the plane through the origin with the (unit) normal vector N is given by the matrix I-2.NT.N.

There isn’t. MIrroring inevitably swaps the winding order, so you need to use glFrontFace() to account for this. As well as culling, it also affects fixed-function lighting.

Thanks for your reply ProgrammerX and GClements. I have used that scaling method but it did not give me the correct result. I forget to disable the cull facing. Now it render the another half of the geometry fine. :slight_smile: