| 1 |
#ifndef _COLLADA_FORMAT_H |
| 2 |
#define _COLLADA_FORMAT_H |
| 3 |
|
| 4 |
#include <wrap/dae/xmldocumentmanaging.h> |
| 5 |
#include <vcg/space/point4.h> |
| 6 |
#include <QtGui/QImage> |
| 7 |
#include <QtCore/QVector> |
| 8 |
|
| 9 |
|
| 10 |
template<typename POINTTYPE> |
| 11 |
struct CoordNumber |
| 12 |
{ |
| 13 |
public: |
| 14 |
static unsigned int coord() |
| 15 |
{ |
| 16 |
return 0; |
| 17 |
} |
| 18 |
}; |
| 19 |
|
| 20 |
template<> |
| 21 |
struct CoordNumber<vcg::Point2f> |
| 22 |
{ |
| 23 |
public: |
| 24 |
static unsigned int coord() |
| 25 |
{ |
| 26 |
return 2; |
| 27 |
} |
| 28 |
}; |
| 29 |
|
| 30 |
template<> |
| 31 |
struct CoordNumber<vcg::Point3f> |
| 32 |
{ |
| 33 |
public: |
| 34 |
static unsigned int coord() |
| 35 |
{ |
| 36 |
return 3; |
| 37 |
} |
| 38 |
}; |
| 39 |
|
| 40 |
template<> |
| 41 |
struct CoordNumber<vcg::Point4f> |
| 42 |
{ |
| 43 |
public: |
| 44 |
static unsigned int coord() |
| 45 |
{ |
| 46 |
return 4; |
| 47 |
} |
| 48 |
}; |
| 49 |
|
| 50 |
|
| 51 |
namespace Collada |
| 52 |
{ |
| 53 |
namespace Tags |
| 54 |
{ |
| 55 |
static const QString testSharp(const QString& str) |
| 56 |
{ |
| 57 |
QString sharp = ""; |
| 58 |
if (str.at(0) != '#') |
| 59 |
sharp = '#'; |
| 60 |
return (sharp + str); |
| 61 |
} |
| 62 |
|
| 63 |
class ColladaTag : public XMLTag |
| 64 |
{ |
| 65 |
public: |
| 66 |
ColladaTag() |
| 67 |
:XMLTag("COLLADA") |
| 68 |
{ |
| 69 |
_attributes.push_back(TagAttribute("xmlns","http://www.collada.org/2005/11/COLLADASchema")); |
| 70 |
_attributes.push_back(TagAttribute("version","1.4.1")); |
| 71 |
} |
| 72 |
}; |
| 73 |
|
| 74 |
class AssetTag : public XMLTag |
| 75 |
{ |
| 76 |
public: |
| 77 |
AssetTag() |
| 78 |
:XMLTag("asset") |
| 79 |
{ |
| 80 |
} |
| 81 |
}; |
| 82 |
|
| 83 |
class ContributorTag : public XMLTag |
| 84 |
{ |
| 85 |
public: |
| 86 |
ContributorTag() |
| 87 |
:XMLTag("contributor") |
| 88 |
{ |
| 89 |
} |
| 90 |
}; |
| 91 |
|
| 92 |
class AuthorTag : public XMLLeafTag |
| 93 |
{ |
| 94 |
public: |
| 95 |
AuthorTag() |
| 96 |
:XMLLeafTag("author") |
| 97 |
{ |
| 98 |
_text.push_back("VCGLab"); |
| 99 |
} |
| 100 |
}; |
| 101 |
|
| 102 |
class AuthoringToolTag : public XMLLeafTag |
| 103 |
{ |
| 104 |
public: |
| 105 |
AuthoringToolTag() |
| 106 |
:XMLLeafTag("authoring_tool") |
| 107 |
{ |
| 108 |
_text.push_back("VCGLib | MeshLab"); |
| 109 |
} |
| 110 |
}; |
| 111 |
|
| 112 |
class UpAxisTag : public XMLLeafTag |
| 113 |
{ |
| 114 |
public: |
| 115 |
UpAxisTag(const QString& up = "Y_UP") |
| 116 |
:XMLLeafTag("up_axis") |
| 117 |
{ |
| 118 |
_text.push_back(up); |
| 119 |
} |
| 120 |
}; |
| 121 |
|
| 122 |
class LibraryImagesTag : public XMLTag |
| 123 |
{ |
| 124 |
public: |
| 125 |
LibraryImagesTag() |
| 126 |
:XMLTag("library_images") |
| 127 |
{ |
| 128 |
} |
| 129 |
}; |
| 130 |
|
| 131 |
class ImageTag : public XMLTag |
| 132 |
{ |
| 133 |
public: |
| 134 |
ImageTag(const QString& id,const QString& name) |
| 135 |
:XMLTag("image") |
| 136 |
{ |
| 137 |
_attributes.push_back(TagAttribute("id",id)); |
| 138 |
_attributes.push_back(TagAttribute("name",name)); |
| 139 |
} |
| 140 |
}; |
| 141 |
|
| 142 |
class InitFromTag : public XMLLeafTag |
| 143 |
{ |
| 144 |
public: |
| 145 |
InitFromTag(const QString& txtpathname) |
| 146 |
:XMLLeafTag("init_from") |
| 147 |
{ |
| 148 |
_text.push_back(txtpathname); |
| 149 |
} |
| 150 |
}; |
| 151 |
|
| 152 |
class LibraryMaterialsTag : public XMLTag |
| 153 |
{ |
| 154 |
public: |
| 155 |
LibraryMaterialsTag() |
| 156 |
:XMLTag("library_materials") |
| 157 |
{ |
| 158 |
} |
| 159 |
}; |
| 160 |
|
| 161 |
class MaterialTag : public XMLTag |
| 162 |
{ |
| 163 |
public: |
| 164 |
MaterialTag(const QString& id,const QString& name) |
| 165 |
:XMLTag("material") |
| 166 |
{ |
| 167 |
_attributes.push_back(TagAttribute("id",id)); |
| 168 |
_attributes.push_back(TagAttribute("name",name)); |
| 169 |
} |
| 170 |
}; |
| 171 |
|
| 172 |
class InstanceEffectTag : public XMLLeafTag |
| 173 |
{ |
| 174 |
public: |
| 175 |
InstanceEffectTag(const QString& url) |
| 176 |
:XMLLeafTag("instance_effect") |
| 177 |
{ |
| 178 |
_attributes.push_back(TagAttribute("url",testSharp(url))); |
| 179 |
} |
| 180 |
}; |
| 181 |
|
| 182 |
class LibraryEffectsTag : public XMLTag |
| 183 |
{ |
| 184 |
public: |
| 185 |
LibraryEffectsTag() |
| 186 |
:XMLTag("library_effects") |
| 187 |
{ |
| 188 |
} |
| 189 |
}; |
| 190 |
|
| 191 |
class EffectTag : public XMLTag |
| 192 |
{ |
| 193 |
public: |
| 194 |
EffectTag(const QString& id) |
| 195 |
:XMLTag("effect") |
| 196 |
{ |
| 197 |
_attributes.push_back(TagAttribute("id",id)); |
| 198 |
} |
| 199 |
}; |
| 200 |
|
| 201 |
class ProfileCommonTag : public XMLTag |
| 202 |
{ |
| 203 |
public: |
| 204 |
ProfileCommonTag() |
| 205 |
:XMLTag("profile_COMMON") |
| 206 |
{ |
| 207 |
} |
| 208 |
}; |
| 209 |
|
| 210 |
class NewParamTag : public XMLTag |
| 211 |
{ |
| 212 |
public: |
| 213 |
NewParamTag(const QString& sid) |
| 214 |
:XMLTag("newparam") |
| 215 |
{ |
| 216 |
_attributes.push_back(TagAttribute("sid",sid)); |
| 217 |
} |
| 218 |
}; |
| 219 |
|
| 220 |
class SurfaceTag : public XMLTag |
| 221 |
{ |
| 222 |
public: |
| 223 |
SurfaceTag(const QString& type = QString("2D")) |
| 224 |
:XMLTag("surface") |
| 225 |
{ |
| 226 |
_attributes.push_back(TagAttribute("type",type)); |
| 227 |
} |
| 228 |
}; |
| 229 |
|
| 230 |
class FormatTag : public XMLLeafTag |
| 231 |
{ |
| 232 |
public: |
| 233 |
FormatTag(const QString& format) |
| 234 |
:XMLLeafTag("format") |
| 235 |
{ |
| 236 |
_text.push_back(format); |
| 237 |
} |
| 238 |
}; |
| 239 |
|
| 240 |
class Sampler2DTag : public XMLTag |
| 241 |
{ |
| 242 |
public: |
| 243 |
Sampler2DTag() |
| 244 |
:XMLTag("sampler2D") |
| 245 |
{ |
| 246 |
} |
| 247 |
}; |
| 248 |
|
| 249 |
class SourceTag : public XMLLeafTag |
| 250 |
{ |
| 251 |
public: |
| 252 |
SourceTag(const QString& id,const QString& name) |
| 253 |
:XMLLeafTag("source") |
| 254 |
{ |
| 255 |
_attributes.push_back(TagAttribute("id",id)); |
| 256 |
_attributes.push_back(TagAttribute("name",name)); |
| 257 |
} |
| 258 |
|
| 259 |
SourceTag(const QString& source) |
| 260 |
:XMLLeafTag("source") |
| 261 |
{ |
| 262 |
_text.push_back(source); |
| 263 |
} |
| 264 |
}; |
| 265 |
|
| 266 |
class MinFilterTag : public XMLLeafTag |
| 267 |
{ |
| 268 |
public: |
| 269 |
MinFilterTag(const QString& filter) |
| 270 |
:XMLLeafTag("minfilter") |
| 271 |
{ |
| 272 |
_text.push_back(filter); |
| 273 |
} |
| 274 |
}; |
| 275 |
|
| 276 |
class MagFilterTag : public XMLLeafTag |
| 277 |
{ |
| 278 |
public: |
| 279 |
MagFilterTag(const QString& filter) |
| 280 |
:XMLLeafTag("magfilter") |
| 281 |
{ |
| 282 |
_text.push_back(filter); |
| 283 |
} |
| 284 |
}; |
| 285 |
|
| 286 |
class TechniqueTag : public XMLTag |
| 287 |
{ |
| 288 |
public: |
| 289 |
TechniqueTag(const QString& sid) |
| 290 |
:XMLTag("technique") |
| 291 |
{ |
| 292 |
_attributes.push_back(TagAttribute("sid",sid)); |
| 293 |
} |
| 294 |
}; |
| 295 |
|
| 296 |
class TechniqueCommonTag : public XMLTag |
| 297 |
{ |
| 298 |
public: |
| 299 |
TechniqueCommonTag() |
| 300 |
:XMLTag("technique_common") |
| 301 |
{ |
| 302 |
} |
| 303 |
}; |
| 304 |
|
| 305 |
class BlinnTag : public XMLTag |
| 306 |
{ |
| 307 |
public: |
| 308 |
BlinnTag() |
| 309 |
:XMLTag("blinn") |
| 310 |
{ |
| 311 |
} |
| 312 |
}; |
| 313 |
|
| 314 |
class EmissionTag : public XMLTag |
| 315 |
{ |
| 316 |
public: |
| 317 |
EmissionTag() |
| 318 |
:XMLTag("emission") |
| 319 |
{ |
| 320 |
} |
| 321 |
}; |
| 322 |
|
| 323 |
class ColorTag : public XMLLeafTag |
| 324 |
{ |
| 325 |
public: |
| 326 |
ColorTag(const float r,const float g,const float b,const float a) |
| 327 |
:XMLLeafTag("color") |
| 328 |
{ |
| 329 |
|
| 330 |
_text.push_back(QString::number(r)); |
| 331 |
_text.push_back(QString::number(g)); |
| 332 |
_text.push_back(QString::number(b)); |
| 333 |
_text.push_back(QString::number(a)); |
| 334 |
} |
| 335 |
}; |
| 336 |
|
| 337 |
class AmbientTag : public XMLTag |
| 338 |
{ |
| 339 |
public: |
| 340 |
AmbientTag() |
| 341 |
:XMLTag("ambient") |
| 342 |
{ |
| 343 |
} |
| 344 |
}; |
| 345 |
|
| 346 |
class DiffuseTag : public XMLTag |
| 347 |
{ |
| 348 |
public: |
| 349 |
DiffuseTag() |
| 350 |
:XMLTag("diffuse") |
| 351 |
{ |
| 352 |
} |
| 353 |
}; |
| 354 |
|
| 355 |
class TextureTag : public XMLLeafTag |
| 356 |
{ |
| 357 |
public: |
| 358 |
TextureTag(const QString& texture,const QString& texcoord) |
| 359 |
:XMLLeafTag("texture") |
| 360 |
{ |
| 361 |
_attributes.push_back(TagAttribute("texture",texture)); |
| 362 |
_attributes.push_back(TagAttribute("texcoord",texcoord)); |
| 363 |
} |
| 364 |
}; |
| 365 |
|
| 366 |
class SpecularTag : public XMLTag |
| 367 |
{ |
| 368 |
public: |
| 369 |
SpecularTag() |
| 370 |
:XMLTag("specular") |
| 371 |
{ |
| 372 |
} |
| 373 |
}; |
| 374 |
|
| 375 |
class ShininessTag : public XMLTag |
| 376 |
{ |
| 377 |
public: |
| 378 |
ShininessTag() |
| 379 |
:XMLTag("shininess") |
| 380 |
{ |
| 381 |
} |
| 382 |
}; |
| 383 |
|
| 384 |
class FloatTag : public XMLLeafTag |
| 385 |
{ |
| 386 |
public: |
| 387 |
FloatTag(const float floatnum) |
| 388 |
:XMLLeafTag("float") |
| 389 |
{ |
| 390 |
_text.push_back(QString::number(floatnum)); |
| 391 |
} |
| 392 |
}; |
| 393 |
|
| 394 |
class ReflectiveTag : public XMLTag |
| 395 |
{ |
| 396 |
public: |
| 397 |
ReflectiveTag() |
| 398 |
:XMLTag("reflective") |
| 399 |
{ |
| 400 |
} |
| 401 |
}; |
| 402 |
|
| 403 |
class ReflectivityTag : public XMLTag |
| 404 |
{ |
| 405 |
public: |
| 406 |
ReflectivityTag() |
| 407 |
:XMLTag("reflectivity") |
| 408 |
{ |
| 409 |
} |
| 410 |
}; |
| 411 |
|
| 412 |
class TransparentTag : public XMLTag |
| 413 |
{ |
| 414 |
public: |
| 415 |
TransparentTag() |
| 416 |
:XMLTag("transparent") |
| 417 |
{ |
| 418 |
} |
| 419 |
}; |
| 420 |
|
| 421 |
class TransparencyTag : public XMLTag |
| 422 |
{ |
| 423 |
public: |
| 424 |
TransparencyTag() |
| 425 |
:XMLTag("transparency") |
| 426 |
{ |
| 427 |
} |
| 428 |
}; |
| 429 |
|
| 430 |
class IndexOfRefractionTag : public XMLTag |
| 431 |
{ |
| 432 |
public: |
| 433 |
IndexOfRefractionTag() |
| 434 |
:XMLTag("index_of_refraction") |
| 435 |
{ |
| 436 |
} |
| 437 |
}; |
| 438 |
|
| 439 |
class LibraryGeometriesTag : public XMLTag |
| 440 |
{ |
| 441 |
public: |
| 442 |
LibraryGeometriesTag() |
| 443 |
:XMLTag("library_geometries") |
| 444 |
{ |
| 445 |
} |
| 446 |
}; |
| 447 |
|
| 448 |
class GeometryTag : public XMLTag |
| 449 |
{ |
| 450 |
public: |
| 451 |
GeometryTag(const QString& id,const QString& name) |
| 452 |
:XMLTag("geometry") |
| 453 |
{ |
| 454 |
_attributes.push_back(TagAttribute("id",id)); |
| 455 |
_attributes.push_back(TagAttribute("name",name)); |
| 456 |
} |
| 457 |
}; |
| 458 |
|
| 459 |
class MeshTag : public XMLTag |
| 460 |
{ |
| 461 |
public: |
| 462 |
MeshTag() |
| 463 |
:XMLTag("mesh") |
| 464 |
{ |
| 465 |
} |
| 466 |
}; |
| 467 |
|
| 468 |
class ArraySourceTag : public XMLTag |
| 469 |
{ |
| 470 |
public: |
| 471 |
ArraySourceTag(const QString& id,const QString& name) |
| 472 |
:XMLTag("source") |
| 473 |
{ |
| 474 |
_attributes.push_back(TagAttribute("id",id)); |
| 475 |
_attributes.push_back(TagAttribute("name",name)); |
| 476 |
} |
| 477 |
}; |
| 478 |
|
| 479 |
class FloatArrayTag : public XMLLeafTag |
| 480 |
{ |
| 481 |
public: |
| 482 |
enum ARRAYSEMANTIC {VERTPOSITION,VERTNORMAL,FACENORMAL,WEDGETEXCOORD}; |
| 483 |
|
| 484 |
template<typename MESHTYPE> |
| 485 |
FloatArrayTag(const QString& id,const int count,const MESHTYPE& m,ARRAYSEMANTIC sem,const unsigned int componenttype) |
| 486 |
:XMLLeafTag("float_array") |
| 487 |
{ |
| 488 |
_attributes.push_back(TagAttribute("id",id)); |
| 489 |
_attributes.push_back(TagAttribute("count",QString::number(count))); |
| 490 |
|
| 491 |
if ((sem == VERTPOSITION) || (sem == VERTNORMAL)) |
| 492 |
{ |
| 493 |
for(typename MESHTYPE::ConstVertexIterator vit = m.vert.begin();vit != m.vert.end();++vit) |
| 494 |
{ |
| 495 |
for(unsigned int ii = 0; ii < componenttype;++ii) |
| 496 |
{ |
| 497 |
if (sem == VERTPOSITION) |
| 498 |
_text.push_back(QString::number(vit->P()[ii])); |
| 499 |
else |
| 500 |
{ |
| 501 |
typename MESHTYPE::VertexType::NormalType r = vit->cN(); |
| 502 |
r.Normalize(); |
| 503 |
_text.push_back(QString::number(r[ii])); |
| 504 |
|
| 505 |
} |
| 506 |
} |
| 507 |
} |
| 508 |
} |
| 509 |
else |
| 510 |
{ |
| 511 |
for(typename MESHTYPE::ConstFaceIterator fit = m.face.begin();fit != m.face.end();++fit) |
| 512 |
{ |
| 513 |
if (sem == FACENORMAL) |
| 514 |
{ |
| 515 |
for(unsigned int ii = 0; ii < componenttype;++ii) |
| 516 |
{ |
| 517 |
typename MESHTYPE::FaceType::NormalType r = fit->cN(); |
| 518 |
r.Normalize(); |
| 519 |
_text.push_back(QString::number(r[ii])); |
| 520 |
} |
| 521 |
} |
| 522 |
else |
| 523 |
{ |
| 524 |
for(unsigned int ii = 0; ii < 3;++ii) |
| 525 |
{ |
| 526 |
_text.push_back(QString::number(fit->cWT(ii).U())); |
| 527 |
_text.push_back(QString::number(fit->cWT(ii).V())); |
| 528 |
} |
| 529 |
} |
| 530 |
} |
| 531 |
} |
| 532 |
} |
| 533 |
}; |
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
class AccessorTag : public XMLTag |
| 556 |
{ |
| 557 |
public: |
| 558 |
AccessorTag(const int count,const QString& source,const int stride) |
| 559 |
:XMLTag("accessor") |
| 560 |
{ |
| 561 |
_attributes.push_back(TagAttribute("count",QString::number(count))); |
| 562 |
_attributes.push_back(TagAttribute("source",testSharp(source))); |
| 563 |
_attributes.push_back(TagAttribute("stride",QString::number(stride))); |
| 564 |
} |
| 565 |
}; |
| 566 |
|
| 567 |
class ParamTag : public XMLTag |
| 568 |
{ |
| 569 |
public: |
| 570 |
ParamTag(const QString& name,const QString& type) |
| 571 |
:XMLTag("param") |
| 572 |
{ |
| 573 |
_attributes.push_back(TagAttribute("name",name)); |
| 574 |
_attributes.push_back(TagAttribute("type",type)); |
| 575 |
} |
| 576 |
}; |
| 577 |
|
| 578 |
class VerticesTag : public XMLTag |
| 579 |
{ |
| 580 |
public: |
| 581 |
VerticesTag(const QString& id) |
| 582 |
:XMLTag("vertices") |
| 583 |
{ |
| 584 |
_attributes.push_back(TagAttribute("id",id)); |
| 585 |
} |
| 586 |
}; |
| 587 |
|
| 588 |
class InputTag : public XMLTag |
| 589 |
{ |
| 590 |
public: |
| 591 |
|
| 592 |
InputTag(const QString& semantic,const QString& source) |
| 593 |
:XMLTag("input") |
| 594 |
{ |
| 595 |
_attributes.push_back(TagAttribute("semantic",semantic)); |
| 596 |
_attributes.push_back(TagAttribute("source",testSharp(source))); |
| 597 |
} |
| 598 |
|
| 599 |
InputTag(const int offset,const QString& semantic,const QString& source) |
| 600 |
:XMLTag("input") |
| 601 |
{ |
| 602 |
_attributes.push_back(TagAttribute("offset",QString::number(offset))); |
| 603 |
_attributes.push_back(TagAttribute("semantic",semantic)); |
| 604 |
_attributes.push_back(TagAttribute("source",testSharp(source))); |
| 605 |
} |
| 606 |
}; |
| 607 |
|
| 608 |
class TrianglesTag : public XMLTag |
| 609 |
{ |
| 610 |
public: |
| 611 |
TrianglesTag(const int count) |
| 612 |
:XMLTag("triangles") |
| 613 |
{ |
| 614 |
_attributes.push_back(TagAttribute("count",QString::number(count))); |
| 615 |
} |
| 616 |
|
| 617 |
TrianglesTag(const int count,const QString& material) |
| 618 |
:XMLTag("triangles") |
| 619 |
{ |
| 620 |
_attributes.push_back(TagAttribute("count",QString::number(count))); |
| 621 |
_attributes.push_back(TagAttribute("material",material)); |
| 622 |
} |
| 623 |
}; |
| 624 |
|
| 625 |
class PTag : public XMLLeafTag |
| 626 |
{ |
| 627 |
public: |
| 628 |
template<typename MESHTYPE> |
| 629 |
PTag(const MESHTYPE& m,const unsigned int nedge,bool norm = false,bool texcoord = false) |
| 630 |
:XMLLeafTag("p") |
| 631 |
{ |
| 632 |
int cont = 0; |
| 633 |
for(typename MESHTYPE::ConstFaceIterator it= m.face.begin();it != m.face.end(); ++it) |
| 634 |
{ |
| 635 |
for(unsigned int ii = 0; ii < nedge; ++ii) |
| 636 |
{ |
| 637 |
int dist = it->V(ii) - &(*m.vert.begin()); |
| 638 |
_text.push_back(QString::number(dist)); |
| 639 |
if (norm) |
| 640 |
_text.push_back(QString::number(cont)); |
| 641 |
if (texcoord) |
| 642 |
_text.push_back(QString::number(cont * nedge + ii)); |
| 643 |
} |
| 644 |
++cont; |
| 645 |
} |
| 646 |
} |
| 647 |
|
| 648 |
template<typename MESHTYPE> |
| 649 |
PTag(const MESHTYPE& m,const unsigned int nedge,QVector<int>& patchfaces,bool norm = false,bool texcoord = false) |
| 650 |
:XMLLeafTag("p") |
| 651 |
{ |
| 652 |
int cont = 0; |
| 653 |
for(QVector<int>::iterator it = patchfaces.begin();it != patchfaces .end(); ++it) |
| 654 |
{ |
| 655 |
for(unsigned int ii = 0; ii < nedge; ++ii) |
| 656 |
{ |
| 657 |
const typename MESHTYPE::FaceType& f = m.face[*it]; |
| 658 |
int dist = f.V(ii) - &(*m.vert.begin()); |
| 659 |
_text.push_back(QString::number(dist)); |
| 660 |
if (norm) |
| 661 |
_text.push_back(QString::number(*it)); |
| 662 |
if (texcoord) |
| 663 |
_text.push_back(QString::number(*it * nedge + ii)); |
| 664 |
} |
| 665 |
++cont; |
| 666 |
} |
| 667 |
} |
| 668 |
}; |
| 669 |
|
| 670 |
class LibraryVisualScenesTag : public XMLTag |
| 671 |
{ |
| 672 |
public: |
| 673 |
LibraryVisualScenesTag() |
| 674 |
:XMLTag("library_visual_scenes") |
| 675 |
{ |
| 676 |
} |
| 677 |
}; |
| 678 |
|
| 679 |
class VisualSceneTag : public XMLTag |
| 680 |
{ |
| 681 |
public: |
| 682 |
VisualSceneTag(const QString& id,const QString& name) |
| 683 |
:XMLTag("visual_scene") |
| 684 |
{ |
| 685 |
_attributes.push_back(TagAttribute("id",id)); |
| 686 |
_attributes.push_back(TagAttribute("name",name)); |
| 687 |
} |
| 688 |
}; |
| 689 |
|
| 690 |
class NodeTag : public XMLTag |
| 691 |
{ |
| 692 |
public: |
| 693 |
NodeTag(const QString& id,const QString& name) |
| 694 |
:XMLTag("node") |
| 695 |
{ |
| 696 |
_attributes.push_back(TagAttribute("id",id)); |
| 697 |
_attributes.push_back(TagAttribute("name",name)); |
| 698 |
} |
| 699 |
}; |
| 700 |
|
| 701 |
class RotateTag : public XMLLeafTag |
| 702 |
{ |
| 703 |
public: |
| 704 |
RotateTag(const QString& sid,const vcg::Point4f& p) |
| 705 |
:XMLLeafTag("rotate") |
| 706 |
{ |
| 707 |
_attributes.push_back(TagAttribute("sid",sid)); |
| 708 |
|
| 709 |
for(unsigned int ii =0;ii < 4; ++ii) |
| 710 |
_text.push_back(QString::number(p[ii])); |
| 711 |
} |
| 712 |
}; |
| 713 |
|
| 714 |
class TranslateTag : public XMLLeafTag |
| 715 |
{ |
| 716 |
public: |
| 717 |
TranslateTag(const QString& sid,const vcg::Point4f& p) |
| 718 |
:XMLLeafTag("translate") |
| 719 |
{ |
| 720 |
_attributes.push_back(TagAttribute("sid",sid)); |
| 721 |
|
| 722 |
for(unsigned int ii =0;ii < 4; ++ii) |
| 723 |
_text.push_back(QString::number(p[ii])); |
| 724 |
} |
| 725 |
}; |
| 726 |
|
| 727 |
class InstanceGeometryTag : public XMLTag |
| 728 |
{ |
| 729 |
public: |
| 730 |
InstanceGeometryTag(const QString& url) |
| 731 |
:XMLTag("instance_geometry") |
| 732 |
{ |
| 733 |
_attributes.push_back(TagAttribute("url",testSharp(url))); |
| 734 |
} |
| 735 |
}; |
| 736 |
|
| 737 |
class BindMaterialTag : public XMLTag |
| 738 |
{ |
| 739 |
public: |
| 740 |
BindMaterialTag() |
| 741 |
:XMLTag("bind_material") |
| 742 |
{ |
| 743 |
} |
| 744 |
}; |
| 745 |
|
| 746 |
class InstanceMaterialTag : public XMLTag |
| 747 |
{ |
| 748 |
public: |
| 749 |
InstanceMaterialTag(const QString& symbol,const QString& target) |
| 750 |
:XMLTag("instance_material") |
| 751 |
{ |
| 752 |
_attributes.push_back(TagAttribute("symbol",symbol)); |
| 753 |
_attributes.push_back(TagAttribute("target",testSharp(target))); |
| 754 |
} |
| 755 |
}; |
| 756 |
|
| 757 |
class BindVertexInputTag : public XMLTag |
| 758 |
{ |
| 759 |
public: |
| 760 |
BindVertexInputTag(const QString& semantic,const QString& input_semantic,const QString& input_set) |
| 761 |
:XMLTag("bind_vertex_input") |
| 762 |
{ |
| 763 |
_attributes.push_back(TagAttribute("semantic",semantic)); |
| 764 |
_attributes.push_back(TagAttribute("input_semantic",input_semantic)); |
| 765 |
} |
| 766 |
}; |
| 767 |
|
| 768 |
class SceneTag : public XMLTag |
| 769 |
{ |
| 770 |
public: |
| 771 |
SceneTag() |
| 772 |
:XMLTag("scene") |
| 773 |
{ |
| 774 |
} |
| 775 |
}; |
| 776 |
|
| 777 |
#include <QDateTime> |
| 778 |
|
| 779 |
class CreatedTag : public XMLLeafTag |
| 780 |
{ |
| 781 |
public: |
| 782 |
CreatedTag() |
| 783 |
:XMLLeafTag("created") |
| 784 |
{ |
| 785 |
QDateTime dateCreated = QDateTime::currentDateTime().toUTC(); |
| 786 |
QString dateCreatedStr = dateCreated.toString(); |
| 787 |
_text.push_back(dateCreatedStr); |
| 788 |
} |
| 789 |
}; |
| 790 |
|
| 791 |
class ModifiedTag : public XMLLeafTag |
| 792 |
{ |
| 793 |
public: |
| 794 |
ModifiedTag() |
| 795 |
:XMLLeafTag("modified") |
| 796 |
{ |
| 797 |
QDateTime dateModified = QDateTime::currentDateTime().toUTC(); |
| 798 |
QString dateModifiedStr = dateModified.toString(); |
| 799 |
_text.push_back(dateModifiedStr); |
| 800 |
} |
| 801 |
}; |
| 802 |
|
| 803 |
class InstanceVisualSceneTag : public XMLTag |
| 804 |
{ |
| 805 |
public: |
| 806 |
InstanceVisualSceneTag(const QString& url) |
| 807 |
:XMLTag("instance_visual_scene") |
| 808 |
{ |
| 809 |
_attributes.push_back(TagAttribute("url",testSharp(url))); |
| 810 |
} |
| 811 |
}; |
| 812 |
} |
| 813 |
|
| 814 |
class DocumentManager |
| 815 |
{ |
| 816 |
private: |
| 817 |
static void connectHierarchyNode(XMLInteriorNode* node0,XMLInteriorNode* node1,XMLLeafNode* leaf) |
| 818 |
{ |
| 819 |
node1->_sons.push_back(leaf); |
| 820 |
node0->_sons.push_back(node1); |
| 821 |
} |
| 822 |
|
| 823 |
static void connectHierarchyNode(XMLInteriorNode* node0,XMLInteriorNode* node1,XMLInteriorNode* node2,XMLInteriorNode* node3,XMLNode* node4) |
| 824 |
{ |
| 825 |
node3->_sons.push_back(node4); |
| 826 |
node2->_sons.push_back(node3); |
| 827 |
node1->_sons.push_back(node2); |
| 828 |
node0->_sons.push_back(node1); |
| 829 |
} |
| 830 |
|
| 831 |
static void connectHierarchyNode(XMLInteriorNode* node0,XMLInteriorNode* node1,XMLInteriorNode* node2,XMLInteriorNode* node3) |
| 832 |
{ |
| 833 |
node2->_sons.push_back(node3); |
| 834 |
node1->_sons.push_back(node2); |
| 835 |
node0->_sons.push_back(node1); |
| 836 |
} |
| 837 |
|
| 838 |
static void connectHierarchyNode(XMLInteriorNode* node0,XMLInteriorNode* node1,XMLInteriorNode* node2) |
| 839 |
{ |
| 840 |
node1->_sons.push_back(node2); |
| 841 |
node0->_sons.push_back(node1); |
| 842 |
} |
| 843 |
|
| 844 |
template<typename MESHMODELTYPE> |
| 845 |
static void splitMeshInTexturedPatches(const MESHMODELTYPE& m,QVector<QVector<int> >& patches) |
| 846 |
{ |
| 847 |
patches.resize(m.textures.size()); |
| 848 |
int cc = 0; |
| 849 |
for(typename MESHMODELTYPE::ConstFaceIterator itf = m.face.begin();itf != m.face.end();++itf) |
| 850 |
{ |
| 851 |
int tmp = itf->cWT(0).N(); |
| 852 |
patches[tmp].push_back(cc); |
| 853 |
++cc; |
| 854 |
} |
| 855 |
} |
| 856 |
|
| 857 |
public: |
| 858 |
template<typename MESHMODELTYPE> |
| 859 |
static XMLDocument* createColladaDocument(const MESHMODELTYPE& m,const int mask) |
| 860 |
{ |
| 861 |
|
| 862 |
const unsigned int edgefacenum = 3; |
| 863 |
typedef XMLInteriorNode XNode; |
| 864 |
typedef XMLLeafNode XLeaf; |
| 865 |
|
| 866 |
XNode* root = new XNode(new Tags::ColladaTag()); |
| 867 |
XNode* assetnode = new XNode(new Tags::AssetTag()); |
| 868 |
XNode* contributornode = new XNode(new Tags::ContributorTag()); |
| 869 |
contributornode->_sons.push_back(new XLeaf(new Tags::AuthorTag())); |
| 870 |
contributornode->_sons.push_back(new XLeaf(new Tags::AuthoringToolTag())); |
| 871 |
|
| 872 |
assetnode->_sons.push_back(contributornode); |
| 873 |
assetnode->_sons.push_back(new XLeaf(new Tags::UpAxisTag())); |
| 874 |
assetnode->_sons.push_back(new XLeaf(new Tags::CreatedTag())); |
| 875 |
assetnode->_sons.push_back(new XLeaf(new Tags::ModifiedTag())); |
| 876 |
root->_sons.push_back(assetnode); |
| 877 |
|
| 878 |
XNode* libimages = new XNode(new Tags::LibraryImagesTag()); |
| 879 |
for(unsigned int ii = 0;ii < m.textures.size();++ii) |
| 880 |
{ |
| 881 |
QString subfix = QString::number(ii); |
| 882 |
XNode* imagenode = new XNode(new Tags::ImageTag(QString("texture") + subfix,QString("texture") + subfix)); |
| 883 |
XLeaf* initfromnode = new XLeaf(new Tags::InitFromTag(QString::fromStdString(m.textures[ii]))); |
| 884 |
imagenode->_sons.push_back(initfromnode); |
| 885 |
libimages->_sons.push_back(imagenode); |
| 886 |
} |
| 887 |
root->_sons.push_back(libimages); |
| 888 |
|
| 889 |
XNode* libmaterials = new XNode(new Tags::LibraryMaterialsTag()); |
| 890 |
for(unsigned int ii = 0;ii < m.textures.size();++ii) |
| 891 |
{ |
| 892 |
QString subfix = QString::number(ii); |
| 893 |
QString mat = "material" + subfix; |
| 894 |
XNode* materialnode = new XNode(new Tags::MaterialTag(mat,mat)); |
| 895 |
XLeaf* instanceeff = new XLeaf(new Tags::InstanceEffectTag(mat+"-fx")); |
| 896 |
materialnode->_sons.push_back(instanceeff); |
| 897 |
libmaterials->_sons.push_back(materialnode); |
| 898 |
} |
| 899 |
root->_sons.push_back(libmaterials); |
| 900 |
|
| 901 |
XNode* libeffects = new XNode(new Tags::LibraryEffectsTag()); |
| 902 |
for(unsigned int ii = 0;ii < m.textures.size();++ii) |
| 903 |
{ |
| 904 |
QString subfix = QString::number(ii); |
| 905 |
QString mat = "material" + subfix + "-fx"; |
| 906 |
XNode* effectnode = new XNode(new Tags::EffectTag(mat)); |
| 907 |
XNode* procommnode = new XNode(new Tags::ProfileCommonTag()); |
| 908 |
QString tex = QString("texture")+subfix; |
| 909 |
XNode* newparamnode = new XNode(new Tags::NewParamTag(tex+"-surface")); |
| 910 |
XNode* surfacenode = new XNode(new Tags::SurfaceTag()); |
| 911 |
XLeaf* initfromnode = new XLeaf(new Tags::InitFromTag(tex)); |
| 912 |
QImage img(QString::fromStdString(m.textures[ii])); |
| 913 |
QImage::Format f = img.format(); |
| 914 |
QString form = "R8G8B8"; |
| 915 |
if (f==QImage::Format_ARGB32) |
| 916 |
form = "A8R8G8B8"; |
| 917 |
XLeaf* formatnode = new XLeaf(new Tags::FormatTag(form)); |
| 918 |
surfacenode->_sons.push_back(initfromnode); |
| 919 |
surfacenode->_sons.push_back(formatnode); |
| 920 |
newparamnode->_sons.push_back(surfacenode); |
| 921 |
procommnode->_sons.push_back(newparamnode); |
| 922 |
|
| 923 |
XNode* newparamnode2 = new XNode(new Tags::NewParamTag(tex+"-sampler")); |
| 924 |
XNode* samplernode = new XNode(new Tags::Sampler2DTag()); |
| 925 |
XLeaf* sourcenode = new XLeaf(new Tags::SourceTag(tex+"-surface")); |
| 926 |
XLeaf* minfilt = new XLeaf(new Tags::MinFilterTag("LINEAR")); |
| 927 |
XLeaf* magfilt = new XLeaf(new Tags::MagFilterTag("LINEAR")); |
| 928 |
samplernode->_sons.push_back(sourcenode); |
| 929 |
samplernode->_sons.push_back(minfilt); |
| 930 |
samplernode->_sons.push_back(magfilt); |
| 931 |
newparamnode2->_sons.push_back(samplernode); |
| 932 |
procommnode->_sons.push_back(newparamnode2); |
| 933 |
|
| 934 |
XNode* technode = new XNode(new Tags::TechniqueTag("common")); |
| 935 |
XNode* blinnnode = new XNode(new Tags::BlinnTag()); |
| 936 |
|
| 937 |
XNode* emissionnode = new XNode(new Tags::EmissionTag()); |
| 938 |
XLeaf* colorem = new XLeaf(new Tags::ColorTag(0,0,0,1)); |
| 939 |
XNode* ambientnode = new XNode(new Tags::AmbientTag()); |
| 940 |
XLeaf* coloramb = new XLeaf(new Tags::ColorTag(0,0,0,1)); |
| 941 |
XNode* diffusenode = new XNode(new Tags::DiffuseTag()); |
| 942 |
XLeaf* texturenode = new XLeaf(new Tags::TextureTag(tex,"UVSET0")); |
| 943 |
XNode* specularnode = new XNode(new Tags::SpecularTag()); |
| 944 |
XLeaf* colorspec = new XLeaf(new Tags::ColorTag(0,0,0,1)); |
| 945 |
XNode* shinenode = new XNode(new Tags::ShininessTag()); |
| 946 |
XLeaf* floatshine = new XLeaf(new Tags::FloatTag(0.3)); |
| 947 |
XNode* reflectivenode = new XNode(new Tags::ReflectiveTag()); |
| 948 |
XLeaf* colorref = new XLeaf(new Tags::ColorTag(0,0,0,1)); |
| 949 |
XNode* reflectivitynode = new XNode(new Tags::ReflectivityTag()); |
| 950 |
XLeaf* floatrefl = new XLeaf(new Tags::FloatTag(0.5)); |
| 951 |
XNode* transparentnode = new XNode(new Tags::TransparentTag()); |
| 952 |
XLeaf* colortra = new XLeaf(new Tags::ColorTag(0,0,0,1)); |
| 953 |
XNode* transparencynode = new XNode(new Tags::TransparencyTag()); |
| 954 |
XLeaf* floattra = new XLeaf(new Tags::FloatTag(0.0)); |
| 955 |
XNode* refranode = new XNode(new Tags::IndexOfRefractionTag()); |
| 956 |
XLeaf* floatrefrac = new XLeaf(new Tags::FloatTag(0.0)); |
| 957 |
|
| 958 |
connectHierarchyNode(blinnnode,emissionnode,colorem); |
| 959 |
connectHierarchyNode(blinnnode,ambientnode,coloramb); |
| 960 |
connectHierarchyNode(blinnnode,diffusenode,texturenode); |
| 961 |
connectHierarchyNode(blinnnode,specularnode,colorspec); |
| 962 |
connectHierarchyNode(blinnnode,shinenode,floatshine); |
| 963 |
connectHierarchyNode(blinnnode,reflectivenode,colorref); |
| 964 |
connectHierarchyNode(blinnnode,reflectivitynode,floatrefl); |
| 965 |
connectHierarchyNode(blinnnode,transparentnode,colortra); |
| 966 |
connectHierarchyNode(blinnnode,transparencynode,floattra); |
| 967 |
connectHierarchyNode(blinnnode,refranode,floatrefrac); |
| 968 |
|
| 969 |
connectHierarchyNode(procommnode,technode,blinnnode); |
| 970 |
|
| 971 |
effectnode->_sons.push_back(procommnode); |
| 972 |
libeffects->_sons.push_back(effectnode); |
| 973 |
} |
| 974 |
root->_sons.push_back(libeffects); |
| 975 |
|
| 976 |
XNode* libgeo = new XNode(new Tags::LibraryGeometriesTag()); |
| 977 |
QString subfix = "0"; |
| 978 |
QString shape = "shape" + subfix; |
| 979 |
XNode* geometrynode = new XNode(new Tags::GeometryTag(shape+"-lib",shape)); |
| 980 |
XNode* meshnode = new XNode(new Tags::MeshTag()); |
| 981 |
XNode* sourcepos = new XNode(new Tags::SourceTag(shape+"-lib-positions","position")); |
| 982 |
|
| 983 |
unsigned int return_component_number = CoordNumber<typename MESHMODELTYPE::CoordType>::coord(); |
| 984 |
XLeaf* floatarr = new XLeaf(new Tags::FloatArrayTag(shape+"-lib-positions-array",m.vert.size() * return_component_number,m,Tags::FloatArrayTag::VERTPOSITION,return_component_number)); |
| 985 |
XNode* techcommnode = new XNode(new Tags::TechniqueCommonTag()); |
| 986 |
XNode* accessornode = new XNode(new Tags::AccessorTag(m.vert.size(),shape+"-lib-positions-array",return_component_number)); |
| 987 |
XNode* paramx = new XNode(new Tags::ParamTag("X","float")); |
| 988 |
XNode* paramy = new XNode(new Tags::ParamTag("Y","float")); |
| 989 |
XNode* paramz = new XNode(new Tags::ParamTag("Z","float")); |
| 990 |
|
| 991 |
sourcepos->_sons.push_back(floatarr); |
| 992 |
accessornode->_sons.push_back(paramx); |
| 993 |
accessornode->_sons.push_back(paramy); |
| 994 |
accessornode->_sons.push_back(paramz); |
| 995 |
|
| 996 |
techcommnode->_sons.push_back(accessornode); |
| 997 |
sourcepos->_sons.push_back(techcommnode); |
| 998 |
|
| 999 |
meshnode->_sons.push_back(sourcepos); |
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
bool normalmask = bool((mask & vcg::tri::io::Mask::IOM_FACENORMAL) || (mask & vcg::tri::io::Mask::IOM_WEDGNORMAL) || (mask & vcg::tri::io::Mask::IOM_VERTNORMAL)); |
| 1004 |
if (normalmask) |
| 1005 |
{ |
| 1006 |
XNode* sourcenormal = new XNode(new Tags::SourceTag(shape+"-lib-normals","normal")); |
| 1007 |
|
| 1008 |
|
| 1009 |
XLeaf* floatnormarr = new XLeaf(new Tags::FloatArrayTag(shape+"-lib-normals-array",m.face.size() * return_component_number,m,Tags::FloatArrayTag::FACENORMAL,return_component_number)); |
| 1010 |
XNode* techcommnormnode = new XNode(new Tags::TechniqueCommonTag()); |
| 1011 |
XNode* accessornormnode = new XNode(new Tags::AccessorTag(m.face.size(),shape+"-lib-normals-array",return_component_number)); |
| 1012 |
|
| 1013 |
|
| 1014 |
XNode* paramnormx = new XNode(new Tags::ParamTag("X","float")); |
| 1015 |
XNode* paramnormy = new XNode(new Tags::ParamTag("Y","float")); |
| 1016 |
XNode* paramnormz = new XNode(new Tags::ParamTag("Z","float")); |
| 1017 |
|
| 1018 |
sourcenormal->_sons.push_back(floatnormarr); |
| 1019 |
|
| 1020 |
accessornormnode->_sons.push_back(paramnormx); |
| 1021 |
accessornormnode->_sons.push_back(paramnormy); |
| 1022 |
accessornormnode->_sons.push_back(paramnormz); |
| 1023 |
|
| 1024 |
techcommnormnode->_sons.push_back(accessornormnode); |
| 1025 |
sourcenormal->_sons.push_back(techcommnormnode); |
| 1026 |
|
| 1027 |
meshnode->_sons.push_back(sourcenormal); |
| 1028 |
} |
| 1029 |
|
| 1030 |
bool texmask = bool(mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD); |
| 1031 |
if (texmask) |
| 1032 |
{ |
| 1033 |
XNode* sourcewedge = new XNode(new Tags::SourceTag(shape+"-lib-map","map")); |
| 1034 |
return_component_number = CoordNumber<typename MESHMODELTYPE::FaceType::TexCoordType::PointType>::coord(); |
| 1035 |
|
| 1036 |
XLeaf* floatwedgearr = new XLeaf(new Tags::FloatArrayTag(shape+"-lib-map-array",m.face.size() * return_component_number * edgefacenum,m,Tags::FloatArrayTag::WEDGETEXCOORD,return_component_number)); |
| 1037 |
XNode* techcommwedgenode = new XNode(new Tags::TechniqueCommonTag()); |
| 1038 |
XNode* accessorwedgenode = new XNode(new Tags::AccessorTag(m.face.size() * edgefacenum,shape+"-lib-map-array",return_component_number)); |
| 1039 |
|
| 1040 |
|
| 1041 |
XNode* paramwedgeu = new XNode(new Tags::ParamTag("U","float")); |
| 1042 |
XNode* paramwedgev = new XNode(new Tags::ParamTag("V","float")); |
| 1043 |
|
| 1044 |
sourcewedge->_sons.push_back(floatwedgearr); |
| 1045 |
|
| 1046 |
accessorwedgenode->_sons.push_back(paramwedgeu); |
| 1047 |
accessorwedgenode->_sons.push_back(paramwedgev); |
| 1048 |
|
| 1049 |
techcommwedgenode->_sons.push_back(accessorwedgenode); |
| 1050 |
sourcewedge->_sons.push_back(techcommwedgenode); |
| 1051 |
|
| 1052 |
meshnode->_sons.push_back(sourcewedge); |
| 1053 |
} |
| 1054 |
|
| 1055 |
XNode* vertnode = new XNode(new Tags::VerticesTag(shape+"-lib-vertices")); |
| 1056 |
XNode* inputposnode = new XNode(new Tags::InputTag("POSITION",shape+"-lib-positions")); |
| 1057 |
vertnode->_sons.push_back(inputposnode); |
| 1058 |
meshnode->_sons.push_back(vertnode); |
| 1059 |
XNode* trianglesnode = NULL; |
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
|
| 1072 |
|
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
QVector<QVector<int> > mytripatches; |
| 1079 |
if ((texmask) && (m.textures.size() != 0)) |
| 1080 |
splitMeshInTexturedPatches(m,mytripatches); |
| 1081 |
|
| 1082 |
QVector<QVector<int> >::iterator itp = mytripatches.begin(); |
| 1083 |
int indmat = 0; |
| 1084 |
do |
| 1085 |
{ |
| 1086 |
if ((m.textures.size() == 0) || (!texmask)) |
| 1087 |
{ |
| 1088 |
|
| 1089 |
trianglesnode = new XNode(new Tags::TrianglesTag(m.face.size())); |
| 1090 |
} |
| 1091 |
else |
| 1092 |
trianglesnode = new XNode(new Tags::TrianglesTag(mytripatches[indmat].size(),"material" + QString::number(indmat))); |
| 1093 |
|
| 1094 |
XNode* inputtrinode = new XNode(new Tags::InputTag(0,"VERTEX",shape+"-lib-vertices")); |
| 1095 |
trianglesnode->_sons.push_back(inputtrinode); |
| 1096 |
if (normalmask) |
| 1097 |
{ |
| 1098 |
XNode* inputnormnode = new XNode(new Tags::InputTag(1,"NORMAL",shape+"-lib-normals")); |
| 1099 |
trianglesnode->_sons.push_back(inputnormnode); |
| 1100 |
} |
| 1101 |
|
| 1102 |
if (texmask) |
| 1103 |
{ |
| 1104 |
XNode* inputwedgenode = new XNode(new Tags::InputTag(2,"TEXCOORD",shape+"-lib-map")); |
| 1105 |
trianglesnode->_sons.push_back(inputwedgenode); |
| 1106 |
} |
| 1107 |
|
| 1108 |
XLeaf* polyleaf = NULL; |
| 1109 |
if (itp == mytripatches.end()) |
| 1110 |
polyleaf = new XLeaf(new Tags::PTag(m,edgefacenum,normalmask,texmask)); |
| 1111 |
else |
| 1112 |
polyleaf = new XLeaf(new Tags::PTag(m,edgefacenum,(*itp),normalmask,texmask)); |
| 1113 |
|
| 1114 |
trianglesnode->_sons.push_back(polyleaf); |
| 1115 |
meshnode->_sons.push_back(trianglesnode); |
| 1116 |
|
| 1117 |
++indmat; |
| 1118 |
if (itp != mytripatches.end()) |
| 1119 |
++itp; |
| 1120 |
}while(itp != mytripatches.end()); |
| 1121 |
|
| 1122 |
connectHierarchyNode(libgeo,geometrynode,meshnode); |
| 1123 |
root->_sons.push_back(libgeo); |
| 1124 |
|
| 1125 |
XNode* libvisualnode = new XNode(new Tags::LibraryVisualScenesTag()); |
| 1126 |
XNode* visualscenenode = new XNode(new Tags::VisualSceneTag("VisualSceneNode","VisualScene")); |
| 1127 |
XNode* nodenode = new XNode(new Tags::NodeTag("node","node")); |
| 1128 |
XNode* instgeonode = new XNode(new Tags::InstanceGeometryTag(shape+"-lib")); |
| 1129 |
XNode* bindnode = new XNode(new Tags::BindMaterialTag()); |
| 1130 |
XNode* techcommmatnode = new XNode(new Tags::TechniqueCommonTag()); |
| 1131 |
for(unsigned int ii = 0; ii < m.textures.size(); ++ii) |
| 1132 |
{ |
| 1133 |
XNode* instmatnode = new XNode(new Tags::InstanceMaterialTag("material" + QString::number(ii),"material" + QString::number(ii))); |
| 1134 |
XNode* bindvertnode = new XNode(new Tags::BindVertexInputTag("UVSET0","TEXCOORD","0")); |
| 1135 |
connectHierarchyNode(techcommmatnode,instmatnode,bindvertnode); |
| 1136 |
} |
| 1137 |
|
| 1138 |
connectHierarchyNode(visualscenenode,nodenode,instgeonode,bindnode,techcommmatnode); |
| 1139 |
libvisualnode->_sons.push_back(visualscenenode); |
| 1140 |
root->_sons.push_back(libvisualnode); |
| 1141 |
|
| 1142 |
XNode* scenenode = new XNode(new Tags::SceneTag()); |
| 1143 |
XNode* instvisualscenenode = new XNode(new Tags::InstanceVisualSceneTag("VisualSceneNode")); |
| 1144 |
|
| 1145 |
scenenode->_sons.push_back(instvisualscenenode); |
| 1146 |
root->_sons.push_back(scenenode); |
| 1147 |
|
| 1148 |
return new XMLDocument(root); |
| 1149 |
} |
| 1150 |
|
| 1151 |
static void destroyColladaDocument(XMLDocument* doc) |
| 1152 |
{ |
| 1153 |
delete doc; |
| 1154 |
} |
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
|
| 1161 |
|
| 1162 |
|
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
}; |
| 1168 |
} |
| 1169 |
#endif |