Commit to cope with API changes in OpenCOLLADA (latest for Windows right now r827).

This commit is contained in:
Nathan Letwory 2011-01-27 19:39:06 +00:00
parent ba9dacbd3d
commit 71cb745941
10 changed files with 80 additions and 70 deletions

View File

@ -528,7 +528,7 @@ elseif(WIN32)
set(OPENCOLLADA ${LIBDIR}/opencollada)
set(OPENCOLLADA_INC ${OPENCOLLADA}/include)
set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
set(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser xml2 buffer ftoa)
set(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser xml2 buffer ftoa UTF)
set(PCRE_LIB pcre)
endif()

View File

@ -143,6 +143,11 @@ if not env:
Exit()
env.Append(RCFLAGS="TEST=\"test it\"")
print env['RCFLAGS']
Exit()
cc = B.arguments.get('CC', None)
cxx = B.arguments.get('CXX', None)
if cc:

View File

@ -146,7 +146,7 @@ BF_COLLADA_LIB = 'bf_collada'
BF_OPENCOLLADA = LIBDIR + '/opencollada'
BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser MathMLSolver xml2 pcre buffer ftoa'
BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser MathMLSolver xml2 pcre buffer ftoa UTF'
BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib'
WITH_BF_LCMS = False

View File

@ -148,7 +148,7 @@ BF_COLLADA_LIB = 'bf_collada'
BF_OPENCOLLADA = LIBDIR + '/opencollada'
BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser MathMLSolver xml2 pcre buffer ftoa'
BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser MathMLSolver xml2 pcre buffer ftoa UTF'
BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib'
WITH_BF_LCMS = False

View File

@ -265,9 +265,9 @@ void ArmatureExporter::add_joints_element(ListBase *defbase,
COLLADASW::JointsElement joints(mSW);
COLLADASW::InputList &input = joints.getInputList();
input.push_back(COLLADASW::Input(COLLADASW::JOINT, // constant declared in COLLADASWInputList.h
input.push_back(COLLADASW::Input(COLLADASW::InputSemantic::JOINT, // constant declared in COLLADASWInputList.h
COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, joints_source_id)));
input.push_back(COLLADASW::Input(COLLADASW::BINDMATRIX,
input.push_back(COLLADASW::Input(COLLADASW::InputSemantic::BINDMATRIX,
COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, inv_bind_mat_source_id)));
joints.add();
}
@ -425,9 +425,9 @@ void ArmatureExporter::add_vertex_weights_element(const std::string& weights_sou
COLLADASW::InputList &input = weights.getInputList();
int offset = 0;
input.push_back(COLLADASW::Input(COLLADASW::JOINT, // constant declared in COLLADASWInputList.h
input.push_back(COLLADASW::Input(COLLADASW::InputSemantic::JOINT, // constant declared in COLLADASWInputList.h
COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, joints_source_id), offset++));
input.push_back(COLLADASW::Input(COLLADASW::WEIGHT,
input.push_back(COLLADASW::Input(COLLADASW::InputSemantic::WEIGHT,
COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, weights_source_id), offset++));
weights.setCount(me->totvert);

View File

@ -296,10 +296,11 @@ public:
class AnimationExporter: COLLADASW::LibraryAnimations
{
Scene *scene;
COLLADASW::StreamWriter *sw;
public:
AnimationExporter(COLLADASW::StreamWriter *sw): COLLADASW::LibraryAnimations(sw) {}
AnimationExporter(COLLADASW::StreamWriter *sw): COLLADASW::LibraryAnimations(sw) { this->sw = sw; }
void exportAnimations(Scene *sce)
{
@ -357,22 +358,22 @@ protected:
openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING);
// create input source
std::string input_id = create_source_from_fcurve(Sampler::INPUT, fcu, anim_id, axis_name);
std::string input_id = create_source_from_fcurve(COLLADASW::InputSemantic::INPUT, fcu, anim_id, axis_name);
// create output source
std::string output_id = create_source_from_fcurve(Sampler::OUTPUT, fcu, anim_id, axis_name);
std::string output_id = create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name);
// create interpolations source
std::string interpolation_id = create_interpolation_source(fcu->totvert, anim_id, axis_name);
std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX;
COLLADASW::LibraryAnimations::Sampler sampler(sampler_id);
COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id);
std::string empty;
sampler.addInput(Sampler::INPUT, COLLADABU::URI(empty, input_id));
sampler.addInput(Sampler::OUTPUT, COLLADABU::URI(empty, output_id));
sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id));
sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id));
// this input is required
sampler.addInput(Sampler::INTERPOLATION, COLLADABU::URI(empty, interpolation_id));
sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id));
addSampler(sampler);
@ -533,28 +534,28 @@ protected:
openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING);
// create input source
std::string input_id = create_source_from_vector(Sampler::INPUT, fra, is_rot, anim_id, axis_name);
std::string input_id = create_source_from_vector(COLLADASW::InputSemantic::INPUT, fra, is_rot, anim_id, axis_name);
// create output source
std::string output_id;
if (axis == -1)
output_id = create_xyz_source(v, fra.size(), anim_id);
else
output_id = create_source_from_array(Sampler::OUTPUT, v, fra.size(), is_rot, anim_id, axis_name);
output_id = create_source_from_array(COLLADASW::InputSemantic::OUTPUT, v, fra.size(), is_rot, anim_id, axis_name);
// create interpolations source
std::string interpolation_id = create_interpolation_source(fra.size(), anim_id, axis_name);
std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX;
COLLADASW::LibraryAnimations::Sampler sampler(sampler_id);
COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id);
std::string empty;
sampler.addInput(Sampler::INPUT, COLLADABU::URI(empty, input_id));
sampler.addInput(Sampler::OUTPUT, COLLADABU::URI(empty, output_id));
sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id));
sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id));
// TODO create in/out tangents source
// this input is required
sampler.addInput(Sampler::INTERPOLATION, COLLADABU::URI(empty, interpolation_id));
sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id));
addSampler(sampler);
@ -574,18 +575,18 @@ protected:
return COLLADABU::Math::Utils::radToDegF(angle);
}
std::string get_semantic_suffix(Sampler::Semantic semantic)
std::string get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic)
{
switch(semantic) {
case Sampler::INPUT:
case COLLADASW::InputSemantic::INPUT:
return INPUT_SOURCE_ID_SUFFIX;
case Sampler::OUTPUT:
case COLLADASW::InputSemantic::OUTPUT:
return OUTPUT_SOURCE_ID_SUFFIX;
case Sampler::INTERPOLATION:
case COLLADASW::InputSemantic::INTERPOLATION:
return INTERPOLATION_SOURCE_ID_SUFFIX;
case Sampler::IN_TANGENT:
case COLLADASW::InputSemantic::IN_TANGENT:
return INTANGENT_SOURCE_ID_SUFFIX;
case Sampler::OUT_TANGENT:
case COLLADASW::InputSemantic::OUT_TANGENT:
return OUTTANGENT_SOURCE_ID_SUFFIX;
default:
break;
@ -594,13 +595,13 @@ protected:
}
void add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param,
Sampler::Semantic semantic, bool is_rot, const char *axis)
COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis)
{
switch(semantic) {
case Sampler::INPUT:
case COLLADASW::InputSemantic::INPUT:
param.push_back("TIME");
break;
case Sampler::OUTPUT:
case COLLADASW::InputSemantic::OUTPUT:
if (is_rot) {
param.push_back("ANGLE");
}
@ -615,8 +616,8 @@ protected:
}
}
break;
case Sampler::IN_TANGENT:
case Sampler::OUT_TANGENT:
case COLLADASW::InputSemantic::IN_TANGENT:
case COLLADASW::InputSemantic::OUT_TANGENT:
param.push_back("X");
param.push_back("Y");
break;
@ -625,14 +626,14 @@ protected:
}
}
void get_source_values(BezTriple *bezt, Sampler::Semantic semantic, bool rotation, float *values, int *length)
void get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool rotation, float *values, int *length)
{
switch (semantic) {
case Sampler::INPUT:
case COLLADASW::InputSemantic::INPUT:
*length = 1;
values[0] = convert_time(bezt->vec[1][0]);
break;
case Sampler::OUTPUT:
case COLLADASW::InputSemantic::OUTPUT:
*length = 1;
if (rotation) {
values[0] = convert_angle(bezt->vec[1][1]);
@ -641,8 +642,8 @@ protected:
values[0] = bezt->vec[1][1];
}
break;
case Sampler::IN_TANGENT:
case Sampler::OUT_TANGENT:
case COLLADASW::InputSemantic::IN_TANGENT:
case COLLADASW::InputSemantic::OUT_TANGENT:
// XXX
*length = 2;
break;
@ -652,7 +653,7 @@ protected:
}
}
std::string create_source_from_fcurve(Sampler::Semantic semantic, FCurve *fcu, const std::string& anim_id, const char *axis_name)
std::string create_source_from_fcurve(COLLADASW::InputSemantic::Semantics semantic, FCurve *fcu, const std::string& anim_id, const char *axis_name)
{
std::string source_id = anim_id + get_semantic_suffix(semantic);
@ -686,7 +687,7 @@ protected:
return source_id;
}
std::string create_source_from_array(Sampler::Semantic semantic, float *v, int tot, bool is_rot, const std::string& anim_id, const char *axis_name)
std::string create_source_from_array(COLLADASW::InputSemantic::Semantics semantic, float *v, int tot, bool is_rot, const std::string& anim_id, const char *axis_name)
{
std::string source_id = anim_id + get_semantic_suffix(semantic);
@ -703,7 +704,7 @@ protected:
for (int i = 0; i < tot; i++) {
float val = v[i];
if (semantic == Sampler::INPUT)
if (semantic == COLLADASW::InputSemantic::INPUT)
val = convert_time(val);
else if (is_rot)
val = convert_angle(val);
@ -715,7 +716,7 @@ protected:
return source_id;
}
std::string create_source_from_vector(Sampler::Semantic semantic, std::vector<float> &fra, bool is_rot, const std::string& anim_id, const char *axis_name)
std::string create_source_from_vector(COLLADASW::InputSemantic::Semantics semantic, std::vector<float> &fra, bool is_rot, const std::string& anim_id, const char *axis_name)
{
std::string source_id = anim_id + get_semantic_suffix(semantic);
@ -733,7 +734,7 @@ protected:
std::vector<float>::iterator it;
for (it = fra.begin(); it != fra.end(); it++) {
float val = *it;
if (semantic == Sampler::INPUT)
if (semantic == COLLADASW::InputSemantic::INPUT)
val = convert_time(val);
else if (is_rot)
val = convert_angle(val);
@ -748,7 +749,7 @@ protected:
// only used for sources with OUTPUT semantic
std::string create_xyz_source(float *v, int tot, const std::string& anim_id)
{
Sampler::Semantic semantic = Sampler::OUTPUT;
COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT;
std::string source_id = anim_id + get_semantic_suffix(semantic);
COLLADASW::FloatSourceF source(mSW);
@ -774,7 +775,7 @@ protected:
std::string create_interpolation_source(int tot, const std::string& anim_id, const char *axis_name)
{
std::string source_id = anim_id + get_semantic_suffix(Sampler::INTERPOLATION);
std::string source_id = anim_id + get_semantic_suffix(COLLADASW::InputSemantic::INTERPOLATION);
COLLADASW::NameSource source(mSW);
source.setId(source_id);

View File

@ -92,9 +92,9 @@ void GeometryExporter::operator()(Object *ob)
// <vertices>
COLLADASW::Vertices verts(mSW);
verts.setId(getIdBySemantics(geom_id, COLLADASW::VERTEX));
verts.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX));
COLLADASW::InputList &input_list = verts.getInputList();
COLLADASW::Input input(COLLADASW::POSITION, getUrlBySemantics(geom_id, COLLADASW::POSITION));
COLLADASW::Input input(COLLADASW::InputSemantic::POSITION, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::POSITION));
input_list.push_back(input);
verts.add();
@ -168,10 +168,10 @@ void GeometryExporter::createPolylist(int material_index,
COLLADASW::InputList &til = polylist.getInputList();
// creates <input> in <polylist> for vertices
COLLADASW::Input input1(COLLADASW::VERTEX, getUrlBySemantics(geom_id, COLLADASW::VERTEX), 0);
COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX), 0);
// creates <input> in <polylist> for normals
COLLADASW::Input input2(COLLADASW::NORMAL, getUrlBySemantics(geom_id, COLLADASW::NORMAL), 1);
COLLADASW::Input input2(COLLADASW::InputSemantic::NORMAL, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL), 1);
til.push_back(input1);
til.push_back(input2);
@ -181,7 +181,7 @@ void GeometryExporter::createPolylist(int material_index,
for (i = 0; i < num_layers; i++) {
// char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, i);
COLLADASW::Input input3(COLLADASW::TEXCOORD,
COLLADASW::Input input3(COLLADASW::InputSemantic::TEXCOORD,
makeUrl(makeTexcoordSourceId(geom_id, i)),
2, // offset always 2, this is only until we have optimized UV sets
i // set number equals UV layer index
@ -190,7 +190,7 @@ void GeometryExporter::createPolylist(int material_index,
}
if (has_color) {
COLLADASW::Input input4(COLLADASW::COLOR, getUrlBySemantics(geom_id, COLLADASW::COLOR), has_uvs ? 3 : 2);
COLLADASW::Input input4(COLLADASW::InputSemantic::COLOR, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::COLOR), has_uvs ? 3 : 2);
til.push_back(input4);
}
@ -240,8 +240,8 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
MVert *verts = me->mvert;
COLLADASW::FloatSourceF source(mSW);
source.setId(getIdBySemantics(geom_id, COLLADASW::POSITION));
source.setArrayId(getIdBySemantics(geom_id, COLLADASW::POSITION) +
source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::POSITION));
source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::POSITION) +
ARRAY_ID_SUFFIX);
source.setAccessorCount(totverts);
source.setAccessorStride(3);
@ -274,8 +274,8 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
totcolor += f->v4 ? 4 : 3;
COLLADASW::FloatSourceF source(mSW);
source.setId(getIdBySemantics(geom_id, COLLADASW::COLOR));
source.setArrayId(getIdBySemantics(geom_id, COLLADASW::COLOR) + ARRAY_ID_SUFFIX);
source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::COLOR));
source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::COLOR) + ARRAY_ID_SUFFIX);
source.setAccessorCount(totcolor);
source.setAccessorStride(3);
@ -302,7 +302,7 @@ std::string GeometryExporter::makeTexcoordSourceId(std::string& geom_id, int lay
{
char suffix[20];
sprintf(suffix, "-%d", layer_index);
return getIdBySemantics(geom_id, COLLADASW::TEXCOORD) + suffix;
return getIdBySemantics(geom_id, COLLADASW::InputSemantic::TEXCOORD) + suffix;
}
//creates <source> for texcoords
@ -373,8 +373,8 @@ void GeometryExporter::createNormalsSource(std::string geom_id, Mesh *me, std::v
#endif
COLLADASW::FloatSourceF source(mSW);
source.setId(getIdBySemantics(geom_id, COLLADASW::NORMAL));
source.setArrayId(getIdBySemantics(geom_id, COLLADASW::NORMAL) +
source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL));
source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL) +
ARRAY_ID_SUFFIX);
source.setAccessorCount((unsigned long)nor.size());
source.setAccessorStride(3);
@ -444,12 +444,12 @@ void GeometryExporter::create_normals(std::vector<Normal> &nor, std::vector<Face
}
}
std::string GeometryExporter::getIdBySemantics(std::string geom_id, COLLADASW::Semantics type, std::string other_suffix) {
std::string GeometryExporter::getIdBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix) {
return geom_id + getSuffixBySemantic(type) + other_suffix;
}
COLLADASW::URI GeometryExporter::getUrlBySemantics(std::string geom_id, COLLADASW::Semantics type, std::string other_suffix) {
COLLADASW::URI GeometryExporter::getUrlBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix) {
std::string id(getIdBySemantics(geom_id, type, other_suffix));
return COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, id);

View File

@ -83,9 +83,9 @@ public:
void create_normals(std::vector<Normal> &nor, std::vector<Face> &ind, Mesh *me);
std::string getIdBySemantics(std::string geom_id, COLLADASW::Semantics type, std::string other_suffix = "");
std::string getIdBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix = "");
COLLADASW::URI getUrlBySemantics(std::string geom_id, COLLADASW::Semantics type, std::string other_suffix = "");
COLLADASW::URI getUrlBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix = "");
COLLADASW::URI makeUrl(std::string id);

View File

@ -315,16 +315,19 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh)
void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh, Mesh *me)
{
// vertices
me->totvert = mesh->getPositions().getFloatValues()->getCount() / 3;
// vertices
COLLADAFW::MeshVertexData& pos = mesh->getPositions();
int stride = pos.getStride(0);
if(stride==0) stride = 3;
me->totvert = mesh->getPositions().getFloatValues()->getCount() / stride;
me->mvert = (MVert*)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert);
COLLADAFW::MeshVertexData& pos = mesh->getPositions();
MVert *mvert;
int i;
for (i = 0, mvert = me->mvert; i < me->totvert; i++, mvert++) {
get_vector(mvert->co, pos, i);
get_vector(mvert->co, pos, i, stride);
}
}
@ -634,10 +637,10 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris)
geom_uid_mat_mapping_map[mesh->getUniqueId()] = mat_prim_map;
}
void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i)
void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i, int stride)
{
i *= 3;
i *= stride;
switch(arr.getType()) {
case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
{
@ -647,6 +650,7 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i)
v[0] = (*values)[i++];
v[1] = (*values)[i++];
v[2] = (*values)[i];
}
break;
case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
@ -668,13 +672,13 @@ bool MeshImporter::flat_face(unsigned int *nind, COLLADAFW::MeshVertexData& nor,
{
float a[3], b[3];
get_vector(a, nor, *nind);
get_vector(a, nor, *nind, 3);
normalize_v3(a);
nind++;
for (int i = 1; i < count; i++, nind++) {
get_vector(b, nor, *nind);
get_vector(b, nor, *nind, 3);
normalize_v3(b);
float dp = dot_v3v3(a, b);

View File

@ -118,7 +118,7 @@ private:
// TODO: import uv set names
void read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris);
void get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i);
void get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i, int stride);
bool flat_face(unsigned int *nind, COLLADAFW::MeshVertexData& nor, int count);