Search Results

Search found 2 results on 1 pages for 'ayanonagon'.

Page 1/1 | 1 

  • Rotating an object in OpenGL ES for iPhone [translate to origin --> rotate --> translate back is not

    - by ayanonagon
    I recently started working with OpenGL ES for the iPhone, and I am having a bit of trouble with it. I want to be able to rotate an object with your fingers. My problem is that I have my object placed at (0, 0, -3), and I would like to rotate it about its center. I know that I need to translate back to the origin, rotate, and then bring it back to the original place. I think I am facing a problem because I am using a matrix to keep track (?) of all of my rotations/translation/scaling etc, and I think it may be combining the operations in a way that order is not even considered (so the two translations would cancel each other). I just started learning OpenGL a day ago and am a complete newbie, so my assumption may be wrong. Here is the part of the in drawView that I am having trouble with: GLfloat matrix[16]; glGetFloatv(GL_MODELVIEW_MATRIX, matrix); glLoadIdentity(); glTranslatef(0, 0, 3); // bring to origin glRotatef(self.angle, self.dy, self.dx, 0); // rotate glTranslatef(0, 0, -3); // put it back in place glMultMatrixf(matrix); // save the transformations performed Help would be much appreciated, thank you!

    Read the article

  • Adding nil to NSMutableArray

    - by ayanonagon
    I am trying to create a NSMutableArray by reading in a .txt file and am having trouble setting the last element of the array to nil. NSString *filePath = [[NSBundle mainBundle] pathForResource:@"namelist" ofType:@"txt"]; NSString *data = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; NSArray *list = [data componentsSeparatedByString:@"\n"]; NSMutableArray *mutableList = [[NSMutableArray alloc] initWithArray:list]; I wanted to use NSMutableArray's function addObject, but that will not allow me to add nil. I also tried: [mutableList addObject:[NSNull null]]; but that does not seem to work either. Is there a way around this problem?

    Read the article

1