diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7517288d5..589b97694 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -68,10 +68,15 @@ set(Magnum_SRCS Implementation/State.cpp Trade/AbstractImporter.cpp + Trade/AbstractMaterialData.cpp Trade/MeshData2D.cpp Trade/MeshData3D.cpp + Trade/MeshObjectData2D.cpp + Trade/MeshObjectData3D.cpp Trade/ObjectData2D.cpp - Trade/ObjectData3D.cpp) + Trade/ObjectData3D.cpp + Trade/PhongMaterialData.cpp + Trade/SceneData.cpp) # Desktop-only code if(NOT TARGET_GLES) diff --git a/src/Trade/AbstractMaterialData.cpp b/src/Trade/AbstractMaterialData.cpp new file mode 100644 index 000000000..39135072c --- /dev/null +++ b/src/Trade/AbstractMaterialData.cpp @@ -0,0 +1,33 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "AbstractMaterialData.h" + +namespace Magnum { namespace Trade { + +AbstractMaterialData::AbstractMaterialData(AbstractMaterialData::Type type): _type(type) {} + +AbstractMaterialData::~AbstractMaterialData() {} + +}} diff --git a/src/Trade/AbstractMaterialData.h b/src/Trade/AbstractMaterialData.h index 92630b427..7b26ee0b8 100644 --- a/src/Trade/AbstractMaterialData.h +++ b/src/Trade/AbstractMaterialData.h @@ -28,7 +28,7 @@ * @brief Class Magnum::Trade::AbstractMaterialData */ -#include +#include "magnumVisibility.h" namespace Magnum { namespace Trade { @@ -37,7 +37,7 @@ namespace Magnum { namespace Trade { Subclasses provide access to parameters for given material type. */ -class AbstractMaterialData { +class MAGNUM_EXPORT AbstractMaterialData { AbstractMaterialData(const AbstractMaterialData&) = delete; AbstractMaterialData(AbstractMaterialData&&) = delete; AbstractMaterialData& operator=(const AbstractMaterialData&) = delete; @@ -53,7 +53,7 @@ class AbstractMaterialData { * @brief Constructor * @param type Material type */ - inline AbstractMaterialData(Type type): _type(type) {} + explicit AbstractMaterialData(Type type); /** @brief Destructor */ virtual ~AbstractMaterialData() = 0; @@ -65,8 +65,6 @@ class AbstractMaterialData { Type _type; }; -inline AbstractMaterialData::~AbstractMaterialData() {} - }} #endif diff --git a/src/Trade/ImageData.h b/src/Trade/ImageData.h index fbe6d8c4c..8fd76c525 100644 --- a/src/Trade/ImageData.h +++ b/src/Trade/ImageData.h @@ -55,7 +55,7 @@ template class ImageData: public AbstractImage { * Note that the image data are not copied on construction, but they * are deleted on class destruction. */ - inline ImageData(const typename DimensionTraits::VectorType& size, Format format, Type type, GLvoid* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} + inline explicit ImageData(const typename DimensionTraits::VectorType& size, Format format, Type type, GLvoid* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} /** @brief Destructor */ inline ~ImageData() { delete[] _data; } diff --git a/src/Trade/MeshData2D.h b/src/Trade/MeshData2D.h index 696a3bd70..97369a79e 100644 --- a/src/Trade/MeshData2D.h +++ b/src/Trade/MeshData2D.h @@ -56,7 +56,7 @@ class MAGNUM_EXPORT MeshData2D { * @param textureCoords2D Array with two-dimensional texture * coordinate arrays or empty array */ - MeshData2D(Mesh::Primitive primitive, std::vector* indices, std::vector*> positions, std::vector*> textureCoords2D); + explicit MeshData2D(Mesh::Primitive primitive, std::vector* indices, std::vector*> positions, std::vector*> textureCoords2D); /** @brief Move constructor */ MeshData2D(MeshData2D&&); diff --git a/src/Trade/MeshData3D.h b/src/Trade/MeshData3D.h index 54fef49aa..61e02e807 100644 --- a/src/Trade/MeshData3D.h +++ b/src/Trade/MeshData3D.h @@ -57,7 +57,7 @@ class MAGNUM_EXPORT MeshData3D { * @param textureCoords2D Array with two-dimensional texture * coordinate arrays or empty array */ - MeshData3D(Mesh::Primitive primitive, std::vector* indices, std::vector*> positions, std::vector*> normals, std::vector*> textureCoords2D); + explicit MeshData3D(Mesh::Primitive primitive, std::vector* indices, std::vector*> positions, std::vector*> normals, std::vector*> textureCoords2D); /** @brief Move constructor */ MeshData3D(MeshData3D&&); diff --git a/src/Trade/MeshObjectData2D.cpp b/src/Trade/MeshObjectData2D.cpp new file mode 100644 index 000000000..bc52d77fe --- /dev/null +++ b/src/Trade/MeshObjectData2D.cpp @@ -0,0 +1,31 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "MeshObjectData2D.h" + +namespace Magnum { namespace Trade { + +MeshObjectData2D::MeshObjectData2D(std::vector children, const Matrix3& transformation, UnsignedInt instance, UnsignedInt material): ObjectData2D(std::move(children), transformation, InstanceType::Mesh, instance), _material(material) {} + +}} diff --git a/src/Trade/MeshObjectData2D.h b/src/Trade/MeshObjectData2D.h index d6137fffc..bbe38cd0c 100644 --- a/src/Trade/MeshObjectData2D.h +++ b/src/Trade/MeshObjectData2D.h @@ -38,7 +38,7 @@ namespace Magnum { namespace Trade { Provides access to material information for given mesh instance. @see MeshObjectData3D */ -class MeshObjectData2D: public ObjectData2D { +class MAGNUM_EXPORT MeshObjectData2D: public ObjectData2D { MeshObjectData2D(const MeshObjectData2D&) = delete; MeshObjectData2D(MeshObjectData2D&&) = delete; MeshObjectData2D& operator=(const MeshObjectData2D&) = delete; @@ -54,7 +54,7 @@ class MeshObjectData2D: public ObjectData2D { * * Creates object with mesh instance type. */ - inline MeshObjectData2D(const std::vector& children, const Matrix4& transformation, UnsignedInt instance, UnsignedInt material): ObjectData2D(children, transformation, InstanceType::Mesh, instance), _material(material) {} + explicit MeshObjectData2D(std::vector children, const Matrix3& transformation, UnsignedInt instance, UnsignedInt material); /** @brief Material ID */ inline UnsignedInt material() const { return _material; } diff --git a/src/Trade/MeshObjectData3D.cpp b/src/Trade/MeshObjectData3D.cpp new file mode 100644 index 000000000..dfd6e766b --- /dev/null +++ b/src/Trade/MeshObjectData3D.cpp @@ -0,0 +1,31 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "MeshObjectData3D.h" + +namespace Magnum { namespace Trade { + +MeshObjectData3D::MeshObjectData3D(std::vector< UnsignedInt > children, const Matrix4& transformation, UnsignedInt instance, UnsignedInt material): ObjectData3D(children, transformation, InstanceType::Mesh, instance), _material(material) {} + +}} diff --git a/src/Trade/MeshObjectData3D.h b/src/Trade/MeshObjectData3D.h index b692b51e2..636ad52b1 100644 --- a/src/Trade/MeshObjectData3D.h +++ b/src/Trade/MeshObjectData3D.h @@ -38,7 +38,7 @@ namespace Magnum { namespace Trade { Provides access to material information for given mesh instance. @see MeshObjectData2D */ -class MeshObjectData3D: public ObjectData3D { +class MAGNUM_EXPORT MeshObjectData3D: public ObjectData3D { MeshObjectData3D(const MeshObjectData3D&) = delete; MeshObjectData3D(MeshObjectData3D&&) = delete; MeshObjectData3D& operator=(const MeshObjectData3D&) = delete; @@ -54,7 +54,7 @@ class MeshObjectData3D: public ObjectData3D { * * Creates object with mesh instance type. */ - inline MeshObjectData3D(const std::vector& children, const Matrix4& transformation, UnsignedInt instance, UnsignedInt material): ObjectData3D(children, transformation, InstanceType::Mesh, instance), _material(material) {} + explicit MeshObjectData3D(std::vector children, const Matrix4& transformation, UnsignedInt instance, UnsignedInt material); /** @brief Material ID */ inline UnsignedInt material() const { return _material; } diff --git a/src/Trade/ObjectData2D.cpp b/src/Trade/ObjectData2D.cpp index 4c44c12f6..e4d8413b9 100644 --- a/src/Trade/ObjectData2D.cpp +++ b/src/Trade/ObjectData2D.cpp @@ -26,6 +26,12 @@ namespace Magnum { namespace Trade { +ObjectData2D::ObjectData2D(std::vector children, const Matrix3& transformation, ObjectData2D::InstanceType instanceType, UnsignedInt instanceId): _children(std::move(children)), _transformation(transformation), _instanceType(instanceType), _instanceId(instanceId) {} + +ObjectData2D::ObjectData2D(std::vector children, const Matrix3& transformation): _children(children), _transformation(transformation), _instanceType(InstanceType::Empty), _instanceId(-1) {} + +ObjectData2D::~ObjectData2D() = default; + #ifndef DOXYGEN_GENERATING_OUTPUT Debug operator<<(Debug debug, ObjectData2D::InstanceType value) { switch(value) { diff --git a/src/Trade/ObjectData2D.h b/src/Trade/ObjectData2D.h index 466b8d18e..46d2305f3 100644 --- a/src/Trade/ObjectData2D.h +++ b/src/Trade/ObjectData2D.h @@ -42,7 +42,7 @@ Provides access to object transformation and hierarchy. See also MeshObjectData2D, which is specialized for objects with mesh instance type. @see ObjectData3D */ -class ObjectData2D { +class MAGNUM_EXPORT ObjectData2D { ObjectData2D(const ObjectData2D&) = delete; ObjectData2D(ObjectData2D&&) = delete; ObjectData2D& operator=(const ObjectData2D&) = delete; @@ -63,17 +63,17 @@ class ObjectData2D { * @param instanceType Instance type * @param instanceId Instance ID */ - inline ObjectData2D(const std::vector& children, const Matrix3& transformation, InstanceType instanceType, UnsignedInt instanceId): _children(children), _transformation(transformation), _instanceType(instanceType), _instanceId(instanceId) {} + explicit ObjectData2D(std::vector children, const Matrix3& transformation, InstanceType instanceType, UnsignedInt instanceId); /** * @brief Constructor for empty instance * @param children Child objects * @param transformation Transformation (relative to parent) */ - inline ObjectData2D(const std::vector& children, const Matrix3& transformation): _children(children), _transformation(transformation), _instanceType(InstanceType::Empty), _instanceId(-1) {} + explicit ObjectData2D(std::vector children, const Matrix3& transformation); /** @brief Destructor */ - inline virtual ~ObjectData2D() {} + virtual ~ObjectData2D(); /** @brief Child objects */ inline std::vector& children() { return _children; } diff --git a/src/Trade/ObjectData3D.cpp b/src/Trade/ObjectData3D.cpp index b021b4305..81b5e2dde 100644 --- a/src/Trade/ObjectData3D.cpp +++ b/src/Trade/ObjectData3D.cpp @@ -26,6 +26,10 @@ namespace Magnum { namespace Trade { +ObjectData3D::ObjectData3D(std::vector children, const Matrix4& transformation, ObjectData3D::InstanceType instanceType, UnsignedInt instanceId): _children(std::move(children)), _transformation(transformation), _instanceType(instanceType), _instanceId(instanceId) {} + +ObjectData3D::ObjectData3D(std::vector children, const Matrix4& transformation): _children(std::move(children)), _transformation(transformation), _instanceType(InstanceType::Empty), _instanceId(-1) {} + #ifndef DOXYGEN_GENERATING_OUTPUT Debug operator<<(Debug debug, ObjectData3D::InstanceType value) { switch(value) { diff --git a/src/Trade/ObjectData3D.h b/src/Trade/ObjectData3D.h index 8b5be8a68..f6ac02923 100644 --- a/src/Trade/ObjectData3D.h +++ b/src/Trade/ObjectData3D.h @@ -42,7 +42,7 @@ Provides access to object transformation and hierarchy. See also MeshObjectData3D, which is specialized for objects with mesh instance type. @see ObjectData2D */ -class ObjectData3D { +class MAGNUM_EXPORT ObjectData3D { ObjectData3D(const ObjectData3D&) = delete; ObjectData3D(ObjectData3D&&) = delete; ObjectData3D& operator=(const ObjectData3D&) = delete; @@ -64,14 +64,14 @@ class ObjectData3D { * @param instanceType Instance type * @param instanceId Instance ID */ - inline ObjectData3D(const std::vector& children, const Matrix4& transformation, InstanceType instanceType, UnsignedInt instanceId): _children(children), _transformation(transformation), _instanceType(instanceType), _instanceId(instanceId) {} + explicit ObjectData3D(std::vector children, const Matrix4& transformation, InstanceType instanceType, UnsignedInt instanceId); /** * @brief Constructor for empty instance * @param children Child objects * @param transformation Transformation (relative to parent) */ - inline ObjectData3D(const std::vector& children, const Matrix4& transformation): _children(children), _transformation(transformation), _instanceType(InstanceType::Empty), _instanceId(-1) {} + explicit ObjectData3D(std::vector children, const Matrix4& transformation); /** @brief Destructor */ inline virtual ~ObjectData3D() {} diff --git a/src/Trade/PhongMaterialData.cpp b/src/Trade/PhongMaterialData.cpp new file mode 100644 index 000000000..5f640a4fa --- /dev/null +++ b/src/Trade/PhongMaterialData.cpp @@ -0,0 +1,31 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "PhongMaterialData.h" + +namespace Magnum { namespace Trade { + +PhongMaterialData::PhongMaterialData(const Vector3& ambientColor, const Vector3& diffuseColor, const Vector3& specularColor, Float shininess): AbstractMaterialData(Phong), _ambientColor(ambientColor), _diffuseColor(diffuseColor), _specularColor(specularColor), _shininess(shininess) {} + +}} diff --git a/src/Trade/PhongMaterialData.h b/src/Trade/PhongMaterialData.h index fed9fd310..dec88b406 100644 --- a/src/Trade/PhongMaterialData.h +++ b/src/Trade/PhongMaterialData.h @@ -37,7 +37,7 @@ namespace Magnum { namespace Trade { /** @brief Phong material data */ -class PhongMaterialData: public AbstractMaterialData { +class MAGNUM_EXPORT PhongMaterialData: public AbstractMaterialData { public: /** * @brief Constructor @@ -46,7 +46,7 @@ class PhongMaterialData: public AbstractMaterialData { * @param specularColor Specular color * @param shininess Shininess */ - PhongMaterialData(const Vector3& ambientColor, const Vector3& diffuseColor, const Vector3& specularColor, Float shininess): AbstractMaterialData(Phong), _ambientColor(ambientColor), _diffuseColor(diffuseColor), _specularColor(specularColor), _shininess(shininess) {} + explicit PhongMaterialData(const Vector3& ambientColor, const Vector3& diffuseColor, const Vector3& specularColor, Float shininess); /** @brief Ambient color */ inline Vector3 ambientColor() const { return _ambientColor; } diff --git a/src/Trade/SceneData.cpp b/src/Trade/SceneData.cpp new file mode 100644 index 000000000..889085bb0 --- /dev/null +++ b/src/Trade/SceneData.cpp @@ -0,0 +1,31 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "SceneData.h" + +namespace Magnum { namespace Trade { + +SceneData::SceneData(std::vector children2D, std::vector children3D): _children2D(std::move(children2D)), _children3D(std::move(children3D)) {} + +}} diff --git a/src/Trade/SceneData.h b/src/Trade/SceneData.h index 519573fb9..66b33c21a 100644 --- a/src/Trade/SceneData.h +++ b/src/Trade/SceneData.h @@ -32,6 +32,7 @@ #include #include "Types.h" +#include "magnumVisibility.h" namespace Magnum { namespace Trade { @@ -50,7 +51,7 @@ class MAGNUM_EXPORT SceneData { * @param children2D Two-dimensional child objects * @param children3D Three-dimensional child objects */ - inline SceneData(const std::vector& children2D, const std::vector& children3D): _children2D(children2D), _children3D(children3D) {} + explicit SceneData(std::vector children2D, std::vector children3D); /** @brief Two-dimensional child objects */ inline const std::vector& children2D() const { return _children2D; }