diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 37ed9b096b..53450e112e 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1803,10 +1803,10 @@ B60C5BD519AC68B10056FBDE /* CCBillBoard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */; }; B60C5BD619AC68B10056FBDE /* CCBillBoard.h in Headers */ = {isa = PBXBuildFile; fileRef = B60C5BD319AC68B10056FBDE /* CCBillBoard.h */; }; B60C5BD719AC68B10056FBDE /* CCBillBoard.h in Headers */ = {isa = PBXBuildFile; fileRef = B60C5BD319AC68B10056FBDE /* CCBillBoard.h */; }; - B6C039DD19C95E03007207DC /* CCLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6C039DB19C95E03007207DC /* CCLight.cpp */; }; - B6C039DE19C95E03007207DC /* CCLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6C039DB19C95E03007207DC /* CCLight.cpp */; }; - B6C039DF19C95E03007207DC /* CCLight.h in Headers */ = {isa = PBXBuildFile; fileRef = B6C039DC19C95E03007207DC /* CCLight.h */; }; - B6C039E019C95E03007207DC /* CCLight.h in Headers */ = {isa = PBXBuildFile; fileRef = B6C039DC19C95E03007207DC /* CCLight.h */; }; + B6C039DD19C95E03007207DC /* CCLight3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6C039DB19C95E03007207DC /* CCLight3D.cpp */; }; + B6C039DE19C95E03007207DC /* CCLight3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6C039DB19C95E03007207DC /* CCLight3D.cpp */; }; + B6C039DF19C95E03007207DC /* CCLight3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6C039DC19C95E03007207DC /* CCLight3D.h */; }; + B6C039E019C95E03007207DC /* CCLight3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6C039DC19C95E03007207DC /* CCLight3D.h */; }; ED9C6A9418599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; }; ED9C6A9518599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; }; ED9C6A9618599AD8000A5232 /* CCNodeGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */; }; @@ -2792,8 +2792,8 @@ B3AF019F1842FBA400A98B85 /* b2MotorJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b2MotorJoint.h; sourceTree = ""; }; B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBillBoard.cpp; sourceTree = ""; }; B60C5BD319AC68B10056FBDE /* CCBillBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBillBoard.h; sourceTree = ""; }; - B6C039DB19C95E03007207DC /* CCLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLight.cpp; sourceTree = ""; }; - B6C039DC19C95E03007207DC /* CCLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLight.h; sourceTree = ""; }; + B6C039DB19C95E03007207DC /* CCLight3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLight3D.cpp; sourceTree = ""; }; + B6C039DC19C95E03007207DC /* CCLight3D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLight3D.h; sourceTree = ""; }; ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCNodeGrid.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeGrid.h; sourceTree = ""; }; /* End PBXFileReference section */ @@ -4739,8 +4739,8 @@ B29594B81926D61F003EEF37 /* 3d */ = { isa = PBXGroup; children = ( - B6C039DB19C95E03007207DC /* CCLight.cpp */, - B6C039DC19C95E03007207DC /* CCLight.h */, + B6C039DB19C95E03007207DC /* CCLight3D.cpp */, + B6C039DC19C95E03007207DC /* CCLight3D.h */, B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */, B60C5BD319AC68B10056FBDE /* CCBillBoard.h */, 15AE17E319AAD2F700C27E9E /* 3dExport.h */, @@ -4835,7 +4835,7 @@ 15AE1A6D19AAD40300C27E9E /* b2ChainAndPolygonContact.h in Headers */, 15AE183A19AAD2F700C27E9E /* CCRay.h in Headers */, 15AE19E919AAD3A700C27E9E /* Slot.h in Headers */, - B6C039DF19C95E03007207DC /* CCLight.h in Headers */, + B6C039DF19C95E03007207DC /* CCLight3D.h in Headers */, B375107B1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */, 15AE18A319AAD33D00C27E9E /* CCParticleSystemQuadLoader.h in Headers */, 46A170F01807CECA005B8026 /* CCPhysicsWorld.h in Headers */, @@ -5710,7 +5710,7 @@ 1A01C6A718F58F7500EFE3A6 /* CCNotificationCenter.h in Headers */, 50ABBEDA1925AB6F00A911A9 /* ZipUtils.h in Headers */, 50ABBDC01925AB4100A911A9 /* CCTextureCache.h in Headers */, - B6C039E019C95E03007207DC /* CCLight.h in Headers */, + B6C039E019C95E03007207DC /* CCLight3D.h in Headers */, B276EF641988D1D500CD400F /* CCVertexIndexBuffer.h in Headers */, 15AE1A0619AAD3A700C27E9E /* Bone.h in Headers */, ED9C6A9718599AD8000A5232 /* CCNodeGrid.h in Headers */, @@ -5881,7 +5881,7 @@ 15AE1BDC19AAE01E00C27E9E /* CCControlUtils.cpp in Sources */, 50ABBEC51925AB6F00A911A9 /* etc1.cpp in Sources */, 50643BDE19BFCCA400EF68ED /* LocalStorage-android.cpp in Sources */, - B6C039DD19C95E03007207DC /* CCLight.cpp in Sources */, + B6C039DD19C95E03007207DC /* CCLight3D.cpp in Sources */, 15AE1B5B19AADA9900C27E9E /* UITextAtlas.cpp in Sources */, 1A570065180BC5A10088DEC7 /* CCActionCamera.cpp in Sources */, 50ABBEAB1925AB6F00A911A9 /* ccTypes.cpp in Sources */, @@ -6614,7 +6614,7 @@ 15AE196719AAD35100C27E9E /* CCUtilMath.cpp in Sources */, 50ABBE201925AB6F00A911A9 /* atitc.cpp in Sources */, 50ABBE9A1925AB6F00A911A9 /* CCRef.cpp in Sources */, - B6C039DE19C95E03007207DC /* CCLight.cpp in Sources */, + B6C039DE19C95E03007207DC /* CCLight3D.cpp in Sources */, 15AE18BF19AAD33D00C27E9E /* CCLabelTTFLoader.cpp in Sources */, 15AE1B9519AADA9A00C27E9E /* CocosGUI.cpp in Sources */, 15AE1A0D19AAD3A700C27E9E /* extension.cpp in Sources */, diff --git a/cocos/3d/CCLight.h b/cocos/3d/CCLight.h deleted file mode 100644 index 2b633ce557..0000000000 --- a/cocos/3d/CCLight.h +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __CCLIGHT_H__ -#define __CCLIGHT_H__ - -#include "2d/CCNode.h" -#include "3d/3dExport.h" - -NS_CC_BEGIN - -class CC_3D_DLL Light3D : public Node -{ -public: - - enum class LightType - { - DIRECTIONAL = 0, - POINT = 1, - SPOT = 2 - }; - - /** - * Create light according to type. - */ - static Light3D* createDirectionalLight(const Vec3 &direction, const Color3B &color); - static Light3D* createPointLight(const Vec3 &position, const Color3B &color, float range); - static Light3D* createSpotLight(const Vec3 &direction, const Vec3 &position, const Color3B &color, float innerAngle, float outerAngle, float range); - - //override - virtual void onEnter() override; - virtual void onExit() override; - - /** - * Gets light type. - */ - LightType getLightType(); - - /** - * Sets Light Enabled. - */ - void setEnabled(bool enabled); - - /** - * Gets Light Enabled. - */ - bool getEnabled(); - - - /** - * Sets the range of point or spot light. - * - * @param range The range of point or spot light. - */ - void setRange(float range); - - /** - * Returns the range of point or spot light. - * - * @return The range of the point or spot light. - */ - float getRange(); - - /** - * Sets the Direction of Directional light or Spot light. - * - * @param dir The Direction of the Directional light or Spot light. - */ - void setDirection(const Vec3 &dir); - - /** - * Returns the Direction of Directional light or Spot light. - * - * @return dir Direction of the Directional light or Spot light. - */ - Vec3 getDirection() const; - - /** - * Returns the World coordinate Direction of Directional light or Spot light. - * - * @return dir the World coordinate Direction of the Directional light or Spot light. - */ - Vec3 getWorldDirection() const; - - /** - * Sets the inner angle of a spot light (in radians). - * - * @param angle The angle of spot light (in radians). - */ - void setInnerAngle(float angle); - - /** - * Returns the inner angle the spot light (in radians). - * - * @return The inner angle of the spot light (in radians). - */ - float getInnerAngle(); - - /** - * Sets the outer angle of a spot light (in radians). - * - * @param outerAngle The angle of spot light (in radians). - */ - void setOuterAngle(float angle); - - /** - * Returns the outer angle of the spot light (in radians). - * - * @return The outer angle of the spot light (in radians). - */ - float getOuterAngle(); - -CC_CONSTRUCTOR_ACCESS: - - Light3D(); - virtual ~Light3D(); - -protected: - - /** - * Sets light type. - */ - void setLightType(LightType lightType); - void calculateRotation(const Vec3 &direction); - -protected: - - LightType _lightType; - bool _isEnabled; - float _range; - float _innerAngle; - float _outerAngle; -}; - -NS_CC_END - -#endif \ No newline at end of file diff --git a/cocos/3d/CCLight.cpp b/cocos/3d/CCLight3D.cpp similarity index 58% rename from cocos/3d/CCLight.cpp rename to cocos/3d/CCLight3D.cpp index f9482641f6..3a623c3190 100644 --- a/cocos/3d/CCLight.cpp +++ b/cocos/3d/CCLight3D.cpp @@ -1,8 +1,153 @@ -#include "CCLight.h" +#include "CCLight3D.h" #include "2d/CCScene.h" NS_CC_BEGIN +void BaseLight3D::setIntensity(float intensity) +{ + CC_ASSERT(intensity >= 0); + _intensity = intensity; +} + +void BaseLight3D::onEnter() +{ + auto scene = getScene(); + if (scene) + { + auto &lights = scene->_lights; + auto iter = std::find(lights.begin(), lights.end(), this); + if (iter == lights.end()) + lights.push_back(this); + } + Node::onEnter(); +} +void BaseLight3D::onExit() +{ + auto scene = getScene(); + if (scene) + { + auto &lights = scene->_lights; + auto iter = std::find(lights.begin(), lights.end(), this); + if (iter != lights.end()) + lights.erase(iter); + } + Node::onExit(); +} + +BaseLight3D::BaseLight3D() +: _intensity(1.0f) +, _enabled(true) +, _lightFlag(LightFlag::LIGHT0) +{ + +} +BaseLight3D::~BaseLight3D() +{ + +} + + +//////////////////////////////////////////////////////////////////// +DirectionLight3D* DirectionLight3D::create(const Vec3 &direction, const Color3B &color) +{ + +} + +void DirectionLight3D::setDirection(const Vec3 &dir) +{ + +} +const Vec3& DirectionLight3D::getDirection() const +{ + static Vec3 dir; + Mat4 mat = getNodeToParentTransform(); + dir.set(-mat.m[8], -mat.m[9], -mat.m[10]); + return dir; +} +const Vec3& DirectionLight3D::getDirectionInWorld() const +{ + static Vec3 dir; + Mat4 mat = getNodeToWorldTransform(); + dir.set(-mat.m[8], -mat.m[9], -mat.m[10]); + return dir; +} +DirectionLight3D::DirectionLight3D() +{ + +} +DirectionLight3D::~DirectionLight3D() +{ + +} + +////////////////////////////////////////////////////////////////// +PointLight3D* PointLight3D::create(const Vec3 &position, const Color3B &color, float range) +{ + +} + +PointLight3D::PointLight3D() +{ + +} +PointLight3D::~PointLight3D() +{ + +} + +////////////////////////////////////////////////////////////// +SpotLight3D* SpotLight3D::create(const Vec3 &direction, const Vec3 &position, const Color3B &color, float innerAngle, float outerAngle, float range) +{ + +} + +void SpotLight3D::setDirection(const Vec3 &dir) +{ + +} + +const Vec3& SpotLight3D::getDirection() const +{ + +} + +const Vec3& SpotLight3D::getDirectionInWorld() const +{ + +} + +void SpotLight3D::setRange(float range) +{ + +} + +float SpotLight3D::getRange() +{ + +} + +void SpotLight3D::setInnerAngle(float angle) +{ + +} + +float SpotLight3D::getInnerAngle() +{ + +} + +void SpotLight3D::setOuterAngle(float angle) +{ + +} + +float SpotLight3D::getOuterAngle() +{ + +} + +///////////////////////////////////////////////////////////// + Light3D::Light3D() : _isEnabled(true) , _range(0.0) diff --git a/cocos/3d/CCLight3D.h b/cocos/3d/CCLight3D.h new file mode 100644 index 0000000000..48c03a4c73 --- /dev/null +++ b/cocos/3d/CCLight3D.h @@ -0,0 +1,385 @@ +/**************************************************************************** + Copyright (c) 2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __CCLIGHT_H__ +#define __CCLIGHT_H__ + +#include "2d/CCNode.h" +#include "3d/3dExport.h" + +NS_CC_BEGIN + +enum class LightType +{ + DIRECTIONAL = 0, + POINT = 1, + SPOT = 2, + AMBIENT = 3, +}; + +enum class LightFlag +{ + LIGHT0 = 1, + LIGHT1 = 1 << 1, + LIGHT2 = 1 << 2, + LIGHT3 = 1 << 3, + LIGHT4 = 1 << 4, + LIGHT5 = 1 << 5, + LIGHT6 = 1 << 6, + LIGHT7 = 1 << 7, + LIGHT8 = 1 << 8, + LIGHT9 = 1 << 9, + LIGHT10 = 1 << 10, + LIGHT11 = 1 << 11, + LIGHT12 = 1 << 12, + LIGHT13 = 1 << 13, + LIGHT14 = 1 << 14, + LIGHT15 = 1 << 15, +}; + +class CC_3D_DLL BaseLight3D : public Node +{ +public: + + //get light type + virtual LightType getLightType() = 0; + + /** intensity getter and setter */ + float getIntensity() const { return _intensity; } + void setIntensity(float intensity); + + /**light flag getter and setter*/ + LightFlag getLightFlag() const { return _lightFlag; } + void setLightFlag(LightFlag flag) { _lightFlag = flag; } + + /** + * light enabled getter and setter. + */ + void setEnabled(bool enabled) { _enabled = enabled; } + bool isEnabled() const { return _enabled; } + + //override + virtual void onEnter() override; + virtual void onExit() override; + +CC_CONSTRUCTOR_ACCESS: + BaseLight3D(); + virtual ~BaseLight3D(); + +protected: + float _intensity; + LightFlag _lightFlag; + bool _enabled; +}; + +class CC_3D_DLL DirectionLight3D : public BaseLight3D +{ +public: + //get light type + virtual LightType getLightType() { return LightType::DIRECTIONAL; } + /** + * Creates a direction light. + * @param direction The light's direction + * @param color The light's color. + * + * @return The new direction light. + */ + static DirectionLight3D* create(const Vec3 &direction, const Color3B &color); + + /** + * Sets the Direction in parent. + * + * @param dir The Direction in parent. + */ + void setDirection(const Vec3 &dir); + + /** + * Returns the Direction in parent. + */ + const Vec3& getDirection() const; + + /** + * Returns direction in world. + */ + const Vec3& getDirectionInWorld() const; + +CC_CONSTRUCTOR_ACCESS: + DirectionLight3D(); + virtual ~DirectionLight3D(); + +}; + +class CC_3D_DLL PointLight3D : public BaseLight3D +{ +public: + //get light type + virtual LightType getLightType() { return LightType::POINT; } + /** + * Creates a point light. + * @param position The light's position + * @param color The light's color. + * @param range The light's range. + * + * @return The new point light. + */ + static PointLight3D* create(const Vec3 &position, const Color3B &color, float range); + +CC_CONSTRUCTOR_ACCESS: + PointLight3D(); + virtual ~PointLight3D(); +}; + +class CC_3D_DLL SpotLight3D : public BaseLight3D +{ +public: + //get light type + virtual LightType getLightType() { return LightType::SPOT; } + /** + * Creates a spot light. + * @param direction The light's direction + * @param position The light's position + * @param color The light's color. + * @param innerAngle The light's inner angle (in radians). + * @param outerAngle The light's outer angle (in radians). + * @param range The light's range. + * + * @return The new spot light. + */ + static SpotLight3D* create(const Vec3 &direction, const Vec3 &position, const Color3B &color, float innerAngle, float outerAngle, float range); + + /** + * Sets the Direction in parent. + * + * @param dir The Direction in parent. + */ + void setDirection(const Vec3 &dir); + + /** + * Returns the Direction in parent. + */ + const Vec3& getDirection() const; + + /** + * Returns direction in world. + */ + const Vec3& getDirectionInWorld() const; + + /** + * Sets the range of point or spot light. + * + * @param range The range of point or spot light. + */ + void setRange(float range) { _range = range; } + + /** + * Returns the range of point or spot light. + * + * @return The range of the point or spot light. + */ + float getRange() const { return _range; } + /** + * Sets the inner angle of a spot light (in radians). + * + * @param angle The angle of spot light (in radians). + */ + void setInnerAngle(float angle); + + /** + * Returns the inner angle the spot light (in radians). + */ + float getInnerAngle() const { return _innerAngle; } + + /** get cos innerAngle */ + float getCosInnerAngle() const { return _cosInnerAngle; } + + /** + * Sets the outer angle of a spot light (in radians). + * + * @param outerAngle The angle of spot light (in radians). + */ + void setOuterAngle(float angle); + + /** + * Returns the outer angle of the spot light (in radians). + */ + float getOuterAngle() const { return _outerAngle; } + + /** get cos outAngle */ + float getCosOuterAngle() const { return _cosInnerAngle; } + +CC_CONSTRUCTOR_ACCESS: + SpotLight3D(); + virtual ~SpotLight3D(); + +protected: + float _range; + float _innerAngle; + float _cosInnerAngle; + float _outerAngle; + float _cosOuterAngle; +}; + +class CC_3D_DLL AmbientLight3D : public BaseLight3D +{ +public: + virtual LightType getLightType() { return LightType::AMBIENT; } + /** + * Creates a ambient light. + * @param color The light's color. + * + * @return The new ambient light. + */ + static AmbientLight3D* create(const Color3B &color); + +CC_CONSTRUCTOR_ACCESS: + AmbientLight3D() {} + virtual ~AmbientLight3D() {} +}; + +class CC_3D_DLL Light3D : public Node +{ +public: + + enum class LightType + { + DIRECTIONAL = 0, + POINT = 1, + SPOT = 2 + }; + + /** + * Create light according to type. + */ + static Light3D* createDirectionalLight(const Vec3 &direction, const Color3B &color); + static Light3D* createPointLight(const Vec3 &position, const Color3B &color, float range); + static Light3D* createSpotLight(const Vec3 &direction, const Vec3 &position, const Color3B &color, float innerAngle, float outerAngle, float range); + + //override + virtual void onEnter() override; + virtual void onExit() override; + + /** + * Gets light type. + */ + LightType getLightType(); + + /** + * Sets Light Enabled. + */ + void setEnabled(bool enabled); + + /** + * Gets Light Enabled. + */ + bool getEnabled(); + + + /** + * Sets the range of point or spot light. + * + * @param range The range of point or spot light. + */ + void setRange(float range); + + /** + * Returns the range of point or spot light. + * + * @return The range of the point or spot light. + */ + float getRange(); + + /** + * Sets the Direction of Directional light or Spot light. + * + * @param dir The Direction of the Directional light or Spot light. + */ + void setDirection(const Vec3 &dir); + + /** + * Returns the Direction of Directional light or Spot light. + * + * @return dir Direction of the Directional light or Spot light. + */ + Vec3 getDirection() const; + + /** + * Returns the World coordinate Direction of Directional light or Spot light. + * + * @return dir the World coordinate Direction of the Directional light or Spot light. + */ + Vec3 getWorldDirection() const; + + /** + * Sets the inner angle of a spot light (in radians). + * + * @param angle The angle of spot light (in radians). + */ + void setInnerAngle(float angle); + + /** + * Returns the inner angle the spot light (in radians). + * + * @return The inner angle of the spot light (in radians). + */ + float getInnerAngle(); + + /** + * Sets the outer angle of a spot light (in radians). + * + * @param outerAngle The angle of spot light (in radians). + */ + void setOuterAngle(float angle); + + /** + * Returns the outer angle of the spot light (in radians). + * + * @return The outer angle of the spot light (in radians). + */ + float getOuterAngle(); + +CC_CONSTRUCTOR_ACCESS: + + Light3D(); + virtual ~Light3D(); + +protected: + + /** + * Sets light type. + */ + void setLightType(LightType lightType); + void calculateRotation(const Vec3 &direction); + +protected: + + LightType _lightType; + bool _isEnabled; + float _range; + float _innerAngle; + float _outerAngle; +}; + +NS_CC_END + +#endif \ No newline at end of file