goat3d

diff src/goat3d.cc @ 27:4deb0b12fe14

wtf... corrupted heap?
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 29 Sep 2013 08:20:19 +0300
parents 1c601bf07b86
children 3d669155709d
line diff
     1.1 --- a/src/goat3d.cc	Sat Sep 28 20:36:55 2013 +0300
     1.2 +++ b/src/goat3d.cc	Sun Sep 29 08:20:19 2013 +0300
     1.3 @@ -25,6 +25,7 @@
     1.4  struct goat3d *goat3d_create(void)
     1.5  {
     1.6  	goat3d *goat = new goat3d;
     1.7 +	goat->flags = 0;
     1.8  	goat->scn = new Scene;
     1.9  	return goat;
    1.10  }
    1.11 @@ -142,6 +143,11 @@
    1.12  }
    1.13  
    1.14  // ---- materials ----
    1.15 +void goat3d_add_mtl(struct goat3d *g, struct goat3d_material *mtl)
    1.16 +{
    1.17 +	g->scn->add_material(mtl);
    1.18 +}
    1.19 +
    1.20  struct goat3d_material *goat3d_create_mtl(void)
    1.21  {
    1.22  	return new goat3d_material;
    1.23 @@ -197,12 +203,27 @@
    1.24  	return (*mtl)[attrib].map.c_str();
    1.25  }
    1.26  
    1.27 -void goat3d_add_mtl(struct goat3d *g, struct goat3d_material *mtl)
    1.28 +// ---- meshes ----
    1.29 +void goat3d_add_mesh(struct goat3d *g, struct goat3d_mesh *mesh)
    1.30  {
    1.31 -	g->scn->add_material(mtl);
    1.32 +	g->scn->add_mesh(mesh);
    1.33  }
    1.34  
    1.35 -// ---- meshes ----
    1.36 +int goat3d_get_mesh_count(struct goat3d *g)
    1.37 +{
    1.38 +	return g->scn->get_mesh_count();
    1.39 +}
    1.40 +
    1.41 +struct goat3d_mesh *goat3d_get_mesh(struct goat3d *g, int idx)
    1.42 +{
    1.43 +	return (goat3d_mesh*)g->scn->get_mesh(idx);
    1.44 +}
    1.45 +
    1.46 +struct goat3d_mesh *goat3d_get_mesh_by_name(struct goat3d *g, const char *name)
    1.47 +{
    1.48 +	return (goat3d_mesh*)g->scn->get_mesh(name);
    1.49 +}
    1.50 +
    1.51  struct goat3d_mesh *goat3d_create_mesh(void)
    1.52  {
    1.53  	return new goat3d_mesh;
    1.54 @@ -459,23 +480,92 @@
    1.55  	im_use[GOAT3D_MESH_ATTR_COLOR] = true;
    1.56  }
    1.57  
    1.58 -void goat3d_add_mesh(struct goat3d *g, struct goat3d_mesh *mesh)
    1.59 +/* lights */
    1.60 +void goat3d_add_light(struct goat3d *g, struct goat3d_light *lt)
    1.61  {
    1.62 -	g->scn->add_mesh(mesh);
    1.63 +	g->scn->add_light(lt);
    1.64  }
    1.65  
    1.66 -int goat3d_get_mesh_count(struct goat3d *g)
    1.67 +int goat3d_get_light_count(struct goat3d *g)
    1.68  {
    1.69 -	return g->scn->get_mesh_count();
    1.70 +	return g->scn->get_light_count();
    1.71  }
    1.72  
    1.73 -struct goat3d_mesh *goat3d_get_mesh(struct goat3d *g, int idx)
    1.74 +struct goat3d_light *goat3d_get_light(struct goat3d *g, int idx)
    1.75  {
    1.76 -	return (goat3d_mesh*)g->scn->get_mesh(idx);
    1.77 +	return (goat3d_light*)g->scn->get_light(idx);
    1.78  }
    1.79  
    1.80 +struct goat3d_light *goat3d_get_light_by_name(struct goat3d *g, const char *name)
    1.81 +{
    1.82 +	return (goat3d_light*)g->scn->get_light(name);
    1.83 +}
    1.84 +
    1.85 +
    1.86 +struct goat3d_light *goat3d_create_light(void)
    1.87 +{
    1.88 +	return new goat3d_light;
    1.89 +}
    1.90 +
    1.91 +void goat3d_destroy_light(struct goat3d_light *lt)
    1.92 +{
    1.93 +	delete lt;
    1.94 +}
    1.95 +
    1.96 +
    1.97 +/* cameras */
    1.98 +void goat3d_add_camera(struct goat3d *g, struct goat3d_camera *cam)
    1.99 +{
   1.100 +	g->scn->add_camera(cam);
   1.101 +}
   1.102 +
   1.103 +int goat3d_get_camera_count(struct goat3d *g)
   1.104 +{
   1.105 +	return g->scn->get_camera_count();
   1.106 +}
   1.107 +
   1.108 +struct goat3d_camera *goat3d_get_camera(struct goat3d *g, int idx)
   1.109 +{
   1.110 +	return (goat3d_camera*)g->scn->get_camera(idx);
   1.111 +}
   1.112 +
   1.113 +struct goat3d_camera *goat3d_get_camera_by_name(struct goat3d *g, const char *name)
   1.114 +{
   1.115 +	return (goat3d_camera*)g->scn->get_camera(name);
   1.116 +}
   1.117 +
   1.118 +struct goat3d_camera *goat3d_create_camera(void)
   1.119 +{
   1.120 +	return new goat3d_camera;
   1.121 +}
   1.122 +
   1.123 +void goat3d_destroy_camera(struct goat3d_camera *cam)
   1.124 +{
   1.125 +	delete cam;
   1.126 +}
   1.127 +
   1.128 +
   1.129  
   1.130  // node
   1.131 +void goat3d_add_node(struct goat3d *g, struct goat3d_node *node)
   1.132 +{
   1.133 +	g->scn->add_node(node);
   1.134 +}
   1.135 +
   1.136 +int goat3d_get_node_count(struct goat3d *g)
   1.137 +{
   1.138 +	return g->scn->get_node_count();
   1.139 +}
   1.140 +
   1.141 +struct goat3d_node *goat3d_get_node(struct goat3d *g, int idx)
   1.142 +{
   1.143 +	return (goat3d_node*)g->scn->get_node(idx);
   1.144 +}
   1.145 +
   1.146 +struct goat3d_node *goat3d_get_node_by_name(struct goat3d *g, const char *name)
   1.147 +{
   1.148 +	return (goat3d_node*)g->scn->get_node(name);
   1.149 +}
   1.150  
   1.151  struct goat3d_node *goat3d_create_node(void)
   1.152  {