|
Blender
V2.59
|
00001 /* 00002 * $Id: BlenderWorldInfo.cpp 35167 2011-02-25 13:30:41Z jesterking $ 00003 * ***** BEGIN GPL LICENSE BLOCK ***** 00004 * 00005 * This program is free software; you can [0]istribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software Foundation, 00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 * 00019 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00020 * All rights reserved. 00021 * 00022 * The Original Code is: all of this file. 00023 * 00024 * Contributor(s): none yet. 00025 * 00026 * ***** END GPL LICENSE BLOCK ***** 00027 */ 00028 00034 #include <stdio.h> // printf() 00035 00036 #include "BlenderWorldInfo.h" 00037 #include "KX_BlenderGL.h" 00038 00039 /* This little block needed for linking to Blender... */ 00040 #ifdef WIN32 00041 #include "BLI_winstuff.h" 00042 #endif 00043 00044 /* This list includes only data type definitions */ 00045 #include "DNA_object_types.h" 00046 #include "DNA_material_types.h" 00047 #include "DNA_image_types.h" 00048 #include "DNA_lamp_types.h" 00049 #include "DNA_group_types.h" 00050 #include "DNA_scene_types.h" 00051 #include "DNA_camera_types.h" 00052 #include "DNA_property_types.h" 00053 #include "DNA_text_types.h" 00054 #include "DNA_sensor_types.h" 00055 #include "DNA_controller_types.h" 00056 #include "DNA_actuator_types.h" 00057 #include "DNA_mesh_types.h" 00058 #include "DNA_meshdata_types.h" 00059 #include "DNA_view3d_types.h" 00060 #include "DNA_world_types.h" 00061 #include "DNA_screen_types.h" 00062 00063 #include "BLI_math.h" 00064 00065 #include "BKE_global.h" 00066 /* end of blender include block */ 00067 00068 00069 BlenderWorldInfo::BlenderWorldInfo(struct Scene *blenderscene, struct World* blenderworld) 00070 { 00071 if (blenderworld) 00072 { 00073 m_hasworld = true; 00074 00075 // do we have mist? 00076 if ((blenderworld->mode) & WO_MIST) 00077 { 00078 m_hasmist = true; 00079 m_miststart = blenderworld->miststa; 00080 m_mistdistance = blenderworld->mistdist; 00081 copy_v3_v3(m_mistcolor, &blenderworld->horr); 00082 } 00083 else 00084 { 00085 m_hasmist = false; 00086 m_miststart = 0.0; 00087 m_mistdistance = 0.0; 00088 zero_v3(m_mistcolor); 00089 } 00090 00091 copy_v3_v3(m_backgroundcolor, &blenderworld->horr); 00092 copy_v3_v3(m_ambientcolor, &blenderworld->ambr); 00093 00094 if(blenderscene->r.color_mgt_flag & R_COLOR_MANAGEMENT) { 00095 linearrgb_to_srgb_v3_v3(m_mistcolor, m_mistcolor); 00096 linearrgb_to_srgb_v3_v3(m_backgroundcolor, m_backgroundcolor); 00097 linearrgb_to_srgb_v3_v3(m_ambientcolor, m_ambientcolor); 00098 } 00099 } 00100 else 00101 { 00102 m_hasworld = false; 00103 } 00104 } 00105 00106 00107 00108 BlenderWorldInfo::~BlenderWorldInfo() 00109 { 00110 00111 } 00112 00113 00114 bool BlenderWorldInfo::hasWorld() 00115 { 00116 return m_hasworld; 00117 } 00118 00119 00120 00121 bool BlenderWorldInfo::hasMist() 00122 { 00123 return m_hasmist; 00124 } 00125 00126 00127 00128 float BlenderWorldInfo::getBackColorRed() 00129 { 00130 return m_backgroundcolor[0]; 00131 } 00132 00133 00134 00135 float BlenderWorldInfo::getBackColorGreen() 00136 { 00137 return m_backgroundcolor[1]; 00138 } 00139 00140 00141 00142 float BlenderWorldInfo::getBackColorBlue() 00143 { 00144 return m_backgroundcolor[2]; 00145 } 00146 00147 00148 float BlenderWorldInfo::getAmbientColorRed() 00149 { 00150 return m_ambientcolor[0]; 00151 } 00152 00153 float BlenderWorldInfo::getAmbientColorGreen() 00154 { 00155 return m_ambientcolor[1]; 00156 } 00157 00158 float BlenderWorldInfo::getAmbientColorBlue() 00159 { 00160 return m_ambientcolor[2]; 00161 } 00162 00163 float BlenderWorldInfo::getMistStart() 00164 { 00165 return m_miststart; 00166 } 00167 00168 00169 00170 float BlenderWorldInfo::getMistDistance() 00171 { 00172 return m_mistdistance; 00173 } 00174 00175 00176 00177 float BlenderWorldInfo::getMistColorRed() 00178 { 00179 return m_mistcolor[0]; 00180 } 00181 00182 00183 00184 float BlenderWorldInfo::getMistColorGreen() 00185 { 00186 return m_mistcolor[1]; 00187 } 00188 00189 00190 00191 float BlenderWorldInfo::getMistColorBlue() 00192 { 00193 return m_mistcolor[2]; 00194 } 00195 00196 void BlenderWorldInfo::setBackColor(float r, float g, float b) 00197 { 00198 m_backgroundcolor[0] = r; 00199 m_backgroundcolor[1] = g; 00200 m_backgroundcolor[2] = b; 00201 } 00202 00203 void 00204 BlenderWorldInfo::setMistStart( 00205 float d 00206 ) { 00207 m_miststart = d; 00208 } 00209 00210 00211 void 00212 BlenderWorldInfo::setMistDistance( 00213 float d 00214 ) { 00215 m_mistdistance = d; 00216 } 00217 00218 00219 void 00220 BlenderWorldInfo::setMistColorRed( 00221 float d 00222 ) { 00223 m_mistcolor[0] = d; 00224 } 00225 00226 00227 void 00228 BlenderWorldInfo::setMistColorGreen( 00229 float d 00230 ) { 00231 m_mistcolor[1] = d; 00232 } 00233 00234 00235 void 00236 BlenderWorldInfo::setMistColorBlue( 00237 float d 00238 ) { 00239 m_mistcolor[2] = d; 00240 }