Fix issues with Vertex + Color4
parent
565b7f6d56
commit
b14a50a124
|
@ -384,17 +384,17 @@ void AMFImporter::ParseNode_Instance(XmlNode &node) {
|
|||
for (auto ¤tNode : node.children()) {
|
||||
const std::string ¤tName = currentNode.name();
|
||||
if (currentName == "deltax") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Delta.x);
|
||||
XmlParser::getValueAsReal(currentNode, als.Delta.x);
|
||||
} else if (currentName == "deltay") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Delta.y);
|
||||
XmlParser::getValueAsReal(currentNode, als.Delta.y);
|
||||
} else if (currentName == "deltaz") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Delta.z);
|
||||
XmlParser::getValueAsReal(currentNode, als.Delta.z);
|
||||
} else if (currentName == "rx") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Delta.x);
|
||||
XmlParser::getValueAsReal(currentNode, als.Delta.x);
|
||||
} else if (currentName == "ry") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Delta.y);
|
||||
XmlParser::getValueAsReal(currentNode, als.Delta.y);
|
||||
} else if (currentName == "rz") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Delta.z);
|
||||
XmlParser::getValueAsReal(currentNode, als.Delta.z);
|
||||
}
|
||||
}
|
||||
ParseHelper_Node_Exit();
|
||||
|
|
|
@ -167,11 +167,11 @@ void AMFImporter::ParseNode_Coordinates(XmlNode &node) {
|
|||
AMFCoordinates &als = *((AMFCoordinates *)ne); // alias for convenience
|
||||
const std::string ¤tName = ai_tolower(currentNode.name());
|
||||
if (currentName == "x") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Coordinate.x);
|
||||
XmlParser::getValueAsReal(currentNode, als.Coordinate.x);
|
||||
} else if (currentName == "y") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Coordinate.y);
|
||||
XmlParser::getValueAsReal(currentNode, als.Coordinate.y);
|
||||
} else if (currentName == "z") {
|
||||
XmlParser::getValueAsFloat(currentNode, als.Coordinate.z);
|
||||
XmlParser::getValueAsReal(currentNode, als.Coordinate.z);
|
||||
}
|
||||
}
|
||||
ParseHelper_Node_Exit();
|
||||
|
|
|
@ -263,26 +263,25 @@ void AMFImporter::ParseNode_TexMap(XmlNode &node, const bool pUseOldName) {
|
|||
const std::string &name = currentNode.name();
|
||||
if (name == "utex1") {
|
||||
read_flag[0] = true;
|
||||
XmlParser::getValueAsFloat(node, als.TextureCoordinate[0].x);
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[0].x);
|
||||
} else if (name == "utex2") {
|
||||
read_flag[1] = true;
|
||||
XmlParser::getValueAsFloat(node, als.TextureCoordinate[1].x);
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[1].x);
|
||||
} else if (name == "utex3") {
|
||||
read_flag[2] = true;
|
||||
XmlParser::getValueAsFloat(node, als.TextureCoordinate[2].x);
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[2].x);
|
||||
} else if (name == "vtex1") {
|
||||
read_flag[3] = true;
|
||||
XmlParser::getValueAsFloat(node, als.TextureCoordinate[0].y);
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[0].y);
|
||||
} else if (name == "vtex2") {
|
||||
read_flag[4] = true;
|
||||
XmlParser::getValueAsFloat(node, als.TextureCoordinate[1].y);
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[1].y);
|
||||
} else if (name == "vtex3") {
|
||||
read_flag[5] = true;
|
||||
XmlParser::getValueAsFloat(node, als.TextureCoordinate[2].y);
|
||||
XmlParser::getValueAsReal(node, als.TextureCoordinate[2].y);
|
||||
}
|
||||
}
|
||||
ParseHelper_Node_Exit();
|
||||
|
||||
} else {
|
||||
for (pugi::xml_attribute &attr : node.attributes()) {
|
||||
const std::string name = attr.name();
|
||||
|
|
|
@ -1600,7 +1600,7 @@ void Parser::ParseLV3MeshCListBlock(unsigned int iNumVertices, ASE::Mesh &mesh)
|
|||
aiColor4D vTemp;
|
||||
vTemp.a = 1.0f;
|
||||
unsigned int iIndex;
|
||||
ParseLV4MeshRealTriple(&vTemp.r, iIndex);
|
||||
ParseLV4MeshFloatTriple(&vTemp.r, iIndex);
|
||||
|
||||
if (iIndex >= iNumVertices) {
|
||||
LogWarning("Vertex color has an invalid index. It will be ignored");
|
||||
|
|
|
@ -968,34 +968,34 @@ void ColladaParser::ReadLight(XmlNode &node, Collada::Light &pLight) {
|
|||
content = fast_atoreal_move<ai_real>(content, (ai_real &)pLight.mColor.b);
|
||||
SkipSpacesAndLineEnd(&content, end);
|
||||
} else if (currentName == "constant_attenuation") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mAttConstant);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mAttConstant);
|
||||
} else if (currentName == "linear_attenuation") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mAttLinear);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mAttLinear);
|
||||
} else if (currentName == "quadratic_attenuation") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mAttQuadratic);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mAttQuadratic);
|
||||
} else if (currentName == "falloff_angle") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mFalloffAngle);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mFalloffAngle);
|
||||
} else if (currentName == "falloff_exponent") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mFalloffExponent);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mFalloffExponent);
|
||||
}
|
||||
// FCOLLADA extensions
|
||||
// -------------------------------------------------------
|
||||
else if (currentName == "outer_cone") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mOuterAngle);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mOuterAngle);
|
||||
} else if (currentName == "penumbra_angle") { // this one is deprecated, now calculated using outer_cone
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mPenumbraAngle);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mPenumbraAngle);
|
||||
} else if (currentName == "intensity") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mIntensity);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mIntensity);
|
||||
}
|
||||
else if (currentName == "falloff") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mOuterAngle);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mOuterAngle);
|
||||
} else if (currentName == "hotspot_beam") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mFalloffAngle);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mFalloffAngle);
|
||||
}
|
||||
// OpenCOLLADA extensions
|
||||
// -------------------------------------------------------
|
||||
else if (currentName == "decay_falloff") {
|
||||
XmlParser::getValueAsFloat(currentNode, pLight.mOuterAngle);
|
||||
XmlParser::getValueAsReal(currentNode, pLight.mOuterAngle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1010,15 +1010,15 @@ void ColladaParser::ReadCamera(XmlNode &node, Collada::Camera &camera) {
|
|||
if (currentName == "orthographic") {
|
||||
camera.mOrtho = true;
|
||||
} else if (currentName == "xfov" || currentName == "xmag") {
|
||||
XmlParser::getValueAsFloat(currentNode, camera.mHorFov);
|
||||
XmlParser::getValueAsReal(currentNode, camera.mHorFov);
|
||||
} else if (currentName == "yfov" || currentName == "ymag") {
|
||||
XmlParser::getValueAsFloat(currentNode, camera.mVerFov);
|
||||
XmlParser::getValueAsReal(currentNode, camera.mVerFov);
|
||||
} else if (currentName == "aspect_ratio") {
|
||||
XmlParser::getValueAsFloat(currentNode, camera.mAspect);
|
||||
XmlParser::getValueAsReal(currentNode, camera.mAspect);
|
||||
} else if (currentName == "znear") {
|
||||
XmlParser::getValueAsFloat(currentNode, camera.mZNear);
|
||||
XmlParser::getValueAsReal(currentNode, camera.mZNear);
|
||||
} else if (currentName == "zfar") {
|
||||
XmlParser::getValueAsFloat(currentNode, camera.mZFar);
|
||||
XmlParser::getValueAsReal(currentNode, camera.mZFar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1170,15 +1170,15 @@ void ColladaParser::ReadSamplerProperties(XmlNode &node, Sampler &out) {
|
|||
} else if (currentName == "mirrorV") {
|
||||
XmlParser::getValueAsBool(currentNode, out.mMirrorV);
|
||||
} else if (currentName == "repeatU") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mTransform.mScaling.x);
|
||||
XmlParser::getValueAsReal(currentNode, out.mTransform.mScaling.x);
|
||||
} else if (currentName == "repeatV") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mTransform.mScaling.y);
|
||||
XmlParser::getValueAsReal(currentNode, out.mTransform.mScaling.y);
|
||||
} else if (currentName == "offsetU") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mTransform.mTranslation.x);
|
||||
XmlParser::getValueAsReal(currentNode, out.mTransform.mTranslation.x);
|
||||
} else if (currentName == "offsetV") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mTransform.mTranslation.y);
|
||||
XmlParser::getValueAsReal(currentNode, out.mTransform.mTranslation.y);
|
||||
} else if (currentName == "rotateUV") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mTransform.mRotation);
|
||||
XmlParser::getValueAsReal(currentNode, out.mTransform.mRotation);
|
||||
} else if (currentName == "blend_mode") {
|
||||
std::string v;
|
||||
XmlParser::getValueAsString(currentNode, v);
|
||||
|
@ -1198,14 +1198,14 @@ void ColladaParser::ReadSamplerProperties(XmlNode &node, Sampler &out) {
|
|||
// OKINO extensions
|
||||
// -------------------------------------------------------
|
||||
else if (currentName == "weighting") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mWeighting);
|
||||
XmlParser::getValueAsReal(currentNode, out.mWeighting);
|
||||
} else if (currentName == "mix_with_previous_layer") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mMixWithPrevious);
|
||||
XmlParser::getValueAsReal(currentNode, out.mMixWithPrevious);
|
||||
}
|
||||
// MAX3D extensions
|
||||
// -------------------------------------------------------
|
||||
else if (currentName == "amount") {
|
||||
XmlParser::getValueAsFloat(currentNode, out.mWeighting);
|
||||
XmlParser::getValueAsReal(currentNode, out.mWeighting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1265,13 +1265,13 @@ void ColladaParser::ReadEffectColor(XmlNode &node, aiColor4D &pColor, Sampler &p
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reads an effect entry containing a float
|
||||
void ColladaParser::ReadEffectFloat(XmlNode &node, ai_real &pFloat) {
|
||||
pFloat = 0.f;
|
||||
void ColladaParser::ReadEffectFloat(XmlNode &node, ai_real &pReal) {
|
||||
pReal = 0.f;
|
||||
XmlNode floatNode = node.child("float");
|
||||
if (floatNode.empty()) {
|
||||
return;
|
||||
}
|
||||
XmlParser::getValueAsFloat(floatNode, pFloat);
|
||||
XmlParser::getValueAsReal(floatNode, pReal);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -316,7 +316,7 @@ void OFFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
pScene->mMaterials = new aiMaterial *[pScene->mNumMaterials];
|
||||
aiMaterial *pcMat = new aiMaterial();
|
||||
|
||||
aiColor4D clr(ai_real(0.6), ai_real(0.6), ai_real(0.6), ai_real(1.0));
|
||||
aiColor4D clr(0.6f, 0.6f, 0.6f, 1.0f);
|
||||
pcMat->AddProperty(&clr, 1, AI_MATKEY_COLOR_DIFFUSE);
|
||||
pScene->mMaterials[0] = pcMat;
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ void STLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
mBuffer = &buffer2[0];
|
||||
|
||||
// the default vertex color is light gray.
|
||||
mClrColorDefault.r = mClrColorDefault.g = mClrColorDefault.b = mClrColorDefault.a = (ai_real)0.6;
|
||||
mClrColorDefault.r = mClrColorDefault.g = mClrColorDefault.b = mClrColorDefault.a = 0.6f;
|
||||
|
||||
// allocate a single node
|
||||
mScene->mRootNode = new aiNode();
|
||||
|
@ -209,7 +209,7 @@ void STLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
}
|
||||
pcMat->AddProperty(&clrDiffuse, 1, AI_MATKEY_COLOR_DIFFUSE);
|
||||
pcMat->AddProperty(&clrDiffuse, 1, AI_MATKEY_COLOR_SPECULAR);
|
||||
clrDiffuse = aiColor4D(ai_real(0.05), ai_real(0.05), ai_real(0.05), ai_real(1.0));
|
||||
clrDiffuse = aiColor4D(0.05f, 0.05f, 0.05f, 1.0f);
|
||||
pcMat->AddProperty(&clrDiffuse, 1, AI_MATKEY_COLOR_AMBIENT);
|
||||
|
||||
mScene->mNumMaterials = 1;
|
||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -61,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <functional>
|
||||
|
||||
namespace Assimp {
|
||||
namespace Assimp {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// std::plus-family operates on operands with identical types - we need to
|
||||
|
@ -287,6 +286,10 @@ AI_FORCE_INLINE Vertex operator / (const Vertex& v0,ai_real f) {
|
|||
return Vertex::BinaryOp<Intern::multiplies>(v0,1.f/f);
|
||||
}
|
||||
|
||||
#ifdef AI_DO
|
||||
|
||||
#endif // AI_DO
|
||||
|
||||
AI_FORCE_INLINE Vertex operator * (ai_real f,const Vertex& v0) {
|
||||
return Vertex::BinaryOp<Intern::multiplies>(f,v0);
|
||||
}
|
||||
|
|
|
@ -211,21 +211,27 @@ public:
|
|||
/// @return true, if the value can be read out.
|
||||
static inline bool getValueAsString(XmlNode &node, std::string &text);
|
||||
|
||||
/// @brief Will try to get the value of the node as a real.
|
||||
/// @param[in] node The node to search in.
|
||||
/// @param[out] v The value as a ai_real.
|
||||
/// @return true, if the value can be read out.
|
||||
static inline bool getValueAsReal(XmlNode &node, ai_real &v);
|
||||
|
||||
/// @brief Will try to get the value of the node as a float.
|
||||
/// @param[in] node The node to search in.
|
||||
/// @param[out] text The value as a float.
|
||||
/// @param[out]v The value as a float.
|
||||
/// @return true, if the value can be read out.
|
||||
static inline bool getValueAsFloat(XmlNode &node, ai_real &v);
|
||||
static inline bool getValueAsFloat(XmlNode &node, float &v);
|
||||
|
||||
/// @brief Will try to get the value of the node as an integer.
|
||||
/// @param[in] node The node to search in.
|
||||
/// @param[out] text The value as a int.
|
||||
/// @param[in] node The node to search in.
|
||||
/// @param[out] i The value as a int.
|
||||
/// @return true, if the value can be read out.
|
||||
static inline bool getValueAsInt(XmlNode &node, int &v);
|
||||
|
||||
/// @brief Will try to get the value of the node as an bool.
|
||||
/// @param[in] node The node to search in.
|
||||
/// @param[out] text The value as a bool.
|
||||
/// @param[in] node The node to search in.
|
||||
/// @param[out] v The value as a bool.
|
||||
/// @return true, if the value can be read out.
|
||||
static inline bool getValueAsBool(XmlNode &node, bool &v);
|
||||
|
||||
|
@ -454,7 +460,19 @@ inline bool TXmlParser<TNodeType>::getValueAsString(XmlNode &node, std::string &
|
|||
}
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::getValueAsFloat(XmlNode &node, ai_real &v) {
|
||||
inline bool TXmlParser<TNodeType>::getValueAsReal(XmlNode& node, ai_real& v) {
|
||||
if (node.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
v = node.text().as_float();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template <class TNodeType>
|
||||
inline bool TXmlParser<TNodeType>::getValueAsFloat(XmlNode &node, float &v) {
|
||||
if (node.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue