[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef3d-commits] r522 - branches/better_lod/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/lwjgl branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/multi branches/better_lod/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d branches/better_lod/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/doc-files branches/better_lod/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl trunk/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry

Author: kduske
Date: 2010-08-20 10:05:20 -0400 (Fri, 20 Aug 2010)
New Revision: 522

Added:
   branches/better_lod/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/doc-files/
   branches/better_lod/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/doc-files/ILodHelper-1.jpg
Modified:
   branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/lwjgl/LwjglTextureText.java
   branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/lwjgl/LwjglVectorFont.java
   branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/lwjgl/LwjglVectorText.java
   branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/multi/MultiText.java
   branches/better_lod/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/ILodHelper.java
   branches/better_lod/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/TextRenderImage.java
   branches/better_lod/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/CameraLodHelper.java
   trunk/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/Math3DVector3f.java
Log:
Implemented a more sensible LOD curve (non-linear in distance to camera) and used that for font LOD. Blending is still not supported.

Modified: branches/better_lod/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/CameraLodHelper.java
===================================================================
--- branches/better_lod/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/CameraLodHelper.java	2010-08-19 15:04:33 UTC (rev 521)
+++ branches/better_lod/org.eclipse.draw3d/src/java/org/eclipse/draw3d/camera/CameraLodHelper.java	2010-08-20 14:05:20 UTC (rev 522)
@@ -32,6 +32,8 @@
 	private static final Logger log =
 		Logger.getLogger(CameraLodHelper.class.getName());
 
+	private static final float FACTOR = 100f;
+
 	private ICamera m_camera;
 
 	/**
@@ -46,44 +48,34 @@
 	/**
 	 * {@inheritDoc}
 	 * 
-	 * @see org.eclipse.draw3d.graphics3d.ILodHelper#getLODFactor(org.eclipse.draw3d.geometry.IVector3f)
+	 * @see org.eclipse.draw3d.graphics3d.ILodHelper#getLinearLOD(org.eclipse.draw3d.geometry.IVector3f)
 	 */
-	public float getLODFactor(IVector3f i_position) {
-		Vector3f cPos = Draw3DCache.getVector3f();
-		Vector3f v = Draw3DCache.getVector3f();
+	public float getLinearLOD(IVector3f i_point) {
+		Vector3f c = Draw3DCache.getVector3f();
 		try {
-			m_camera.getPosition(cPos);
-			Math3D.sub(i_position, cPos, v);
-			return v.length() / m_camera.getFar();
+			m_camera.getPosition(c);
+			float d = Math3D.distanceSquared(c, i_point);
+			float f = m_camera.getFar();
+			return 1f - d / (f * f);
 		} finally {
-			Draw3DCache.returnVector3f(cPos, v);
+			Draw3DCache.returnVector3f(c);
 		}
 	}
 
 	/**
 	 * {@inheritDoc}
 	 * 
-	 * @see org.eclipse.draw3d.graphics3d.ILodHelper#getLODFactor(org.eclipse.draw3d.geometry.IVector3f,
-	 *      org.eclipse.draw3d.geometry.IVector3f)
+	 * @see org.eclipse.draw3d.graphics3d.ILodHelper#getQuotientLOD(IVector3f)
 	 */
-	public float getLODFactor(IVector3f i_position, IVector3f i_normal) {
-		Vector3f cPos = Draw3DCache.getVector3f();
-		Vector3f v = Draw3DCache.getVector3f();
-		Vector3f vDir = Draw3DCache.getVector3f();
+	public float getQuotientLOD(IVector3f i_point) {
+		Vector3f c = Draw3DCache.getVector3f();
 		try {
-			m_camera.getViewDirection(vDir);
-
-			float cosa = Math3D.dot(vDir, i_normal);
-			if (cosa <= 0)
-				return 1;
-
-			m_camera.getPosition(cPos);
-			Math3D.sub(i_position, cPos, v);
-			float l = v.length() / m_camera.getFar();
-
-			return l / cosa;
+			m_camera.getPosition(c);
+			float d = Math3D.distanceSquared(c, i_point);
+			float m = m_camera.getFar() * m_camera.getFar();
+			return (m - d) / (FACTOR * d + m);
 		} finally {
-			Draw3DCache.returnVector3f(cPos, v, vDir);
+			Draw3DCache.returnVector3f(c);
 		}
 	}
 }

Modified: branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/lwjgl/LwjglTextureText.java
===================================================================
--- branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/lwjgl/LwjglTextureText.java	2010-08-19 15:04:33 UTC (rev 521)
+++ branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/lwjgl/LwjglTextureText.java	2010-08-20 14:05:20 UTC (rev 522)
@@ -137,10 +137,8 @@
 			glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, m_width,
 				m_height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, buf);
 
-			// GLU.gluBuild2DMipmaps(m_textureId, 2, m_width,
-			// m_height,
-			// GL_LUMINANCE_ALPHA, GL11.GL_UNSIGNED_BYTE,
-			// buffer);
+			// GLU.gluBuild2DMipmaps(m_textureId, 2, m_width, m_height,
+			// GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, buffer);
 		} finally {
 			Draw3DCache.returnIntBuffer(idBuf);
 			glPopAttrib();
@@ -161,16 +159,27 @@
 		else if (m_state == State.UNINITIALIZED)
 			initialize();
 
-		glBindTexture(GL_TEXTURE_2D, m_textureId);
-		glBegin(GL_QUADS);
-		glTexCoord2f(0, 0);
-		glVertex2f(0, m_height);
-		glTexCoord2f(1, 0);
-		glVertex2f(m_width, m_height);
-		glTexCoord2f(1, 1);
-		glVertex2f(m_width, 0);
-		glTexCoord2f(0, 1);
-		glVertex2f(0, 0);
-		glEnd();
+		glPushAttrib(GL_TEXTURE_BIT | GL_COLOR_BUFFER_BIT);
+		try {
+			glBindTexture(GL_TEXTURE_2D, m_textureId);
+			glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
+			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+
+			glEnable(GL_BLEND);
+			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+			glBegin(GL_QUADS);
+			glTexCoord2f(0, 0);
+			glVertex2f(0, m_height);
+			glTexCoord2f(1, 0);
+			glVertex2f(m_width, m_height);
+			glTexCoord2f(1, 1);
+			glVertex2f(m_width, 0);
+			glTexCoord2f(0, 1);
+			glVertex2f(0, 0);
+			glEnd();
+		} finally {
+			glPopAttrib();
+		}
 	}
 }

Modified: branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/lwjgl/LwjglVectorFont.java
===================================================================
--- branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/lwjgl/LwjglVectorFont.java	2010-08-19 15:04:33 UTC (rev 521)
+++ branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/lwjgl/LwjglVectorFont.java	2010-08-20 14:05:20 UTC (rev 522)
@@ -183,7 +183,7 @@
 		AffineTransform at = new AffineTransform();
 		at.translate(0, bounds.height - lineMetrics.getDescent() - 0.5f);
 
-		double flatness = 1.9d * m_precision + 0.1d;
+		double flatness = 1.9d * (1 - m_precision) + 0.1d;
 		VectorChar[] stringChars = new VectorChar[glyphs.getNumGlyphs()];
 
 		for (int i = 0; i < glyphs.getNumGlyphs(); i++)

Modified: branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/lwjgl/LwjglVectorText.java
===================================================================
--- branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/lwjgl/LwjglVectorText.java	2010-08-19 15:04:33 UTC (rev 521)
+++ branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/lwjgl/LwjglVectorText.java	2010-08-20 14:05:20 UTC (rev 522)
@@ -40,20 +40,22 @@
 
 	private float m_height;
 
+	private IntBuffer m_setCnt;
+
+	private IntBuffer m_setIdx;
+
 	private IntBuffer m_stripCnt;
 
 	private IntBuffer m_stripIdx;
 
-	private IntBuffer m_triCnt;
-
-	private IntBuffer m_triIdx;
-
 	private float m_width;
 
 	/**
 	 * Creates a new instance that renders the given characters.
 	 * 
 	 * @param i_chars the characters to render
+	 * @param i_width the width of the text block
+	 * @param i_height the height of the text block
 	 * @throws NullPointerException if the given character array is
 	 *             <code>null</code>
 	 */
@@ -67,12 +69,12 @@
 		// create vertex buffer
 		int numFans = 0;
 		int numStrips = 0;
-		int numTris = 0;
+		int numSets = 0;
 		int numVertices = 0;
 		for (int i = 0; i < i_chars.length; i++) {
 			numFans += i_chars[i].getNumFans();
 			numStrips += i_chars[i].getNumStrips();
-			numTris += i_chars[i].getNumSets();
+			numSets += i_chars[i].getNumSets();
 			numVertices += i_chars[i].getNumVertices();
 		}
 
@@ -84,9 +86,9 @@
 			m_stripIdx = BufferUtils.createIntBuffer(numStrips);
 			m_stripCnt = BufferUtils.createIntBuffer(numStrips);
 		}
-		if (numTris > 0) {
-			m_triIdx = BufferUtils.createIntBuffer(numTris);
-			m_triCnt = BufferUtils.createIntBuffer(numTris);
+		if (numSets > 0) {
+			m_setIdx = BufferUtils.createIntBuffer(numSets);
+			m_setCnt = BufferUtils.createIntBuffer(numSets);
 		}
 
 		int i = 0;
@@ -94,9 +96,24 @@
 		for (int j = 0; j < i_chars.length; j++) {
 			i = i_chars[j].compileFans(buf, i, m_fanIdx, m_fanCnt);
 			i = i_chars[j].compileStrips(buf, i, m_stripIdx, m_stripCnt);
-			i = i_chars[j].compileSets(buf, i, m_triIdx, m_triCnt);
+			i = i_chars[j].compileSets(buf, i, m_setIdx, m_setCnt);
 		}
 
+		if (numFans > 0) {
+			m_fanIdx.rewind();
+			m_fanCnt.rewind();
+		}
+
+		if (numStrips > 0) {
+			m_stripIdx.rewind();
+			m_stripCnt.rewind();
+		}
+
+		if (numSets > 0) {
+			m_setIdx.rewind();
+			m_setCnt.rewind();
+		}
+
 		// upload vertex buffer
 		IntBuffer idBuffer = Draw3DCache.getIntBuffer(1);
 		try {
@@ -164,22 +181,6 @@
 		if (m_disposed)
 			throw new IllegalStateException(this + " is disposed");
 
-		// TODO: move this to initialization if possible
-		if (m_fanIdx != null) {
-			m_fanIdx.rewind();
-			m_fanCnt.rewind();
-		}
-
-		if (m_stripIdx != null) {
-			m_stripIdx.rewind();
-			m_stripCnt.rewind();
-		}
-
-		if (m_triIdx != null) {
-			m_triIdx.rewind();
-			m_triCnt.rewind();
-		}
-
 		glBindBuffer(GL_ARRAY_BUFFER, m_bufferId);
 		glEnableClientState(GL_VERTEX_ARRAY);
 		glVertexPointer(2, GL_FLOAT, 0, 0);
@@ -188,8 +189,8 @@
 				glMultiDrawArrays(GL_TRIANGLE_FAN, m_fanIdx, m_fanCnt);
 			if (m_stripIdx != null)
 				glMultiDrawArrays(GL_TRIANGLE_STRIP, m_stripIdx, m_stripCnt);
-			if (m_triIdx != null)
-				glMultiDrawArrays(GL_TRIANGLES, m_triIdx, m_triCnt);
+			if (m_setIdx != null)
+				glMultiDrawArrays(GL_TRIANGLES, m_setIdx, m_setCnt);
 		} finally {
 			glDisableClientState(GL_VERTEX_ARRAY);
 		}

Modified: branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/multi/MultiText.java
===================================================================
--- branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/multi/MultiText.java	2010-08-19 15:04:33 UTC (rev 521)
+++ branches/better_lod/org.eclipse.draw3d.font/src/org/eclipse/draw3d/font/multi/MultiText.java	2010-08-20 14:05:20 UTC (rev 522)
@@ -34,26 +34,26 @@
 	private static final Logger log =
 		Logger.getLogger(MultiText.class.getName());
 
-	private static final float TEXTURE_FONT_TH = 0.09f;
+	/**
+	 * If the LOD value is smaller than {@link #VECTOR_FONT_TH} and greater or
+	 * equal to this value, texture fonts are used.
+	 */
+	private static final float TEXTURE_FONT_TH = 0.20f;
 
-	private IDraw3DText[] m_cache = new IDraw3DText[11];
+	private static final float VECTOR_FONT_PREC = 1f;
 
+	/**
+	 * If the LOD value is greater or equal to this value, vector fonts are
+	 * used.
+	 */
+	private static final float VECTOR_FONT_TH = 0.87f;
+
 	private boolean m_disposed = false;
 
-	private Flag[] m_fontFlags;
+	private IDraw3DText m_textureText;
 
-	private MultiFontManager m_fontManager;
+	private IDraw3DText m_vectorText;
 
-	private String m_fontName;
-
-	private int m_fontSize;
-
-	private float m_height;
-
-	private String m_string;
-
-	private float m_width;
-
 	/**
 	 * Creates a new instance with the given parameters that renders the given
 	 * string.
@@ -80,18 +80,14 @@
 		if (i_fontSize <= 0)
 			throw new IllegalArgumentException("font size must be positive");
 
-		m_string = i_string;
-		m_fontManager = i_fontManager;
-		m_fontName = i_fontName;
-		m_fontSize = i_fontSize;
-		m_fontFlags = i_fontFlags;
+		IDraw3DFont textureFont =
+			i_fontManager.getTextureFont(i_fontName, i_fontSize, i_fontFlags);
+		m_textureText = textureFont.createText(i_string);
 
-		IDraw3DFont font =
-			m_fontManager.getTextureFont(m_fontName, m_fontSize, m_fontFlags);
-		IDraw3DText text = font.createText(m_string);
-		m_width = text.getWidth();
-		m_height = text.getHeight();
-		text.dispose();
+		IDraw3DFont vectorFont =
+			i_fontManager.getVectorFont(i_fontName, i_fontSize,
+				VECTOR_FONT_PREC, i_fontFlags);
+		m_vectorText = vectorFont.createText(i_string);
 	}
 
 	/**
@@ -103,15 +99,15 @@
 		if (m_disposed)
 			throw new IllegalStateException(this + " is disposed");
 
-		for (IDraw3DText text : m_cache)
-			if (text != null)
-				text.dispose();
+		if (m_textureText != null) {
+			m_textureText.dispose();
+			m_textureText = null;
+		}
 
-		m_cache = null;
-		m_fontFlags = null;
-		m_fontName = null;
-		m_string = null;
-		m_fontManager = null;
+		if (m_vectorText != null) {
+			m_vectorText.dispose();
+			m_vectorText = null;
+		}
 
 		m_disposed = true;
 	}
@@ -122,7 +118,7 @@
 	 * @see org.eclipse.draw3d.font.multi.IDraw3DMultiText#getHeight()
 	 */
 	public float getHeight() {
-		return m_height;
+		return m_textureText.getHeight();
 	}
 
 	/**
@@ -131,13 +127,9 @@
 	 * @see org.eclipse.draw3d.font.multi.IDraw3DMultiText#getWidth()
 	 */
 	public float getWidth() {
-		return m_width;
+		return m_vectorText.getWidth();
 	}
 
-	private int index(float i_scaledLod) {
-		return (int) i_scaledLod * 10;
-	}
-
 	/**
 	 * {@inheritDoc}
 	 * 
@@ -147,30 +139,9 @@
 		if (m_disposed)
 			throw new IllegalStateException(this + " is disposed");
 
-		float sl = scaleLod(i_lod);
-		int i = index(sl);
-
-		IDraw3DText text = m_cache[i];
-		if (text == null) {
-			IDraw3DFont font = selectFont(sl);
-			text = font.createText(m_string);
-			m_cache[i] = text;
-		}
-
-		text.render();
+		if (i_lod >= VECTOR_FONT_TH)
+			m_vectorText.render();
+		else if (i_lod >= TEXTURE_FONT_TH)
+			m_textureText.render();
 	}
-
-	private float scaleLod(float i_lod) {
-		return (float) Math.floor(i_lod * 10) / 10;
-	}
-
-	private IDraw3DFont selectFont(float i_sl) {
-		if (i_sl <= TEXTURE_FONT_TH)
-			return m_fontManager.getTextureFont(m_fontName, m_fontSize,
-				m_fontFlags);
-
-		float p = 1 - (i_sl - TEXTURE_FONT_TH) / (1 - TEXTURE_FONT_TH);
-		return m_fontManager.getVectorFont(m_fontName, m_fontSize, p,
-			m_fontFlags);
-	}
 }

Modified: branches/better_lod/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/ILodHelper.java
===================================================================
--- branches/better_lod/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/ILodHelper.java	2010-08-19 15:04:33 UTC (rev 521)
+++ branches/better_lod/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/ILodHelper.java	2010-08-20 14:05:20 UTC (rev 522)
@@ -13,10 +13,10 @@
 import org.eclipse.draw3d.geometry.IVector3f;
 
 /**
- * Instances of this class calculate an LOD factor (a float between 0 and 1,
- * inclusive) for a given object. This factor can be used as a measure to
- * determine the detail level for that object, where 0 equals full detail and 1
- * equals the least detail.
+ * Instances of this class are used to calculate a LOD value for an object at a
+ * given position. This value is based on the distance between an object and the
+ * camera, but it is not linear. A high LOD value means that the object is close
+ * to the camera and thus should be rendered with a lot of detail.
  * 
  * @author Kristian Duske
  * @version $Revision$
@@ -24,24 +24,31 @@
  */
 public interface ILodHelper {
 	/**
-	 * Returns the LOD factor of a 2D object at the given position with the
-	 * given normal vector.
+	 * Returns an LOD value that is calculated by the following function:
 	 * 
-	 * @param i_position the object's position
-	 * @param i_normal the object's normal vector
-	 * @return a value between 0 and 1, inclusive
-	 * @throws NullPointerException if any of the given arguments is
-	 *             <code>null</code>
-	 */
-	public float getLODFactor(IVector3f i_position, IVector3f i_normal);
-
-	/**
-	 * Returns the LOD factor of an object at the given position.
+	 * <pre>
+	 *           m<sup>2</sup> - d<sup>2</sup>
+	 * f(d) = ------------
+	 *        100 * d<sup>2</sup> + m<sup>2</sup>
+	 * </pre>
 	 * 
-	 * @param i_position the object's position
-	 * @return a value between 0 and 1, inclusive
-	 * @throws NullPointerException if any of the given arguments is
-	 *             <code>null</code>
+	 * where
+	 * <ul>
+	 * <li><b>d</b> is the distance between the given point and the camera</li>
+	 * <li><b>m</b> is the distance after which an object is no longer visible
+	 * at all</li>
+	 * </ul>
+	 * The function has the following invariants:
+	 * <ul>
+	 * <li>f(0) = 1</li>
+	 * <li>f(m) = 0</li>
+	 * <li>f(d) is in [0, 1] for every d >= 0</li>
+	 * </ul>
+	 * The following graphic shows the curve for m = 10000: <br />
+	 * <img src="doc-files/ILodHelper-1.jpg" />
+	 * 
+	 * @param i_point the point
+	 * @return the LOD value
 	 */
-	public float getLODFactor(IVector3f i_position);
+	public float getQuotientLOD(IVector3f i_point);
 }

Added: branches/better_lod/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/doc-files/ILodHelper-1.jpg
===================================================================
(Binary files differ)


Property changes on: branches/better_lod/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/doc-files/ILodHelper-1.jpg
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: branches/better_lod/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/TextRenderImage.java
===================================================================
--- branches/better_lod/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/TextRenderImage.java	2010-08-19 15:04:33 UTC (rev 521)
+++ branches/better_lod/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/TextRenderImage.java	2010-08-20 14:05:20 UTC (rev 522)
@@ -50,21 +50,7 @@
  * @since 29.01.2010
  */
 public class TextRenderImage implements RenderImage {
-	/**
-	 * If distance of text to camera is less this value (but greater
-	 * {@link #LOD_VF}, the text is rendered as bitmap. If distance is greater
-	 * this value, text is not rendered at all.
-	 */
-	private static final float LOD_TF = 0.5f; // 10000f;
 
-	/**
-	 * If distance of text to camera is less this value, the text is rendered
-	 * using vector fonts.
-	 */
-	private static final float LOD_VF = 0.01f; // 1100f;
-
-	private static final float LOD_B = 0.1f;
-
 	@SuppressWarnings("unused")
 	private static final Logger log =
 		Logger.getLogger(TextRenderImage.class.getName());
@@ -158,59 +144,19 @@
 	 *      org.eclipse.draw3d.graphics3d.ILodHelper)
 	 */
 	public void render(Graphics3D i_g3d, ILodHelper i_lodHelper) {
-		float l = i_lodHelper.getLODFactor(m_absPos); // , m_normal);
-		if (l <= LOD_TF) {
-			if (m_transformationBuffer != null) {
-				GL11.glMatrixMode(GL11.GL_MODELVIEW);
-				GL11.glPushMatrix();
-				try {
-					GL11.glMultMatrix(m_transformationBuffer);
-					renderLOD(l);
-				} finally {
-					GL11.glPopMatrix();
-				}
-			} else {
-				renderLOD(l);
+		float l = i_lodHelper.getQuotientLOD(m_absPos); // , m_normal);
+		GL11.glColor4f(m_c[0], m_c[1], m_c[2], m_c[3]);
+		if (m_transformationBuffer != null) {
+			GL11.glMatrixMode(GL11.GL_MODELVIEW);
+			GL11.glPushMatrix();
+			try {
+				GL11.glMultMatrix(m_transformationBuffer);
+				m_text.render(l);
+			} finally {
+				GL11.glPopMatrix();
 			}
+		} else {
+			m_text.render(l);
 		}
 	}
-
-	/**
-	 * @param l normalized distance to camera
-	 */
-	private void renderLOD(float l) {
-
-		GL11.glColor4f(m_c[0], m_c[1], m_c[2], m_c[3]);
-		m_text.render(l);
-		// if (l <= LOD_VF) {
-		// // GL11.glColor4f(m_c[0], m_c[1], m_c[2], m_c[3]);
-		// GL11.glColor4f(1, 0, 0, 1);
-		// m_vectorFont.render(l, m_text);
-		// } else if (l <= LOD_VF + LOD_B) {
-		// float f = (l - LOD_VF) / LOD_B;
-		//
-		// // GL11.glColor4f(m_c[0], m_c[1], m_c[2], f * m_c[3]);
-		// // GL11.glColor4f(0, 1, 0, 1); // f);
-		// // m_textureFont.renderString(m_text, 0, 0, false);
-		//
-		// GL11.glMatrixMode(GL11.GL_MODELVIEW);
-		// GL11.glPushMatrix();
-		// try {
-		// GL11.glTranslatef(0, 0,
-		// Graphics3DLwjgl.OFFSET_2DCONTENT_SURFACE);
-		// // GL11.glColor4f(m_c[0], m_c[1], m_c[2], (1 - f) * m_c[3]);
-		// GL11.glColor4f(1, 0, 0, 1); //1 - f);
-		// m_vectorFont.render(l, m_text);
-		// } finally {
-		// GL11.glPopMatrix();
-		// }
-		// } else if (l <= LOD_TF - LOD_B) {
-		// GL11.glColor4f(0, 1, 0, 1);
-		// m_textureFont.renderString(m_text, 0, 0, false);
-		// } else {
-		// float f = (LOD_TF - l) / LOD_B;
-		// GL11.glColor4f(0, 1, 0, f);
-		// m_textureFont.renderString(m_text, 0, 0, false);
-		// }
-	}
 }

Modified: trunk/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/Math3DVector3f.java
===================================================================
--- trunk/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/Math3DVector3f.java	2010-08-19 15:04:33 UTC (rev 521)
+++ trunk/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/Math3DVector3f.java	2010-08-20 14:05:20 UTC (rev 522)
@@ -114,6 +114,40 @@
 	}
 
 	/**
+	 * Returns the distance between the given points.
+	 * 
+	 * @param i_v1 a vector to the first point
+	 * @param i_v2 a vector to the second point
+	 * @return the distance between the two points
+	 */
+	public static float distance(IVector3f i_v1, IVector3f i_v2) {
+		Vector3f d = Math3DCache.getVector3f();
+		try {
+			sub(i_v1, i_v2, d);
+			return d.length();
+		} finally {
+			Math3DCache.returnVector3f(d);
+		}
+	}
+
+	/**
+	 * Returns the squared distance between the given points.
+	 * 
+	 * @param i_v1 a vector to the first point
+	 * @param i_v2 a vector to the second point
+	 * @return the squared distance between the two points
+	 */
+	public static float distanceSquared(IVector3f i_v1, IVector3f i_v2) {
+		Vector3f d = Math3DCache.getVector3f();
+		try {
+			sub(i_v1, i_v2, d);
+			return d.lengthSquared();
+		} finally {
+			Math3DCache.returnVector3f(d);
+		}
+	}
+
+	/**
 	 * Calculates the dot product (scalar product) of the two vectors.
 	 * 
 	 * @param i_left