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 130 //! @brief ライトの光源の種類です。 131 enum Kind 132 { 133 KIND_DIRECTIONAL, //!< ディレクショナルライトです。 134 KIND_POINT, //!< ポイントライトです。 135 KIND_SPOT, //!< スポットライトです。 136 KIND_UNUSED, //!< 光源の種類を考慮しないライトです。 137 KIND_COUNT //!< enum の最大値です。 138 }; 139 NW_RES_CTOR_INHERIT(ResLight,ResTransformNode)140 NW_RES_CTOR_INHERIT( ResLight, ResTransformNode ) 141 142 //--------------------------------------------------------------------------- 143 //! @fn void SetLightEnabled(bool value) 144 //! @brief ライトの有効フラグを設定します。 145 //--------------------------------------------------------------------------- 146 //--------------------------------------------------------------------------- 147 //! @fn bool IsLightEnabled() const 148 //! @brief ライトの有効フラグを取得します。 149 //--------------------------------------------------------------------------- 150 NW_RES_FIELD_BOOL_PRIMITIVE_DECL( LightEnabled ) // IsLightEnabled(), SetLightEnabled() 151 152 //--------------------------------------------------------------------------- 153 //! @brief リビジョンを取得します。 154 //! 155 //! @return リソースのリビジョン情報です。 156 //--------------------------------------------------------------------------- 157 u32 GetRevision() const { return this->GetHeader().revision; } 158 159 //--------------------------------------------------------------------------- 160 //! @brief リソースのセットアップをおこないます。 161 //! 162 //! @param[in] allocator アロケータです。 163 //! @param[in] graphicsFile グラフィックスリソースです。 164 //--------------------------------------------------------------------------- 165 Result Setup(os::IAllocator* allocator, ResGraphicsFile graphicsFile); 166 167 //--------------------------------------------------------------------------- 168 //! @brief リソースの後始末をおこないます。 169 //--------------------------------------------------------------------------- 170 void Cleanup(); 171 }; 172 typedef nw::ut::ResArrayPatricia<ResLight>::type ResLightArray; 173 174 //-------------------------------------------------------------------------- 175 //! @brief フラグメントライトを表すバイナリリソースクラスです。 176 //--------------------------------------------------------------------------- 177 class ResFragmentLight : public ResLight 178 { 179 public: 180 enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResFragmentLight) }; 181 enum { SIGNATURE = NW_RES_SIGNATURE32('CFLT') }; 182 NW_RES_CTOR_INHERIT(ResFragmentLight,ResLight)183 NW_RES_CTOR_INHERIT( ResFragmentLight, ResLight ) 184 185 186 //--------------------------------------------------------------------------- 187 //! @fn void SetSpecular1(f32 r, f32 g, f32 b) 188 //! @brief ライトのスペキュラカラー1を設定します。 189 //--------------------------------------------------------------------------- 190 //--------------------------------------------------------------------------- 191 //! @fn void SetSpecular0(f32 r, f32 g, f32 b) 192 //! @brief ライトのスペキュラカラー0を設定します。 193 //--------------------------------------------------------------------------- 194 //--------------------------------------------------------------------------- 195 //! @fn void SetLightKind(s32 value) 196 //! @brief 光源の種類を設定します。 197 //--------------------------------------------------------------------------- 198 //--------------------------------------------------------------------------- 199 //! @fn void SetDirty(bool value) 200 //! @brief ライトの内容が更新されているかどうかのフラグを設定します。 201 //--------------------------------------------------------------------------- 202 //--------------------------------------------------------------------------- 203 //! @fn void SetDirection(f32 x, f32 y, f32 z) 204 //! @brief ライトの方向を設定します。 205 //--------------------------------------------------------------------------- 206 //--------------------------------------------------------------------------- 207 //! @fn void SetDiffuse(f32 r, f32 g, f32 b) 208 //! @brief ライトのディフューズカラーを設定します。 209 //--------------------------------------------------------------------------- 210 //--------------------------------------------------------------------------- 211 //! @fn void SetAmbient(f32 r, f32 g, f32 b) 212 //! @brief ライトのアンビエントカラーを設定します。 213 //--------------------------------------------------------------------------- 214 //--------------------------------------------------------------------------- 215 //! @fn bool IsDirty() const 216 //! @brief ライトの内容が更新されているかどうかのフラグを取得します。 217 //--------------------------------------------------------------------------- 218 //--------------------------------------------------------------------------- 219 //! @fn u32 GetSpecular1U32() const 220 //! @brief ライトのスペキュラカラー1を RGBA8 の32bitフォーマットで取得します。 221 //--------------------------------------------------------------------------- 222 //--------------------------------------------------------------------------- 223 //! @fn const nw::ut::FloatColor & GetSpecular1() const 224 //! @brief ライトのスペキュラカラー1を取得します。 225 //--------------------------------------------------------------------------- 226 //--------------------------------------------------------------------------- 227 //! @fn u32 GetSpecular0U32() const 228 //! @brief ライトのスペキュラカラー0を RGBA8 の32bitフォーマットで取得します。 229 //--------------------------------------------------------------------------- 230 //--------------------------------------------------------------------------- 231 //! @fn const nw::ut::FloatColor & GetSpecular0() const 232 //! @brief ライトのスペキュラカラー0を取得します。 233 //--------------------------------------------------------------------------- 234 //--------------------------------------------------------------------------- 235 //! @fn s32 GetLightKind() const 236 //! @brief 光源の種類を取得します。 237 //--------------------------------------------------------------------------- 238 //--------------------------------------------------------------------------- 239 //! @fn ResLookupTable GetDistanceSampler() 240 //! @brief 距離減衰用のルックアップテーブルを取得します。 241 //--------------------------------------------------------------------------- 242 //--------------------------------------------------------------------------- 243 //! @fn const nw::math::VEC3 & GetDirection() const 244 //! @brief ライトの方向を取得します。 245 //--------------------------------------------------------------------------- 246 //--------------------------------------------------------------------------- 247 //! @fn u32 GetDiffuseU32() const 248 //! @brief ライトのディフューズカラーを RGBA8 の32bitフォーマットで取得します。 249 //--------------------------------------------------------------------------- 250 //--------------------------------------------------------------------------- 251 //! @fn const nw::ut::FloatColor & GetDiffuse() const 252 //! @brief ライトのディフューズカラーを取得します。 253 //--------------------------------------------------------------------------- 254 //--------------------------------------------------------------------------- 255 //! @fn ResLightingLookupTable GetAngleSampler() 256 //! @brief 角度減衰用のルックアップテーブルを取得します。 257 //--------------------------------------------------------------------------- 258 //--------------------------------------------------------------------------- 259 //! @fn u32 GetAmbientU32() const 260 //! @brief ライトのアンビエントカラーを RGBA8 の32bitフォーマットで取得します。 261 //--------------------------------------------------------------------------- 262 //--------------------------------------------------------------------------- 263 //! @fn const nw::ut::FloatColor & GetAmbient() const 264 //! @brief ライトのアンビエントカラーを取得します。 265 //--------------------------------------------------------------------------- 266 NW_RES_FIELD_PRIMITIVE_DECL( s32, LightKind ) // GetLightKind(), SetLightKind() 267 NW_RES_FIELD_FLOAT_U32_COLOR_DECL( nw::ut::FloatColor, Ambient ) // const FloatColor& GetAmbient() 268 NW_RES_FIELD_FLOAT_U32_COLOR_DECL( nw::ut::FloatColor, Diffuse ) // const FloatColor& GetDiffuse() 269 NW_RES_FIELD_FLOAT_U32_COLOR_DECL( nw::ut::FloatColor, Specular0 ) // const FloatColor& GetSpecular0() 270 NW_RES_FIELD_FLOAT_U32_COLOR_DECL( nw::ut::FloatColor, Specular1 ) // const FloatColor& GetSpecular1() 271 NW_RES_FIELD_VECTOR3_DECL( nw::math::VEC3, Direction ) // VEC3& GetDirection() 272 NW_RES_FIELD_CLASS_DECL( ResLookupTable, DistanceSampler ) // GetDistanceSampler() 273 NW_RES_FIELD_CLASS_DECL( ResLightingLookupTable, AngleSampler ) // GetAngleSampler() 274 275 //--------------------------------------------------------------------------- 276 //! @brief 参照テーブルを設定します。 277 //! 参照先に設定しますのでリソースの解放はされません。 278 //! 279 //! @param[in] 参照テーブルです。 280 //--------------------------------------------------------------------------- 281 void SetDistanceSampler(ResImageLookupTable lookupTable) 282 { 283 NW_ASSERT(lookupTable.IsValid()); 284 ResReferenceLookupTable referenceLut = ResStaticCast<ResReferenceLookupTable>(GetDistanceSampler()); 285 referenceLut.ref().toTargetLut.set_ptr(lookupTable.ptr()); 286 } 287 288 //-------------------------------------------------------------------------- 289 //! @brief 距離減衰の開始距離を取得します。 290 //! 291 //! @return 距離減衰の開始距離設定です。 292 //--------------------------------------------------------------------------- GetDistanceAttenuationStart()293 f32 GetDistanceAttenuationStart() const 294 { 295 return ref().m_DistanceAttenuationStart; 296 } 297 298 //-------------------------------------------------------------------------- 299 //! @brief 距離減衰の終了距離を取得します。 300 //! 301 //! @return 距離減衰の終了距離設定です。 302 //--------------------------------------------------------------------------- GetDistanceAttenuationEnd()303 f32 GetDistanceAttenuationEnd() const 304 { 305 return ref().m_DistanceAttenuationEnd; 306 } 307 308 //-------------------------------------------------------------------------- 309 //! @brief 距離減衰の開始距離を設定します。 310 //--------------------------------------------------------------------------- SetDistanceAttenuationStart(f32 start)311 void SetDistanceAttenuationStart(f32 start) 312 { 313 ref().m_DistanceAttenuationStart = start; 314 SetDistanceAttenuation(ref().m_DistanceAttenuationStart, ref().m_DistanceAttenuationEnd); 315 } 316 317 //-------------------------------------------------------------------------- 318 //! @brief 距離減衰の終了距離を設定します。 319 //--------------------------------------------------------------------------- SetDistanceAttenuationEnd(f32 end)320 void SetDistanceAttenuationEnd(f32 end) 321 { 322 ref().m_DistanceAttenuationEnd = end; 323 SetDistanceAttenuation(ref().m_DistanceAttenuationStart, ref().m_DistanceAttenuationEnd); 324 } 325 326 //-------------------------------------------------------------------------- 327 //! @brief 距離減衰の開始、終了パラメータを設定します。 328 //! 329 //! @param[in] start 減衰開始距離です。 330 //! @param[in] end 減衰終了距離です。 331 //--------------------------------------------------------------------------- SetDistanceAttenuation(f32 start,f32 end)332 void SetDistanceAttenuation(f32 start, f32 end) 333 { 334 f32 diff = end - start; 335 336 f32 minimumDistance = 0.01f; 337 if (math::FAbs(diff) < minimumDistance) 338 { 339 diff = minimumDistance; 340 } 341 342 ref().m_DistanceAttenuationScale = ut::Float20::Float32ToBits20(1.0f / diff); 343 ref().m_DistanceAttenuationBias = ut::Float20::Float32ToBits20(-start / diff); 344 } 345 346 NW_RES_FIELD_BOOL_PRIMITIVE_DECL( Dirty ) // IsDirty(), SetDirty() 347 }; 348 349 //-------------------------------------------------------------------------- 350 //! @brief グローバルアンビエントライトを表すバイナリリソースクラスです。 351 //--------------------------------------------------------------------------- 352 class ResAmbientLight : public ResLight 353 { 354 public: 355 enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResAmbientLight) }; 356 enum { SIGNATURE = NW_RES_SIGNATURE32('CALT') }; 357 358 NW_RES_CTOR_INHERIT( ResAmbientLight, ResLight ) 359 360 //--------------------------------------------------------------------------- 361 //! @fn void SetAmbient(f32 r, f32 g, f32 b) 362 //! @brief ライトのアンビエントカラーを設定します。 363 //--------------------------------------------------------------------------- 364 //--------------------------------------------------------------------------- 365 //! @fn u32 GetAmbientU32() const 366 //! @brief ライトのアンビエントカラーを RGBA8 の32bitフォーマットで取得します。 367 //--------------------------------------------------------------------------- 368 //--------------------------------------------------------------------------- 369 //! @fn const nw::ut::FloatColor & GetAmbient() const 370 //! @brief ライトのアンビエントカラーを取得します。 371 //--------------------------------------------------------------------------- 372 NW_RES_FIELD_FLOAT_U32_COLOR_DECL( nw::ut::FloatColor, Ambient ) // FloatColor& GetAmbient() 373 }; 374 375 //-------------------------------------------------------------------------- 376 //! @brief 頂点ライトを表すバイナリリソースクラスです。 377 //--------------------------------------------------------------------------- 378 class ResVertexLight : public ResLight 379 { 380 public: 381 enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResVertexLight) }; 382 enum { SIGNATURE = NW_RES_SIGNATURE32('CVLT') }; 383 NW_RES_CTOR_INHERIT(ResVertexLight,ResLight)384 NW_RES_CTOR_INHERIT( ResVertexLight, ResLight ) 385 386 //--------------------------------------------------------------------------- 387 //! @fn void SetSpotFactor(f32 x, f32 y) 388 //! @brief スポットライトの角度減衰係数を設定します。 389 //--------------------------------------------------------------------------- 390 //--------------------------------------------------------------------------- 391 //! @fn void SetLightKind(s32 value) 392 //! @brief 光源の種類を設定します。 393 //--------------------------------------------------------------------------- 394 //--------------------------------------------------------------------------- 395 //! @fn void SetDistanceAttenuation(f32 x, f32 y, f32 z) 396 //! @brief 距離減衰のパラメータを設定します。 397 //--------------------------------------------------------------------------- 398 //--------------------------------------------------------------------------- 399 //! @fn void SetDirection(f32 x, f32 y, f32 z) 400 //! @brief ライトの方向を設定します。 401 //--------------------------------------------------------------------------- 402 //--------------------------------------------------------------------------- 403 //! @fn void SetDiffuse(f32 r, f32 g, f32 b) 404 //! @brief ライトのディフューズカラーを設定します。 405 //--------------------------------------------------------------------------- 406 //--------------------------------------------------------------------------- 407 //! @fn void SetAmbient(f32 r, f32 g, f32 b) 408 //! @brief ライトのアンビエントカラーを設定します。 409 //--------------------------------------------------------------------------- 410 //--------------------------------------------------------------------------- 411 //! @fn const nw::math::VEC2 & GetSpotFactor() const 412 //! @brief スポットライトの角度減衰係数を取得します。 413 //--------------------------------------------------------------------------- 414 //--------------------------------------------------------------------------- 415 //! @fn s32 GetLightKind() const 416 //! @brief 光源の種類を取得します。 417 //--------------------------------------------------------------------------- 418 //--------------------------------------------------------------------------- 419 //! @fn const nw::math::VEC3 & GetDistanceAttenuation() const 420 //! @brief 距離減衰のパラメータを取得します。 421 //--------------------------------------------------------------------------- 422 //--------------------------------------------------------------------------- 423 //! @fn const nw::math::VEC3 & GetDirection() const 424 //! @brief ライトの方向を取得します。 425 //--------------------------------------------------------------------------- 426 //--------------------------------------------------------------------------- 427 //! @fn const nw::ut::FloatColor & GetDiffuse() const 428 //! @brief ライトのディフューズカラーを取得します。 429 //--------------------------------------------------------------------------- 430 //--------------------------------------------------------------------------- 431 //! @fn const nw::ut::FloatColor & GetAmbient() const 432 //! @brief ライトのアンビエントカラーを取得します。 433 //--------------------------------------------------------------------------- 434 NW_RES_FIELD_PRIMITIVE_DECL( s32, LightKind ) // GetLightLind(), SetLightKind() 435 NW_RES_FIELD_FLOAT_COLOR_DECL( nw::ut::FloatColor, Ambient ) // const FloatColor& GetAmbient() 436 NW_RES_FIELD_FLOAT_COLOR_DECL( nw::ut::FloatColor, Diffuse ) // const FloatColor& GetDiffuse() 437 NW_RES_FIELD_VECTOR3_DECL( nw::math::VEC3, Direction ) // VEC3& GetDirection() 438 NW_RES_FIELD_VECTOR3_DECL( nw::math::VEC3, DistanceAttenuation ) // VEC3& GetDistanceAttenuation() 439 NW_RES_FIELD_VECTOR2_DECL( nw::math::VEC2, SpotFactor ) // VEC2& GetSpotFactor() 440 441 //--------------------------------------------------------------------------- 442 //! @brief 距離減衰が有効かどうかを取得します。 443 //! 444 //! @return 距離減衰が有効であれば true を返します。 445 //--------------------------------------------------------------------------- 446 bool IsDistanceAttenuationEnabled() const { return ref().m_IsDistanceAttenuationEnabled != 0.0f; } 447 448 //--------------------------------------------------------------------------- 449 //! @brief 距離減衰が有効かどうかを設定します。 450 //! 451 //! @param[in] enable 距離減衰を有効にするためには true を指定します。 452 //--------------------------------------------------------------------------- SetDistanceAttenuationEnabled(bool enable)453 void SetDistanceAttenuationEnabled(bool enable) 454 { 455 ref().m_IsDistanceAttenuationEnabled = enable ? 1.0f : 0.0f; 456 } 457 458 //--------------------------------------------------------------------------- 459 //! @brief DistanceAttenuation と IsDistanceAttenuationEnabled を VEC4 として取得します。 460 //! 461 //! @return w 値に IsDistanceAttenuationEnabled が格納された 4 要素のベクトルです。 462 //--------------------------------------------------------------------------- GetDistanceAttenuationAndEnabled()463 math::VEC4& GetDistanceAttenuationAndEnabled() 464 { 465 return reinterpret_cast<nw::math::VEC4&>( ref().m_DistanceAttenuation ); 466 } 467 468 //--------------------------------------------------------------------------- 469 //! @brief Direction と IsDistanceAttenuationEnabled を VEC4 として取得します。 470 //! 471 //! @return w 値に IsDistanceAttenuationEnabled が格納された 4 要素のベクトルです。 472 //--------------------------------------------------------------------------- GetDistanceAttenuationAndEnabled()473 const math::VEC4& GetDistanceAttenuationAndEnabled() const 474 { 475 return reinterpret_cast<const nw::math::VEC4&>( ref().m_DistanceAttenuation ); 476 } 477 }; 478 479 //-------------------------------------------------------------------------- 480 //! @brief 半球ライトを表すバイナリリソースクラスです。 481 //--------------------------------------------------------------------------- 482 class ResHemiSphereLight : public ResLight 483 { 484 public: 485 enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResHemiSphereLight) }; 486 enum { SIGNATURE = NW_RES_SIGNATURE32('CHLT') }; 487 NW_RES_CTOR_INHERIT(ResHemiSphereLight,ResLight)488 NW_RES_CTOR_INHERIT( ResHemiSphereLight, ResLight ) 489 490 //--------------------------------------------------------------------------- 491 //! @fn void SetSkyColor(f32 r, f32 g, f32 b) 492 //! @brief 空の色を設定します。 493 //--------------------------------------------------------------------------- 494 //--------------------------------------------------------------------------- 495 //! @fn void SetLerpFactor(f32 value) 496 //! @brief 線形補間係数を設定します。 497 //--------------------------------------------------------------------------- 498 //--------------------------------------------------------------------------- 499 //! @fn void SetGroundColor(f32 r, f32 g, f32 b) 500 //! @brief 地面の色を設定します。 501 //--------------------------------------------------------------------------- 502 //--------------------------------------------------------------------------- 503 //! @fn void SetDirection(f32 x, f32 y, f32 z) 504 //! @brief ライトの方向を設定します。 505 //--------------------------------------------------------------------------- 506 //--------------------------------------------------------------------------- 507 //! @fn const nw::ut::FloatColor & GetSkyColor() const 508 //! @brief 空の色を取得します。 509 //--------------------------------------------------------------------------- 510 //--------------------------------------------------------------------------- 511 //! @fn f32 GetLerpFactor() const 512 //! @brief 線形補間係数を取得します。 513 //--------------------------------------------------------------------------- 514 //--------------------------------------------------------------------------- 515 //! @fn const nw::ut::FloatColor & GetGroundColor() const 516 //! @brief 地面の色を取得します。 517 //--------------------------------------------------------------------------- 518 //--------------------------------------------------------------------------- 519 //! @fn const nw::math::VEC3 & GetDirection() const 520 //! @brief ライトの方向を取得します。 521 //--------------------------------------------------------------------------- 522 NW_RES_FIELD_FLOAT_COLOR_DECL( nw::ut::FloatColor, GroundColor ) // FloatColor& GetGroundColor() 523 NW_RES_FIELD_FLOAT_COLOR_DECL( nw::ut::FloatColor, SkyColor ) // FloatColor& GetSkyColor() 524 NW_RES_FIELD_VECTOR3_DECL( nw::math::VEC3, Direction ) // VEC3& GetDirection() 525 NW_RES_FIELD_PRIMITIVE_DECL( f32, LerpFactor ) // GetLerpFactor(), SetLerpFactor() 526 527 //--------------------------------------------------------------------------- 528 //! @brief Direction と Lerp を VEC4 として取得します。 529 //! 530 //! @return w 値に Lerp が格納された 4 要素のベクトルです。 531 //--------------------------------------------------------------------------- 532 nw::math::VEC4& GetDirectionAndLerp() 533 { 534 return reinterpret_cast<nw::math::VEC4&>( ref().m_Direction ); 535 } 536 537 //--------------------------------------------------------------------------- 538 //! @brief Direction と Lerp を VEC4 として取得します。 539 //! 540 //! @return w 値に Lerp が格納された 4 要素のベクトルです。 541 //--------------------------------------------------------------------------- GetDirectionAndLerp()542 const nw::math::VEC4& GetDirectionAndLerp() const 543 { 544 return reinterpret_cast<const nw::math::VEC4&>( ref().m_Direction ); 545 } 546 }; 547 548 } // namespace res 549 } // namespace gfx 550 } // namespace nw 551 552 #endif // NW_GFX_RESLIGHT_H_ 553