Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.88 KB | None | 0 0
  1. //
  2. // C++ Interface: mesh
  3. //
  4. // Description:
  5. //
  6. //
  7. // Author: Juan Linietsky <reduz@codenix.com>, (C) 2006
  8. //
  9. // Copyright: See COPYING file that comes with this distribution
  10. //
  11. //
  12. #ifndef SCENEMESH_H
  13. #define SCENEMESH_H
  14.  
  15. #include "node.h"
  16.  
  17. #include "resource/resource.h"
  18. #include "memory/mem_vector.h"
  19. #include "scene/visual_node.h"
  20. #include "scene/scene_store.h"
  21.  
  22. /**
  23.     @author Juan Linietsky <reduz@codenix.com>
  24. */
  25.  
  26.  
  27. class MeshNode : public VisualNode {
  28. public:
  29.  
  30.     enum VolumeMode {
  31.  
  32.         VOLUME_STATIC, // default, for objects that either wont rotate/move that much, or need good culling precision
  33.         VOLUME_ANY_ORIENTATION, // best used for objects that can rotate in any axis
  34.     };
  35.  
  36.     /**
  37.      * Some platforms benefit from optimizing the geometry specifically for them.
  38.      * Mesh optimization is done upon loading by the MeshNodeStore class.
  39.      * Mesh nodes can hint wether on how they want to be optimized.
  40.      *
  41.      */
  42.  
  43.     enum OptimizationHintType {
  44.  
  45.         OPTIMIZE_NONE, /** Don't perform any optimization, unless the platform requires it */
  46.         OPTIMIZE_REALTIME, /** Optimize after loading, optionally */
  47.             OPTIMIZE_FROM_CACHE, /** The scene provides a cache to load the optimization from */
  48.  
  49.     };
  50. private:
  51.  
  52.     VolumeMode volume_mode;
  53.  
  54.     RID mesh;
  55.     RID skeleton; //in case it uses a skeleton
  56.     RID material_override;
  57.  
  58.     AABB static_volume;
  59.  
  60.     OptimizationHintType optimization_hint;
  61.     String optimized_cache_file;
  62.    
  63.     void render(const RenderData& p_render_data);
  64. public:
  65.  
  66.     AABB get_static_volume();
  67.  
  68.     NodeType get_type() const {return TYPE_MESH;};
  69.  
  70.     void set_mesh(RID p_mesh);
  71.     void set_skeleton(RID p_skeleton);
  72.  
  73.     RID get_mesh();
  74.     RID get_skeleton();
  75.  
  76.     void set_volume_mode(VolumeMode p_volume_mode);
  77.     VolumeMode get_volume_mode();
  78.    
  79.     void set_material_override(RID p_mat);
  80.  
  81.     void regenerate_volume(); ///< This function is pretty slow, dont be calling it constantly please. This will just regenerate the AABB volume.
  82.     void set_scene_main(SceneMain* p_scene_main);
  83.  
  84.     void get_optimization_hint(OptimizationHintType p_type);
  85.     void get_optimized_cache_file(String p_file);
  86.  
  87.     OptimizationHintType get_optimization_hint();
  88.     String get_optimized_cache_file();
  89.  
  90.     virtual Error get_polygon_shapes(List< MemVector<Face3> > &p_dst);
  91.  
  92.     MeshNode(VolumeMode p_volume_mode=VOLUME_ANY_ORIENTATION);
  93.     ~MeshNode();
  94.  
  95. };
  96.  
  97.  
  98. class StaticMeshNode : public MeshNode {
  99.  
  100. public:
  101.  
  102.     StaticMeshNode() : MeshNode( VOLUME_STATIC ) {}
  103. };
  104.  
  105. class MeshNodeStore : public NodeStore {
  106. public:
  107.     virtual bool handles_node(Node *p_node);
  108.     virtual String get_node_string();
  109.     virtual bool load(TreeLoader *p_tree,Node *p_node); ///< Returns false if load was succesful, true if node was unrecognized
  110.     virtual bool save(TreeSaver*p_tree,Node *p_node); ///< Returns false if save
  111.     virtual Node* create_node() { return memnew(MeshNode); } ///< create a node of the type it handles
  112.  
  113.  
  114. };
  115.  
  116.  
  117. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement