render - Top and bottom button clicked the obj model is flipped in opengl? -
@anton stucked flipping.
i downloaded project here. have 4 buttons each button set title right,left,bottom,top str variable.
in rendering initial rotation axis teapotnode_.rotationaxis = cc3vectormake(0.1, 1, 0.3);
- (void)update:(float)dt { if ([str isequaltostring:@"right"]) { teapotnode_.rotationaxis = cc3vectormake(0.1, 1, 0.3); angle +=2.0; } else if ([str isequaltostring:@"left"]) { teapotnode_.rotationaxis = cc3vectormake(0.1, 1, 0.3); angle -=2.0; } else if ([str isequaltostring:@"bottom"]) { teapotnode_.rotationaxis = cc3vectormake(1,0,0); angle +=2.0; } else if ([str isequaltostring:@"top"]) { teapotnode_.rotationaxis = cc3vectormake(1,0,0); angle -=2.0; } else{ angle +=2.0; } teapotnode_.rotationangle = angle; }
i touch top(or)down rotation button change axis teapotnode_.rotationaxis = cc3vectormake(1,0,0); object flipped.
i want same axis position rotate object top bottom , bottom top.
the solution is:
you says rotation axis value (0.1,1,0.3) initial one. don't change value.
this project having separate function rotation. teapotnode_.rotation
use this. working fine me. try this.
globally declared:
float x=0.0; float y=0.0; float z=0.0; float angle; float rangle=2.0; float xangle; float yangle; - (void)update:(float)dt { if ([str isequaltostring:@"right"]) { x=0; y=1; z=0; //rotate object in y-axis(y=1 & x=0) yangle+=rangle; //get angle of object rotation in y-axis (anti clockwise) angle +=rangle; //increment angle of object rotation in anticloclwise } else if ([str isequaltostring:@"left"]) { x=0; y=1; z=0; //rotate object in y-axis(y=1 & x=0) yangle-=rangle; //get angle of object rotation in y-axis (cloclwise) angle -= rangle; //inc angle of object rotation in clockwise } else if ([str isequaltostring:@"bottom"]) { x=1; y=0; z=0; //rotate object in x-axis(x=1 & y=0) xangle+=rangle; //get angle of object rotation in x-axis (anti clockwise) angle += rangle; //inc angle of object rotation } else if ([str isequaltostring:@"top"]) { x=1; y=0; z=0 ; //rotate object in y-axis(x=1 & y=0) xangle-=rangle; //get angle of object rotation in x-axis (cloclwise) angle -= rangle; //inc angle of object rotation } else { angle +=rangle; } // teapotnode_.rotationaxis = cc3vectormake(x, y, z); // teapotnode_.rotationangle = angle; teapotnode_.rotation = cc3vectormake(xangle, yangle, 0); }
Comments
Post a Comment