forked from bartvdbraak/blender
Import light blender profile if it exists.
This commit is contained in:
parent
e5bf21898e
commit
bd9854e7d1
@ -103,7 +103,7 @@ DocumentImporter::DocumentImporter(bContext *C, const char *filename) :
|
||||
|
||||
DocumentImporter::~DocumentImporter()
|
||||
{
|
||||
std::map<COLLADAFW::UniqueId, ExtraTags*>::iterator etit;
|
||||
TagsMap::iterator etit;
|
||||
etit = uid_tags_map.begin();
|
||||
while(etit!=uid_tags_map.end()) {
|
||||
delete etit->second;
|
||||
@ -867,6 +867,12 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
|
||||
Lamp *lamp = NULL;
|
||||
std::string la_id, la_name;
|
||||
|
||||
TagsMap::iterator etit;
|
||||
ExtraTags *et = 0;
|
||||
etit = uid_tags_map.find(light->getUniqueId().toAscii());
|
||||
if(etit != uid_tags_map.end())
|
||||
et = etit->second;
|
||||
|
||||
la_id = light->getOriginalId();
|
||||
la_name = light->getName();
|
||||
if (la_name.size()) lamp = (Lamp*)add_lamp((char*)la_name.c_str());
|
||||
@ -954,6 +960,61 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(et) {
|
||||
et->setData("type", &(lamp->type));
|
||||
et->setData("flag", &(lamp->flag));
|
||||
et->setData("mode", &(lamp->mode));
|
||||
et->setData("gamma", &(lamp->k));
|
||||
et->setData("shadow_r", &(lamp->shdwr));
|
||||
et->setData("shadow_g", &(lamp->shdwg));
|
||||
et->setData("shadow_b", &(lamp->shdwb));
|
||||
et->setData("energy", &(lamp->energy));
|
||||
et->setData("dist", &(lamp->dist));
|
||||
et->setData("spotsize", &(lamp->spotsize));
|
||||
et->setData("spotblend", &(lamp->spotblend));
|
||||
et->setData("halo_intensity", &(lamp->haint));
|
||||
et->setData("att1", &(lamp->att1));
|
||||
et->setData("att2", &(lamp->att2));
|
||||
et->setData("falloff_type", &(lamp->falloff_type));
|
||||
et->setData("clipsta", &(lamp->clipsta));
|
||||
et->setData("clipend", &(lamp->clipend));
|
||||
et->setData("shadspotsize", &(lamp->shadspotsize));
|
||||
et->setData("bias", &(lamp->bias));
|
||||
et->setData("soft", &(lamp->soft));
|
||||
et->setData("compressthresh", &(lamp->compressthresh));
|
||||
et->setData("bufsize", &(lamp->bufsize));
|
||||
et->setData("samp", &(lamp->samp));
|
||||
et->setData("buffers", &(lamp->buffers));
|
||||
et->setData("filtertype", &(lamp->filtertype));
|
||||
et->setData("bufflag", &(lamp->bufflag));
|
||||
et->setData("buftype", &(lamp->buftype));
|
||||
et->setData("ray_samp", &(lamp->ray_samp));
|
||||
et->setData("ray_sampy", &(lamp->ray_sampy));
|
||||
et->setData("ray_sampz", &(lamp->ray_sampz));
|
||||
et->setData("ray_samp_type", &(lamp->ray_samp_type));
|
||||
et->setData("area_shape", &(lamp->area_shape));
|
||||
et->setData("area_size", &(lamp->area_size));
|
||||
et->setData("area_sizey", &(lamp->area_sizey));
|
||||
et->setData("area_sizez", &(lamp->area_sizez));
|
||||
et->setData("adapt_thresh", &(lamp->adapt_thresh));
|
||||
et->setData("ray_samp_method", &(lamp->ray_samp_method));
|
||||
et->setData("shadhalostep", &(lamp->shadhalostep));
|
||||
et->setData("sun_effect_type", &(lamp->shadhalostep));
|
||||
et->setData("skyblendtype", &(lamp->skyblendtype));
|
||||
et->setData("horizon_brightness", &(lamp->horizon_brightness));
|
||||
et->setData("spread", &(lamp->spread));
|
||||
et->setData("sun_brightness", &(lamp->sun_brightness));
|
||||
et->setData("sun_size", &(lamp->sun_size));
|
||||
et->setData("backscattered_light", &(lamp->backscattered_light));
|
||||
et->setData("sun_intensity", &(lamp->sun_intensity));
|
||||
et->setData("atm_turbidity", &(lamp->atm_turbidity));
|
||||
et->setData("atm_extinction_factor", &(lamp->atm_extinction_factor));
|
||||
et->setData("atm_distance_factor", &(lamp->atm_distance_factor));
|
||||
et->setData("skyblendfac", &(lamp->skyblendfac));
|
||||
et->setData("sky_exposure", &(lamp->sky_exposure));
|
||||
et->setData("sky_colorspace", &(lamp->sky_colorspace));
|
||||
}
|
||||
|
||||
this->uid_lamp_map[light->getUniqueId()] = lamp;
|
||||
return true;
|
||||
@ -1007,15 +1068,15 @@ bool DocumentImporter::writeKinematicsScene( const COLLADAFW::KinematicsScene* k
|
||||
|
||||
ExtraTags* DocumentImporter::getExtraTags(const COLLADAFW::UniqueId &uid)
|
||||
{
|
||||
if(uid_tags_map.find(uid)==uid_tags_map.end()) {
|
||||
if(uid_tags_map.find(uid.toAscii())==uid_tags_map.end()) {
|
||||
return NULL;
|
||||
}
|
||||
return uid_tags_map[uid];
|
||||
return uid_tags_map[uid.toAscii()];
|
||||
}
|
||||
|
||||
bool DocumentImporter::addExtraTags( const COLLADAFW::UniqueId &uid, ExtraTags *extra_tags)
|
||||
{
|
||||
uid_tags_map[uid] = extra_tags;
|
||||
uid_tags_map[uid.toAscii()] = extra_tags;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -139,13 +139,17 @@ private:
|
||||
ArmatureImporter armature_importer;
|
||||
MeshImporter mesh_importer;
|
||||
AnimationImporter anim_importer;
|
||||
|
||||
/** TagsMap typedef for uid_tags_map. */
|
||||
typedef std::map<std::string, ExtraTags*> TagsMap;
|
||||
/** Tags map of unique id as a string and ExtraTags instance. */
|
||||
TagsMap uid_tags_map;
|
||||
|
||||
std::map<COLLADAFW::UniqueId, Image*> uid_image_map;
|
||||
std::map<COLLADAFW::UniqueId, Material*> uid_material_map;
|
||||
std::map<COLLADAFW::UniqueId, Material*> uid_effect_map;
|
||||
std::map<COLLADAFW::UniqueId, Camera*> uid_camera_map;
|
||||
std::map<COLLADAFW::UniqueId, Lamp*> uid_lamp_map;
|
||||
std::map<COLLADAFW::UniqueId, ExtraTags*> uid_tags_map;
|
||||
std::map<Material*, TexIndexTextureArrayMap> material_texture_mapping_map;
|
||||
std::map<COLLADAFW::UniqueId, Object*> object_map;
|
||||
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> node_map;
|
||||
|
@ -47,9 +47,6 @@ bool ExtraHandler::elementBegin( const char* elementName, const char** attribute
|
||||
|
||||
bool ExtraHandler::elementEnd(const char* elementName )
|
||||
{
|
||||
currentUid = COLLADAFW::UniqueId();
|
||||
currentExtraTags = 0;
|
||||
currentElement.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -60,7 +57,7 @@ bool ExtraHandler::textData(const char* text, size_t textLength)
|
||||
if(currentElement.length() == 0) return false;
|
||||
|
||||
BLI_snprintf(buf, textLength+1, "%s", text);
|
||||
currentExtraTags->addTag(std::string(currentElement), std::string(buf));
|
||||
currentExtraTags->addTag(currentElement, std::string(buf));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -33,18 +33,84 @@
|
||||
|
||||
#include "ExtraTags.h"
|
||||
|
||||
ExtraTags::ExtraTags(const std::string profile)
|
||||
ExtraTags::ExtraTags( std::string profile)
|
||||
{
|
||||
this->profile = profile;
|
||||
this->tags = std::map<std::string, std::string>();
|
||||
}
|
||||
|
||||
ExtraTags::~ExtraTags()
|
||||
{
|
||||
}
|
||||
|
||||
bool ExtraTags::addTag(const std::string tag, const std::string data)
|
||||
bool ExtraTags::addTag( std::string tag, std::string data)
|
||||
{
|
||||
std::cout << "ready to add " << tag << ": " << data << "." << std::endl;
|
||||
tags[tag] = data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int ExtraTags::asInt( std::string tag, bool *ok)
|
||||
{
|
||||
if(tags.find(tag) == tags.end()) {
|
||||
*ok = false;
|
||||
return -1;
|
||||
}
|
||||
*ok = true;
|
||||
return atoi(tags[tag].c_str());
|
||||
}
|
||||
|
||||
float ExtraTags::asFloat( std::string tag, bool *ok)
|
||||
{
|
||||
if(tags.find(tag) == tags.end()) {
|
||||
*ok = false;
|
||||
return -1.0f;
|
||||
}
|
||||
*ok = true;
|
||||
return (float)atof(tags[tag].c_str());
|
||||
}
|
||||
|
||||
std::string ExtraTags::asString( std::string tag, bool *ok)
|
||||
{
|
||||
if(tags.find(tag) == tags.end()) {
|
||||
*ok = false;
|
||||
return "";
|
||||
}
|
||||
*ok = true;
|
||||
return tags[tag];
|
||||
}
|
||||
|
||||
|
||||
void ExtraTags::setData(std::string tag, short *data)
|
||||
{
|
||||
bool ok = false;
|
||||
int tmp = 0;
|
||||
tmp = asInt(tag, &ok);
|
||||
if(ok)
|
||||
*data = (short)tmp;
|
||||
}
|
||||
void ExtraTags::setData(std::string tag, int *data)
|
||||
{
|
||||
bool ok = false;
|
||||
int tmp = 0;
|
||||
tmp = asInt(tag, &ok);
|
||||
if(ok)
|
||||
*data = tmp;
|
||||
}
|
||||
void ExtraTags::setData(std::string tag, float *data)
|
||||
{
|
||||
bool ok = false;
|
||||
float tmp = 0.0f;
|
||||
tmp = asFloat(tag, &ok);
|
||||
if(ok)
|
||||
*data = tmp;
|
||||
}
|
||||
void ExtraTags::setData(std::string tag, char *data)
|
||||
{
|
||||
bool ok = false;
|
||||
int tmp = 0;
|
||||
tmp = asInt(tag, &ok);
|
||||
if(ok)
|
||||
*data = (char)tmp;
|
||||
}
|
||||
|
@ -42,7 +42,19 @@ public:
|
||||
virtual ~ExtraTags();
|
||||
|
||||
/** Handle the beginning of an element. */
|
||||
bool addTag( const std::string tag, const std::string data);
|
||||
bool addTag(std::string tag, std::string data);
|
||||
|
||||
/** Set given short pointer to value of tag, if it exists. */
|
||||
void setData(std::string tag, short *data);
|
||||
|
||||
/** Set given int pointer to value of tag, if it exists. */
|
||||
void setData(std::string tag, int *data);
|
||||
|
||||
/** Set given float pointer to value of tag, if it exists. */
|
||||
void setData(std::string tag, float *data);
|
||||
|
||||
/** Set given char pointer to value of tag, if it exists. */
|
||||
void setData(std::string tag, char *data);
|
||||
|
||||
private:
|
||||
/** Disable default copy constructor. */
|
||||
@ -50,5 +62,16 @@ private:
|
||||
/** Disable default assignment operator. */
|
||||
const ExtraTags& operator= ( const ExtraTags& pre );
|
||||
|
||||
/** The profile for which the tags are. */
|
||||
std::string profile;
|
||||
|
||||
/** Map of tag and text pairs. */
|
||||
std::map<std::string, std::string> tags;
|
||||
|
||||
/** Get text data for tag as an int. */
|
||||
int asInt(std::string tag, bool *ok);
|
||||
/** Get text data for tag as a float. */
|
||||
float asFloat(std::string tag, bool *ok);
|
||||
/** Get text data for tag as a string. */
|
||||
std::string asString(std::string tag, bool *ok);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user