Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

170 Zeilen
5.1 KiB

  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2012, assimp team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the assimp team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the assimp team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. /** @file FBXNoteAttribute.cpp
  34. * @brief Assimp::FBX::NodeAttribute (and subclasses) implementation
  35. */
  36. #include "AssimpPCH.h"
  37. #ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
  38. #include "FBXParser.h"
  39. #include "FBXDocument.h"
  40. #include "FBXImporter.h"
  41. #include "FBXImportSettings.h"
  42. #include "FBXDocumentUtil.h"
  43. #include "FBXProperties.h"
  44. namespace Assimp {
  45. namespace FBX {
  46. using namespace Util;
  47. // ------------------------------------------------------------------------------------------------
  48. Deformer::Deformer(uint64_t id, const Element& element, const Document& doc, const std::string& name)
  49. : Object(id,element,name)
  50. {
  51. const Scope& sc = GetRequiredScope(element);
  52. const std::string& classname = ParseTokenAsString(GetRequiredToken(element,2));
  53. props = GetPropertyTable(doc,"Deformer.Fbx" + classname,element,sc,true);
  54. }
  55. // ------------------------------------------------------------------------------------------------
  56. Deformer::~Deformer()
  57. {
  58. }
  59. // ------------------------------------------------------------------------------------------------
  60. Cluster::Cluster(uint64_t id, const Element& element, const Document& doc, const std::string& name)
  61. : Deformer(id,element,doc,name)
  62. , node()
  63. {
  64. const Scope& sc = GetRequiredScope(element);
  65. const Element* const Indexes = sc["Indexes"];
  66. const Element* const Weights = sc["Weights"];
  67. const Element& Transform = GetRequiredElement(sc,"Transform",&element);
  68. const Element& TransformLink = GetRequiredElement(sc,"TransformLink",&element);
  69. transform = ReadMatrix(Transform);
  70. transformLink = ReadMatrix(TransformLink);
  71. // it is actually possible that there be Deformer's with no weights
  72. if (!!Indexes != !!Weights) {
  73. DOMError("either Indexes or Weights are missing from Cluster",&element);
  74. }
  75. if(Indexes) {
  76. ParseVectorDataArray(indices,*Indexes);
  77. ParseVectorDataArray(weights,*Weights);
  78. }
  79. if(indices.size() != weights.size()) {
  80. DOMError("sizes of index and weight array don't match up",&element);
  81. }
  82. // read assigned node
  83. const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID(),"Model");
  84. BOOST_FOREACH(const Connection* con, conns) {
  85. const Model* const mod = ProcessSimpleConnection<Model>(*con, false, "Model -> Cluster", element);
  86. if(mod) {
  87. node = mod;
  88. break;
  89. }
  90. }
  91. if (!node) {
  92. DOMError("failed to read target Node for Cluster",&element);
  93. }
  94. }
  95. // ------------------------------------------------------------------------------------------------
  96. Cluster::~Cluster()
  97. {
  98. }
  99. // ------------------------------------------------------------------------------------------------
  100. Skin::Skin(uint64_t id, const Element& element, const Document& doc, const std::string& name)
  101. : Deformer(id,element,doc,name)
  102. {
  103. const Scope& sc = GetRequiredScope(element);
  104. const Element* const Link_DeformAcuracy = sc["Link_DeformAcuracy"];
  105. if(Link_DeformAcuracy) {
  106. accuracy = ParseTokenAsFloat(GetRequiredToken(*Link_DeformAcuracy,0));
  107. }
  108. // resolve assigned clusters
  109. const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID(),"Deformer");
  110. clusters.reserve(conns.size());
  111. BOOST_FOREACH(const Connection* con, conns) {
  112. const Cluster* const cluster = ProcessSimpleConnection<Cluster>(*con, false, "Cluster -> Skin", element);
  113. if(cluster) {
  114. clusters.push_back(cluster);
  115. continue;
  116. }
  117. }
  118. }
  119. // ------------------------------------------------------------------------------------------------
  120. Skin::~Skin()
  121. {
  122. }
  123. }
  124. }
  125. #endif