Simulant  21.12-574
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
geom.h
1 /* * Copyright (c) 2011-2017 Luke Benstead https://simulant-engine.appspot.com
2  *
3  * This file is part of Simulant.
4  *
5  * Simulant is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * Simulant is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with Simulant. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include "../generic/managed.h"
22 #include "../generic/manual_object.h"
23 #include "../interfaces.h"
24 #include "../meshes/mesh.h"
25 #include "../sound.h"
26 
27 #include "stage_node.h"
28 
29 namespace smlt {
30 
31 
32 class GeomCuller;
33 
34 
35 enum GeomCullerType {
36  GEOM_CULLER_TYPE_OCTREE,
37  GEOM_CULLER_TYPE_QUADTREE
38 };
39 
41  GeomCullerType type = GEOM_CULLER_TYPE_OCTREE;
42  uint8_t octree_max_depth = 4;
43  uint8_t quadtree_max_depth = 4;
44 };
45 
57 class Geom :
58  public TypedDestroyableObject<Geom, Stage>,
59  public StageNode,
60  public virtual Boundable,
61  public generic::Identifiable<GeomID>,
62  public AudioSource,
64  public ChainNameable<Geom> {
65 
66 public:
67  Geom(
68  Stage* stage,
69  SoundDriver *sound_driver,
70  MeshID mesh,
71  const Vec3& position=Vec3(),
72  const Quaternion rotation=Quaternion(),
73  const Vec3& scale=Vec3(1, 1, 1),
74  GeomCullerOptions culler_options=GeomCullerOptions()
75  );
76 
77  const AABB& aabb() const override;
78 
79  void clean_up() override {
80  StageNode::clean_up();
81  }
82 
83  bool init() override;
84 
85  void _get_renderables(batcher::RenderQueue* render_queue, const CameraPtr camera, const DetailLevel detail_level) override;
86 
87 private:
88  UniqueIDKey make_key() const override {
89  return make_unique_id_key(id());
90  }
91 
92  MeshID mesh_id_;
93  GeomCullerOptions culler_options_;
94  Vec3 desired_transform;
95  Quaternion desired_rotation;
96  Vec3 desired_scale;
97 
98  std::shared_ptr<GeomCuller> culler_;
99 
100  AABB aabb_;
101 
102 public:
103  Property<decltype(&Geom::culler_)> culler = {this, &Geom::culler_};
104 
105 };
106 
107 }
108 
smlt::Property
Definition: property.h:202
smlt::Geom
The Geom class.
Definition: geom.h:64
smlt::Vec3
Definition: vec3.h:23
smlt::Quaternion
Definition: quaternion.h:20
smlt::AudioSource
Definition: sound.h:106
smlt::Stage
Definition: stage.h:80
smlt
Definition: animation.cpp:25
smlt::GeomCullerOptions
Definition: geom.h:40
smlt::HasMutableRenderPriority
Definition: renderable.h:38
smlt::batcher::RenderQueue
Definition: render_queue.h:156
smlt::generic::Identifiable
Definition: identifiable.h:26
smlt::UniqueID< MeshPtr >
smlt::TypedDestroyableObject
Definition: manual_object.h:34
smlt::ChainNameable
Definition: nameable.h:34
smlt::AABB
Definition: aabb.h:22
smlt::StageNode
Definition: stage_node.h:62
smlt::default_init_ptr< Camera >
smlt::SoundDriver
Definition: sound_driver.h:74
smlt::Boundable
The Boundable class.
Definition: boundable.h:12