We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › 3D shape library - now available
Pages: 1 2 3 
3D shape library - now available (Read 11656 times)
Re: 3D shape library - now available
Reply #15 - Jan 11th, 2010, 1:51am
 
Extending a class wirtten by a 3rd party is not for the faint hearted, and certainly depends on the users programming skill and experience.

Certainly calculating the angles for lat and long based on a 'location' on the texture image is easy enough but that is just the start of what jeffg was looking to do.
Re: 3D shape library - now available
Reply #16 - Jan 11th, 2010, 12:25pm
 
Yes... looks like quite an effort.   Undecided

Looking at the Sphere up close, how do I improve the quality?  sphereDetail() seems to have no effect.
Re: 3D shape library - now available
Reply #17 - Jan 11th, 2010, 12:59pm
 
The sphere is created form the Ellipsoid class and the level of detail is determined when the object is created so
Code:

Ellipsoid sphere = new Ellipsoid(this, 20, 30);

The first parameter is the main sketch so will invariably be this the next 2 numbers represent the number of slices (north-south) and the number of segments (east-west). Want more detail then increase these numbers.

It is not possible to change the level of detail after sphere has been created.

If you are using texture tiling then the number of texture repeats must be a factor of the the number of slices/segments e.g.
No of slices = 20 : no.of texture permitted repeats 1,2,4,5,10 or 20
No of segs = 30 : no.of texture permitted repeats 1,2,5,6,10,15 or 30
any other value will be changed to a valid factor.
Smiley
Re: 3D shape library - now available
Reply #18 - Jan 16th, 2010, 5:54am
 

Dear quark,

first of all, thank you very much!

James Carruthers wrote a beautiful function that allows to paint a thin 3D-Box between two points. This is a replacement for a line that wouldn't look good in 3D.

I like the approach that you tell the box the exact Start- and Endpoint. I like to have this in your 3DShapes.

At the moment I wonder whether it's possible to use the approach with your tube to tell it exactly go from x1,y1,z1 to x2,y2,z2. I also asked James about that. It would be cool if you could help with that.

His function is:
void drawLine(float x1, float y1, float z1, float x2, float y2, float z2, float weight, color strokeColour) {

you see it in http://processing.org/discourse/yabb2/num_1262458611.html#4
reply #4

Thanks!

Greetings,

Chrisir

Re: 3D shape library - now available
Reply #19 - Jan 16th, 2010, 6:19am
 
thats a really good idea.
Re: 3D shape library - now available
Reply #20 - Jan 16th, 2010, 6:59am
 


Hello Quark,

I would also appreciate a 3D-arrow as
posted in

http://processing.org/discourse/yabb2/num_1262857665.html#8

Thanks,

Greetings, Chrisir


Re: 3D shape library - now available
Reply #21 - Jan 16th, 2010, 11:40am
 
It is easy to create an arrow using the shapes available in the library and linking them. Try this.
Code:
import shapes3d.utils.*;
import shapes3d.org.apache.commons.math.util.*;
import shapes3d.org.apache.commons.maths.*;
import shapes3d.org.apache.commons.maths.geometry.*;
import shapes3d.*;

import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;

PeasyCam pcam;
Tube tube;
Cone head1, head2;

void setup(){
 size(300,300,P3D);
 
 pcam = new PeasyCam(this, 0,0,0,100);
 
 tube = new Tube(this,1,20);
 tube.setSize(1.5,1.5,1.5,1.5,100);
 tube.fill(color(160,80,16));
 head1 = new Cone(this,20);
 head1.setSize(3,8,2);
 head1.moveTo(0,-46,0);
 head1.fill(color(124,96,72));
 head2 = new Cone(this,20);
 head2.setSize(3,8,16);
 head2.moveTo(0,-46,0);
 head2.fill(color(124,96,72));
 tube.addShape(head1);
 tube.addShape(head2);
 noStroke();
}

void draw(){
 background(64);
 ambientLight(200,200,200);
 tube.draw();
}

Smiley
Re: 3D shape library - now available
Reply #22 - Jan 16th, 2010, 12:01pm
 

That's beautiful and could well be part of 3D-Shapes!

What about my other questions about the tubes?...

I am just so interested what you have to say!

Thanks!

Chrisir

Re: 3D shape library - now available
Reply #23 - Jan 16th, 2010, 12:10pm
 
Quote:
That's beautiful and could well be part of 3D-Shapes!

True but it would be easy to create an Arrow class with tube, head1 and head2 as attributes, the library supports composite shapes so that others can create arrows etc.

With regard to the tubes, I have read the thread started by James and the problem is not the lines but the joins. This problem would still exist using Tubes although you could use Ellipsoids (spheres) for them. Umm! neeed to think more about this.

Re: 3D shape library - now available
Reply #24 - Jan 16th, 2010, 12:22pm
 

Hello,

I am more interested in the question how to put your tube between two defined points x1,y1,z1 and x2,y2,z2.

I just do not know how it's done...

Thanks,

Chrisir

Re: 3D shape library - now available
Reply #25 - Jan 17th, 2010, 4:56pm
 
thnx! this is really helpful. Smiley i dont know much about processing, cuz i just started and have never taken a class, and maybe now i can make something worthwhile.  Grin
Re: 3D shape library - now available
Reply #26 - Jan 18th, 2010, 12:52pm
 
@ ChibiGirl901
Welcome to Processing and I hope you enjoy it. Processing is for everyone from newbies to experienced software developers.
I like it because it supports people being creative and creativity is fun. Smiley

@Chrisir
Quote:
I am more interested in the question how to put your tube between two defined points x1,y1,z1 and x2,y2,z2.

I just do not know how it's done...

It is not easy because inside the Shapes3D library the tube is represented by a position (x/y/z) and 3 angles of rotation (one per axis). To create a tube given a start and end position requires some serious math. This library uses the apache commons math library and I have used that for the math.

To create a '3D line' first create a Tube object and then call the setTubePosition passing the tube object and PVector(s) for the start and end positions.
The code inside the method looks horrendous because I have also used the PeasyCam library and that also uses the Math library so references to Vector3D and Rotation have to state which classes to use. The code inside this method does not need the PeasyCam to be present to work it is solely dependent on the Shapes3D library.

I am working on the next version of the library and I will include this feature in it. If you have problems with this let me know the version of the library I am using is halfway between the one you have and the next one.
Cheesy
It it works I have another example for James which creates a smooth 3D bezier ciurve.
Grin
Code:
import shapes3d.utils.*;
import shapes3d.org.apache.commons.math.util.*;
import shapes3d.org.apache.commons.math.*;
import shapes3d.org.apache.commons.math.geometry.*;
import shapes3d.*;

import processing.opengl.*;

import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;

// The 3D line
Tube line;
float tubeRad = 2.0f;
PVector start, end;

// End line markers to confirm working
Ellipsoid es, ee;

PeasyCam pcam;

void setup(){
 size(300,300,OPENGL);
 pcam = new PeasyCam(this,0,0,0,240);

 // Create the vectors for the start and end line positions
 start = new PVector(-50,-50,60);
 end = new PVector(-70,-30,-10);

 // Create the tube will be used for the line
 line = new Tube(this,1,20);
 line.fill(color(0,0,128));
 // Set the tube to go from start to end
 setTubePosition(line, start, end);

 // Green start line marker to confirm it works
 es = new Ellipsoid(this,6,6);
 es.fill(color(0,128,0));
 es.setRadius(tubeRad);
 es.moveTo(start);
 // Red end line marker to confirm it works
 ee = new Ellipsoid(this,6,6);
 ee.fill(color(255,0,0));
 ee.setRadius(tubeRad);
 ee.moveTo(end);
 noStroke();
}

// Change the tube attributes so it goes from
// position vector start to position vector end
void setTubePosition(Tube tube, PVector start, PVector end){
 double[] angles = new double[]{
   0,0,0      };
 PVector pos = PVector.add(start, end);
 pos.div(2);
 tube.moveTo(pos);
 float tubeLength = PVector.dist(start, end);
 tube.setSize(tubeRad, tubeRad, tubeRad, tubeRad, tubeLength);

 //PVector dir = PVector.sub(end, start);
 shapes3d.org.apache.commons.math.geometry.Vector3D dir = VecTransform.p2v(PVector.sub(end, pos));
 shapes3d.org.apache.commons.math.geometry.Vector3D e =
   new shapes3d.org.apache.commons.math.geometry.Vector3D(0,1,0);

 shapes3d.org.apache.commons.math.geometry.Rotation rot =
   new shapes3d.org.apache.commons.math.geometry.Rotation(e,dir);
 try{
   angles = rot.getAngles(shapes3d.org.apache.commons.math.geometry.RotationOrder.XYZ);
 }
 catch(Exception excp){
   println("ERROR");
 }
 tube.rotateToX((float)angles[0]);
 tube.rotateToY((float)angles[1]);
 tube.rotateToZ((float)angles[2]);
}

void draw(){
 background(64);
 ambientLight(200,200,200);
 directionalLight(120, 120, 120, 0, -1, 0);
 line.draw();
 es.draw();
 ee.draw();
}
Re: 3D shape library - now available
Reply #27 - Jan 18th, 2010, 1:08pm
 
thanks!!!!

He can't find
shapes3d.org.apache.commons.math
Re: 3D shape library - now available
Reply #28 - Jan 19th, 2010, 2:45am
 
Quote:
He can't find
shapes3d.org.apache.commons.math


I am using the next version of the library (yet to be released) and have renamed the packages so for the moment remove the "org." i.e.

Code:
shapes3d.apache.commons.math 



The next version of the library will have the 3d line function so no this will not be a problem. I will try and get the next version out by weekend with examples of the 3d line function included.
Smiley

Re: 3D shape library - now available
Reply #29 - Jan 19th, 2010, 7:16am
 



Hello,

Thank you so much!

Is there are 3D-Line as tube and as thin box?
Can it have a color or shader?

Greetings, Chrisir

Pages: 1 2 3