Panda3D
|
00001 // Filename: modelNode.h 00002 // Created by: drose (16Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef MODELNODE_H 00016 #define MODELNODE_H 00017 00018 #include "pandabase.h" 00019 00020 #include "pandaNode.h" 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : ModelNode 00024 // Description : This node is placed at key points within the scene 00025 // graph to indicate the roots of "models": subtrees 00026 // that are conceptually to be treated as a single unit, 00027 // like a car or a room, for instance. It doesn't 00028 // affect rendering or any other operations; it's 00029 // primarily useful as a high-level model indication. 00030 // 00031 // ModelNodes are created in response to a <Model> { 1 } 00032 // flag within an egg file. 00033 //////////////////////////////////////////////////////////////////// 00034 class EXPCL_PANDA_PGRAPH ModelNode : public PandaNode { 00035 PUBLISHED: 00036 INLINE ModelNode(const string &name); 00037 00038 protected: 00039 INLINE ModelNode(const ModelNode ©); 00040 00041 public: 00042 virtual PandaNode *make_copy() const; 00043 00044 virtual PandaNode *combine_with(PandaNode *other); 00045 virtual bool safe_to_flatten() const; 00046 virtual bool safe_to_flatten_below() const; 00047 virtual bool safe_to_transform() const; 00048 virtual bool safe_to_modify_transform() const; 00049 virtual bool safe_to_combine() const; 00050 virtual bool preserve_name() const; 00051 virtual int get_unsafe_to_apply_attribs() const; 00052 00053 PUBLISHED: 00054 enum PreserveTransform { 00055 PT_none, 00056 PT_local, 00057 PT_net, 00058 PT_drop_node, 00059 PT_no_touch, 00060 }; 00061 00062 INLINE void set_preserve_transform(PreserveTransform preserve_transform); 00063 INLINE PreserveTransform get_preserve_transform() const; 00064 00065 INLINE void set_preserve_attributes(int attrib_mask); 00066 INLINE int get_preserve_attributes() const; 00067 00068 void set_transform_limit(PN_stdfloat limit) { _transform_limit = limit; }; 00069 00070 private: 00071 PreserveTransform _preserve_transform; 00072 int _preserve_attributes; 00073 00074 public: 00075 static void register_with_read_factory(); 00076 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00077 00078 protected: 00079 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00080 void fillin(DatagramIterator &scan, BamReader *manager); 00081 00082 virtual void transform_changed(); 00083 void test_transform(const TransformState *ts) const; 00084 00085 PN_stdfloat _transform_limit; 00086 00087 00088 00089 public: 00090 static TypeHandle get_class_type() { 00091 return _type_handle; 00092 } 00093 static void init_type() { 00094 PandaNode::init_type(); 00095 register_type(_type_handle, "ModelNode", 00096 PandaNode::get_class_type()); 00097 } 00098 virtual TypeHandle get_type() const { 00099 return get_class_type(); 00100 } 00101 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00102 00103 private: 00104 static TypeHandle _type_handle; 00105 }; 00106 00107 #include "modelNode.I" 00108 00109 #endif 00110 00111