I was checking the source code of SuperEllipsoidMeshBuilder example here:
http://haptic-data.com/toxiclibsjs/examples/SuperEllipsoidMeshBuilder_pjs-webgl.html
And i was playing with the source code as below:
if(!isWireFrame)
{
for(i=0;i<numFaces;i++)
{
Face f = faces[i];
toxi.Vec3D a = f.a;
toxi.Vec3D b = f.b;
toxi.Vec3D c = f.c;
//normal(a.normal.x,a.normal.y,a.normal.z);
vertex(a.x,a.y,a.z);
//normal(b.normal.x,b.normal.y,b.normal.z);
vertex(b.x,b.y,b.z);
//normal(c.normal.x,c.normal.y,c.normal.z);
vertex(c.x,c.y,c.z);
}
}
else
{
for(i=0;i<numFaces;i++)
{
toxi.Face f = faces[i];
toxi.Vec3D n = f.normal;
toxi.Vec3D a = f.a;
toxi.Vec3D b = f.b;
toxi.Vec3D c = f.c;
//normal(n.x,n.y,n.z);
vertex(a.x,a.y,a.z);
vertex(b.x,b.y,b.z);
vertex(c.x,c.y,c.z);
}
}
endShape();
/*if(len>0){
int strokeCol = 0;
int j;
if (!isWireFrame) {
toxi.Vertex[] vertices = mesh.getVertices();
int numVertices = vertices.length;
for (j=0;j<numVertices;j++) {
toxi.Vertex v = vertices[j];
toxi.Vec3D w = v.add(v.normal.scale(normalLength));
toxi.Vec3D n = v.normal.scale(127);
stroke(n.x + 128, n.y + 128, n.z + 128);
//stroke(0, 0, 255);
line(v.x, v.y, v.z, w.x, w.y, w.z);
}
} else {
float third = 1.0 / 3;
for (j=0;j<numFaces;j++) {
toxi.Face f = faces[j];
toxi.Vec3D c = f.a.add(f.b).addSelf(f.c).scaleSelf(third);
toxi.Vec3D d = c.add(f.normal.scale(normalLength));
toxi.Vec3D n = f.normal.scale(127);
stroke(n.x + 128, n.y + 128, n.z + 128);
line(c.x, c.y, c.z, d.x, d.y, d.z);
}
}
}*/
As you can see i commented the if(len>0) part. By pressing w, it is possible to see wired mesh and a filled version. Although the two if-else part is same, why is the pressing 'w' resulting in a filled version of the mesh?
Also i wonder, whether i can change the mesh's z value. I mean, i change the line as toxi.SurfaceFunction functor=new toxi.SuperEllipsoid(1, 1); and created square partitions. I want the z value of these grid partitons defined as custom when they are filled. So i want to see some parts higher, some not. How can i do that?
And i was playing with the source code as below:
if(!isWireFrame)
{
for(i=0;i<numFaces;i++)
{
Face f = faces[i];
toxi.Vec3D a = f.a;
toxi.Vec3D b = f.b;
toxi.Vec3D c = f.c;
//normal(a.normal.x,a.normal.y,a.normal.z);
vertex(a.x,a.y,a.z);
//normal(b.normal.x,b.normal.y,b.normal.z);
vertex(b.x,b.y,b.z);
//normal(c.normal.x,c.normal.y,c.normal.z);
vertex(c.x,c.y,c.z);
}
}
else
{
for(i=0;i<numFaces;i++)
{
toxi.Face f = faces[i];
toxi.Vec3D n = f.normal;
toxi.Vec3D a = f.a;
toxi.Vec3D b = f.b;
toxi.Vec3D c = f.c;
//normal(n.x,n.y,n.z);
vertex(a.x,a.y,a.z);
vertex(b.x,b.y,b.z);
vertex(c.x,c.y,c.z);
}
}
endShape();
/*if(len>0){
int strokeCol = 0;
int j;
if (!isWireFrame) {
toxi.Vertex[] vertices = mesh.getVertices();
int numVertices = vertices.length;
for (j=0;j<numVertices;j++) {
toxi.Vertex v = vertices[j];
toxi.Vec3D w = v.add(v.normal.scale(normalLength));
toxi.Vec3D n = v.normal.scale(127);
stroke(n.x + 128, n.y + 128, n.z + 128);
//stroke(0, 0, 255);
line(v.x, v.y, v.z, w.x, w.y, w.z);
}
} else {
float third = 1.0 / 3;
for (j=0;j<numFaces;j++) {
toxi.Face f = faces[j];
toxi.Vec3D c = f.a.add(f.b).addSelf(f.c).scaleSelf(third);
toxi.Vec3D d = c.add(f.normal.scale(normalLength));
toxi.Vec3D n = f.normal.scale(127);
stroke(n.x + 128, n.y + 128, n.z + 128);
line(c.x, c.y, c.z, d.x, d.y, d.z);
}
}
}*/
As you can see i commented the if(len>0) part. By pressing w, it is possible to see wired mesh and a filled version. Although the two if-else part is same, why is the pressing 'w' resulting in a filled version of the mesh?
Also i wonder, whether i can change the mesh's z value. I mean, i change the line as toxi.SurfaceFunction functor=new toxi.SuperEllipsoid(1, 1); and created square partitions. I want the z value of these grid partitons defined as custom when they are filled. So i want to see some parts higher, some not. How can i do that?
1