Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-05-03 21:04:02 +0000
committerStijn Buys <ingar@osirion.org>2008-05-03 21:04:02 +0000
commit82293065b52f5a4e5c4ccde5eade4ebae18014ca (patch)
tree254f1fa3259f03f033b3d1fd225742a12de167b1 /src/core/model.h
parent5388c37bdc040ba50d21ec16a01f399d20592a90 (diff)
liibmodel
Diffstat (limited to 'src/core/model.h')
-rw-r--r--src/core/model.h259
1 files changed, 0 insertions, 259 deletions
diff --git a/src/core/model.h b/src/core/model.h
deleted file mode 100644
index e9b3de4..0000000
--- a/src/core/model.h
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- render/model.h
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
-*/
-
-#ifndef __INCLUDED_CORE_MODEL_H__
-#define __INCLUDED_CORE_MODEL_H__
-
-namespace core
-{
-class Model;
-}
-
-#include <vector>
-#include <map>
-#include <list>
-
-#include "math/mathlib.h"
-#include "math/plane3f.h"
-#include "core/entity.h"
-
-namespace core
-{
-
-/// global vertex array
-
-const int SPHERESEGMENTS=33;
-
-class VertexArray
-{
-public:
- /// Create a new VertexArray with size in Mb
- VertexArray(size_t size);
- ~VertexArray();
-
- void clear();
-
- void add_vertex(math::Vector3f const &v, math::Vector3f const &n, math::Color const &color);
-
-
- inline float *vertex() { return vertex_vertex; }
- inline float *color() { return vertex_color; }
- inline float *normal() { return vertex_normal; }
- inline float *texture() { return vertex_texture; }
-
- inline size_t size() const { return vertex_size; }
- inline size_t index() const { return vertex_index; }
-
- static inline VertexArray *instance() { return vertex_instance; }
-
-private:
- /// model vertices
- float *vertex_vertex;
- float *vertex_color;
- float *vertex_normal;
- float *vertex_texture;
-
- size_t vertex_index;
- size_t vertex_size;
-
- void add_sphere();
-
- static VertexArray *vertex_instance;
-};
-
-/// a model triangle
-class Triangle
-{
-public:
- /// a new triangle with 3 vertices, a normal, color and a detail flag
- Triangle(math::Vector3f const &v0, math::Vector3f const &v1, math::Vector3f const &v2, math::Vector3f const &n,
- math::Color *color=0, bool detail=false);
- ~Triangle();
-
- /// normal of the triangle
- inline math::Vector3f const & normal() const { return triangle_normal; }
- /// color of the triangle
- inline math::Color const & color() const { return triangle_color;}
- /// indidcates if this triangle was generated from a detail brush
- inline bool detail() const { return triangle_detail; }
-
- /// triangle vertex 0
- math::Vector3f triangle_v0;
- /// triangle vertex 1
- math::Vector3f triangle_v1;
- /// triangle vertex 2
- math::Vector3f triangle_v2;
-
-private:
- math::Vector3f triangle_normal;
- math::Color triangle_color;
- bool triangle_detail;
-};
-
-/// a spacecraft engine
-class Engine
-{
-public:
- Engine(math::Vector3f const & location);
- ~Engine();
-
- inline math::Vector3f const & location() const
- {
- return engine_location;
- }
-
- math::Vector3f engine_location;
-};
-
-/// an exterior light
-class Light
-{
-public:
- Light(math::Vector3f const & location, math::Color const & color, bool strobe=false);
- ~Light();
-
- inline math::Vector3f const & location() const { return light_location; }
-
- inline math::Color const & color() const { return light_color; };
-
- /// true if this is a strobe light
- inline bool strobe() const { return light_strobe; }
-
- /// size if the light, default is 1.0f
- inline float radius() const { return light_radius; }
-
- /// strobe time offset, in seconds
- inline float offset() const { return light_offset; }
-
- /// frequency in strobes per second
- inline float frequency() const { return light_frequency; }
-
- /// fraction a strobe light will be on, default is 0.5f
- inline float time() const { return light_time; }
-
- /// flare texture number
- inline size_t flare() const { return light_flare; }
-
- /// render texture number
- inline size_t texture() const { return render_texture; }
-
- math::Vector3f light_location;
- math::Color light_color;
- bool light_strobe;
- float light_radius;
- float light_frequency;
- float light_offset;
- float light_time;
-
- size_t light_flare;
-
- size_t render_texture;
-};
-
-
-/// a 3D model contains a list of faces
-class Model
-{
-public:
- /// load a model from disk
- Model(std::string const & name);
- ~Model();
-
- /// the name of the model
- inline std::string const & name() const
- {
- return model_name;
- }
-
- /// maximum values of the bounding box
- inline math::Vector3f const & maxbbox() const { return model_maxbbox; }
-
- /// minimum values of the bounding box
- inline math::Vector3f const & minbbox() const { return model_minbbox; }
-
- /// first vertex in the global VertexArray
- inline size_t first_vertex() const { return model_first_vertex; }
-
- /// number of structural vertices in this model
- inline size_t vertex_structural() const { return model_vertex_count; }
-
- /// number of detail vertices
- inline size_t vertex_detail() const { return model_vertex_countdetail; }
-
- /// first vertex in the global VertexArray
- inline size_t first_evertex() const { return model_first_evertex; }
-
- /// number of structural evertices in this model
- inline size_t evertex_structural() const { return model_evertex_count; }
-
- /// number of detail evertices in this model
- inline size_t evertex_detail() const { return model_evertex_countdetail; }
-
- /// total number of triangles in this model
- size_t tris() const;
-
- /// number of detail triangles in this model
- size_t details() const;
-
- /// radius
- inline float radius() const { return model_radius; }
-
- /// the Model registry
- static std::map<std::string, Model*> registry;
-
- /* ---- static functions for the Model registry -------------------- */
-
- /// get name model, returns 0 if not found
- static Model *find(std::string const & name);
-
- /// get named model from the registry and load it if necessary
- static Model *get(std::string const & name);
-
- /// clear the model registry
- static void clear();
-
- /// list the content of the model registry
- static void list();
-
- /// list of Engines
- std::list<Engine *> model_engine;
-
- /// list of Lights
- std::list<Light *> model_light;
-
-
-
-private:
- void make_face(math::Plane3f *face, std::vector<math::Plane3f *> & planes, bool detail);
- void add_engine(Engine *engine);
- void add_light(Light *light);
-
- std::string model_name;
-
- float model_radius;
- float model_scale;
- bool model_valid;
-
- math::Vector3f model_maxbbox;
- math::Vector3f model_minbbox;
-
- // tmp lists with triangles
- std::list<Triangle *> model_tris;
- std::list<Triangle *> model_etris;
-
- size_t model_first_vertex;
- size_t model_vertex_count;
- size_t model_vertex_countdetail;
-
- size_t model_first_evertex;
- size_t model_evertex_count;
- size_t model_evertex_countdetail;
-};
-
-}
-
-#endif // __INCLUDED_RENDER_MODEL_H__
-