objective c - Trying a tiny winy 3D classes for iPhone -


ok,

i'm trying save time creating generic classes draw objects in 3d space.

i created object3d class properties x, y, , z.

the thumbnail3d "son" of object3d using inheritance. vertex3d struct glfloat every coord.

the problem when try compile method initwithposition:( vertex3d *)vertex, , error is:

request member 'x' in not structure or union. request member 'y' in not structure or union. request member 'z' in not structure or union.

but, structure on 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 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 

when read part

vertex3d struct glfloat every coord.

i think should write

-(void)initwithposition:(vertex3d *)vertex {   x = vertex->x;   y = vertex->y;   z = vertex->z; } 

...as vertex plain-old pointer c struct


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -