Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can [0]istribute 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 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): none yet. 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 00033 #include <stdio.h> // printf() 00034 00035 #include "BlenderWorldInfo.h" 00036 #include "KX_BlenderGL.h" 00037 00038 /* This little block needed for linking to Blender... */ 00039 #ifdef WIN32 00040 #include "BLI_winstuff.h" 00041 #endif 00042 00043 /* This list includes only data type definitions */ 00044 #include "DNA_object_types.h" 00045 #include "DNA_material_types.h" 00046 #include "DNA_image_types.h" 00047 #include "DNA_lamp_types.h" 00048 #include "DNA_group_types.h" 00049 #include "DNA_scene_types.h" 00050 #include "DNA_camera_types.h" 00051 #include "DNA_property_types.h" 00052 #include "DNA_text_types.h" 00053 #include "DNA_sensor_types.h" 00054 #include "DNA_controller_types.h" 00055 #include "DNA_actuator_types.h" 00056 #include "DNA_mesh_types.h" 00057 #include "DNA_meshdata_types.h" 00058 #include "DNA_view3d_types.h" 00059 #include "DNA_world_types.h" 00060 #include "DNA_screen_types.h" 00061 00062 #include "BLI_math.h" 00063 00064 #include "BKE_global.h" 00065 /* end of blender include block */ 00066 00067 00068 BlenderWorldInfo::BlenderWorldInfo(struct Scene *blenderscene, struct World* blenderworld) 00069 { 00070 if (blenderworld) 00071 { 00072 m_hasworld = true; 00073 00074 // do we have mist? 00075 if ((blenderworld->mode) & WO_MIST) 00076 { 00077 m_hasmist = true; 00078 m_miststart = blenderworld->miststa; 00079 m_mistdistance = blenderworld->mistdist; 00080 copy_v3_v3(m_mistcolor, &blenderworld->horr); 00081 } 00082 else 00083 { 00084 m_hasmist = false; 00085 m_miststart = 0.0; 00086 m_mistdistance = 0.0; 00087 zero_v3(m_mistcolor); 00088 } 00089 00090 copy_v3_v3(m_backgroundcolor, &blenderworld->horr); 00091 copy_v3_v3(m_ambientcolor, &blenderworld->ambr); 00092 00093 if(blenderscene->r.color_mgt_flag & R_COLOR_MANAGEMENT) { 00094 linearrgb_to_srgb_v3_v3(m_mistcolor, m_mistcolor); 00095 linearrgb_to_srgb_v3_v3(m_backgroundcolor, m_backgroundcolor); 00096 linearrgb_to_srgb_v3_v3(m_ambientcolor, m_ambientcolor); 00097 } 00098 } 00099 else 00100 { 00101 m_hasworld = false; 00102 } 00103 } 00104 00105 00106 00107 BlenderWorldInfo::~BlenderWorldInfo() 00108 { 00109 00110 } 00111 00112 00113 bool BlenderWorldInfo::hasWorld() 00114 { 00115 return m_hasworld; 00116 } 00117 00118 00119 00120 bool BlenderWorldInfo::hasMist() 00121 { 00122 return m_hasmist; 00123 } 00124 00125 00126 00127 float BlenderWorldInfo::getBackColorRed() 00128 { 00129 return m_backgroundcolor[0]; 00130 } 00131 00132 00133 00134 float BlenderWorldInfo::getBackColorGreen() 00135 { 00136 return m_backgroundcolor[1]; 00137 } 00138 00139 00140 00141 float BlenderWorldInfo::getBackColorBlue() 00142 { 00143 return m_backgroundcolor[2]; 00144 } 00145 00146 00147 float BlenderWorldInfo::getAmbientColorRed() 00148 { 00149 return m_ambientcolor[0]; 00150 } 00151 00152 float BlenderWorldInfo::getAmbientColorGreen() 00153 { 00154 return m_ambientcolor[1]; 00155 } 00156 00157 float BlenderWorldInfo::getAmbientColorBlue() 00158 { 00159 return m_ambientcolor[2]; 00160 } 00161 00162 float BlenderWorldInfo::getMistStart() 00163 { 00164 return m_miststart; 00165 } 00166 00167 00168 00169 float BlenderWorldInfo::getMistDistance() 00170 { 00171 return m_mistdistance; 00172 } 00173 00174 00175 00176 float BlenderWorldInfo::getMistColorRed() 00177 { 00178 return m_mistcolor[0]; 00179 } 00180 00181 00182 00183 float BlenderWorldInfo::getMistColorGreen() 00184 { 00185 return m_mistcolor[1]; 00186 } 00187 00188 00189 00190 float BlenderWorldInfo::getMistColorBlue() 00191 { 00192 return m_mistcolor[2]; 00193 } 00194 00195 void BlenderWorldInfo::setBackColor(float r, float g, float b) 00196 { 00197 m_backgroundcolor[0] = r; 00198 m_backgroundcolor[1] = g; 00199 m_backgroundcolor[2] = b; 00200 } 00201 00202 void 00203 BlenderWorldInfo::setMistStart( 00204 float d 00205 ) { 00206 m_miststart = d; 00207 } 00208 00209 00210 void 00211 BlenderWorldInfo::setMistDistance( 00212 float d 00213 ) { 00214 m_mistdistance = d; 00215 } 00216 00217 00218 void 00219 BlenderWorldInfo::setMistColorRed( 00220 float d 00221 ) { 00222 m_mistcolor[0] = d; 00223 } 00224 00225 00226 void 00227 BlenderWorldInfo::setMistColorGreen( 00228 float d 00229 ) { 00230 m_mistcolor[1] = d; 00231 } 00232 00233 00234 void 00235 BlenderWorldInfo::setMistColorBlue( 00236 float d 00237 ) { 00238 m_mistcolor[2] = d; 00239 }