feat: hard face normals per vertex
This commit is contained in:
@@ -25,17 +25,31 @@ void GOP_house::cookOp(enzo::op::Context context)
|
||||
ga::AttributeHandleVector3 PAttrHandle(PAttr);
|
||||
int startPt = PAttrHandle.getSize();
|
||||
std::vector<bt::Vector3> 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},
|
||||
{0,2,-1},{0,2,1}
|
||||
{-1,-1,-1},
|
||||
{1,-1,-1},
|
||||
{1,-1,1},
|
||||
{-1,-1,1},
|
||||
{-1,1,-1},
|
||||
{1,1,-1},
|
||||
{1,1,1},
|
||||
{-1,1,1},
|
||||
{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<std::vector<int>> faces = {
|
||||
{3,2,6,9,7},{0,1,5,8,4},{0,3,7,4},{1,2,6,5},
|
||||
{0,1,2,3},{4,7,9},{4,9,8},{5,6,9},{5,9,8}
|
||||
{7,9,6,2,3},
|
||||
{4,8,5,1,0},
|
||||
{4,7,3,0},
|
||||
{5,6,2,1},
|
||||
{0,1,2,3},
|
||||
{9,7,4},
|
||||
{8,9,4},
|
||||
{9,6,5},
|
||||
{8,5,9}
|
||||
};
|
||||
for (auto& f : faces) for (int i : f) pointAttrHandle.addValue(startPt + i);
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "OpDefs/GopTransform.hpp"
|
||||
#include "Engine/Operator/AttributeHandle.h"
|
||||
#include "Engine/Parameter/Template.h"
|
||||
#include <Eigen/src/Core/Matrix.h>
|
||||
#include <Eigen/src/Geometry/AngleAxis.h>
|
||||
|
||||
GopTransform::GopTransform(enzo::nt::NetworkManager* network, enzo::op::OpInfo opInfo)
|
||||
: GeometryOpDef(network, opInfo)
|
||||
@@ -26,6 +28,10 @@ void GopTransform::cookOp(enzo::op::Context context)
|
||||
for(int i=0; i<PAttrHandle.getAllValues().size(); ++i)
|
||||
{
|
||||
enzo::bt::Vector3 vector = PAttrHandle.getValue(i);
|
||||
Eigen::AngleAxisd rotationX(context.evalFloatParm("rotateX"), Eigen::Vector3d(1,0,0));
|
||||
Eigen::AngleAxisd rotationY(context.evalFloatParm("rotateY"), Eigen::Vector3d(0,1,0));
|
||||
Eigen::AngleAxisd rotationZ(context.evalFloatParm("rotateZ"), Eigen::Vector3d(0,0,1));
|
||||
vector = (rotationX*rotationY*rotationZ)*vector;
|
||||
vector.x()+=context.evalFloatParm("translateX");
|
||||
vector.y()+=context.evalFloatParm("translateY");
|
||||
vector.z()+=context.evalFloatParm("translateZ");
|
||||
@@ -46,6 +52,9 @@ enzo::prm::Template GopTransform::parameterList[] =
|
||||
enzo::prm::Template(enzo::prm::Type::FLOAT, "translateX", 0),
|
||||
enzo::prm::Template(enzo::prm::Type::FLOAT, "translateY", 0),
|
||||
enzo::prm::Template(enzo::prm::Type::FLOAT, "translateZ", 0),
|
||||
enzo::prm::Template(enzo::prm::Type::FLOAT, "rotateX", 0),
|
||||
enzo::prm::Template(enzo::prm::Type::FLOAT, "rotateY", 0),
|
||||
enzo::prm::Template(enzo::prm::Type::FLOAT, "rotateZ", 0),
|
||||
enzo::prm::Terminator
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user