expanded light sample

minor improvements
This commit is contained in:
devZoGok
2021-10-19 19:06:41 +03:00
parent 1d102d091f
commit 9aa2981e70
11 changed files with 60 additions and 14 deletions
+34 -2
View File
@@ -3,6 +3,9 @@
#include "material.h"
#include "node.h"
#include "light.h"
#include "animation.h"
#include "animationController.h"
#include "animationChannel.h"
using namespace std;
using namespace vb01;
@@ -43,11 +46,40 @@ int main(){
Light *light = new Light(Light::SPOT);
light->setColor(Vector3(1, 1, 1));
Node *lightNode = new Node();
Node *lightNode = new Node(Vector3::VEC_ZERO, Quaternion::QUAT_W, Vector3::VEC_IJK, "", new AnimationController());
lightNode->addLight(light);
rootNode->attachChild(lightNode);
lightNode->setOrientation(Quaternion(1.57, Vector3(1, 0, 0)));
lightNode->setPosition(Vector3(0, 2, 0));
lightNode->setPosition(Vector3(0, 5, 0));
KeyframeChannel kcA;
kcA.animatable = light;
kcA.type = KeyframeChannel::SPOTLIGHT_OUTER_ANGLE;
kcA.keyframes = vector<Keyframe>({
KeyframeChannel::createKeyframe(Keyframe::LINEAR, .1, 1),
KeyframeChannel::createKeyframe(Keyframe::LINEAR, .7, 60),
KeyframeChannel::createKeyframe(Keyframe::LINEAR, .9, 120)
});
KeyframeChannel kcB;
kcA.animatable = light;
kcA.type = KeyframeChannel::SPOTLIGHT_INNER_ANGLE;
kcA.keyframes = vector<Keyframe>({
KeyframeChannel::createKeyframe(Keyframe::LINEAR, .1, 1),
KeyframeChannel::createKeyframe(Keyframe::LINEAR, .7, 60)
});
Animation *animation = new Animation("spotlightAnim");
animation->addKeyframeChannel(kcA);
animation->addKeyframeChannel(kcB);
AnimationController *controller = lightNode->getAnimationController();
controller->addAnimation(animation);
AnimationChannel *channel = new AnimationChannel();
controller->addAnimationChannel(channel);
channel->addAnimatable(light);
channel->setLoop(true);
channel->setAnimationName("spotlightAnim");
while(true)
root->update();