mirror of https://github.com/mosra/magnum.git
Browse Source
Conflicts: src/AbstractFramebuffer.h src/AbstractImage.h src/AbstractTexture.cpp src/DebugTools/ShapeRenderer.cpp src/Primitives/Icosphere.cpp src/Primitives/Icosphere.h src/ResourceManager.h src/SceneGraph/AbstractFeature.hpp src/SceneGraph/AbstractTransformation.h src/SceneGraph/FeatureGroup.h src/SceneGraph/FeatureGroup.hpp src/Shader.cpp src/Shapes/Implementation/CollisionDispatch.cpp src/Text/AbstractFontConverter.cpp
213 changed files with 6108 additions and 5347 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,115 @@ |
|||||||
|
/*
|
||||||
|
This file is part of Magnum. |
||||||
|
|
||||||
|
Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz> |
||||||
|
|
||||||
|
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 "WireframeSpheroid.h" |
||||||
|
|
||||||
|
#include "Math/Functions.h" |
||||||
|
#include "Math/Vector3.h" |
||||||
|
#include "Trade/MeshData3D.h" |
||||||
|
|
||||||
|
namespace Magnum { namespace Primitives { namespace Implementation { |
||||||
|
|
||||||
|
WireframeSpheroid::WireframeSpheroid(const UnsignedInt segments): _segments(segments) {} |
||||||
|
|
||||||
|
void WireframeSpheroid::bottomHemisphere(const Float endY, const UnsignedInt rings) { |
||||||
|
CORRADE_INTERNAL_ASSERT(_positions.empty()); |
||||||
|
|
||||||
|
/* Initial vertex */ |
||||||
|
_positions.push_back(Vector3::yAxis(endY - 1.0f)); |
||||||
|
|
||||||
|
/* Connect initial vertex to first ring */ |
||||||
|
for(UnsignedInt i = 0; i != 4; ++i) |
||||||
|
_indices.insert(_indices.end(), {0, i+1}); |
||||||
|
|
||||||
|
/* Hemisphere vertices and indices */ |
||||||
|
const Rad ringAngleIncrement(Constants::pi()/(2*rings)); |
||||||
|
for(UnsignedInt j = 0; j != rings-1; ++j) { |
||||||
|
const Rad angle = (j+1)*ringAngleIncrement; |
||||||
|
|
||||||
|
_positions.emplace_back(0.0f, endY - Math::cos(angle), Math::sin(angle)); |
||||||
|
_positions.emplace_back(Math::sin(angle), endY - Math::cos(angle), 0.0f); |
||||||
|
_positions.emplace_back(0.0f, endY - Math::cos(angle), -Math::sin(angle)); |
||||||
|
_positions.emplace_back(-Math::sin(angle), endY - Math::cos(angle), 0.0f); |
||||||
|
|
||||||
|
/* Connect vertices to next ring */ |
||||||
|
for(UnsignedInt i = 0; i != 4; ++i) |
||||||
|
_indices.insert(_indices.end(), {UnsignedInt(_positions.size())-4+i, UnsignedInt(_positions.size())+i}); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void WireframeSpheroid::topHemisphere(const Float startY, const UnsignedInt rings) { |
||||||
|
/* Connect previous ring to following vertices */ |
||||||
|
for(UnsignedInt i = 0; i != 4; ++i) |
||||||
|
_indices.insert(_indices.end(), {UnsignedInt(_positions.size())-4*_segments+i, UnsignedInt(_positions.size())+i}); |
||||||
|
|
||||||
|
/* Hemisphere vertices and indices */ |
||||||
|
const Rad ringAngleIncrement(Constants::pi()/(2*rings)); |
||||||
|
for(UnsignedInt j = 0; j != rings-1; ++j) { |
||||||
|
const Rad angle = (j+1)*ringAngleIncrement; |
||||||
|
|
||||||
|
/* Connect previous hemisphere ring to current vertices */ |
||||||
|
if(j != 0) for(UnsignedInt i = 0; i != 4; ++i) |
||||||
|
_indices.insert(_indices.end(), {UnsignedInt(_positions.size())-4+i, UnsignedInt(_positions.size())+i}); |
||||||
|
|
||||||
|
_positions.emplace_back(0.0f, startY + Math::sin(angle), Math::cos(angle)); |
||||||
|
_positions.emplace_back(Math::cos(angle), startY + Math::sin(angle), 0.0f); |
||||||
|
_positions.emplace_back(0.0f, startY + Math::sin(angle), -Math::cos(angle)); |
||||||
|
_positions.emplace_back(-Math::cos(angle), startY + Math::sin(angle), 0.0f); |
||||||
|
} |
||||||
|
|
||||||
|
/* Final vertex */ |
||||||
|
_positions.push_back(Vector3::yAxis(startY + 1.0f)); |
||||||
|
|
||||||
|
/* Connect last ring to final vertex */ |
||||||
|
for(UnsignedInt i = 0; i != 4; ++i) |
||||||
|
_indices.insert(_indices.end(), {UnsignedInt(_positions.size())-5+i, UnsignedInt(_positions.size())-1}); |
||||||
|
} |
||||||
|
|
||||||
|
void WireframeSpheroid::ring(const Float y) { |
||||||
|
/* Ring vertices and indices */ |
||||||
|
const Rad segmentAngleIncrement(Constants::pi()/(2*_segments)); |
||||||
|
for(UnsignedInt j = 0; j != _segments; ++j) { |
||||||
|
for(UnsignedInt i = 0; i != 4; ++i) { |
||||||
|
const Rad segmentAngle = Rad(i*Constants::pi()/2) + j*segmentAngleIncrement; |
||||||
|
if(j != 0) _indices.insert(_indices.end(), {UnsignedInt(_positions.size()-4), UnsignedInt(_positions.size())}); |
||||||
|
_positions.emplace_back(Math::sin(segmentAngle), y, Math::cos(segmentAngle)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* Close the ring */ |
||||||
|
for(UnsignedInt i = 0; i != 4; ++i) |
||||||
|
_indices.insert(_indices.end(), {UnsignedInt(_positions.size())-4+i, UnsignedInt(_positions.size())-4*_segments+(i+1)%4}); |
||||||
|
} |
||||||
|
|
||||||
|
void WireframeSpheroid::cylinder() { |
||||||
|
/* Connect four vertex pairs of previous and next ring */ |
||||||
|
for(UnsignedInt i = 0; i != 4; ++i) |
||||||
|
_indices.insert(_indices.end(), {UnsignedInt(_positions.size())-4*_segments+i, UnsignedInt(_positions.size())+i}); |
||||||
|
} |
||||||
|
|
||||||
|
Trade::MeshData3D WireframeSpheroid::finalize() { |
||||||
|
return Trade::MeshData3D(Mesh::Primitive::Lines, std::move(_indices), {std::move(_positions)}, {}, {}); |
||||||
|
} |
||||||
|
|
||||||
|
}}} |
||||||
@ -0,0 +1,54 @@ |
|||||||
|
#ifndef Magnum_Primitives_WireframeSpheroid_h |
||||||
|
#define Magnum_Primitives_WireframeSpheroid_h |
||||||
|
/*
|
||||||
|
This file is part of Magnum. |
||||||
|
|
||||||
|
Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz> |
||||||
|
|
||||||
|
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 <vector> |
||||||
|
|
||||||
|
#include "Magnum.h" |
||||||
|
#include "Trade/Trade.h" |
||||||
|
|
||||||
|
namespace Magnum { namespace Primitives { namespace Implementation { |
||||||
|
|
||||||
|
class WireframeSpheroid { |
||||||
|
public: |
||||||
|
WireframeSpheroid(UnsignedInt segments); |
||||||
|
|
||||||
|
void bottomHemisphere(Float endY, UnsignedInt rings); |
||||||
|
void topHemisphere(Float startY, UnsignedInt rings); |
||||||
|
void ring(Float y); |
||||||
|
void cylinder(); |
||||||
|
|
||||||
|
Trade::MeshData3D finalize(); |
||||||
|
|
||||||
|
private: |
||||||
|
UnsignedInt _segments; |
||||||
|
|
||||||
|
std::vector<UnsignedInt> _indices; |
||||||
|
std::vector<Vector3> _positions; |
||||||
|
}; |
||||||
|
|
||||||
|
}}} |
||||||
|
|
||||||
|
#endif |
||||||
@ -0,0 +1,57 @@ |
|||||||
|
/*
|
||||||
|
This file is part of Magnum. |
||||||
|
|
||||||
|
Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz> |
||||||
|
|
||||||
|
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 <TestSuite/Tester.h> |
||||||
|
|
||||||
|
#include "Math/Vector3.h" |
||||||
|
#include "Primitives/Icosphere.h" |
||||||
|
#include "Trade/MeshData3D.h" |
||||||
|
|
||||||
|
namespace Magnum { namespace Primitives { namespace Test { |
||||||
|
|
||||||
|
class IcosphereTest: public TestSuite::Tester { |
||||||
|
public: |
||||||
|
explicit IcosphereTest(); |
||||||
|
|
||||||
|
void count(); |
||||||
|
}; |
||||||
|
|
||||||
|
IcosphereTest::IcosphereTest() { |
||||||
|
addTests({&IcosphereTest::count}); |
||||||
|
} |
||||||
|
|
||||||
|
void IcosphereTest::count() { |
||||||
|
Trade::MeshData3D data = Primitives::Icosphere::solid(2); |
||||||
|
|
||||||
|
CORRADE_COMPARE(data.positionArrayCount(), 1); |
||||||
|
CORRADE_COMPARE(data.normalArrayCount(), 1); |
||||||
|
|
||||||
|
CORRADE_COMPARE(data.indices().size(), 960); |
||||||
|
CORRADE_COMPARE(data.positions(0).size(), 162); |
||||||
|
CORRADE_COMPARE(data.normals(0).size(), 162); |
||||||
|
} |
||||||
|
|
||||||
|
}}} |
||||||
|
|
||||||
|
CORRADE_TEST_MAIN(Magnum::Primitives::Test::IcosphereTest) |
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue