Reputation:
I am working with open gl es 2.0 on iOS. I want to set the object to fit to screen when rendered initially.
I have this code:
CATransform3D currentCalculatedMatrix = CATransform3DIdentity;
currentCalculatedMatrix = CATransform3DScale(currentCalculatedMatrix,scaleFactor, scaleFactor,scaleFactor);
How should I calculate and set the scale factor?
Upvotes: 0
Views: 1234
Reputation: 21902
It depends on the projection you are using and the distance of the object from the camera. Obviously, it depends on your object shape as well. If all of the parameters I just mentioned are constant, then you might want to just go for trial and error until you are happy with the result. If the shape is variable, but the others are constant, then you will need to mathematically project your vertices using the projection you are using to make sure they all fall within the view port.
Here is another post that might help you as well: Fit 3d model inside a window
Upvotes: 1