从零开始构造几何体(CREATING GEOMETRY FROM SCRATCH)

Here we explain how to generate geometry procedurally. There are two node types that allow tho do this: Nodes of type Attribute Wrangle allow to specify geometry using the programming language VEX. Nodes of type Python allow to do the same in the Python language. In general you should keep in mind the following: Quite often the same task implemented in VEX leads to a much better performance than the corresponding implementation in python. The reason is that VEX is compiled on the fly in such a way as to exploit all available possibilities for parallelization. On the other hand, Python offers a wealth of numerical libraries. This means that many tasks have to be done in Python, but the standard choice should be VEX.


一般推荐使用VEX语言,VEX语法与C语言差不多。Python推荐使用复杂数学计算时使用。Attribute Wrangle节点可以用来构造点面属性。

VEX构造几何体(VEX Code Geometry)

// VEX code example
// this code runs over "detail" (see wrangle parameters)

// create a basic geometry

// grab index of it's own geometry
int geo = geoself();
// add 5 points to that geometry
// and remember their indices.
int p0 = addpoint(geo,{0,0,0});
int p1 = addpoint(geo,{.5,.5,.5});
int p2 = addpoint(geo,{.5,-.5,-.5});
int p3 = addpoint(geo,{-.5,.5,-.5});
int p4 = addpoint(geo,{-.5,-.5,.5});

// define a function to create triangles
int addtriangle(const int g,p,q,r) {
 // create a polygon index
 int f = addprim(g,"poly");
 // and add vertices to the polygon
 addvertex(g,f,p);
 addvertex(g,f,q);
 addvertex(g,f,r);
 return f;
}

// add the 6 triangles
addtriangle(geo,p0,p1,p2);
addtriangle(geo,p0,p1,p3);
addtriangle(geo,p0,p1,p4);
addtriangle(geo,p0,p2,p3);
addtriangle(geo,p0,p2,p4);
addtriangle(geo,p0,p3,p4);

从零开始构造几何体(CREATING GEOMETRY FROM SCRATCH)_第1张图片
从零开始构造几何体(CREATING GEOMETRY FROM SCRATCH)_第2张图片
同时也能使用python构建。
这里只单纯的尝试几何体的构建
hip:https://pan.baidu.com/s/1aB5mIJwuR0QOqbJRVR2sOA
原文:https://wordpress.discretization.de/houdini/home/introduction/creating-geometry-from-scratch/

你可能感兴趣的:(Houdini,Houdini,构建几何体,VEX)