vjjv
July 20, 2018, 5:50am
1
hello. im trying to create a path tube with shape3D library, but i have a problem to implements a I_PathGen interface… is the first time that i “implements” a interface and i dont know how exactly make it works.
import shapes3d.*;
import shapes3d.animation.*;
import shapes3d.utils.*;
I_PathGen[] pathh;
PathTube path;
Points points;
Tube tube;
PeasyCam cam;
void setup() {
size(600, 600, P3D);
pathh = new I_PathGen[20];
pathh[0] = new Points();
pathh[0].x(1000);
pathh[0].y(100);
pathh[0].z(100);
path = new PathTube(this, pathh[0], 5, 300, 10, false);
path.fill(color(0, 255, 0), S3D.E_CAP);
}
void draw() {
background(0);
path.draw();
}
class Points implements I_PathGen {
}
the reference of I_PathGen
/*
Part of the Shapes 3D library for Processing
http://www.lagers.org.uk
Copyright (c) 2010 Peter Lager
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
This file has been truncated. show original
thanks a lot…
jb4x
July 20, 2018, 5:59am
2
Hello,
When you implement an interface, you need to define some functions listed in the interface.
In that case, you need to define the 3 following functions in your class :
public float x(float t);
public float y(float t);
public float z(float t);
For more explanations :
vjjv
July 20, 2018, 6:01am
3
some like this ?
maybe need also some information about this library…
import shapes3d.*;
import shapes3d.animation.*;
import shapes3d.utils.*;
I_PathGen[] pathh;
PathTube path;
Points points;
Tube tube;
PeasyCam cam;
void setup() {
size(600, 600, P3D);
pathh = new I_PathGen[20];
pathh[0] = new Points(0, 0,0);
pathh[0].x(1000);
pathh[0].y(100);
pathh[0].z(100);
path = new PathTube(this, pathh[0], 5, 300, 10, false);
path.fill(color(0, 255, 0), S3D.E_CAP);
}
void draw() {
background(0);
path.draw();
}
class Points implements I_PathGen {
float xx, yy, zz;
Points (float _x, float _y, float _z){
xx = _x;
yy = _y;
zz = _z;
}
public float x(float t){
return t;
}
public float y(float t){
return t;
}
public float z(float t){
return t;
}
}
vjjv
July 20, 2018, 6:09am
5
thanks. but still dont understand. i just wanna connect two points with a tube… but i dont find any example. this is ok?
class Points implements I_PathGen {
float xx, yy, zz;
Points (float _x, float _y, float _z){
xx = _x;
yy = _y;
zz = _z;
}
public float x(float t){
t = xx;
return t;
}
public float y(float t){
t = yy;
return t;
}
public float z(float t){
t = zz;
return t;
}
}
cos i expected to set a point but this dont display anything
jb4x
July 20, 2018, 6:13am
6
I don’t know the library so I can’t be 100% sure but I don’t think that you need to set all the points manually.
The 3 functions x, y, and z are the equations that defines the shape of your path.
So when you write :
public float x(float t){
return t;
}
public float y(float t){
return t;
}
public float z(float t){
return t;
}
You are actually building a straight path that follows :
x(t) = t
y(t) = t
z(t) = t
I’m afraid I can’t really help more than that
Parameters die along its function, so it’s useless to re-assign them!
I believe you were meant to assign the x() 's t parameter to the Points ::xx field instead: xx = t;
@Override float x(final float t) {
return xx = t;
}
vjjv
July 20, 2018, 6:21am
8
import shapes3d.*;
import shapes3d.animation.*;
import shapes3d.utils.*;
I_PathGen[] pathh;
PathTube path;
Points points;
Tube tube;
void setup() {
size(600, 600, P3D);
pathh = new I_PathGen[20];
pathh[0] = new Points(2, 500, 6);
path = new PathTube(this, pathh[0], 50, 300, 10, false);
path.fill(color(0, 255, 0), S3D.E_CAP);
}
void draw() {
background(0);
translate(width/2, height/2);
path.draw();
}
class Points implements I_PathGen {
float xx, yy, zz;
Points (float _x, float _y, float _z){
xx = _x;
yy = _y;
zz = _z;
}
@Override float x(final float t) {
return xx = t;
}
@Override float y(final float t) {
return yy = t;
}
@Override float z(final float t) {
return zz = t;
}
}
try this and this is the result… dont know, im so lost…
vjjv
July 21, 2018, 4:06am
10
I want to connect two points with a tube. first in a rect line, later, generate a spline or bezier curve