|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object glapp.GLLine
public class GLLine
GLLine creates a quad-strip line from a series of points. To use:
draw() { GLLine L = new GLLine(); L.setWidth(20); L.point(0,0); L.point(5,5); L.point(0,10); L.point(5,15); L.close(); // if you want a closed shape L.draw(); }
NOTE: gets ugly when points are very close, or reverse direction sharply. Uses my home-grown trigonometry... probably not the best way to do this, but it works in most cases.
ALSO NOTE: the line will be drawn with the active texture. To draw an untextured line, call activateTexture(0) or disable textures (GL11.glDisable(GL11.GL_TEXTURE_2D) before calling line.draw().
Constructor Summary | |
---|---|
GLLine()
|
|
GLLine(float lineWidth)
|
Method Summary | |
---|---|
void |
clear()
reset the line |
void |
close()
Close the line by adding a line segment that connects the last point to the first. |
void |
draw()
draw the mesh geometry created by rebuild() |
void |
draw3D(float height)
draw the mesh geometry created by rebuild() as a 3D shape (extrude the line shape along the Z axis). |
void |
drawV(GL_Vector v,
float x,
float y)
for debugging |
GL_Vector |
getNormal(GL_Vector a,
GL_Vector b,
float width)
Make an average normal to the two vectors with the right length to make a join for a line |
float |
getNormalLen(GL_Vector v1,
GL_Vector v2,
float width)
Return the length of the normal needed to make a join in a line of the given width. |
int |
getNumPoints()
return number of points in this line |
GL_Vector |
getPoint(int n)
return the given xy point |
float |
getWidth()
return line width |
static GLLine |
makeCircle(float x,
float y,
float radius,
int numSegments,
float linewidth)
return a GLLine shaped into a circle. |
int |
makeDisplayList()
render the line into a display list and return the list ID. |
void |
makeLine()
create the line geometry from point positions |
static GLLine |
makeRectangle(float x,
float y,
float w,
float h,
float linewidth)
return a GLLine shaped into a rectangle. |
void |
makeSegment(GL_Vector p1,
GL_Vector p2,
GL_Vector prevV,
GL_Vector postV)
Draw one segment from a line. |
void |
point(float x,
float y)
Add an xy point to the line. |
void |
rebuild()
regenerate the line geometry from the added points. |
void |
setUVfactor(float tilefactor)
set texture tiling factor. |
void |
setWidth(float w)
set line width |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GLLine()
public GLLine(float lineWidth)
Method Detail |
---|
public void clear()
public void point(float x, float y)
public void close()
public void setWidth(float w)
public float getWidth()
public int getNumPoints()
public GL_Vector getPoint(int n)
public void setUVfactor(float tilefactor)
public void rebuild()
public void makeLine()
public void makeSegment(GL_Vector p1, GL_Vector p2, GL_Vector prevV, GL_Vector postV)
qv4 p2 qv3 +----o----+ -N2 | N2 | | line segment p1-p2 | -N1 | N1 +----o----+ qv1 p1 qv2
p1
- start point of line segmentp2
- end point of line segmentprevV
- direction of previous line segmentpostV
- direction of next line segmentpublic GL_Vector getNormal(GL_Vector a, GL_Vector b, float width)
+ - - - - - - |\ normal | \ | o-----------o line b | | | o line a
a
- b
-
public float getNormalLen(GL_Vector v1, GL_Vector v2, float width)
v1
- v2
- width
-
public void drawV(GL_Vector v, float x, float y)
v
- x
- y
- public void draw()
public void draw3D(float height)
public int makeDisplayList()
public static GLLine makeRectangle(float x, float y, float w, float h, float linewidth)
public static GLLine makeCircle(float x, float y, float radius, int numSegments, float linewidth)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |