PDA

View Full Version : Zooming objects : OpenGL ES 2.0



useruser
12-11-2014, 02:11 AM
I'm very new to OpenGL and attempting to make a graph plotter app. I have 6 lines representing 3 positive axes and 3 negative axes rendered from the origin. Now I'm trying to add some rotation functions to it. Here is some of the code I wrote in glkView.


axis = GLKVector3Make(-AXIS_LENGTH, 0.0f, 0.0f);
col = GLKVector4Make(1.0f, 1.0f, 1.0f, 0.5f);
[self drawAxis:axis color:col];

axis = GLKVector3Make(0.0f, -AXIS_LENGTH, 0.0f);
col = GLKVector4Make(1.0f, 1.0f, 1.0f, 0.5f);
[self drawAxis:axis color:col];

axis = GLKVector3Make(0.0f, 0.0f, -AXIS_LENGTH);
col = GLKVector4Make(1.0f, 1.0f, 1.0f, 0.5f);
[self drawAxis:axis color:col];


axis = GLKVector3Make(AXIS_LENGTH, 0.0f, 0.0f);
col = GLKVector4Make(1.0f, 0.5f, 0.5f, 1.0f);
[self drawAxis:axis color:col];

axis = GLKVector3Make(0.0f, AXIS_LENGTH, 0.0f);
col = GLKVector4Make(0.5f, 1.0f, 0.5f, 1.0f);
[self drawAxis:axis color:col];

axis = GLKVector3Make(0.0f, 0.0f, AXIS_LENGTH);
col = GLKVector4Make(0.5f, 0.5f, 1.0f, 1.0f);
[self drawAxis:axis color:col];

I have some functions to rotate the axes. How can I make it possible to zoom the axes from any directions?
I can zoom the objects using GLKMatrix4Translate, but after I rotate the axes I just get the axes moving along one axis.