/* * GRacer * * Copyright (C) 1999 Takashi Matsuda * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ #ifndef __GRACER_SCENE_H__ #define __GRACER_SCENE_H__ #include #include #include "gr_scene_option.h" #include "gr_vertex.h" #include "gr_texture.h" typedef struct _GrScene GrScene; typedef struct _GrMaterial GrMaterial; typedef struct _GrObject GrObject; typedef struct _GrSurface GrSurface; typedef struct _GrSElement GrSElement; typedef struct _GrSegment GrSegment; typedef struct _GrSubObject GrSubObject; typedef struct _GrSubSurface GrSubSurface; struct _GrMaterial { GLfloat rgba[4]; GLfloat amb[4]; GLfloat dfs[4]; GLfloat ems[4]; GLfloat spc[4]; GLint shi; int flag; }; struct _GrSElement { int mat; GLuint ref; GLfloat n[3]; GLfloat s, t; }; struct _GrSurface { GLenum type; int flag; int twoside; int smooth; int num_elements; GrSElement *elements; }; struct _GrObject { GrRef ref; GrScene *scene; GrObject *parent; int flag; char *name; char *url; char *texture_name; GrTexture *texture; GLenum clamp_or_repeat_s; GLenum clamp_or_repeat_t; GLint list_name; GrObjectDrawOption draw_option; GrVertex pos; GrVertex next_pos; /* tiny enhancement for not use glPushMatrix */ GrVertex center, min, max; float radius; int num_verts; GLfloat *vertex; GLfloat *normal; int num_surfs; GrSurface **surfs; int num_kids; GrObject **kids; }; struct _GrSubSurface { GrSurface *surf; int start; int num; }; struct _GrSubObject { GrObject *obj; int num_surfs; GrSubSurface **surfs; }; struct _GrSegment { char *name; GLuint dl; GrVertex min, max, center; float radius; int num_objs; GrSubObject **objs; }; struct _GrScene { GrRef ref; char *key; GrObjectDrawOption draw_option; int num_mats; GrMaterial *mats; int num_objs; GrObject **objs; int num_segs; GrSegment **segs; GrVertex center, min, max; float radius; }; #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #if 0 } #endif GrScene* gr_scene_new_from_file (FILE *file); GrScene* gr_scene_new_from_data (char *data); void gr_scene_write_file (GrScene *scene, FILE *file); GrObject* gr_scene_find_object (GrScene *scene, char *name, GrObject *from); void gr_scene_draw (GrScene *scene, GrObject *from, GrObjectDrawOption option, int recursive); void gr_object_draw (GrObject *obj, GrObjectDrawOption option, int recursive); void gr_object_absolute_coord(GrObject *obj, float x, float y, float z, int recursive); void gr_scene_scale (GrScene *scene, float x, float y, float z); void gr_object_scale (GrObject *obj, float x, float y, float z, int recursive); void gr_scene_setup_gl (GrScene *scene, GrObjectDrawOption option); void gr_scene_release_gl (GrScene *scene); void gr_object_accum_normal (GrObject *obj); void gr_surface_free (GrSurface *surf); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __GRACER_SCENE_H__ */