1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: gfx_ResLight.h 4 5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Revision: 19456 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_GFX_RESLIGHT_H_ 17 #define NW_GFX_RESLIGHT_H_ 18 19 #include <nw/ut/ut_ResUtil.h> 20 #include <nw/ut/ut_ResDictionary.h> 21 #include <nw/gfx/res/gfx_ResLookupTable.h> 22 #include <nw/gfx/res/gfx_ResFragmentShader.h> 23 #include <nw/gfx/res/gfx_ResRevision.h> 24 #include <nw/gfx/res/gfx_ResTypeInfo.h> 25 26 namespace nw { 27 namespace gfx { 28 namespace res { 29 30 class ResGraphicsFile; 31 32 //! @details :private 33 struct ResLightData : public ResTransformNodeData 34 { 35 nw::ut::ResBool m_IsLightEnabled; 36 u8 padding_[3]; 37 }; 38 39 //! @details :private 40 struct ResFragmentLightData : public ResLightData 41 { 42 enum Flag 43 { 44 FLAG_TWO_SIDE_DIFFUSE_ENABLED_SHIFT = ResTransformNode::FLAG_SHIFT_MAX, 45 FLAG_DISTANCE_ATTENUATION_ENABLED_SHIFT, 46 FLAG_INHERITING_DIRECTION_ROTATE_SHIFT, 47 FLAG_SHIFT_MAX, 48 49 FLAG_TWO_SIDE_DIFFUSE_ENABLED = 0x1 << FLAG_TWO_SIDE_DIFFUSE_ENABLED_SHIFT, 50 FLAG_DISTANCE_ATTENUATION_ENABLED = 0x1 << FLAG_DISTANCE_ATTENUATION_ENABLED_SHIFT, 51 FLAG_IS_INHERITING_DIRECTION_ROTATE = 0x1 << FLAG_INHERITING_DIRECTION_ROTATE_SHIFT 52 }; 53 54 nw::ut::ResS32 m_LightKind; 55 nw::ut::ResFloatColor m_Ambient; 56 nw::ut::ResFloatColor m_Diffuse; 57 nw::ut::ResFloatColor m_Specular0; 58 nw::ut::ResFloatColor m_Specular1; 59 nw::ut::ResU32 m_AmbientU32; 60 nw::ut::ResU32 m_DiffuseU32; 61 nw::ut::ResU32 m_Specular0U32; 62 nw::ut::ResU32 m_Specular1U32; 63 nw::ut::ResVec3 m_Direction; 64 nw::ut::Offset toDistanceSampler; 65 nw::ut::Offset toAngleSampler; 66 nw::ut::ResF32 m_DistanceAttenuationStart; // アニメーション書き込み用バッファ 67 nw::ut::ResF32 m_DistanceAttenuationEnd; // アニメーション書き込み用バッファ 68 nw::ut::ResU32 m_DistanceAttenuationScale; 69 nw::ut::ResU32 m_DistanceAttenuationBias; 70 71 nw::ut::ResBool m_IsDirty; 72 u8 padding_[3]; 73 }; 74 75 //! @details :private 76 struct ResAmbientLightData : public ResLightData 77 { 78 nw::ut::ResFloatColor m_Ambient; 79 nw::ut::ResU32 m_AmbientU32; 80 81 nw::ut::ResBool m_IsDirty; 82 u8 padding_[3]; 83 }; 84 85 //! @details :private 86 struct ResVertexLightData : public ResLightData 87 { 88 enum Flag 89 { 90 FLAG_INHERITING_DIRECTION_ROTATE_SHIFT = ResTransformNode::FLAG_SHIFT_MAX, 91 FLAG_SHIFT_MAX, 92 93 FLAG_IS_INHERITING_DIRECTION_ROTATE = 0x1 << FLAG_INHERITING_DIRECTION_ROTATE_SHIFT 94 }; 95 96 nw::ut::ResS32 m_LightKind; 97 nw::ut::ResFloatColor m_Ambient; 98 nw::ut::ResFloatColor m_Diffuse; 99 nw::ut::ResVec3 m_Direction; 100 nw::ut::ResVec3 m_DistanceAttenuation; 101 nw::ut::ResF32 m_IsDistanceAttenuationEnabled; 102 nw::ut::ResVec2 m_SpotFactor; 103 }; 104 105 //! @details :private 106 struct ResHemiSphereLightData : public ResLightData 107 { 108 enum Flag 109 { 110 FLAG_INHERITING_DIRECTION_ROTATE_SHIFT = ResTransformNode::FLAG_SHIFT_MAX, 111 FLAG_SHIFT_MAX, 112 113 FLAG_IS_INHERITING_DIRECTION_ROTATE = 0x1 << FLAG_INHERITING_DIRECTION_ROTATE_SHIFT 114 }; 115 116 nw::ut::ResFloatColor m_GroundColor; 117 nw::ut::ResFloatColor m_SkyColor; 118 nw::ut::ResVec3 m_Direction; 119 nw::ut::ResF32 m_LerpFactor; 120 }; 121 122 //-------------------------------------------------------------------------- 123 //! @brief ライトを表すバイナリリソースの基底クラスです。 124 //--------------------------------------------------------------------------- 125 class ResLight : public ResTransformNode 126 { 127 public: 128 enum { BINARY_REVISION = REVISION_RES_LIGHT }; 129 NW_RES_CTOR_INHERIT(ResLight,ResTransformNode)130 NW_RES_CTOR_INHERIT( ResLight, ResTransformNode ) 131 132 //--------------------------------------------------------------------------- 133 //! @fn void SetLightEnabled(bool value) 134 //! @brief ライトの有効フラグを設定します。 135 //--------------------------------------------------------------------------- 136 //--------------------------------------------------------------------------- 137 //! @fn bool IsLightEnabled() const 138 //! @brief ライトの有効フラグを取得します。 139 //--------------------------------------------------------------------------- 140 NW_RES_FIELD_BOOL_PRIMITIVE_DECL( LightEnabled ) // IsLightEnabled(), SetLightEnabled() 141 142 //--------------------------------------------------------------------------- 143 //! @brief リビジョンを取得します。 144 //! 145 //! @return リソースのリビジョン情報です。 146 //--------------------------------------------------------------------------- 147 u32 GetRevision() const { return this->GetHeader().revision; } 148 149 //--------------------------------------------------------------------------- 150 //! @brief リソースのセットアップをおこないます。 151 //! 152 //! @param[in] allocator アロケータです。 153 //! @param[in] graphicsFile グラフィックスリソースです。 154 //--------------------------------------------------------------------------- 155 Result Setup(os::IAllocator* allocator, ResGraphicsFile graphicsFile); 156 157 //--------------------------------------------------------------------------- 158 //! @brief リソースの後始末をおこないます。 159 //--------------------------------------------------------------------------- 160 void Cleanup(); 161 }; 162 typedef nw::ut::ResArrayPatricia<ResLight>::type ResLightArray; 163 164 //-------------------------------------------------------------------------- 165 //! @brief フラグメントライトを表すバイナリリソースクラスです。 166 //--------------------------------------------------------------------------- 167 class ResFragmentLight : public ResLight 168 { 169 public: 170 enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResFragmentLight) }; 171 enum { SIGNATURE = NW_RES_SIGNATURE32('CFLT') }; 172 173 //! @brief ライトの種類です。 174 enum Kind 175 { 176 KIND_DIRECTIONAL, //!< ディレクショナルライトです。 177 KIND_POINT, //!< ポイントライトです。 178 KIND_SPOT, //!< スポットライトです。 179 KIND_COUNT //!< enum の最大値です。 180 }; 181 NW_RES_CTOR_INHERIT(ResFragmentLight,ResLight)182 NW_RES_CTOR_INHERIT( ResFragmentLight, ResLight ) 183 184 185 //--------------------------------------------------------------------------- 186 //! @fn void SetSpecular1(f32 r, f32 g, f32 b) 187 //! @brief ライトのスペキュラカラー1を設定します。 188 //--------------------------------------------------------------------------- 189 //--------------------------------------------------------------------------- 190 //! @fn void SetSpecular0(f32 r, f32 g, f32 b) 191 //! @brief ライトのスペキュラカラー0を設定します。 192 //--------------------------------------------------------------------------- 193 //--------------------------------------------------------------------------- 194 //! @fn void SetLightKind(s32 value) 195 //! @brief 光源の種類を設定します。 196 //--------------------------------------------------------------------------- 197 //--------------------------------------------------------------------------- 198 //! @fn void SetDirty(bool value) 199 //! @brief ライトの内容が更新されているかどうかのフラグを設定します。 200 //--------------------------------------------------------------------------- 201 //--------------------------------------------------------------------------- 202 //! @fn void SetDirection(f32 x, f32 y, f32 z) 203 //! @brief ライトの方向を設定します。 204 //--------------------------------------------------------------------------- 205 //--------------------------------------------------------------------------- 206 //! @fn void SetDiffuse(f32 r, f32 g, f32 b) 207 //! @brief ライトのディフューズカラーを設定します。 208 //--------------------------------------------------------------------------- 209 //--------------------------------------------------------------------------- 210 //! @fn void SetAmbient(f32 r, f32 g, f32 b) 211 //! @brief ライトのアンビエントカラーを設定します。 212 //--------------------------------------------------------------------------- 213 //--------------------------------------------------------------------------- 214 //! @fn bool IsDirty() const 215 //! @brief ライトの内容が更新されているかどうかのフラグを取得します。 216 //--------------------------------------------------------------------------- 217 //--------------------------------------------------------------------------- 218 //! @fn u32 GetSpecular1U32() const 219 //! @brief ライトのスペキュラカラー1を RGBA8 の32bitフォーマットで取得します。 220 //--------------------------------------------------------------------------- 221 //--------------------------------------------------------------------------- 222 //! @fn const nw::ut::FloatColor & GetSpecular1() const 223 //! @brief ライトのスペキュラカラー1を取得します。 224 //--------------------------------------------------------------------------- 225 //--------------------------------------------------------------------------- 226 //! @fn u32 GetSpecular0U32() const 227 //! @brief ライトのスペキュラカラー0を RGBA8 の32bitフォーマットで取得します。 228 //--------------------------------------------------------------------------- 229 //--------------------------------------------------------------------------- 230 //! @fn const nw::ut::FloatColor & GetSpecular0() const 231 //! @brief ライトのスペキュラカラー0を取得します。 232 //--------------------------------------------------------------------------- 233 //--------------------------------------------------------------------------- 234 //! @fn s32 GetLightKind() const 235 //! @brief 光源の種類を取得します。 236 //--------------------------------------------------------------------------- 237 //--------------------------------------------------------------------------- 238 //! @fn ResLookupTable GetDistanceSampler() 239 //! @brief 距離減衰用のルックアップテーブルを取得します。 240 //--------------------------------------------------------------------------- 241 //--------------------------------------------------------------------------- 242 //! @fn const nw::math::VEC3 & GetDirection() const 243 //! @brief ライトの方向を取得します。 244 //--------------------------------------------------------------------------- 245 //--------------------------------------------------------------------------- 246 //! @fn u32 GetDiffuseU32() const 247 //! @brief ライトのディフューズカラーを RGBA8 の32bitフォーマットで取得します。 248 //--------------------------------------------------------------------------- 249 //--------------------------------------------------------------------------- 250 //! @fn const nw::ut::FloatColor & GetDiffuse() const 251 //! @brief ライトのディフューズカラーを取得します。 252 //--------------------------------------------------------------------------- 253 //--------------------------------------------------------------------------- 254 //! @fn ResLightingLookupTable GetAngleSampler() 255 //! @brief 角度減衰用のルックアップテーブルを取得します。 256 //--------------------------------------------------------------------------- 257 //--------------------------------------------------------------------------- 258 //! @fn u32 GetAmbientU32() const 259 //! @brief ライトのアンビエントカラーを RGBA8 の32bitフォーマットで取得します。 260 //--------------------------------------------------------------------------- 261 //--------------------------------------------------------------------------- 262 //! @fn const nw::ut::FloatColor & GetAmbient() const 263 //! @brief ライトのアンビエントカラーを取得します。 264 //--------------------------------------------------------------------------- 265 NW_RES_FIELD_PRIMITIVE_DECL( s32, LightKind ) // GetLightKind(), SetLightKind() 266 NW_RES_FIELD_FLOAT_U32_COLOR_DECL( nw::ut::FloatColor, Ambient ) // const FloatColor& GetAmbient() 267 NW_RES_FIELD_FLOAT_U32_COLOR_DECL( nw::ut::FloatColor, Diffuse ) // const FloatColor& GetDiffuse() 268 NW_RES_FIELD_FLOAT_U32_COLOR_DECL( nw::ut::FloatColor, Specular0 ) // const FloatColor& GetSpecular0() 269 NW_RES_FIELD_FLOAT_U32_COLOR_DECL( nw::ut::FloatColor, Specular1 ) // const FloatColor& GetSpecular1() 270 NW_RES_FIELD_VECTOR3_DECL( nw::math::VEC3, Direction ) // VEC3& GetDirection() 271 NW_RES_FIELD_CLASS_DECL( ResLookupTable, DistanceSampler ) // GetDistanceSampler() 272 NW_RES_FIELD_CLASS_DECL( ResLightingLookupTable, AngleSampler ) // GetAngleSampler() 273 274 //--------------------------------------------------------------------------- 275 //! @brief 参照テーブルを設定します。 276 //! 参照先に設定しますのでリソースの解放はされません。 277 //! 278 //! @param[in] 参照テーブルです。 279 //--------------------------------------------------------------------------- 280 void SetDistanceSampler(ResImageLookupTable lookupTable) 281 { 282 NW_ASSERT(lookupTable.IsValid()); 283 ResReferenceLookupTable referenceLut = ResStaticCast<ResReferenceLookupTable>(GetDistanceSampler()); 284 referenceLut.ref().toTargetLut.set_ptr(lookupTable.ptr()); 285 } 286 287 //-------------------------------------------------------------------------- 288 //! @brief 距離減衰の開始距離を取得します。 289 //! 290 //! @return 距離減衰の開始距離設定です。 291 //--------------------------------------------------------------------------- GetDistanceAttenuationStart()292 f32 GetDistanceAttenuationStart() const 293 { 294 return ref().m_DistanceAttenuationStart; 295 } 296 297 //-------------------------------------------------------------------------- 298 //! @brief 距離減衰の終了距離を取得します。 299 //! 300 //! @return 距離減衰の終了距離設定です。 301 //--------------------------------------------------------------------------- GetDistanceAttenuationEnd()302 f32 GetDistanceAttenuationEnd() const 303 { 304 return ref().m_DistanceAttenuationEnd; 305 } 306 307 //-------------------------------------------------------------------------- 308 //! @brief 距離減衰の開始距離を設定します。 309 //--------------------------------------------------------------------------- SetDistanceAttenuationStart(f32 start)310 void SetDistanceAttenuationStart(f32 start) 311 { 312 ref().m_DistanceAttenuationStart = start; 313 SetDistanceAttenuation(ref().m_DistanceAttenuationStart, ref().m_DistanceAttenuationEnd); 314 } 315 316 //-------------------------------------------------------------------------- 317 //! @brief 距離減衰の終了距離を設定します。 318 //--------------------------------------------------------------------------- SetDistanceAttenuationEnd(f32 end)319 void SetDistanceAttenuationEnd(f32 end) 320 { 321 ref().m_DistanceAttenuationEnd = end; 322 SetDistanceAttenuation(ref().m_DistanceAttenuationStart, ref().m_DistanceAttenuationEnd); 323 } 324 325 //-------------------------------------------------------------------------- 326 //! @brief 距離減衰の開始、終了パラメータを設定します。 327 //! 328 //! @param[in] start 減衰開始距離です。 329 //! @param[in] end 減衰終了距離です。 330 //--------------------------------------------------------------------------- SetDistanceAttenuation(f32 start,f32 end)331 void SetDistanceAttenuation(f32 start, f32 end) 332 { 333 f32 diff = end - start; 334 335 f32 minimumDistance = 0.01f; 336 if (math::FAbs(diff) < minimumDistance) 337 { 338 diff = minimumDistance; 339 } 340 341 ref().m_DistanceAttenuationScale = ut::Float20::Float32ToBits20(1.0f / diff); 342 ref().m_DistanceAttenuationBias = ut::Float20::Float32ToBits20(-start / diff); 343 } 344 345 NW_RES_FIELD_BOOL_PRIMITIVE_DECL( Dirty ) // IsDirty(), SetDirty() 346 }; 347 348 //-------------------------------------------------------------------------- 349 //! @brief グローバルアンビエントライトを表すバイナリリソースクラスです。 350 //--------------------------------------------------------------------------- 351 class ResAmbientLight : public ResLight 352 { 353 public: 354 enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResAmbientLight) }; 355 enum { SIGNATURE = NW_RES_SIGNATURE32('CALT') }; 356 357 NW_RES_CTOR_INHERIT( ResAmbientLight, ResLight ) 358 359 //--------------------------------------------------------------------------- 360 //! @fn void SetAmbient(f32 r, f32 g, f32 b) 361 //! @brief ライトのアンビエントカラーを設定します。 362 //--------------------------------------------------------------------------- 363 //--------------------------------------------------------------------------- 364 //! @fn u32 GetAmbientU32() const 365 //! @brief ライトのアンビエントカラーを RGBA8 の32bitフォーマットで取得します。 366 //--------------------------------------------------------------------------- 367 //--------------------------------------------------------------------------- 368 //! @fn const nw::ut::FloatColor & GetAmbient() const 369 //! @brief ライトのアンビエントカラーを取得します。 370 //--------------------------------------------------------------------------- 371 NW_RES_FIELD_FLOAT_U32_COLOR_DECL( nw::ut::FloatColor, Ambient ) // FloatColor& GetAmbient() 372 }; 373 374 //-------------------------------------------------------------------------- 375 //! @brief 頂点ライトを表すバイナリリソースクラスです。 376 //--------------------------------------------------------------------------- 377 class ResVertexLight : public ResLight 378 { 379 public: 380 enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResVertexLight) }; 381 enum { SIGNATURE = NW_RES_SIGNATURE32('CVLT') }; 382 383 //! @brief ライトの種類です。 384 enum Kind 385 { 386 KIND_DIRECTIONAL, //!< ディレクショナルライトです。 387 KIND_POINT, //!< ポイントライトです。 388 KIND_SPOT, //!< スポットライトです。 389 KIND_COUNT //!< enum の最大値です。 390 }; 391 NW_RES_CTOR_INHERIT(ResVertexLight,ResLight)392 NW_RES_CTOR_INHERIT( ResVertexLight, ResLight ) 393 394 //--------------------------------------------------------------------------- 395 //! @fn void SetSpotFactor(f32 x, f32 y) 396 //! @brief スポットライトの角度減衰係数を設定します。 397 //--------------------------------------------------------------------------- 398 //--------------------------------------------------------------------------- 399 //! @fn void SetLightKind(s32 value) 400 //! @brief 光源の種類を設定します。 401 //--------------------------------------------------------------------------- 402 //--------------------------------------------------------------------------- 403 //! @fn void SetDistanceAttenuation(f32 x, f32 y, f32 z) 404 //! @brief 距離減衰のパラメータを設定します。 405 //--------------------------------------------------------------------------- 406 //--------------------------------------------------------------------------- 407 //! @fn void SetDirection(f32 x, f32 y, f32 z) 408 //! @brief ライトの方向を設定します。 409 //--------------------------------------------------------------------------- 410 //--------------------------------------------------------------------------- 411 //! @fn void SetDiffuse(f32 r, f32 g, f32 b) 412 //! @brief ライトのディフューズカラーを設定します。 413 //--------------------------------------------------------------------------- 414 //--------------------------------------------------------------------------- 415 //! @fn void SetAmbient(f32 r, f32 g, f32 b) 416 //! @brief ライトのアンビエントカラーを設定します。 417 //--------------------------------------------------------------------------- 418 //--------------------------------------------------------------------------- 419 //! @fn const nw::math::VEC2 & GetSpotFactor() const 420 //! @brief スポットライトの角度減衰係数を取得します。 421 //--------------------------------------------------------------------------- 422 //--------------------------------------------------------------------------- 423 //! @fn s32 GetLightKind() const 424 //! @brief 光源の種類を取得します。 425 //--------------------------------------------------------------------------- 426 //--------------------------------------------------------------------------- 427 //! @fn const nw::math::VEC3 & GetDistanceAttenuation() const 428 //! @brief 距離減衰のパラメータを取得します。 429 //--------------------------------------------------------------------------- 430 //--------------------------------------------------------------------------- 431 //! @fn const nw::math::VEC3 & GetDirection() const 432 //! @brief ライトの方向を取得します。 433 //--------------------------------------------------------------------------- 434 //--------------------------------------------------------------------------- 435 //! @fn const nw::ut::FloatColor & GetDiffuse() const 436 //! @brief ライトのディフューズカラーを取得します。 437 //--------------------------------------------------------------------------- 438 //--------------------------------------------------------------------------- 439 //! @fn const nw::ut::FloatColor & GetAmbient() const 440 //! @brief ライトのアンビエントカラーを取得します。 441 //--------------------------------------------------------------------------- 442 NW_RES_FIELD_PRIMITIVE_DECL( s32, LightKind ) // GetLightLind(), SetLightKind() 443 NW_RES_FIELD_FLOAT_COLOR_DECL( nw::ut::FloatColor, Ambient ) // const FloatColor& GetAmbient() 444 NW_RES_FIELD_FLOAT_COLOR_DECL( nw::ut::FloatColor, Diffuse ) // const FloatColor& GetDiffuse() 445 NW_RES_FIELD_VECTOR3_DECL( nw::math::VEC3, Direction ) // VEC3& GetDirection() 446 NW_RES_FIELD_VECTOR3_DECL( nw::math::VEC3, DistanceAttenuation ) // VEC3& GetDistanceAttenuation() 447 NW_RES_FIELD_VECTOR2_DECL( nw::math::VEC2, SpotFactor ) // VEC2& GetSpotFactor() 448 449 //--------------------------------------------------------------------------- 450 //! @brief 距離減衰が有効かどうかを取得します。 451 //! 452 //! @return 距離減衰が有効であれば true を返します。 453 //--------------------------------------------------------------------------- 454 bool IsDistanceAttenuationEnabled() const { return ref().m_IsDistanceAttenuationEnabled != 0.0f; } 455 456 //--------------------------------------------------------------------------- 457 //! @brief 距離減衰が有効かどうかを設定します。 458 //! 459 //! @param[in] enable 距離減衰を有効にするためには true を指定します。 460 //--------------------------------------------------------------------------- SetDistanceAttenuationEnabled(bool enable)461 void SetDistanceAttenuationEnabled(bool enable) 462 { 463 ref().m_IsDistanceAttenuationEnabled = enable ? 1.0f : 0.0f; 464 } 465 466 //--------------------------------------------------------------------------- 467 //! @brief DistanceAttenuation と IsDistanceAttenuationEnabled を VEC4 として取得します。 468 //! 469 //! @return w 値に IsDistanceAttenuationEnabled が格納された 4 要素のベクトルです。 470 //--------------------------------------------------------------------------- GetDistanceAttenuationAndEnabled()471 math::VEC4& GetDistanceAttenuationAndEnabled() 472 { 473 return reinterpret_cast<nw::math::VEC4&>( ref().m_DistanceAttenuation ); 474 } 475 476 //--------------------------------------------------------------------------- 477 //! @brief Direction と IsDistanceAttenuationEnabled を VEC4 として取得します。 478 //! 479 //! @return w 値に IsDistanceAttenuationEnabled が格納された 4 要素のベクトルです。 480 //--------------------------------------------------------------------------- GetDistanceAttenuationAndEnabled()481 const math::VEC4& GetDistanceAttenuationAndEnabled() const 482 { 483 return reinterpret_cast<const nw::math::VEC4&>( ref().m_DistanceAttenuation ); 484 } 485 }; 486 487 //-------------------------------------------------------------------------- 488 //! @brief 半球ライトを表すバイナリリソースクラスです。 489 //--------------------------------------------------------------------------- 490 class ResHemiSphereLight : public ResLight 491 { 492 public: 493 enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResHemiSphereLight) }; 494 enum { SIGNATURE = NW_RES_SIGNATURE32('CHLT') }; 495 NW_RES_CTOR_INHERIT(ResHemiSphereLight,ResLight)496 NW_RES_CTOR_INHERIT( ResHemiSphereLight, ResLight ) 497 498 //--------------------------------------------------------------------------- 499 //! @fn void SetSkyColor(f32 r, f32 g, f32 b) 500 //! @brief 空の色を設定します。 501 //--------------------------------------------------------------------------- 502 //--------------------------------------------------------------------------- 503 //! @fn void SetLerpFactor(f32 value) 504 //! @brief 線形補間係数を設定します。 505 //--------------------------------------------------------------------------- 506 //--------------------------------------------------------------------------- 507 //! @fn void SetGroundColor(f32 r, f32 g, f32 b) 508 //! @brief 地面の色を設定します。 509 //--------------------------------------------------------------------------- 510 //--------------------------------------------------------------------------- 511 //! @fn void SetDirection(f32 x, f32 y, f32 z) 512 //! @brief ライトの方向を設定します。 513 //--------------------------------------------------------------------------- 514 //--------------------------------------------------------------------------- 515 //! @fn const nw::ut::FloatColor & GetSkyColor() const 516 //! @brief 空の色を取得します。 517 //--------------------------------------------------------------------------- 518 //--------------------------------------------------------------------------- 519 //! @fn f32 GetLerpFactor() const 520 //! @brief 線形補間係数を取得します。 521 //--------------------------------------------------------------------------- 522 //--------------------------------------------------------------------------- 523 //! @fn const nw::ut::FloatColor & GetGroundColor() const 524 //! @brief 地面の色を取得します。 525 //--------------------------------------------------------------------------- 526 //--------------------------------------------------------------------------- 527 //! @fn const nw::math::VEC3 & GetDirection() const 528 //! @brief ライトの方向を取得します。 529 //--------------------------------------------------------------------------- 530 NW_RES_FIELD_FLOAT_COLOR_DECL( nw::ut::FloatColor, GroundColor ) // FloatColor& GetGroundColor() 531 NW_RES_FIELD_FLOAT_COLOR_DECL( nw::ut::FloatColor, SkyColor ) // FloatColor& GetSkyColor() 532 NW_RES_FIELD_VECTOR3_DECL( nw::math::VEC3, Direction ) // VEC3& GetDirection() 533 NW_RES_FIELD_PRIMITIVE_DECL( f32, LerpFactor ) // GetLerpFactor(), SetLerpFactor() 534 535 //--------------------------------------------------------------------------- 536 //! @brief Direction と Lerp を VEC4 として取得します。 537 //! 538 //! @return w 値に Lerp が格納された 4 要素のベクトルです。 539 //--------------------------------------------------------------------------- 540 nw::math::VEC4& GetDirectionAndLerp() 541 { 542 return reinterpret_cast<nw::math::VEC4&>( ref().m_Direction ); 543 } 544 545 //--------------------------------------------------------------------------- 546 //! @brief Direction と Lerp を VEC4 として取得します。 547 //! 548 //! @return w 値に Lerp が格納された 4 要素のベクトルです。 549 //--------------------------------------------------------------------------- GetDirectionAndLerp()550 const nw::math::VEC4& GetDirectionAndLerp() const 551 { 552 return reinterpret_cast<const nw::math::VEC4&>( ref().m_Direction ); 553 } 554 }; 555 556 } // namespace res 557 } // namespace gfx 558 } // namespace nw 559 560 #endif // NW_GFX_RESLIGHT_H_ 561