mirror of
https://github.com/ApfelTeeSaft/vb01.git
synced 2026-08-26 19:33:45 +00:00
lights color animation reading
This commit is contained in:
@@ -53,6 +53,12 @@ namespace vb01{
|
||||
type = KeyframeChannelType::SCALE_Y;
|
||||
else if(typeString == "scale_z")
|
||||
type = KeyframeChannelType::SCALE_Z;
|
||||
else if(typeString == "diffuse_color_x")
|
||||
type = KeyframeChannelType::DIFFUSE_COLOR_X;
|
||||
else if(typeString == "diffuse_color_y")
|
||||
type = KeyframeChannelType::DIFFUSE_COLOR_Y;
|
||||
else if(typeString == "diffuse_color_z")
|
||||
type = KeyframeChannelType::DIFFUSE_COLOR_Z;
|
||||
else if(typeString == "shape_key_min")
|
||||
type = KeyframeChannelType::SHAPE_KEY_MIN;
|
||||
else if(typeString == "shape_key_value")
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace vb01{
|
||||
SHAPE_KEY_MIN,
|
||||
SHAPE_KEY_VALUE,
|
||||
SHAPE_KEY_MAX,
|
||||
DIFFUSE_COLOR_X,
|
||||
DIFFUSE_COLOR_Y,
|
||||
DIFFUSE_COLOR_Z,
|
||||
SPOTLIGHT_INNER_ANGLE,
|
||||
SPOTLIGHT_OUTER_ANGLE
|
||||
};
|
||||
|
||||
@@ -32,6 +32,15 @@ namespace vb01{
|
||||
|
||||
void Light::animate(float value, KeyframeChannel keyframeChannel){
|
||||
switch(keyframeChannel.type){
|
||||
case KeyframeChannel::DIFFUSE_COLOR_X:
|
||||
color.x = value;
|
||||
break;
|
||||
case KeyframeChannel::DIFFUSE_COLOR_Y:
|
||||
color.y = value;
|
||||
break;
|
||||
case KeyframeChannel::DIFFUSE_COLOR_Z:
|
||||
color.z = value;
|
||||
break;
|
||||
case KeyframeChannel::SPOTLIGHT_INNER_ANGLE:
|
||||
innerAngle = value;
|
||||
break;
|
||||
|
||||
@@ -120,11 +120,13 @@ def exportData(ob):
|
||||
|
||||
|
||||
file.write('animations: ' + str(numAnims) + '\n')
|
||||
if ob.type != 'LIGHT' and numAnims > 0:
|
||||
readAnimations(ob, numAnims)
|
||||
elif ob.type == 'LIGHT':
|
||||
readAnimations(ob, len(ob.animation_data.nla_tracks[0].strips))
|
||||
readAnimations(ob.data, len(ob.data.animation_data.nla_tracks[0].strips))
|
||||
if numAnims > 0:
|
||||
if ob.type == 'LIGHT':
|
||||
readAnimations(ob, len(ob.animation_data.nla_tracks[0].strips))
|
||||
if(ob.data.animation_data is not None and len(ob.data.animation_data.nla_tracks) > 0):
|
||||
readAnimations(ob.data, len(ob.data.animation_data.nla_tracks[0].strips))
|
||||
else:
|
||||
readAnimations(ob, numAnims)
|
||||
|
||||
if ob.animation_data is not None:
|
||||
channels.extend(ob.animation_data.drivers)
|
||||
@@ -152,6 +154,8 @@ def getChannelType(channel):
|
||||
channelType = 'rot_' + coords[arrInd]
|
||||
elif coordType == 'scale':
|
||||
channelType = 'scale_' + coords[arrInd + 1]
|
||||
elif coordType == 'color':
|
||||
channelType = 'diffuse_color_' + coords[arrInd + 1]
|
||||
elif coordType == 'slider_min':
|
||||
channelType = 'shape_key_min'
|
||||
elif coordType == 'value':
|
||||
|
||||
+11
-1
@@ -238,7 +238,12 @@ namespace vb01{
|
||||
int keyframeStartLine = keyframeChannelStartLine + 1;
|
||||
|
||||
KeyframeChannel keyframeChannel;
|
||||
keyframeChannel.animatable = (animatable || !currentSkeleton ? animatable : currentSkeleton->getBone(animatableName));
|
||||
if(currentSkeleton)
|
||||
keyframeChannel.animatable = currentSkeleton->getBone(animatableName);
|
||||
else if(currentLight)
|
||||
keyframeChannel.animatable = ((Node*)animatable)->getLight(0);
|
||||
else
|
||||
keyframeChannel.animatable = animatable;
|
||||
keyframeChannel.type = KeyframeChannel::getKeyframeChannelType(typeStr);
|
||||
|
||||
for(int k = 0; k < numKeyframes; k++){
|
||||
@@ -568,6 +573,7 @@ namespace vb01{
|
||||
getLineData(lightData[3].substr(lightData[3].find_first_of(':') + 2), data, 3);
|
||||
Vector3 scale = Vector3(atof(data[0].c_str()), atof(data[1].c_str()) + 2, atof(data[2].c_str()));
|
||||
string parent = lightData[4].substr(lightData[4].find_first_of(':') + 2);
|
||||
relationships.emplace(name, parent);
|
||||
|
||||
string typeStr = lightData[5].substr(lightData[5].find_first_of(':') + 2);
|
||||
Light::Type type;
|
||||
@@ -588,9 +594,11 @@ namespace vb01{
|
||||
light->setColor(color);
|
||||
light->setOuterAngle(outerAngle);
|
||||
light->setInnerAngle(innerAngle);
|
||||
currentLight = light;
|
||||
|
||||
AnimationController *controller = new AnimationController();
|
||||
Node *node = new Node(pos, rot, scale, name, controller);
|
||||
node->addLight(light);
|
||||
nodes.push_back(node);
|
||||
|
||||
int animationStartLine = 9;
|
||||
@@ -602,6 +610,8 @@ namespace vb01{
|
||||
lightSubData = vector<string>(lightData.begin() + driverStartLine, lightData.end());
|
||||
readDrivers(lightSubData, name);
|
||||
lightSubData.clear();
|
||||
|
||||
currentLight = nullptr;
|
||||
}
|
||||
|
||||
int VbModelReader::findDriverStartLine(vector<string> &data, int animationStartLine){
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace vb01{
|
||||
std::map<std::string, std::string> relationships;
|
||||
std::vector<std::string*> driverSetups;
|
||||
Skeleton *currentSkeleton = nullptr;
|
||||
Light *currentLight = nullptr;
|
||||
std::vector<Skeleton*> skeletons;
|
||||
std::vector<Mesh*> meshes;
|
||||
std::vector<Node*> nodes;
|
||||
|
||||
Reference in New Issue
Block a user