-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[render] DrawableObjectConcept and test for vertex and wedge textures
- Loading branch information
1 parent
3da1ad1
commit 853efd7
Showing
9 changed files
with
251 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#***************************************************************************** | ||
#* VCLib * | ||
#* Visual Computing Library * | ||
#* * | ||
#* Copyright(C) 2021-2025 * | ||
#* Visual Computing Lab * | ||
#* ISTI - Italian National Research Council * | ||
#* * | ||
#* All rights reserved. * | ||
#* * | ||
#* This program is free software; you can redistribute it and/or modify * | ||
#* it under the terms of the Mozilla Public License Version 2.0 as published * | ||
#* by the Mozilla Foundation; either version 2 of the License, or * | ||
#* (at your option) any later version. * | ||
#* * | ||
#* This program is distributed in the hope that it will be useful, * | ||
#* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
#* Mozilla Public License Version 2.0 * | ||
#* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. * | ||
#****************************************************************************/ | ||
|
||
cmake_minimum_required(VERSION 3.24) | ||
|
||
set(EXAMPLE_NAME 06-test-texcoords) | ||
project(vclib-render-example-${EXAMPLE_NAME}) | ||
|
||
### Build settings | ||
set(CMAKE_CXX_STANDARD 20) | ||
|
||
set(SOURCES | ||
main.cpp) | ||
|
||
# will create a target called 'vclib-render-example-${EXAMPLE_NAME}' | ||
vclib_add_example(${EXAMPLE_NAME} | ||
VCLIB_MODULE render | ||
SOURCES ${SOURCES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/***************************************************************************** | ||
* VCLib * | ||
* Visual Computing Library * | ||
* * | ||
* Copyright(C) 2021-2025 * | ||
* Visual Computing Lab * | ||
* ISTI - Italian National Research Council * | ||
* * | ||
* All rights reserved. * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the Mozilla Public License Version 2.0 as published * | ||
* by the Mozilla Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* Mozilla Public License Version 2.0 * | ||
* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. * | ||
****************************************************************************/ | ||
|
||
#include <default_viewer.h> | ||
#include <get_drawable_mesh.h> | ||
|
||
#include <vclib/qt/viewer_widget.h> | ||
|
||
#include <QApplication> | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
#if VCLIB_RENDER_EXAMPLES_WITH_QT | ||
QApplication application(argc, argv); | ||
#endif | ||
|
||
auto viewer = defaultViewer(); | ||
|
||
const bool TEXCOORDS_PER_VERTEX = false; | ||
|
||
if (TEXCOORDS_PER_VERTEX) { | ||
vcl::DrawableMesh<vcl::TriMesh> drawable = | ||
getDrawableMesh<vcl::TriMesh>("VertTextureDouble.ply"); | ||
auto mrs = drawable.renderSettings(); | ||
mrs.setSurfaceShadingFlat(); | ||
mrs.setSurfaceColorPerVertexTexcoords(); | ||
drawable.setRenderSettings(mrs); | ||
showMeshesOnViewer(argc, argv, viewer, drawable); | ||
} | ||
else { | ||
vcl::DrawableMesh<vcl::TriMesh> drawable = | ||
getDrawableMesh<vcl::TriMesh>("TextureDouble.ply"); | ||
auto mrs = drawable.renderSettings(); | ||
mrs.setSurfaceShadingFlat(); | ||
mrs.setSurfaceColorPerWedgeTexcoords(); | ||
drawable.setRenderSettings(mrs); | ||
showMeshesOnViewer(argc, argv, viewer, drawable); | ||
} | ||
|
||
#if VCLIB_RENDER_EXAMPLES_WITH_QT | ||
viewer.showMaximized(); | ||
return application.exec(); | ||
#else | ||
(void) argc; // unused | ||
(void) argv; | ||
return 0; | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/***************************************************************************** | ||
* VCLib * | ||
* Visual Computing Library * | ||
* * | ||
* Copyright(C) 2021-2025 * | ||
* Visual Computing Lab * | ||
* ISTI - Italian National Research Council * | ||
* * | ||
* All rights reserved. * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the Mozilla Public License Version 2.0 as published * | ||
* by the Mozilla Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* Mozilla Public License Version 2.0 * | ||
* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. * | ||
****************************************************************************/ | ||
|
||
#ifndef DRAWABLE_OBJECT_H | ||
#define DRAWABLE_OBJECT_H | ||
|
||
#include <vclib/meshes.h> | ||
#include <vclib/render/concepts/drawable_object.h> | ||
#include <vclib/render/drawable/drawable_mesh.h> | ||
|
||
void drawableObjectStaticAsserts() | ||
{ | ||
using namespace vcl; | ||
|
||
static_assert( | ||
DrawableObjectConcept<DrawableMesh<TriMesh>>, | ||
"DrawableMesh does not satisfy the DrawableObjectConcept"); | ||
static_assert( | ||
DrawableObjectConcept<const DrawableMesh<TriMesh>>, | ||
"const DrawableMesh does not satisfy the DrawableObjectConcept"); | ||
static_assert( | ||
DrawableObjectConcept<DrawableMesh<TriMesh>&>, | ||
"DrawableMesh& does not satisfy the DrawableObjectConcept"); | ||
static_assert( | ||
DrawableObjectConcept<const DrawableMesh<TriMesh>&>, | ||
"const DrawableMesh& does not satisfy the DrawableObjectConcept"); | ||
static_assert( | ||
DrawableObjectConcept<DrawableMesh<TriMesh>&&>, | ||
"DrawableMesh&& does not satisfy the DrawableObjectConcept"); | ||
} | ||
|
||
#endif // DRAWABLE_OBJECT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
vclib/render/include/vclib/render/concepts/drawable_object.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/***************************************************************************** | ||
* VCLib * | ||
* Visual Computing Library * | ||
* * | ||
* Copyright(C) 2021-2025 * | ||
* Visual Computing Lab * | ||
* ISTI - Italian National Research Council * | ||
* * | ||
* All rights reserved. * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the Mozilla Public License Version 2.0 as published * | ||
* by the Mozilla Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* Mozilla Public License Version 2.0 * | ||
* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. * | ||
****************************************************************************/ | ||
|
||
#ifndef VCL_RENDER_CONCEPTS_DRAWABLE_OBJECT_H | ||
#define VCL_RENDER_CONCEPTS_DRAWABLE_OBJECT_H | ||
|
||
#include <vclib/concepts.h> | ||
|
||
namespace vcl { | ||
|
||
template<typename T> | ||
concept DrawableObjectConcept = requires (T&& obj, uint u) { | ||
{ obj.draw(u) } -> std::same_as<void>; | ||
{ obj.boundingBox() } -> Box3Concept; | ||
obj.clone(); | ||
{ obj.isVisible() } -> std::same_as<bool>; | ||
{ obj.name() } -> std::convertible_to<std::string>; | ||
{ obj.info() } -> std::convertible_to<std::string>; | ||
|
||
// non const requirements | ||
requires IsConst<T> || requires { | ||
{ obj.init() } -> std::same_as<void>; | ||
{ obj.setVisibility(bool()) } -> std::same_as<void>; | ||
{ obj.name() } -> std::same_as<std::string&>; | ||
{ obj.info() } -> std::same_as<std::string&>; | ||
}; | ||
}; | ||
|
||
} // namespace vcl | ||
|
||
#endif // VCL_RENDER_CONCEPTS_DRAWABLE_OBJECT_H |