Ok,
I'm trying to save some time creating some generic classes to draw objects in the 3D space.
I created a Object3D class with the properties x, y, and z.
The thumbnail3D is a "son" of Object3D using inheritance. Vertex3D is a struct with a GLfloat for every coord.
The problem is when I try to compile the method initWithPosition:( Vertex3D *)vertex, and the error is:
Request for member 'x' in something not structure or union. Request for member 'y' in something not structure or union. Request for member 'z' in something not structure or union.
But, the structure is on the import...
#import <UIKit/UIKit.h>
#import <OpenGLES/ES2/gl.h>
@interface Object3D : NSObject
{
GLfloat x;
GLfloat y;
GLfloat z;
}
@property GLfloat x;
@property GLfloat y;
@property GLfloat z;
-(void) render;
@end
The render is still hardcoded
#import "Thumbnail3D.h"
#import "ConstantsAndMacros.h"
#import "OpenGLCommon.h"
@implementation Thumbnail3D
@synthesize width;
@synthesize height;
-(void)render
{
Triangle3D triangle[2];
triangle[0].v1 = Vertex3DMake(0.0, 1.0, -3.0);
triangle[0].v2 = Vertex3DMake(1.0, 0.0, -3.0);
triangle[0].v3 = Vertex3DMake(-1.0, 0.0, -3.0);
triangle[1].v1 = Vertex3DMake(-1.0, 0.0, -3.0);
triangle[1].v2 = Vertex3DMake(1.0, 0.0, -3.0);
triangle[1].v3 = Vertex3DMake(0.0, -1.0, -3.0);
glLoadIdentity();
glClearColor(0.7, 0.7, 0.7, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnableClientState(GL_VERTEX_ARRAY);
glColor4f(1.0, 0.0, 0.0, 1.0);
glVertexPointer(3, GL_FLOAT, 0, &triangle);
glDrawArrays(GL_TRIANGLES, 0, 18);
glDisableClientState(GL_VERTEX_ARRAY);
}
-(void)initWithPosition:(Vertex3D *)vertex
{
x = vertex.x;
y = vertex.y;
z = vertex.z;
}
@end