Finished all shape types
MODIFY
ext/MitsubaLoader/CElementFactory.cpp
ext/MitsubaLoader/CElementFactory.cpp
#include "../../ext/MitsubaLoader/CElementTransform.h"
#include "../../ext/MitsubaLoader/CElementColor.h"
#include "../../ext/MitsubaLoader/CElementShapePLY.h"
+#include "../../ext/MitsubaLoader/CElementShapeRectangle.h"
+#include "../../ext/MitsubaLoader/CElementShapeDisk.h"
namespace irr { namespace ext { namespace MitsubaLoader {
@@ -132,6 +134,14 @@ IElement* CElementFactory::parseShape(const char* _el, const char** _atts)
{
return new CElementShapeCylinder();
}
+ else if (!std::strcmp(_atts[i + 1], "rectangle"))
+ {
+ return new CElementShapeRectangle();
+ }
+ else if (!std::strcmp(_atts[i + 1], "disk"))
+ {
+ return new CElementShapeDisk();
+ }
else
{
ParserLog::mitsubaLoaderError(std::string(_atts[i + 1]) + "is not a type of shape element. \n");

MODIFY
ext/MitsubaLoader/CElementMatrix.cpp
ext/MitsubaLoader/CElementMatrix.cpp
@@ -12,6 +12,7 @@ bool CElementMatrix::processAttributes(const char** _atts)
switch (type)
{
case CElementMatrix::Type::ARBITRARY:
+ {
for (int i = 0; _atts[i]; i += 2)
{
if (!std::strcmp(_atts[i], "value"))
@@ -27,6 +28,7 @@ bool CElementMatrix::processAttributes(const char** _atts)
return false;
}
}
+ }
case CElementMatrix::Type::TRANSLATION:
_IRR_DEBUG_BREAK_IF(true);
case CElementMatrix::Type::ROTATION:

MODIFY
ext/MitsubaLoader/CElementShapeCube.cpp
ext/MitsubaLoader/CElementShapeCube.cpp
@@ -24,7 +24,7 @@ bool CElementShapeCube::processAttributes(const char** _atts)
bool CElementShapeCube::onEndTag(asset::IAssetManager& _assetManager, IElement* _parent)
{
- mesh = _assetManager.getGeometryCreator()->createCubeMesh(core::vector3df(2.0f, 2.0f, 2.0f));
+ mesh = _assetManager.getGeometryCreator()->createCubeMesh(core::vector3df(1.0f, 1.0f, 1.0f));
if (!mesh)
return false;

MODIFY
ext/MitsubaLoader/CElementShapeCylinder.cpp
ext/MitsubaLoader/CElementShapeCylinder.cpp
@@ -26,7 +26,7 @@ bool CElementShapeCylinder::onEndTag(asset::IAssetManager& _assetManager, IEleme
{
const float cylinderHeight = (p0 - p1).getLengthAsFloat();
- mesh = _assetManager.getGeometryCreator()->createCylinderMesh(radius,cylinderHeight,32);
+ mesh = _assetManager.getGeometryCreator()->createCylinderMesh(radius,cylinderHeight,32,0xffffffff,false);
if (!mesh)
return false;

ADD
ext/MitsubaLoader/CElementShapeDisk.cpp
+#include "../../ext/MitsubaLoader/CElementShapeDisk.h"
+
+#include "../../ext/MitsubaLoader/ParserUtil.h"
+#include "../../ext/MitsubaLoader/CElementTransform.h"
+#include "../../ext/MitsubaLoader/CSimpleElement.h"
+
+namespace irr { namespace ext { namespace MitsubaLoader {
+
+
+bool CElementShapeDisk::processAttributes(const char** _atts)
+{
+ //only type is an acceptable argument
+ for (int i = 0; _atts[i]; i += 2)
+ {
+ if (std::strcmp(_atts[i], "type"))
+ {
+ ParserLog::wrongAttribute(_atts[i], getLogName());
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool CElementShapeDisk::onEndTag(asset::IAssetManager& _assetManager, IElement* _parent)
+{
+ mesh = _assetManager.getGeometryCreator()->createDiskMesh(1.0f, 64);
+
+ if (!mesh)
+ return false;
+
+ if (flipNormalsFlag)
+ flipNormals(_assetManager);
+
+ return _parent->processChildData(this);
+}
+
+bool CElementShapeDisk::processChildData(IElement* _child)
+{
+ switch (_child->getType())
+ {
+ case IElement::Type::TRANSFORM:
+ {
+ CElementTransform* transformElement = static_cast<CElementTransform*>(_child);
+
+ if (transformElement->getName() == "toWorld")
+ this->transform = static_cast<CElementTransform*>(_child)->getMatrix();
+ else
+ ParserLog::mitsubaLoaderError("Unqueried attribute '" + transformElement->getName() + "' in element 'shape'");
+
+ return true;
+ }
+ case IElement::Type::BOOLEAN:
+ {
+ CElementBoolean* boolElement = static_cast<CElementBoolean*>(_child);
+ const std::string elementName = boolElement->getNameAttribute();
+
+ if (elementName == "flipNormals")
+ {
+ flipNormalsFlag = boolElement->getValueAttribute();
+ }
+ else
+ {
+ //warning
+ ParserLog::mitsubaLoaderError("Unqueried attribute " + elementName + " in element \"shape\"");
+ }
+
+ return true;
+ }
+ default:
+ ParserLog::wrongChildElement(getLogName(), _child->getLogName());
+ return false;
+ }
+}
+
+}
+}
+}
\ No newline at end of file

MODIFY
ext/MitsubaLoader/CElementShapeOBJ.cpp
ext/MitsubaLoader/CElementShapeOBJ.cpp
@@ -38,7 +38,6 @@ bool CElementShapeOBJ::onEndTag(asset::IAssetManager& _assetManager, IElement* _
return false;
}
- //getAssetInHierarchy?
mesh = static_cast<asset::ICPUMesh*>(_assetManager.getAsset(fileName, asset::IAssetLoader::SAssetLoadParams()));
if (!mesh)

ADD
ext/MitsubaLoader/CElementShapeRectangle.cpp
+#include "../../ext/MitsubaLoader/CElementShapeRectangle.h"
+
+#include "../../ext/MitsubaLoader/ParserUtil.h"
+#include "../../ext/MitsubaLoader/CElementTransform.h"
+#include "../../ext/MitsubaLoader/CSimpleElement.h"
+
+namespace irr { namespace ext { namespace MitsubaLoader {
+
+
+bool CElementShapeRectangle::processAttributes(const char** _atts)
+{
+ //only type is an acceptable argument
+ for (int i = 0; _atts[i]; i += 2)
+ {
+ if (std::strcmp(_atts[i], "type"))
+ {
+ ParserLog::wrongAttribute(_atts[i], getLogName());
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool CElementShapeRectangle::onEndTag(asset::IAssetManager& _assetManager, IElement* _parent)
+{
+ mesh = _assetManager.getGeometryCreator()->createRectangleMesh(core::vector2df_SIMD(1.0f, 1.0f));
+
+ if (!mesh)
+ return false;
+
+ if (flipNormalsFlag)
+ flipNormals(_assetManager);
+
+ return _parent->processChildData(this);
+}
+
+bool CElementShapeRectangle::processChildData(IElement* _child)
+{
+ switch (_child->getType())
+ {
+ case IElement::Type::TRANSFORM:
+ {
+ CElementTransform* transformElement = static_cast<CElementTransform*>(_child);
+
+ if (transformElement->getName() == "toWorld")
+ this->transform = static_cast<CElementTransform*>(_child)->getMatrix();
+ else
+ ParserLog::mitsubaLoaderError("Unqueried attribute '" + transformElement->getName() + "' in element 'shape'");
+
+ return true;
+ }
+ case IElement::Type::BOOLEAN:
+ {
+ CElementBoolean* boolElement = static_cast<CElementBoolean*>(_child);
+ const std::string elementName = boolElement->getNameAttribute();
+
+ if (elementName == "flipNormals")
+ {
+ flipNormalsFlag = boolElement->getValueAttribute();
+ }
+ else
+ {
+ //warning
+ ParserLog::mitsubaLoaderError("Unqueried attribute " + elementName + " in element \"shape\"");
+ }
+
+ return true;
+ }
+ default:
+ ParserLog::wrongChildElement(getLogName(), _child->getLogName());
+ return false;
+ }
+}
+
+}
+}
+}
\ No newline at end of file

MODIFY
ext/MitsubaLoader/CMitsubaScene.cpp
ext/MitsubaLoader/CMitsubaScene.cpp
@@ -95,7 +95,7 @@ bool CMitsubaScene::appendMesh(const asset::ICPUMesh* _mesh, const core::matrix4
submesh->setAttribute(pos,submesh->getPositionAttributeIx(), i);
submesh->setAttribute(normal, asset::E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR3, i);
- pos = submesh->getPosition(i);
+
}
mesh->addMeshBuffer(submesh);

MODIFY
ext/MitsubaLoader/IElement.h
ext/MitsubaLoader/IElement.h
@@ -34,7 +34,8 @@ public:
STRING,
MATRIX,
MATERIAL,
- COLOR
+ COLOR,
+ MEDIUM
};
public:

MODIFY
ext/MitsubaLoader/ParserUtil.h
ext/MitsubaLoader/ParserUtil.h
@@ -28,7 +28,7 @@ public:
inline bool isParsingSuspended() const { return isParsingSuspendedFlag; }
private:
- static constexpr const char* unsElements[] = { "integrator", "emitter", "ref", "bsdf", "sensor", nullptr };
+ static constexpr const char* unsElements[] = { "integrator", "emitter", "ref", "bsdf", "sensor", "medium", nullptr };
bool isParsingSuspendedFlag;
std::string notSupportedElement;

MODIFY
src/irr/asset/CGeometryCreator.cpp
src/irr/asset/CGeometryCreator.cpp
@@ -644,18 +644,6 @@ asset::ICPUMesh* CGeometryCreator::createDiskMesh(float radius, uint32_t tessela
asset::ICPUBuffer* vertices = new asset::ICPUBuffer(vertexCount * vertexSize);
DiskVertex* ptr = (DiskVertex*)vertices->getPointer();
-
- /*
- example:
- v1 v0 v7
- \ | /
- v2 -- s -- v6
- / | \
- v3 v4 v5
-
- */
-
-
const core::vectorSIMDf v0(0.0f, radius, 0.0f, 0.0f);
core::matrix3x4SIMD rotation;

Finished all shape types