Blender V2.61 - r43446
|
00001 /* 00002 * Copyright 2011, Blender Foundation. 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef __BLENDER_SYNC_H__ 00020 #define __BLENDER_SYNC_H__ 00021 00022 #include "MEM_guardedalloc.h" 00023 #include "RNA_types.h" 00024 #include "RNA_access.h" 00025 #include "RNA_blender_cpp.h" 00026 00027 #include "blender_util.h" 00028 00029 #include "scene.h" 00030 #include "session.h" 00031 00032 #include "util_map.h" 00033 #include "util_set.h" 00034 #include "util_transform.h" 00035 #include "util_vector.h" 00036 00037 CCL_NAMESPACE_BEGIN 00038 00039 class Background; 00040 class Camera; 00041 class Film; 00042 class Light; 00043 class Mesh; 00044 class Object; 00045 class Scene; 00046 class Shader; 00047 class ShaderGraph; 00048 class ShaderNode; 00049 00050 class BlenderSync { 00051 public: 00052 BlenderSync(BL::BlendData b_data, BL::Scene b_scene, Scene *scene_, bool preview_); 00053 ~BlenderSync(); 00054 00055 /* sync */ 00056 bool sync_recalc(); 00057 void sync_data(BL::SpaceView3D b_v3d, int layer = 0); 00058 void sync_camera(int width, int height); 00059 void sync_view(BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int width, int height); 00060 00061 /* get parameters */ 00062 static SceneParams get_scene_params(BL::Scene b_scene, bool background); 00063 static SessionParams get_session_params(BL::UserPreferences b_userpref, BL::Scene b_scene, bool background); 00064 static bool get_session_pause(BL::Scene b_scene, bool background); 00065 static BufferParams get_buffer_params(BL::Scene b_scene, BL::RegionView3D b_rv3d, int width, int height); 00066 00067 private: 00068 /* sync */ 00069 void sync_lamps(); 00070 void sync_materials(); 00071 void sync_objects(BL::SpaceView3D b_v3d); 00072 void sync_film(); 00073 void sync_integrator(int layer); 00074 void sync_view(); 00075 void sync_world(); 00076 void sync_render_layers(BL::SpaceView3D b_v3d); 00077 void sync_shaders(); 00078 00079 void sync_nodes(Shader *shader, BL::ShaderNodeTree b_ntree); 00080 Mesh *sync_mesh(BL::Object b_ob, bool object_updated); 00081 void sync_object(BL::Object b_parent, int b_index, BL::Object b_object, Transform& tfm, uint layer_flag); 00082 void sync_light(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm); 00083 00084 /* util */ 00085 void find_shader(BL::ID id, vector<uint>& used_shaders, int default_shader); 00086 bool object_is_modified(BL::Object b_ob); 00087 bool object_is_mesh(BL::Object b_ob); 00088 bool object_is_light(BL::Object b_ob); 00089 00090 /* variables */ 00091 BL::BlendData b_data; 00092 BL::Scene b_scene; 00093 00094 id_map<void*, Shader> shader_map; 00095 id_map<ObjectKey, Object> object_map; 00096 id_map<void*, Mesh> mesh_map; 00097 id_map<ObjectKey, Light> light_map; 00098 set<Mesh*> mesh_synced; 00099 void *world_map; 00100 bool world_recalc; 00101 00102 Scene *scene; 00103 bool preview; 00104 bool experimental; 00105 00106 struct RenderLayerInfo { 00107 RenderLayerInfo() 00108 : scene_layer(0), layer(0), 00109 material_override(PointerRNA_NULL) 00110 {} 00111 00112 uint scene_layer; 00113 uint layer; 00114 BL::Material material_override; 00115 }; 00116 00117 vector<RenderLayerInfo> render_layers; 00118 int active_layer; 00119 }; 00120 00121 CCL_NAMESPACE_END 00122 00123 #endif /* __BLENDER_SYNC_H__ */ 00124