mirror of https://github.com/mosra/magnum.git
10 changed files with 610 additions and 1 deletions
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
@ -0,0 +1,108 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 |
||||
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 "Grid.h" |
||||
|
||||
#include "Magnum/Mesh.h" |
||||
#include "Magnum/Math/Color.h" |
||||
#include "Magnum/Trade/MeshData3D.h" |
||||
|
||||
namespace Magnum { namespace Primitives { |
||||
|
||||
Trade::MeshData3D grid3DSolid(const Vector2i& subdivisions, const GridFlags flags) { |
||||
const Vector2i vertexCount = subdivisions + Vector2i{2}; |
||||
const Vector2i faceCount = subdivisions + Vector2i{1}; |
||||
|
||||
std::vector<Vector3> positions; |
||||
positions.reserve(vertexCount.product()); |
||||
for(Int y = 0; y != vertexCount.y(); ++y) |
||||
for(Int x = 0; x != vertexCount.x(); ++x) |
||||
positions.emplace_back((Vector2(x, y)/Vector2(faceCount))*2.0f - Vector2{1.0f}, 0.0f); |
||||
|
||||
std::vector<UnsignedInt> indices; |
||||
indices.reserve(faceCount.product()*6); |
||||
for(Int y = 0; y != faceCount.y(); ++y) { |
||||
for(Int x = 0; x != faceCount.x(); ++x) { |
||||
/* 2--1 5
|
||||
| / /| |
||||
|/ / | |
||||
0 3--4 */ |
||||
indices.insert(indices.end(), { |
||||
UnsignedInt(y*vertexCount.x() + x), |
||||
UnsignedInt((y + 1)*vertexCount.x() + x + 1), |
||||
UnsignedInt((y + 1)*vertexCount.x() + x + 0), |
||||
UnsignedInt(y*vertexCount.x() + x), |
||||
UnsignedInt(y*vertexCount.x() + x + 1), |
||||
UnsignedInt((y + 1)*vertexCount.x() + x + 1)}); |
||||
} |
||||
} |
||||
|
||||
std::vector<std::vector<Vector3>> normals; |
||||
if(flags & GridFlag::GenerateNormals) |
||||
normals.emplace_back(positions.size(), Vector3::zAxis(1.0f)); |
||||
|
||||
std::vector<std::vector<Vector2>> textureCoordinates; |
||||
if(flags & GridFlag::GenerateTextureCoords) { |
||||
textureCoordinates.emplace_back(); |
||||
textureCoordinates[0].reserve(positions.size()); |
||||
for(std::size_t i = 0; i != positions.size(); ++i) |
||||
textureCoordinates[0].emplace_back(positions[i].xy()*0.5f + Vector2{0.5f}); |
||||
} |
||||
|
||||
return Trade::MeshData3D{MeshPrimitive::Triangles, std::move(indices), {std::move(positions)}, std::move(normals), std::move(textureCoordinates), {}, nullptr}; |
||||
} |
||||
|
||||
Trade::MeshData3D grid3DWireframe(const Vector2i& subdivisions) { |
||||
const Vector2i vertexCount = subdivisions + Vector2i{2}; |
||||
const Vector2i faceCount = subdivisions + Vector2i{1}; |
||||
|
||||
std::vector<Vector3> positions; |
||||
positions.reserve(vertexCount.product()); |
||||
for(Int y = 0; y != vertexCount.y(); ++y) |
||||
for(Int x = 0; x != vertexCount.x(); ++x) |
||||
positions.emplace_back((Vector2(x, y)/Vector2(faceCount))*2.0f - Vector2{1.0f}, 0.0f); |
||||
|
||||
std::vector<UnsignedInt> indices; |
||||
indices.reserve(vertexCount.y()*(vertexCount.x() - 1)*2 + |
||||
vertexCount.x()*(vertexCount.y() - 1)*2); |
||||
for(Int y = 0; y != vertexCount.y(); ++y) { |
||||
for(Int x = 0; x != vertexCount.x(); ++x) { |
||||
/* 3 7
|
||||
| | ... |
||||
2 6 |
||||
0--1 4--5 ... */ |
||||
if(x != vertexCount.x() - 1) indices.insert(indices.end(), { |
||||
UnsignedInt(y*vertexCount.x() + x), |
||||
UnsignedInt(y*vertexCount.x() + x + 1)}); |
||||
if(y != vertexCount.y() - 1) indices.insert(indices.end(), { |
||||
UnsignedInt(y*vertexCount.x() + x), |
||||
UnsignedInt((y + 1)*vertexCount.x() + x)}); |
||||
} |
||||
} |
||||
|
||||
return Trade::MeshData3D{MeshPrimitive::Lines, std::move(indices), {std::move(positions)}, {}, {}, {}, nullptr}; |
||||
} |
||||
|
||||
}} |
||||
@ -0,0 +1,101 @@
|
||||
#ifndef Magnum_Primitives_Grid_h |
||||
#define Magnum_Primitives_Grid_h |
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 |
||||
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. |
||||
*/ |
||||
|
||||
/** @file
|
||||
* @brief Function @ref Magnum::Primitives::grid3DSolid(), @ref Magnum::Primitives::grid3DWireframe() |
||||
*/ |
||||
|
||||
#include <Corrade/Containers/EnumSet.h> |
||||
|
||||
#include "Magnum/Magnum.h" |
||||
#include "Magnum/Math/Math.h" |
||||
#include "Magnum/Primitives/visibility.h" |
||||
#include "Magnum/Trade/Trade.h" |
||||
|
||||
namespace Magnum { namespace Primitives { |
||||
|
||||
/**
|
||||
@brief Grid flag |
||||
|
||||
@see @ref GridFlags, @ref grid3DSolid() |
||||
*/ |
||||
enum class GridFlag: UnsignedByte { |
||||
/** Generate texture coordinates with origin in bottom left corner. */ |
||||
GenerateTextureCoords = 1 << 0, |
||||
|
||||
/**
|
||||
* Generate normals inn positive Z direction. Disable if you'd be |
||||
* generating your own normals anyway (for example based on a heightmap). |
||||
*/ |
||||
GenerateNormals = 1 << 1 |
||||
}; |
||||
|
||||
/**
|
||||
@brief Grid flags |
||||
|
||||
@see @ref grid3DSolid() |
||||
*/ |
||||
typedef Containers::EnumSet<GridFlag> GridFlags; |
||||
|
||||
CORRADE_ENUMSET_OPERATORS(GridFlags) |
||||
|
||||
/**
|
||||
@brief 3D solid grid |
||||
|
||||
2x2 grid. Indexed @ref MeshPrimitive::Triangles with optional normals and |
||||
texture coordinates. |
||||
|
||||
@image html primitives-grid3dsolid.png |
||||
|
||||
The @p subdivisions parameter describes how many times the plane gets cut in |
||||
each direction. Specifying @cpp {0, 0} @ce will make the result an (indexed) |
||||
equivalent to @ref planeSolid(); @cpp {5, 3} @ce will make the grid have 6 |
||||
cells horizontally and 4 vertically. In particular, this is different from the |
||||
`subdivisions` parameter in @ref icosphereSolid(). |
||||
@see @ref grid3DWireframe() |
||||
*/ |
||||
MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D grid3DSolid(const Vector2i& subdivisions, GridFlags flags = GridFlag::GenerateNormals); |
||||
|
||||
/**
|
||||
@brief 3D wireframe grid |
||||
|
||||
2x2 grid. Indexed @ref MeshPrimitive::Lines. |
||||
|
||||
@image html primitives-grid3dwireframe.png |
||||
|
||||
The @p subdivisions parameter describes how many times the plane gets cut in |
||||
each direction. Specifying @cpp {0, 0} @ce will make the result an (indexed) |
||||
equivalent to @ref planeWireframe(); @cpp {5, 3} @ce will make the grid have 6 |
||||
cells horizontally and 4 vertically. In particular, this is different from the |
||||
`subdivisions` parameter in @ref icosphereSolid(). |
||||
@see @ref grid3DSolid() |
||||
*/ |
||||
MAGNUM_PRIMITIVES_EXPORT Trade::MeshData3D grid3DWireframe(const Vector2i& subdivisions); |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
@ -0,0 +1,377 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 |
||||
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 <Corrade/TestSuite/Tester.h> |
||||
#include <Corrade/TestSuite/Compare/Container.h> |
||||
|
||||
#include "Magnum/Math/Vector3.h" |
||||
#include "Magnum/Primitives/Grid.h" |
||||
#include "Magnum/Trade/MeshData3D.h" |
||||
|
||||
namespace Magnum { namespace Primitives { namespace Test { |
||||
|
||||
struct GridTest: TestSuite::Tester { |
||||
explicit GridTest(); |
||||
|
||||
void solid3DWithoutAnything(); |
||||
void solid3DWithNormalsAndTextureCoords(); |
||||
void wireframe3D(); |
||||
}; |
||||
|
||||
GridTest::GridTest() { |
||||
addTests({&GridTest::solid3DWithoutAnything, |
||||
&GridTest::solid3DWithNormalsAndTextureCoords, |
||||
&GridTest::wireframe3D}); |
||||
} |
||||
|
||||
void GridTest::solid3DWithoutAnything() { |
||||
Trade::MeshData3D grid = grid3DSolid({5, 3}, {}); |
||||
|
||||
CORRADE_COMPARE_AS(grid.positions(0), (std::vector<Vector3>{ |
||||
{-1.0f, -1.0f, 0.0f}, |
||||
{-0.666667f, -1.0f, 0.0f}, |
||||
{-0.333333f, -1.0f, 0.0f}, |
||||
{0.0f, -1.0f, 0.0f}, |
||||
{0.333333f, -1.0f, 0.0f}, |
||||
{0.666667f, -1.0f, 0.0f}, |
||||
{1.0f, -1.0f, 0.0f}, |
||||
|
||||
{-1.0f, -0.5f, 0.0f}, |
||||
{-0.666667f, -0.5f, 0.0f}, |
||||
{-0.333333f, -0.5f, 0.0f}, |
||||
{0.0f, -0.5f, 0.0f}, |
||||
{0.333333f, -0.5f, 0.0f}, |
||||
{0.666667f, -0.5f, 0.0f}, |
||||
{1.0f, -0.5f, 0.0f}, |
||||
|
||||
{-1.0f, 0.0f, 0.0f}, |
||||
{-0.666667f, 0.0f, 0.0f}, |
||||
{-0.333333f, 0.0f, 0.0f}, |
||||
{0.0f, 0.0f, 0.0f}, |
||||
{0.333333f, 0.0f, 0.0f}, |
||||
{0.666667f, 0.0f, 0.0f}, |
||||
{1.0f, 0.0f, 0.0f}, |
||||
|
||||
{-1.0f, 0.5f, 0.0f}, |
||||
{-0.666667f, 0.5f, 0.0f}, |
||||
{-0.333333f, 0.5f, 0.0f}, |
||||
{0.0f, 0.5f, 0.0f}, |
||||
{0.333333f, 0.5f, 0.0f}, |
||||
{0.666667f, 0.5f, 0.0f}, |
||||
{1.0f, 0.5f, 0.0f}, |
||||
|
||||
{-1.0f, 1.0f, 0.0f}, |
||||
{-0.666667f, 1.0f, 0.0f}, |
||||
{-0.333333f, 1.0f, 0.0f}, |
||||
{0.0f, 1.0f, 0.0f}, |
||||
{0.333333f, 1.0f, 0.0f}, |
||||
{0.666667f, 1.0f, 0.0f}, |
||||
{1.0f, 1.0f, 0.0f} |
||||
}), TestSuite::Compare::Container); |
||||
|
||||
CORRADE_COMPARE(grid.normalArrayCount(), 0); |
||||
CORRADE_COMPARE(grid.textureCoords2DArrayCount(), 0); |
||||
|
||||
CORRADE_COMPARE_AS(grid.indices(), (std::vector<UnsignedInt>{ |
||||
0, 8, 7, 0, 1, 8, |
||||
1, 9, 8, 1, 2, 9, |
||||
2, 10, 9, 2, 3, 10, |
||||
3, 11, 10, 3, 4, 11, |
||||
4, 12, 11, 4, 5, 12, |
||||
5, 13, 12, 5, 6, 13, |
||||
|
||||
7, 15, 14, 7, 8, 15, |
||||
8, 16, 15, 8, 9, 16, |
||||
9, 17, 16, 9, 10, 17, |
||||
10, 18, 17, 10, 11, 18, |
||||
11, 19, 18, 11, 12, 19, |
||||
12, 20, 19, 12, 13, 20, |
||||
|
||||
14, 22, 21, 14, 15, 22, |
||||
15, 23, 22, 15, 16, 23, |
||||
16, 24, 23, 16, 17, 24, |
||||
17, 25, 24, 17, 18, 25, |
||||
18, 26, 25, 18, 19, 26, |
||||
19, 27, 26, 19, 20, 27, |
||||
|
||||
21, 29, 28, 21, 22, 29, |
||||
22, 30, 29, 22, 23, 30, |
||||
23, 31, 30, 23, 24, 31, |
||||
24, 32, 31, 24, 25, 32, |
||||
25, 33, 32, 25, 26, 33, |
||||
26, 34, 33, 26, 27, 34 |
||||
}), TestSuite::Compare::Container); |
||||
} |
||||
|
||||
void GridTest::solid3DWithNormalsAndTextureCoords() { |
||||
Trade::MeshData3D grid = grid3DSolid({5, 3}, GridFlag::GenerateNormals|GridFlag::GenerateTextureCoords); |
||||
|
||||
CORRADE_COMPARE_AS(grid.positions(0), (std::vector<Vector3>{ |
||||
{-1.0f, -1.0f, 0.0f}, |
||||
{-0.666667f, -1.0f, 0.0f}, |
||||
{-0.333333f, -1.0f, 0.0f}, |
||||
{0.0f, -1.0f, 0.0f}, |
||||
{0.333333f, -1.0f, 0.0f}, |
||||
{0.666667f, -1.0f, 0.0f}, |
||||
{1.0f, -1.0f, 0.0f}, |
||||
|
||||
{-1.0f, -0.5f, 0.0f}, |
||||
{-0.666667f, -0.5f, 0.0f}, |
||||
{-0.333333f, -0.5f, 0.0f}, |
||||
{0.0f, -0.5f, 0.0f}, |
||||
{0.333333f, -0.5f, 0.0f}, |
||||
{0.666667f, -0.5f, 0.0f}, |
||||
{1.0f, -0.5f, 0.0f}, |
||||
|
||||
{-1.0f, 0.0f, 0.0f}, |
||||
{-0.666667f, 0.0f, 0.0f}, |
||||
{-0.333333f, 0.0f, 0.0f}, |
||||
{0.0f, 0.0f, 0.0f}, |
||||
{0.333333f, 0.0f, 0.0f}, |
||||
{0.666667f, 0.0f, 0.0f}, |
||||
{1.0f, 0.0f, 0.0f}, |
||||
|
||||
{-1.0f, 0.5f, 0.0f}, |
||||
{-0.666667f, 0.5f, 0.0f}, |
||||
{-0.333333f, 0.5f, 0.0f}, |
||||
{0.0f, 0.5f, 0.0f}, |
||||
{0.333333f, 0.5f, 0.0f}, |
||||
{0.666667f, 0.5f, 0.0f}, |
||||
{1.0f, 0.5f, 0.0f}, |
||||
|
||||
{-1.0f, 1.0f, 0.0f}, |
||||
{-0.666667f, 1.0f, 0.0f}, |
||||
{-0.333333f, 1.0f, 0.0f}, |
||||
{0.0f, 1.0f, 0.0f}, |
||||
{0.333333f, 1.0f, 0.0f}, |
||||
{0.666667f, 1.0f, 0.0f}, |
||||
{1.0f, 1.0f, 0.0f} |
||||
}), TestSuite::Compare::Container); |
||||
|
||||
CORRADE_COMPARE_AS(grid.normals(0), (std::vector<Vector3>{ |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
|
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
|
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
|
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
|
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
{0.0f, 0.0f, 1.0f}, |
||||
}), TestSuite::Compare::Container); |
||||
|
||||
CORRADE_COMPARE_AS(grid.textureCoords2D(0), (std::vector<Vector2>{ |
||||
{0.0f, 0.0f}, |
||||
{0.166667f, 0.0f}, |
||||
{0.333333f, 0.0f}, |
||||
{0.5f, 0.0f}, |
||||
{0.666667f, 0.0f}, |
||||
{0.833333f, 0.0f}, |
||||
{1.0f, 0.0f}, |
||||
|
||||
{0.0f, 0.25f}, |
||||
{0.166667f, 0.25f}, |
||||
{0.333333f, 0.25f}, |
||||
{0.5f, 0.25f}, |
||||
{0.666667f, 0.25f}, |
||||
{0.833333f, 0.25f}, |
||||
{1.0f, 0.25f}, |
||||
|
||||
{0.0f, 0.5f}, |
||||
{0.166667f, 0.5f}, |
||||
{0.333333f, 0.5f}, |
||||
{0.5f, 0.5f}, |
||||
{0.666667f, 0.5f}, |
||||
{0.833333f, 0.5f}, |
||||
{1.0f, 0.5f}, |
||||
|
||||
{0.0f, 0.75f}, |
||||
{0.166667f, 0.75f}, |
||||
{0.333333f, 0.75f}, |
||||
{0.5f, 0.75f}, |
||||
{0.666667f, 0.75f}, |
||||
{0.833333f, 0.75f}, |
||||
{1.0f, 0.75f}, |
||||
|
||||
{0.0f, 1.0f}, |
||||
{0.166667f, 1.0f}, |
||||
{0.333333f, 1.0f}, |
||||
{0.5f, 1.0f}, |
||||
{0.666667f, 1.0f}, |
||||
{0.833333f, 1.0f}, |
||||
{1.0f, 1.0f} |
||||
}), TestSuite::Compare::Container); |
||||
|
||||
CORRADE_COMPARE_AS(grid.indices(), (std::vector<UnsignedInt>{ |
||||
0, 8, 7, 0, 1, 8, |
||||
1, 9, 8, 1, 2, 9, |
||||
2, 10, 9, 2, 3, 10, |
||||
3, 11, 10, 3, 4, 11, |
||||
4, 12, 11, 4, 5, 12, |
||||
5, 13, 12, 5, 6, 13, |
||||
|
||||
7, 15, 14, 7, 8, 15, |
||||
8, 16, 15, 8, 9, 16, |
||||
9, 17, 16, 9, 10, 17, |
||||
10, 18, 17, 10, 11, 18, |
||||
11, 19, 18, 11, 12, 19, |
||||
12, 20, 19, 12, 13, 20, |
||||
|
||||
14, 22, 21, 14, 15, 22, |
||||
15, 23, 22, 15, 16, 23, |
||||
16, 24, 23, 16, 17, 24, |
||||
17, 25, 24, 17, 18, 25, |
||||
18, 26, 25, 18, 19, 26, |
||||
19, 27, 26, 19, 20, 27, |
||||
|
||||
21, 29, 28, 21, 22, 29, |
||||
22, 30, 29, 22, 23, 30, |
||||
23, 31, 30, 23, 24, 31, |
||||
24, 32, 31, 24, 25, 32, |
||||
25, 33, 32, 25, 26, 33, |
||||
26, 34, 33, 26, 27, 34 |
||||
}), TestSuite::Compare::Container); |
||||
} |
||||
|
||||
void GridTest::wireframe3D() { |
||||
Trade::MeshData3D grid = grid3DWireframe({5, 3}); |
||||
|
||||
CORRADE_COMPARE_AS(grid.positions(0), (std::vector<Vector3>{ |
||||
{-1.0f, -1.0f, 0.0f}, |
||||
{-0.666667f, -1.0f, 0.0f}, |
||||
{-0.333333f, -1.0f, 0.0f}, |
||||
{0.0f, -1.0f, 0.0f}, |
||||
{0.333333f, -1.0f, 0.0f}, |
||||
{0.666667f, -1.0f, 0.0f}, |
||||
{1.0f, -1.0f, 0.0f}, |
||||
|
||||
{-1.0f, -0.5f, 0.0f}, |
||||
{-0.666667f, -0.5f, 0.0f}, |
||||
{-0.333333f, -0.5f, 0.0f}, |
||||
{0.0f, -0.5f, 0.0f}, |
||||
{0.333333f, -0.5f, 0.0f}, |
||||
{0.666667f, -0.5f, 0.0f}, |
||||
{1.0f, -0.5f, 0.0f}, |
||||
|
||||
{-1.0f, 0.0f, 0.0f}, |
||||
{-0.666667f, 0.0f, 0.0f}, |
||||
{-0.333333f, 0.0f, 0.0f}, |
||||
{0.0f, 0.0f, 0.0f}, |
||||
{0.333333f, 0.0f, 0.0f}, |
||||
{0.666667f, 0.0f, 0.0f}, |
||||
{1.0f, 0.0f, 0.0f}, |
||||
|
||||
{-1.0f, 0.5f, 0.0f}, |
||||
{-0.666667f, 0.5f, 0.0f}, |
||||
{-0.333333f, 0.5f, 0.0f}, |
||||
{0.0f, 0.5f, 0.0f}, |
||||
{0.333333f, 0.5f, 0.0f}, |
||||
{0.666667f, 0.5f, 0.0f}, |
||||
{1.0f, 0.5f, 0.0f}, |
||||
|
||||
{-1.0f, 1.0f, 0.0f}, |
||||
{-0.666667f, 1.0f, 0.0f}, |
||||
{-0.333333f, 1.0f, 0.0f}, |
||||
{0.0f, 1.0f, 0.0f}, |
||||
{0.333333f, 1.0f, 0.0f}, |
||||
{0.666667f, 1.0f, 0.0f}, |
||||
{1.0f, 1.0f, 0.0f} |
||||
}), TestSuite::Compare::Container); |
||||
|
||||
CORRADE_COMPARE_AS(grid.indices(), (std::vector<UnsignedInt>{ |
||||
0, 1, 0, 7, |
||||
1, 2, 1, 8, |
||||
2, 3, 2, 9, |
||||
3, 4, 3, 10, |
||||
4, 5, 4, 11, |
||||
5, 6, 5, 12, |
||||
6, 13, |
||||
|
||||
7, 8, 7, 14, |
||||
8, 9, 8, 15, |
||||
9, 10, 9, 16, |
||||
10, 11, 10, 17, |
||||
11, 12, 11, 18, |
||||
12, 13, 12, 19, |
||||
13, 20, |
||||
|
||||
14, 15, 14, 21, |
||||
15, 16, 15, 22, |
||||
16, 17, 16, 23, |
||||
17, 18, 17, 24, |
||||
18, 19, 18, 25, |
||||
19, 20, 19, 26, |
||||
20, 27, |
||||
|
||||
21, 22, 21, 28, |
||||
22, 23, 22, 29, |
||||
23, 24, 23, 30, |
||||
24, 25, 24, 31, |
||||
25, 26, 25, 32, |
||||
26, 27, 26, 33, |
||||
27, 34, |
||||
|
||||
28, 29, |
||||
29, 30, |
||||
30, 31, |
||||
31, 32, |
||||
32, 33, |
||||
33, 34 |
||||
}), TestSuite::Compare::Container); |
||||
} |
||||
|
||||
}}} |
||||
|
||||
CORRADE_TEST_MAIN(Magnum::Primitives::Test::GridTest) |
||||
Loading…
Reference in new issue