How to create an infinite bezier tube (beztube) with shapes3d lib
in
Contributed Library Questions
•
2 years ago
Hi all,
i am writing a sort of game in which an airplane (user controlled) should leave a trailing path. This path is made up from a bezTube.
As it is now i record the xyz positions of the plane in a PVector array. The shapes3D lib has a function to create bezier tubes. This function takes the Pvector array as its input and creates the tube.
My problem is that the sketch slow, very slow. This is because i let the beziertube be created every loop of the draw function. It should be faster if i could expand the length of the tube in each loop. There does not seem to be a function for that however...
Any ideas how speed things up?
thanks!
my code:
- void draw() {
- lights();
- background(0);
- //display all floaters
- for (int i=0; i < 1; i++) {
- vlotSet[i].display();
- }
- //record path of floater
- myPath.recordPath();
- //display path of floater
- myPath.display(this);
- }
- class Path {
- //variables
- Bezier3D form;
- BezTube buis;
- PVector[] vectorArray = new PVector[10000];
- int i = 0;
- //constructor
- Path() {
- //initialize vector array
- for (int x = 0; x < vectorArray.length; x++) {
- vectorArray[x] = new PVector(vlotSet[0].getXpos(), vlotSet[0].getYpos(), vlotSet[0].getZpos());
- }
- }
- //methods
- void recordPath() { //here i store the path
- if (frameCount % 10 == 1) { //not every loop
- vectorArray[i].x = vlotSet[0].getXpos();
- vectorArray[i].y = vlotSet[0].getYpos();
- vectorArray[i].z = vlotSet[0].getZpos();
- i++;
- }
- }
- PVector[] getPath() {
- return vectorArray;
- }
- void display(PApplet applet) {
- form = new Bezier3D(vectorArray, 1000);
- buis = new BezTube(applet, form, 5, 500, 16);//Bezier3D bez, float rad, int nbrSlices, int nbrSegments
- buis.draw();
- }
- }
Thanks in advance!
1