Add section preview mesh builder
parent
c3aeea9d10
commit
066e16dcd6
|
@ -294,6 +294,8 @@ HEADERS += ../dust3d/mesh/resolve_triangle_tangent.h
|
||||||
SOURCES += ../dust3d/mesh/resolve_triangle_tangent.cc
|
SOURCES += ../dust3d/mesh/resolve_triangle_tangent.cc
|
||||||
HEADERS += ../dust3d/mesh/rope_mesh.h
|
HEADERS += ../dust3d/mesh/rope_mesh.h
|
||||||
SOURCES += ../dust3d/mesh/rope_mesh.cc
|
SOURCES += ../dust3d/mesh/rope_mesh.cc
|
||||||
|
HEADERS += ../dust3d/mesh/section_preview_mesh_builder.h
|
||||||
|
SOURCES += ../dust3d/mesh/section_preview_mesh_builder.cc
|
||||||
HEADERS += ../dust3d/mesh/smooth_normal.h
|
HEADERS += ../dust3d/mesh/smooth_normal.h
|
||||||
SOURCES += ../dust3d/mesh/smooth_normal.cc
|
SOURCES += ../dust3d/mesh/smooth_normal.cc
|
||||||
HEADERS += ../dust3d/mesh/stitch_mesh_builder.h
|
HEADERS += ../dust3d/mesh/stitch_mesh_builder.h
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <dust3d/mesh/smooth_normal.h>
|
#include <dust3d/mesh/smooth_normal.h>
|
||||||
#include <dust3d/mesh/resolve_triangle_source_node.h>
|
#include <dust3d/mesh/resolve_triangle_source_node.h>
|
||||||
#include <dust3d/mesh/tube_mesh_builder.h>
|
#include <dust3d/mesh/tube_mesh_builder.h>
|
||||||
|
#include <dust3d/mesh/section_preview_mesh_builder.h>
|
||||||
|
|
||||||
namespace dust3d
|
namespace dust3d
|
||||||
{
|
{
|
||||||
|
@ -658,6 +659,11 @@ std::unique_ptr<MeshCombiner::Mesh> MeshGenerator::combinePartMesh(const std::st
|
||||||
if (!fetchPartOrderedNodes(searchPartIdString, &meshNodes, &isCircle))
|
if (!fetchPartOrderedNodes(searchPartIdString, &meshNodes, &isCircle))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
// TODO: Generate section preview mesh
|
||||||
|
// ... ...
|
||||||
|
|
||||||
|
std::unique_ptr<TubeMeshBuilder> tubeMeshBuilder;
|
||||||
|
|
||||||
TubeMeshBuilder::BuildParameters buildParameters;
|
TubeMeshBuilder::BuildParameters buildParameters;
|
||||||
buildParameters.deformThickness = deformThickness;
|
buildParameters.deformThickness = deformThickness;
|
||||||
buildParameters.deformWidth = deformWidth;
|
buildParameters.deformWidth = deformWidth;
|
||||||
|
@ -665,7 +671,7 @@ std::unique_ptr<MeshCombiner::Mesh> MeshGenerator::combinePartMesh(const std::st
|
||||||
buildParameters.baseNormalRotation = cutRotation * Math::Pi;
|
buildParameters.baseNormalRotation = cutRotation * Math::Pi;
|
||||||
buildParameters.cutFace = cutTemplate;
|
buildParameters.cutFace = cutTemplate;
|
||||||
buildParameters.frontEndRounded = buildParameters.backEndRounded = rounded;
|
buildParameters.frontEndRounded = buildParameters.backEndRounded = rounded;
|
||||||
auto tubeMeshBuilder = std::make_unique<TubeMeshBuilder>(buildParameters, std::move(meshNodes), isCircle);
|
tubeMeshBuilder = std::make_unique<TubeMeshBuilder>(buildParameters, std::move(meshNodes), isCircle);
|
||||||
tubeMeshBuilder->build();
|
tubeMeshBuilder->build();
|
||||||
|
|
||||||
auto &partCache = m_cacheContext->parts[partIdString];
|
auto &partCache = m_cacheContext->parts[partIdString];
|
||||||
|
@ -704,9 +710,9 @@ std::unique_ptr<MeshCombiner::Mesh> MeshGenerator::combinePartMesh(const std::st
|
||||||
mesh.reset();
|
mesh.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target != PartTarget::Model) {
|
//if (target != PartTarget::Model) {
|
||||||
mesh.reset();
|
// mesh.reset();
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (hasMeshError && target == PartTarget::Model) {
|
if (hasMeshError && target == PartTarget::Model) {
|
||||||
*hasError = true;
|
*hasError = true;
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016-2022 Jeremy HU <jeremy-at-dust3d dot org>. All rights reserved.
|
||||||
|
*
|
||||||
|
* 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 <dust3d/mesh/section_preview_mesh_builder.h>
|
||||||
|
#include <dust3d/mesh/triangulate.h>
|
||||||
|
|
||||||
|
namespace dust3d
|
||||||
|
{
|
||||||
|
|
||||||
|
SectionPreviewMeshBuilder::SectionPreviewMeshBuilder(const std::vector<Vector2> &cutFace):
|
||||||
|
m_cutFace(cutFace)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Vector3> &SectionPreviewMeshBuilder::resultVertices()
|
||||||
|
{
|
||||||
|
return m_resultVertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<std::vector<size_t>> &SectionPreviewMeshBuilder::resultTriangles()
|
||||||
|
{
|
||||||
|
return m_resultTriangles;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SectionPreviewMeshBuilder::build()
|
||||||
|
{
|
||||||
|
m_resultVertices.resize(m_cutFace.size());
|
||||||
|
for (size_t i = 0; i < m_cutFace.size(); ++i) {
|
||||||
|
m_resultVertices[i] = Vector3(m_cutFace[i][0], m_cutFace[i][1], 0);
|
||||||
|
}
|
||||||
|
std::vector<size_t> cutFaceIndices(m_resultVertices.size());
|
||||||
|
for (size_t i = 0; i < cutFaceIndices.size(); ++i)
|
||||||
|
cutFaceIndices[i] = i;
|
||||||
|
triangulate(m_resultVertices, cutFaceIndices, &m_resultTriangles);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016-2022 Jeremy HU <jeremy-at-dust3d dot org>. All rights reserved.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DUST3D_MESH_SECTION_PREVIEW_MESH_BUILDER_H_
|
||||||
|
#define DUST3D_MESH_SECTION_PREVIEW_MESH_BUILDER_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <dust3d/base/vector2.h>
|
||||||
|
#include <dust3d/base/vector3.h>
|
||||||
|
|
||||||
|
namespace dust3d
|
||||||
|
{
|
||||||
|
|
||||||
|
class SectionPreviewMeshBuilder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SectionPreviewMeshBuilder(const std::vector<Vector2> &cutFace);
|
||||||
|
void build();
|
||||||
|
const std::vector<Vector3> &resultVertices();
|
||||||
|
const std::vector<std::vector<size_t>> &resultTriangles();
|
||||||
|
private:
|
||||||
|
std::vector<Vector2> m_cutFace;
|
||||||
|
std::vector<Vector3> m_resultVertices;
|
||||||
|
std::vector<std::vector<size_t>> m_resultTriangles;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue