00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _FRZ_SCENE_HPP_
00021 #define _FRZ_SCENE_HPP_
00022
00023 #include <stdint.h>
00024
00025 #include <altivec.h>
00026
00027 #include "frz_obj3d.hpp"
00028 #include "frz_misc.hpp"
00029 #include "frz_defs.h"
00030 #include "frz_vertex.hpp"
00031
00032 namespace Frz {
00033
00098 class Scene {
00099 friend class Script;
00100
00103 struct vvertex : public vertex {
00104 vvertex(): vertex() {}
00105 vvertex(const Object3d::Vertex &v): vertex(v.x, v.y, v.z, 1.0f) {}
00106 vvertex(const vertex &v): vertex(v) {}
00107 vertex &as_vertex() const { return *(vertex*)this; }
00108 void update_norm(const vvertex &a, const vvertex &b, const vvertex &c) {
00109 vertex::update_norm(a, b, c);
00110 }
00111 };
00112
00113 public:
00140 struct Triangle {
00142 uint16_t ob_type;
00144 uint16_t sh_type;
00146 uint16_t rot_id;
00148 uint16_t tex_id;
00150 uint16_t flags;
00152 uint16_t thickness;
00154 uint32_t color;
00155
00157 vertex dummy;
00158
00166 vertex a;
00174 vertex b;
00182 vertex c;
00190 vertex d;
00192 svertex na;
00194 svertex nb;
00196 svertex nc;
00198 svertex nd;
00199
00213 Triangle(uint16_t _ob_type, uint16_t _sh_type, uint16_t _rot_id,
00214 uint16_t _tex_id, uint32_t _color, const vvertex &_a, const vvertex &_b,
00215 const vvertex &_c, const vvertex &_d=vvertex()):
00216 ob_type(_ob_type), sh_type(_sh_type), rot_id(_rot_id), tex_id(_tex_id),
00217 flags(0), thickness(0), color(_color),
00218 a(_a), b(_b), c(_c), d(_d), na(), nb(), nc(), nd() {}
00219
00235 void setThickness(uint16_t th);
00245 void setFlatNormal(bool fn=true);
00257 void setDoubleSided(bool ds=true);
00260 void flatNormal();
00261 };
00262
00263 private:
00264 alignvec<Triangle> triangles;
00265 alignvec<Triangle> shared_triangles;
00266 vertex lightsource;
00267 uint16_t n_obj;
00268 int n_tri;
00269 int n_shared_tri;
00270 bool f_flash;
00271 uint32_t background;
00272 uint32_t fade_color;
00273 float fade_strength;
00274
00279 const vertex &getLightSource() const { return lightsource; }
00280
00287 bool getFlash() {
00288 bool f = f_flash;
00289 f_flash = false;
00290 return f;
00291 }
00292
00297 uint32_t getBackgroundColor() const { return background; }
00298
00303 uint32_t getFadeColor() const { return fade_color; }
00304
00309 float getFadeStrength() const { return fade_strength; }
00310
00311 protected:
00317 void flash() {
00318 f_flash = true;
00319 }
00324 void setBackgroundColor(uint32_t c) {
00325 background = c;
00326 }
00337 void setFade(uint32_t c, float s) {
00338 fade_color = c;
00339 fade_strength = s;
00340 }
00352 int add_triangle(uint16_t _sh_type, uint16_t _rot_id, uint16_t _tex_id,
00353 uint32_t _color, const vertex &_a, const vertex &_b, const vertex &_c);
00354
00367 int add_quad(uint16_t _sh_type, uint16_t _rot_id, uint16_t _tex_id,
00368 uint32_t _color, const vertex &_a, const vertex &_b, const vertex &_c,
00369 const vertex &_d);
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00407 int add_object(const Object3d &obj, uint16_t type=SH_SMOOTH, float zoom=1.0f,
00408 uint16_t tex_id=-1);
00409
00423 int add_object_extrude(const Object3d &obj, uint16_t th, float zoom=1.0f);
00424
00433 int add_object();
00434
00439 Triangle *getTriangles() { return &triangles[0]; }
00440
00441
00442
00443
00444
00445
00446
00447
00448
00453 int getTriangleCount() { return n_tri; }
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00468 int getObjectCount() { return n_obj; }
00469
00480 virtual void setupFrame(uint32_t time, trans t[]) = 0;
00481
00482 public:
00484 Scene();
00486 virtual ~Scene();
00487 };
00488
00489 };
00490
00491
00492 #endif
00493