mirror of
https://github.com/devZoGok/vb01.git
synced 2026-08-26 19:43:30 +00:00
expanded light sample
minor improvements
This commit is contained in:
+34
-2
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user