OpenGLScript
Currently I am adding facilities to include the use of variables. This will include a math engine that will calculate values based on variables and math operations (i.e. trig functions, addition, multiplication and powers).
If someone has “Building Cocoa Applications : A Step by Step Guide” that would be great if you could help with the math engine by providing a wrapper for the calculator expample in the book. I think it involved an NSTask and command line tool. The wrapper doesn’t need an interface, only a method that excepts a formula string and returns a value. Once the wrapper is submitted, I can finish the interface part by providing the code that converts a formula with variables into a formula with just numbers (unless the example allows variables, I can’t remember). In the mean time I am going to write a simple math engine that only uses some of the basics included in
NSDictionary *entry; NSMutableArray *scriptSyntax;
entry=[NSDictionary dictionaryWithObjectsAndKeys: @”EOF”, @”shortHand”, @”EndOfFile”, @”glCall”, // 0 - end of file or script in this case nil]; [scriptSyntax addObject:entry]; entry=[NSDictionary dictionaryWithObjectsAndKeys: @”reset”, @”shortHand”, @”glLoadIdentity”, @”glCall”, // 1 - reset the current modelview matrix @”%@glLoadIdentity();\n”, @”format”, nil]; [scriptSyntax addObject:entry]; entry=[NSDictionary dictionaryWithObjectsAndKeys: @”begin”, @”shortHand”, @”glBegin”, @”glCall”, // 2 - begin @”%@glBegin(%@);\n”, @”format”, nil]; [scriptSyntax addObject:entry]; entry=[NSDictionary dictionaryWithObjectsAndKeys: @”disable”, @”shortHand”, @”glDisable”, @”glCall”, // 3 - disable @”%@glDisable(%@);\n”, @”format”, nil]; [scriptSyntax addObject:entry]; entry=[NSDictionary dictionaryWithObjectsAndKeys: @”end”, @”shortHand”, @”glEnd”, @”glCall”, // 4 - to declare the end of a triangle or quadrangle @”%@glEnd();\n”, @”format”, nil]; [scriptSyntax addObject:entry]; entry=[NSDictionary dictionaryWithObjectsAndKeys: @”tex”, @”shortHand”, @”glBindTexture”, @”glCall”, // 5 - selects texture @”%@glBindTexture(%@, %i);\n”, @”format”, nil]; [scriptSyntax addObject:entry]; entry=[NSDictionary dictionaryWithObjectsAndKeys: @”texcord”, @”shortHand”, @”glTexCoord2f”, @”glCall”, // 6 - sets texture cordinates @”%@glTexCoord2f(%[float], %[float]);\n”, @”format”, nil]; [scriptSyntax addObject:entry]; entry=[NSDictionary dictionaryWithObjectsAndKeys: @”norm”, @”shortHand”, @”glNormal3f”, @”glCall”, // 7 - sets normal pointing toward viewer @”%@glNormal3f(%[float], %[float], %[float]);\n”, @”format”, nil]; [scriptSyntax addObject:entry]; entry=[NSDictionary dictionaryWithObjectsAndKeys: @”light”, @”shortHand”, @”glLightfv”, @”glCall”, // 8 - sets lighting (only responds to light1 so far) @”%@glLightfv(%@, %@, );\n”, @”format”, nil]; [scriptSyntax addObject:entry]; entry=[NSDictionary dictionaryWithObjectsAndKeys: @”enable”, @”shortHand”, @”glEnable”, @”glCall”, // 9 - enable @”%@glEnable(%@);\n”, @”format”, nil]; [scriptSyntax addObject:entry]; entry=[NSDictionary dictionaryWithObjectsAndKeys: @”rgb”, @”shortHand”, @”glColor3f”, @”glCall”, // 10 - sets rgb color @”%@glColor3f(%[float], %[float], %[float]);\n”, @”format”, nil]; [scriptSyntax addObject:entry]; entry=[NSDictionary dictionaryWithObjectsAndKeys: @”vert”, @”shortHand”, @”glVertex3f”, @”glCall”, // 11 - vertex @”%@glVertex3f(%[float], %[float], %[float]);\n”, @”format”, nil]; [scriptSyntax addObject:entry]; entry=[NSDictionary dictionaryWithObjectsAndKeys: @”trans”, @”shortHand”, @”glTranslatef”, @”glCall”, // 12 - translate @”%@glTranslatef(%[float], %[float], %[float]);\n”, @”format”, nil]; [scriptSyntax addObject:entry]; entry=[NSDictionary dictionaryWithObjectsAndKeys: @”rot”, @”shortHand”, @”glRotatef”, @”glCall”, // 13 - rotate @”%@glRotatef(%[float], %[float], %[float], %[float]);\n”, @”format”, nil]; [scriptSyntax addObject:entry];