# Hemesh change parameters

**URL:** <https://discourse.processing.org/t/hemesh-change-parameters/1863>\
**Category:** Libraries\
**Created:** [July 17, 2018, 8:04pm UTC](https://discourse.processing.org/t/hemesh-change-parameters/1863 "2018-07-17T20:04:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vjjv](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@vjjv](https://discourse.processing.org/u/vjjv)\
**Post date:** [July 17, 2018, 8:04pm UTC](https://discourse.processing.org/t/hemesh-change-parameters/1863/1 "2018-07-17T20:04:56Z")

</div>

hello! im using the hemesh library to construct 3D meshes, but i`ve a problem when i want to change the values of a constructor.. how can i change them? here in the example, i want to change the radius according mouseX position, but it doesnt do anything. i see hemesh`ve modifiers but i dont find any to change the radius or this parameters, like steps, or points.

```auto
import wblut.nurbs.*;
import wblut.hemesh.*;
import wblut.core.*;
import wblut.geom.*;
import wblut.processing.*;
import wblut.math.*;

WB_Render render;
WB_BSpline C;
WB_Point[] points;
HE_Mesh mesh;
HEC_SweepTube creator;

void setup() {
  size(1000,1000,P3D);
  smooth(8);
  // Several WB_Curve classes are in development. HEC_SweepTube provides
  // a way of generating meshes from them.

  //Generate a BSpline
  points=new WB_Point[11];
  for (int i=0;i<11;i++) {
    points[i]=new WB_Point(5*(i-5)*(i-5), -200+40*i, random(100));
  }
  C=new WB_BSpline(points, 4);

  creator=new HEC_SweepTube();
 
  creator.setCurve(C);//curve should be a WB_BSpline
  creator.setSteps(40);
  creator.setFacets(8);
  creator.setCap(true, true); // Cap start, cap end?
  mesh=new HE_Mesh(creator); 
  //HET_Diagnosis.validate(mesh);
  render=new WB_Render(this);
}

void draw() {
   creator.setRadius(mouseX);

  
  background(55);
  directionalLight(255, 255, 255, 1, 1, -1);
  directionalLight(127, 127, 127, -1, -1, 1);
  translate(width/2,height/2);
  rotateY(mouseX*1.0f/width*TWO_PI);
  rotateX(mouseY*1.0f/height*TWO_PI);
  stroke(0);
  render.drawEdges(mesh);
  noStroke();
  render.drawFaces(mesh);
}

```

---

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [July 18, 2018, 7:38am UTC](https://discourse.processing.org/t/hemesh-change-parameters/1863/2 "2018-07-18T07:38:00Z")

</div>

You probably need to re-create mesh in draw, following works for me

```auto
import wblut.nurbs.*;
import wblut.hemesh.*;
import wblut.core.*;
import wblut.geom.*;
import wblut.processing.*;
import wblut.math.*;

WB_Render render;
WB_BSpline C;
WB_Point[] points;
HE_Mesh mesh;
HEC_SweepTube creator;

void setup() {
  size(1000, 1000, P3D);
  smooth(8);
  // Several WB_Curve classes are in development. HEC_SweepTube provides
  // a way of generating meshes from them.

  //Generate a BSpline
  points=new WB_Point[11];
  for (int i=0; i<11; i++) {
    points[i]=new WB_Point(5*(i-5)*(i-5), -200+40*i, random(100));
  }
  C=new WB_BSpline(points, 4);
  creator=new HEC_SweepTube();
  creator.setCurve(C);//curve should be a WB_BSpline
  creator.setSteps(40);
  creator.setFacets(8);
  creator.setCap(true, true); // Cap start, cap end?
}

void draw() {
  creator.setRadius(mouseX);
  mesh=new HE_Mesh(creator); 
  //HET_Diagnosis.validate(mesh);
  render=new WB_Render(this);
  background(55);
  directionalLight(255, 255, 255, 1, 1, -1);
  directionalLight(127, 127, 127, -1, -1, 1);
  translate(width/2, height/2);
  rotateY(mouseX*1.0f/width*TWO_PI);
  rotateX(mouseY*1.0f/height*TWO_PI);
  stroke(0);
  render.drawEdges(mesh);
  noStroke();
  render.drawFaces(mesh);
}

```

You could make it more efficient by not doing recalculation in every draw loop, there are various ways you could this, but basically mouseX as you correctly identify only makes sense in a draw loop, and I don’t see how you expected it to change the mesh already created in setup.

---

<div class="post-metadata">

**Author:** ![vjjv](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@vjjv](https://discourse.processing.org/u/vjjv)\
**Post date:** [July 18, 2018, 2:16pm UTC](https://discourse.processing.org/t/hemesh-change-parameters/1863/3 "2018-07-18T14:16:16Z")

</div>

thanks Monkstone! witch are those ways? i dont need mouseX, just used for example. I need to change the values with a controlP5 / controller. and yes, doing this the performance down. Is there any other way?

---

<div class="post-metadata">

**Author:** ![vjjv](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@vjjv](https://discourse.processing.org/u/vjjv)\
**Post date:** [July 18, 2018, 6:03pm UTC](https://discourse.processing.org/t/hemesh-change-parameters/1863/4 "2018-07-18T18:03:29Z")

</div>

but the performance problem is caused by recalculation in every draw loop ? what about if the problem is the create new mesh in every draw? im not want to create a new mesh, just change values.

---

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [July 18, 2018, 7:13pm UTC](https://discourse.processing.org/t/hemesh-change-parameters/1863/5 "2018-07-18T19:13:28Z")

</div>

I’ve not tried it myself but this might help [HE\_Mesh GUI update](https://discourse.processing.org/t/he-mesh-gui-update/180/2)

---

<div class="post-metadata">

**Author:** ![vjjv](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@vjjv](https://discourse.processing.org/u/vjjv)\
**Post date:** [July 19, 2018, 2:59am UTC](https://discourse.processing.org/t/hemesh-change-parameters/1863/6 "2018-07-19T02:59:48Z")

</div>

I check that library. but it function with the he-mesh modifiers… and and dont found any to change this values…

---

<div class="post-metadata">

**Author:** ![vjjv](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@vjjv](https://discourse.processing.org/u/vjjv)\
**Post date:** [July 20, 2018, 5:38pm UTC](https://discourse.processing.org/t/hemesh-change-parameters/1863/7 "2018-07-20T17:38:11Z")

</div>

i try this and it works… but now i`ve the problem that PShape factory havent a update(); or apply(); method like mesh. so, im in the same situation but trying to render into a PGraphics via PShape. anybody has a solution?

```auto
import wblut.nurbs.*;
import wblut.hemesh.*;
import wblut.core.*;
import wblut.geom.*;
import wblut.processing.*;
import wblut.math.*;
 
 
 PShape tube;
WB_Render render;
WB_BSpline C;
WB_Point[] points;
HE_Mesh mesh;
HEC_SweepTube creator;
 
void setup() {
  size(1000,1000,P3D);
  smooth(8);
  // Several WB_Curve classes are in development. HEC_SweepTube provides
  // a way of generating meshes from them.
 
  //Generate a BSpline
  points=new WB_Point[11];
     for (int i=0;i<11;i++) {
    points[i]=new WB_Point(5*(i-5)*(i-5), -200+40*i,random(100) );
  }
  C=new WB_BSpline(points, 4);
 
  creator=new HEC_SweepTube();
 
  creator.setCurve(C);//curve should be a WB_BSpline
  creator.setSteps(40);
  creator.setFacets(8);
  creator.setCap(true, true); // Cap start, cap end?
  mesh=new HE_Mesh(creator); 
  //
  render=new WB_Render(this);
      

}
 
void draw() {

     for (int i=0;i<11;i++) {
    points[i]=new WB_Point(cos(i*frameRate/20)*5*(i-5)*(i-5), -200+40*i, sin(i*frameRate/50)*200);
  }
   
    creator.setRadius(15);
    creator.apply(mesh);
    mesh.update();
    
    tube=WB_PShapeFactory.createSmoothPShape(mesh, this); // HERE IS THE PROBLEM. its create a PShape a lot of times and performance down. need some like "update"
    
  background(55);
  directionalLight(255, 255, 255, 1, 1, -1);
  directionalLight(127, 127, 127, -1, -1, 1);
  translate(width/2,height/2);
  rotateY(mouseX*1.0f/width*TWO_PI);
  rotateX(mouseY*1.0f/height*TWO_PI);
  stroke(0);
  shape(tube);
  //render.drawEdges(mesh);
  noStroke();
  //render.drawFaces(mesh);
}

```
