diff --git a/src/Gui/Viewport/GLMesh.cpp b/src/Gui/Viewport/GLMesh.cpp index b9aeb29..0d97ed2 100644 --- a/src/Gui/Viewport/GLMesh.cpp +++ b/src/Gui/Viewport/GLMesh.cpp @@ -119,8 +119,6 @@ void GLMesh::setPosBuffer(enzo::geo::Geometry& geometry) - IC(vertexCount, pointIndex); - IC(p.x(), p.y(), p.z()); vertices.push_back({ { p.x(), p.y(), diff --git a/src/Gui/Viewport/ViewportGLWidget.cpp b/src/Gui/Viewport/ViewportGLWidget.cpp index 7bfeba6..f2cbe58 100644 --- a/src/Gui/Viewport/ViewportGLWidget.cpp +++ b/src/Gui/Viewport/ViewportGLWidget.cpp @@ -99,12 +99,16 @@ void ViewportGLWidget::initializeGL() void main() { - // FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f); vec3 lightDir = normalize(vec3(1.0,1.0,1.0)); float brightness = remap(dot(Normal, lightDir), -1, 1, 0.5, 1); - vec4 Color = vec4(remap(Normal, vec3(-1), vec3(1), vec3(0), vec3(1)), 1.0f); - FragColor = Color; + vec4 Color = vec4(1.0f,1.0f,1.0f,1.0f); + + // set color to normal + // Color = vec4(remap(Normal, vec3(-1), vec3(1), vec3(0), vec3(1)), 1.0f); + + + FragColor = Color*vec4(vec3(brightness), 1.0f); } )"; GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); diff --git a/src/OpDefs/CMakeLists.txt b/src/OpDefs/CMakeLists.txt index 5d90aed..0e127e7 100644 --- a/src/OpDefs/CMakeLists.txt +++ b/src/OpDefs/CMakeLists.txt @@ -21,6 +21,7 @@ add_library(${libName} SHARED ../Engine/Parameter/Parameter.cpp GopTransform.cpp GopHouse.cpp + GopTestCube.cpp ) target_link_libraries(${libName} PRIVATE Qt6::Core Qt6::Widgets Qt6::SvgWidgets Qt6::OpenGLWidgets glm::glm Eigen3::Eigen TBB::tbb) diff --git a/src/OpDefs/GopHouse.cpp b/src/OpDefs/GopHouse.cpp index 3a08583..7a4c0a0 100644 --- a/src/OpDefs/GopHouse.cpp +++ b/src/OpDefs/GopHouse.cpp @@ -36,10 +36,6 @@ void GOP_house::cookOp(enzo::op::Context context) {0,2,-1}, {0,2,1} }; - for (auto& p : pts) PAttrHandle.addValue(p); - - auto pointAttr = geo.getAttribByName(ga::AttrOwner::VERTEX, "point"); - ga::AttributeHandleInt pointAttrHandle(pointAttr); std::vector> faces = { {7,9,6,2,3}, {4,8,5,1,0}, @@ -51,6 +47,11 @@ void GOP_house::cookOp(enzo::op::Context context) {9,6,5}, {8,5,9} }; + + for (auto& p : pts) PAttrHandle.addValue(p); + + auto pointAttr = geo.getAttribByName(ga::AttrOwner::VERTEX, "point"); + ga::AttributeHandleInt pointAttrHandle(pointAttr); for (auto& f : faces) for (int i : f) pointAttrHandle.addValue(startPt + i); auto vertexCountAttr = geo.getAttribByName(ga::AttrOwner::PRIMITIVE, "vertexCount"); @@ -67,18 +68,6 @@ void GOP_house::cookOp(enzo::op::Context context) } // ---- - constexpr int N = 10000; - std::vector results(N); - - oneapi::tbb::parallel_for(0, N, [&](int i) { - double val = 0; - for (int j = 0; j < 100; ++j) { - val += std::sin(i + j); - } - results[i] = val; - }); - - // set output geometry setOutputGeometry(0, geo); } diff --git a/src/OpDefs/GopTestCube.cpp b/src/OpDefs/GopTestCube.cpp new file mode 100644 index 0000000..168b3b0 --- /dev/null +++ b/src/OpDefs/GopTestCube.cpp @@ -0,0 +1,72 @@ +#include "OpDefs/GopTestCube.h" +#include "Engine/Operator/AttributeHandle.h" +#include + +GopTestGeoCube::GopTestGeoCube(enzo::nt::NetworkManager* network, enzo::op::OpInfo opInfo) + : GeometryOpDef(network, opInfo) +{ +} + +void GopTestGeoCube::cookOp(enzo::op::Context context) +{ + using namespace enzo; + + if (outputRequested(0)) + { + geo::Geometry geo = context.cloneInputGeo(0); + + auto PAttr = geo.getAttribByName(ga::AttrOwner::POINT, "P"); + ga::AttributeHandleVector3 PAttrHandle(PAttr); + const int startPt = PAttrHandle.getSize(); + + const std::vector pts = { + {-1, -1, 1}, + { 1, -1, 1}, + { 1, 1, 1}, + {-1, 1, 1}, + {-1, -1, -1}, + { 1, -1, -1}, + { 1, 1, -1}, + {-1, 1, -1} + }; + + for (const auto &p : pts) PAttrHandle.addValue(p); + + const std::vector> faces = { + {0, 1, 2, 3}, + {7, 6, 5, 4}, + {0, 3, 7, 4}, + {5, 6, 2, 1}, + {3, 2, 6, 7}, + {4, 5, 1, 0} + }; + + auto pointAttr = geo.getAttribByName(ga::AttrOwner::VERTEX, "point"); + ga::AttributeHandleInt pointAttrHandle(pointAttr); + for (const auto &f : faces) + for (int i : f) + pointAttrHandle.addValue(startPt + i); + + auto vertexCountAttr = geo.getAttribByName(ga::AttrOwner::PRIMITIVE, + "vertexCount"); + ga::AttributeHandleInt vertexCountHandle(vertexCountAttr); + for (const auto &f : faces) + vertexCountHandle.addValue(static_cast(f.size())); + + const float s = context.evalFloatParm("size"); + for (int i = 0; i < PAttrHandle.getAllValues().size(); ++i) + { + bt::Vector3 v = PAttrHandle.getValue(i); + v *= s; + PAttrHandle.setValue(i, v); + } + + setOutputGeometry(0, geo); + } +} + +enzo::prm::Template GopTestGeoCube::parameterList[] = +{ + enzo::prm::Template(enzo::prm::Type::FLOAT, "size", 1), + enzo::prm::Terminator +}; diff --git a/src/OpDefs/GopTestCube.h b/src/OpDefs/GopTestCube.h new file mode 100644 index 0000000..bb45fc0 --- /dev/null +++ b/src/OpDefs/GopTestCube.h @@ -0,0 +1,18 @@ +#pragma once +#include "Engine/Operator/GeometryOpDef.h" +#include "Engine/Parameter/Template.h" + +class GopTestGeoCube +: public enzo::nt::GeometryOpDef +{ +public: + GopTestGeoCube(enzo::nt::NetworkManager* network, enzo::op::OpInfo opInfo); + virtual void cookOp(enzo::op::Context context); + static enzo::nt::GeometryOpDef* ctor(enzo::nt::NetworkManager* network, enzo::op::OpInfo opInfo) + { + return new GopTestGeoCube(network, opInfo); + } + + static BOOST_SYMBOL_EXPORT enzo::prm::Template parameterList[]; + +}; diff --git a/src/OpDefs/RegisterPlugin.cpp b/src/OpDefs/RegisterPlugin.cpp index 73e574a..2c603d3 100644 --- a/src/OpDefs/RegisterPlugin.cpp +++ b/src/OpDefs/RegisterPlugin.cpp @@ -1,6 +1,7 @@ #include "Engine/Operator/OpInfo.h" #include "Engine/Operator/OperatorTable.h" #include "GopHouse.h" +#include "GopTestCube.h" #include "OpDefs/GopTransform.hpp" #include #include @@ -31,6 +32,17 @@ extern "C" 1, } ); + addOperator( + enzo::op::OpInfo { + "testGeoCube", + "Test Cube", + &GopTestGeoCube::ctor, + GopTestGeoCube::parameterList, + 0, + 0, + 1, + } + ); } }