Any Extrusion Library which can work with Xith

hi i want to extrude 2D contour (polyline) on a 3D path (polyline) .
Can i do this by using Xith ?
Any suggestions are welcome as i have tried my best on net and found one library written in C.

Thier is “GLE Tubing and Extrusion Library” in C ,does anyone know its implementation in java which can run on Jogl .
also ShapeShifter is a re-write of the GLE library in Java but it runs on magician so i think i have to understand the algorithm and write on top of Jogl.

Interesting topic.

Can you post also the links to the mentioned projects?

Yuri

Link for the C library is http://linas.org/gle/
and its implementation on Java is ShapeShifter which you can download from http://www.filegate.net/pdnjava/ file shapesh.zip.
but the problem is its based on Magician binding

Try JGeom, it will allow you to play with NURBS representations you can do extrude as well I think they call it rail or something in this library, you will have to tesellate the NURBS geometry to Xith vertices/normals etc as I am not sure if JGeom have tesselation available.

…or we try to add NURBS rendering to Xith3D… we will see what is possible.

Yuri

JGeom has pretty good implementation of NURBS and Subdivision surfaces already, so on Xith there should be a good and efficient tesselation implemented rather than reimplementing the NURBS, SUbdivs from scratch. Another interesting thing would be playing with mapping coordinates for this geometry. I am not sure if JGeom already has some of that stuff in there, I know they have a utility API that interfaces with Java3D but its licensed.

will try it out…how about adding some base functionality in Xith .
What i have in mind is to able to specify a convex closed ploygon on a plane and depth upto which it should be extruded.
I have wriiten a small class for it ,please give your input to improve this.

import javax.vecmath.Point3f;
import com.xith3d.scenegraph.GeometryArray;
import com.xith3d.scenegraph.Shape3D;
import com.xith3d.scenegraph.TriangleStripArray;

/**
 * @author ksingh2
 * 
 */
public class GeometryExtruder extends Shape3D {

	private float extrusonLength;

	public GeometryExtruder(float length, Point3f[] coordsArray) {
		super();
		this.extrusonLength = length;
		int [b]numLayers [/b]= 8;
		float depthShift = -this.extrusonLength/numLayers;
		Point3f point;
		Point3f[] coords = new Point3f[1+numLayers*(2*coordsArray.length+1)];
		int counter = 0;
		
		
		for (int j = 0; j < numLayers; j++) {
			for (int i = 0; i < coordsArray.length; i++) {
				if(j==0){
				point = new Point3f(coordsArray[i]);
				
				coords[counter++] = point;
				}else{
					coords[counter++] =coords[(j-1)*(coordsArray.length*2+1)+i*2+1];
				}
				
				point = new Point3f(coordsArray[i].x, coordsArray[i].y,coordsArray[i].z + depthShift);	
				
				coords[counter++] = point;
			}
			coords[counter++] =coords[j*(coordsArray.length*2+1)];
			for(int i=0;i<coordsArray.length;i++){
				coordsArray[i].z= coordsArray[i].z+depthShift;
			}
		}
		coords[counter++]=coords[(numLayers-1)*(coordsArray.length*2+1)+1];
		TriangleStripArray qa = null;
		int flags = GeometryArray.COORDINATES;
		qa = new TriangleStripArray(coords.length, flags,
				new int[] { coords.length });
		qa.setCoordinates(0, coords);
		super.setGeometry(qa);
	}

}

It takes arguments :

  1. Point3f[] coordsArray :vertices of convex polygon in XY Plane
    ex: To draw a extruded pentagon Point a=(0,0,0),
    Point b=(3,0,0),
    Point c=(4,2,0),
    Point a=(0,4,0)
  2. float length :length in Z axis upto which this pentagon should be extruded.

Variable numlength is just variable to specify in how many layers this pentagon should be extruded.

Can anyone give me link to basic documentation about Splines ,Nerbs etc and how to use them …
and code sample implementing them for creating geomerty willl be great.
I am totally new to these concepts …
I tried myself on net but was not able to find basic working examples only theoritical discussions.thanks for the help

Hi here is an idea how to do a NURB Spline with JGeom


private NurbsCurve nc;

// Create a Curve by defining some control points in space

CurveCreator cc = new CurveCreator(3);
cc.addControlPoint(new Point3f(0,0,0));
cc.addControlPoint(new Point3f(1,2,0));
cc.addControlPoint(new Point3f(2,0,0));
cc.addControlPoint(new Point3f(3,3,0));
		
nc = cc.getActual();


In order to draw your curve you need to extract some discrete information that you can use. Most of the time it will be points in space, same concept applies for NURBS surfaces you just have to be much smarter about selecting points on the surface. In this case we will go along the curve function (NURBS is parametrized from 0 to 1 so if you do a point on curve with 0.5 it will give you a point in space that cuts the curve in half (length wise).


for(float i = 0f; i < 1; i = i + lineQuality)
{
   Point3f currPt = nc.pointOnCurve(i);
}

If you put these points into array and then if you connect them with straight lines you will end up with an approximation of the curve (NURBS in this case) if you do a more detailed curve sampling you will end up with smoother representation.

Now if you want to do your own implementation of curves of any sort you can find a lot of information on the following site: http://www.realtimerendering.com/ under curves and surfaces section there is a bunch of links to different concepts, there must be some coding examples in there.

Hope that this helps a bit