
Not only can the Shapes3D library do this but you can also specify multiple discontinuous areas of the ellipsoid
For instance the picture on the right is a single ellipsoid with just 4 sections of it being drawn.
The sketch code shown below was used to create this picture (note that the skecth uses the
PeasyCam library to rotate the view of the ellipsoid)
If you look at the code you will see that it creates 4 MeshSection objects which are then used to control the section of the ellipsoid to be drawn.
If you experiment with this sketch it should make things clearer.
As weel as the addDrawSection method other useful methods are removeDrawSection to remove a particular drawSections and setDrawFullShape method that removes all draw sections.
This technique works with classes BezierShape, Ellipsoid, Helix, Toroid, Tube, BezTube and PathTube.
HTH and have fun.
- import peasy.test.*;
- import peasy.org.apache.commons.math.*;
- import peasy.*;
- import peasy.org.apache.commons.math.geometry.*;
- import processing.opengl.*;
- import shapes3d.utils.*;
- import shapes3d.animation.*;
- import shapes3d.*;
- Ellipsoid e;
- MeshSection ms0, ms1, ms2, ms3;
- PeasyCam pcam;
- void setup(){
- size(300,300, OPENGL);
- e = new Ellipsoid(this, 30, 30);
- e.fill(color(100,100,255));
- e.stroke(color(255));
- e.drawMode(Shape3D.SOLID | Shape3D.WIRE);
- ms0 = new MeshSection(31,31);
- ms0.setRange(0.0, 1.0, 0.65, 0.75);
- e.addDrawSection(ms0);
-
- ms1 = new MeshSection(331,31);
- ms1.setRange(0.25, 0.45, 0.25, 0.35);
- e.addDrawSection(ms1);
-
- ms2 = new MeshSection(331,31);
- ms2.setRange(0.55, 0.75, 0.25, 0.35);
- e.addDrawSection(ms2);
-
- ms3 = new MeshSection(331,31);
- ms3.setRange(0.48, 0.52, 0.25, 0.6);
- e.addDrawSection(ms3);
-
- pcam = new PeasyCam(this,200);
- }
- void draw(){
- background(0);
- lights();
- e.draw();
- }