Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/LODInfo.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/LODInfo.h	(revision 2839)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/LODInfo.h	(revision 2844)
@@ -10,7 +10,11 @@
 /** Class representing information about an LOD level.
 */
-struct LODInfo
+struct LODLevel
 {
 public:
+	
+	LODLevel(float squaredDist): mSquaredDistance(squaredDist) {}
+
+
 	/// distance of this LOD level
 	float mSquaredDistance;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h	(revision 2842)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h	(revision 2844)
@@ -18,4 +18,5 @@
 class RenderState;
 class Transform3;
+class Camera;
 
 
@@ -49,7 +50,4 @@
 	*/
 	void SetTransform(Transform3 *trafo);
-	/** Returns the transformed bounding box.
-	*/
-	//AxisAlignedBox3 GetBoundingBox() const;
 	/** set frame where we last rendered this node
 	*/
@@ -61,21 +59,48 @@
 	*/
 	inline Transform3 *GetTransform() const  { return mTransform; }
+	/** Counts number of triangles in this entity using the specified lod level
+		with 0 being the highest or the current lod level (if the argument is -1).
+	*/
+	int CountNumTriangles(int lodLevel = 0);
+	/** Returns the bounding box.
+	*/
+	AxisAlignedBox3 GetBoundingBox() const;
+	/** Returns the transformed bounding box.
+	*/
+	AxisAlignedBox3 GetTransformedBoundingBox() const;
+	
 
-	void GetCurrentLODLevel(ShapeContainer &shapes);
 
-	int CountNumTriangles();
+	////////////////
 
+	/** Internally updates current lod level.
+	*/
+	void UpdateLODs(Camera *cam);
+	/** Returns shapes of specified lod level
+	*/
+	void GetLODLevel(int level, ShapeContainer::iterator &start, ShapeContainer::iterator &end);
+	/** Returns shapes of current lod level
+	*/
+	void GetCurrentLODLevel(ShapeContainer::iterator &start, ShapeContainer::iterator &end);
+	/** Adds a new lod level.
+	*/
+	void AddLODLevel(LODLevel *lod) { mLODLevels.push_back(lod); }
+	/** Returns numbers of lod levels.
+	*/
+	int GetNumLODLevels() const { return (int)mLODLevels.size(); }
 
 protected:
 
-
+	AxisAlignedBox3 mBox;
 	/// transform matrix 
 	Transform3 *mTransform;
 	/// Stores information about the LOD levels
-	LODInfoContainer mLODInfos;
+	LODLevelContainer mLODLevels;
 	/// the renderable shapes
 	ShapeContainer mShapes;
 	/// when this entity was last rendered
 	int mLastRendered;
+
+	int mCurrentLODLevel;
 };
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.h	(revision 2822)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.h	(revision 2844)
@@ -64,5 +64,9 @@
 	
 	inline void SetAlphaTestEnabled(bool alpha) { mAlphaTestEnabled = alpha; }
+	inline void SetCullFaceEnabled(bool cull) { mCullFaceEnabled = cull; }
+
 	inline bool IsAlphaTestEnabled() const { return mAlphaTestEnabled; } 
+	inline bool IsCullFaceEnabled() const { return mCullFaceEnabled; } 
+
 	/** Renders this material.
 	*/
@@ -88,4 +92,5 @@
 
 	bool mAlphaTestEnabled;
+	bool mCullFaceEnabled;
 	/// the assciated texture
 	Texture *mTexture;
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp	(revision 2842)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp	(revision 2844)
@@ -109,4 +109,5 @@
 		{
 			SceneEntity *ent = entities[i];
+			ent->UpdateLODs(mCamera);
 			
 			mStats.mNumRenderedTriangles += ent->CountNumTriangles();
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Vector3.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Vector3.h	(revision 2782)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Vector3.h	(revision 2844)
@@ -314,5 +314,5 @@
 inline float SqrMagnitude(const Vector3 &v) 
 {
-  return v.x * v.x + v.y * v.y + v.z * v.z;
+	return v.x * v.x + v.y * v.y + v.z * v.z;
 }
 
@@ -320,5 +320,6 @@
 inline float Distance(const Vector3 &v1, const Vector3 &v2)
 {
-  return sqrtf(sqrt(v1.x - v2.x) + sqrt(v1.y - v2.y) + sqrt(v1.z - v2.z));
+	//return sqrtf(sqrt(v1.x - v2.x) + sqrt(v1.y - v2.y) + sqrt(v1.z - v2.z));
+	return Magnitude(v1 - v2);
 }
 
@@ -326,5 +327,6 @@
 inline float SqrDistance(const Vector3 &v1, const Vector3 &v2)
 {
-  return sqrt(v1.x - v2.x) + sqrt(v1.y - v2.y) + sqrt(v1.z - v2.z);
+	//return sqrt(v1.x - v2.x) + sqrt(v1.y - v2.y) + sqrt(v1.z - v2.z);
+	return SqrMagnitude(v1 - v2);
 }
 
@@ -332,5 +334,5 @@
 inline Vector3 Normalize(const Vector3 &A)
 {
-  return A * (1.0f / Magnitude(A));
+	return A * (1.0f / Magnitude(A));
 }
 
@@ -338,5 +340,5 @@
 inline float DotProd(const Vector3 &A, const Vector3 &B)
 {
-  return A.x * B.x + A.y * B.y + A.z * B.z;
+	return A.x * B.x + A.y * B.y + A.z * B.z;
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp	(revision 2842)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp	(revision 2844)
@@ -55,10 +55,10 @@
 AxisAlignedBox3 Shape::GetTransformedBoundingBox() const
 {
-	AxisAlignedBox3 box = mGeometry->GetBoundingBox();
 	Matrix4x4 *mat = mParent->GetTransform()->GetMatrix();
 
-	if (mat) Transform(box, *mat);
+	if (!mat)
+		return mGeometry->GetBoundingBox();
 
-	return box;
+	return Transform(mGeometry->GetBoundingBox(), *mat);
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 2825)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 2844)
@@ -18,4 +18,5 @@
 RenderState::RenderState():
 mAlphaTestEnabled(false), 
+mCullFaceEnabled(true), 
 mTexturesEnabled(false), 
 mMode(RENDER),
@@ -51,5 +52,5 @@
 		glDepthMask(GL_FALSE);
 
-		SetState(false, false);
+		SetState(false, false, false);
 	}
 	else // mode returns to render
@@ -77,6 +78,17 @@
 
 	
-void RenderState::SetState(bool texturing, bool alphaTest)
+void RenderState::SetState(bool texturing, bool alphaTest, bool cullFace)
 {
+	if (mCullFaceEnabled && !cullFace) 
+	{
+		mCullFaceEnabled = false;
+		glDisable(GL_CULL_FACE);
+	}
+	else if (!mCullFaceEnabled && cullFace)
+	{
+		mCullFaceEnabled = true;
+		glEnable(GL_CULL_FACE);
+	}
+
 	if (mAlphaTestEnabled && !alphaTest) 
 	{
@@ -122,5 +134,5 @@
 	mCurrentVboId = -1;
 
-	SetState(false, false);
+	SetState(false, false, false);
 	SetState(RENDER);
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp	(revision 2842)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp	(revision 2844)
@@ -10,4 +10,5 @@
 #include "Transform3.h"
 #include "Shape.h"
+#include "LODInfo.h"
 
 
@@ -33,12 +34,4 @@
 SceneEntity *ResourceManager::LoadSceneEntity(igzstream &str)
 {	
-	// shape
-	int shapeId;
-	str.read(reinterpret_cast<char *>(&shapeId), sizeof(int));
-
-	Geometry *geom = mGeometryTable[shapeId];
-	Material *mat = mMaterialTable[shapeId];
-
-
 	bool hasTrafo;
 	str.read(reinterpret_cast<char *>(&hasTrafo), sizeof(bool));
@@ -60,13 +53,49 @@
 	Transform3 *trafo = new Transform3(m);
 	mTrafos.push_back(trafo);
-	
-	// use instancing
+
 	sceneGeom = new SceneEntity(trafo);
 
-	// create shape
-	Shape *shape = new Shape(geom, mat, sceneGeom);
-	mShapes.push_back(shape);
-
-	sceneGeom->AddShape(shape);
+	///////////////
+	//-- load lod levels
+
+	int numLODs;
+	str.read(reinterpret_cast<char *>(&numLODs), sizeof(int));
+
+	//if (numLODs > 1) cout << "numlods: " << numLODs << endl;
+	for (int i = 0; i < numLODs; ++ i)
+	{
+		float distance;
+		str.read(reinterpret_cast<char *>(&distance), sizeof(float));
+
+		int numShapes;
+		str.read(reinterpret_cast<char *>(&numShapes), sizeof(int));
+
+		//if (numLODs > 1) cout << "dist: " << distance << " shapes: " << numShapes;
+
+		LODLevel *lodLevel = new LODLevel(distance);
+
+		for (int j = 0; j < numShapes; ++ j)
+		{
+			int shapeId;
+			str.read(reinterpret_cast<char *>(&shapeId), sizeof(int));
+
+			//if (numLODs > 1) cout << " id " << shapeId;
+			
+			Geometry *geom = mGeometryTable[shapeId];
+			Material *mat = mMaterialTable[shapeId];
+
+			// create shape
+			Shape *shape = new Shape(geom, mat, sceneGeom);
+			
+			mShapes.push_back(shape);
+
+			sceneGeom->AddShape(shape);
+			lodLevel->mShapes.push_back(shape);
+		}
+
+		//if (numLODs > 1) cout << endl;
+
+		sceneGeom->AddLODLevel(lodLevel);
+	}
 
 	return sceneGeom;
@@ -90,5 +119,4 @@
 		str.read(texname, sizeof(char) * texnameSize);
 
-		//cout << "loading texture " << texname << " with len " << texnameSize << " id: " << id << endl;
 		Texture *tex = new Texture(model_path + texname);
 
@@ -135,4 +163,6 @@
 	
 	str.read(reinterpret_cast<char *>(&mat->mAlphaTestEnabled), sizeof(bool));
+
+	//str.read(reinterpret_cast<char *>(&mat->mCullFaceEnabled), sizeof(bool));
 
 	// material
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp	(revision 2842)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp	(revision 2844)
@@ -15,5 +15,5 @@
 
 
-inline static bool CompDist2(RenderQueueBucket *b1, RenderQueueBucket *b2)
+inline static bool CompDist(RenderQueueBucket *b1, RenderQueueBucket *b2)
 {
 	return (b1->mMinDistance < b2->mMinDistance);
@@ -26,5 +26,5 @@
 mMinSizeForSorting(3),
 mCamera(NULL),
-mSize(0)
+mNumEntries(0)
 {
 }
@@ -35,5 +35,5 @@
 mMinSizeForSorting(3),
 mCamera(cam),
-mSize(0)
+mNumEntries(0)
 {
 }
@@ -58,4 +58,7 @@
 		return false;
 
+	if (mat->IsCullFaceEnabled() != mBuckets[idx]->mAlphaTestEnabled)
+		return false;
+
 	const bool hasTexture = (mat->GetTexture() != NULL);
 
@@ -78,12 +81,9 @@
 void RenderQueue::Enqueue(SceneEntity *entity)
 {
-	static ShapeContainer shapes;
-	shapes.clear();
-
-	entity->GetCurrentLODLevel(shapes);
-
-	ShapeContainer::const_iterator sit, sit_end = shapes.end();
-
-	for (sit = shapes.begin(); sit != sit_end; ++ sit)
+	ShapeContainer::iterator sit, sit_end;
+
+	entity->GetCurrentLODLevel(sit, sit_end);
+
+	for (; sit != sit_end; ++ sit)
 	{
 		Enqueue(*sit);
@@ -95,5 +95,5 @@
 {
 	RenderQueueBucket *bucket;
-	++ mSize;
+	++ mNumEntries;
 	
 	if (shape->mRenderQueueBucket)
@@ -117,8 +117,10 @@
 		{
 			RenderQueueBucket *bucket = new RenderQueueBucket();
+			bucket->mMinDistance = -1;
 
 			Material *mat = shape->GetMaterial();
 
 			bucket->mAlphaTestEnabled = mat->IsAlphaTestEnabled();
+			bucket->mCullFaceEnabled = mat->IsCullFaceEnabled();
 
 			const bool hasTexture = (mat->GetTexture() != NULL);
@@ -131,10 +133,4 @@
 			mBuckets.push_back(bucket);
 
-			// assume that the incoming nodes are ordered by distance => set min dist
-			// on first incoming node
-			Vector3 v = shape->GetTransformedBoundingBox().Center() - mCamera->GetPosition();
-			const float dist = SqrMagnitude(v);
-			mBuckets[i]->mMinDistance = dist;
-
 			//cout << "num buckets: " << (int)mBuckets.size() << endl;
 		}
@@ -144,4 +140,14 @@
 	}
 
+	if (bucket->mMinDistance < -0.5f)
+	{
+		// assume that the incoming nodes are ordered by distance 
+		// => set min dist on first incoming node
+		const Vector3 v = shape->GetTransformedBoundingBox().Center() - mCamera->GetPosition();
+		
+		const float dist = SqrMagnitude(v);
+		bucket->mMinDistance = dist;
+	}
+
 	bucket->mShapes.push_back(shape);
 }
@@ -151,7 +157,10 @@
 {
 	for (size_t i = 0; i < mBuckets.size(); ++ i)
+	{
+		mBuckets[i]->mMinDistance = -1;
 		mBuckets[i]->mShapes.clear();
-
-	mSize = 0;
+	}
+
+	mNumEntries = 0;
 }
 
@@ -210,5 +219,5 @@
 {
 	// sort buckets itself
-	sort(mBuckets.begin(), mBuckets.end(), CompDist2);
+	sort(mBuckets.begin(), mBuckets.end(), CompDist);
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h	(revision 2825)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h	(revision 2844)
@@ -44,5 +44,5 @@
 	/** Sets the current render state.
 	*/
-	void SetState(bool texturing, bool alphaTest);
+	void SetState(bool texturing, bool alphaTest, bool cullFace);
 	/** Returns wether we are in query or render mode
 	*/
@@ -74,4 +74,5 @@
 
 	bool mAlphaTestEnabled;
+	bool mCullFaceEnabled;
 	bool mTexturesEnabled;
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.h	(revision 2842)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.h	(revision 2844)
@@ -34,4 +34,5 @@
 	*/
 	bool Load(const std::string &filename, SceneEntityContainer &geometry);
+	SceneEntityContainer mSceneEntities;
 
 protected:
@@ -56,5 +57,4 @@
 	std::vector<Transform3 *> mTrafos;
 	
-	SceneEntityContainer mSceneEntities;
 	ShapeContainer mShapes;
 };
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h	(revision 2842)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h	(revision 2844)
@@ -25,4 +25,5 @@
 	bool mHasTexture;
 	bool mAlphaTestEnabled;
+	bool mCullFaceEnabled;
 
 	/// minimal distance to the camera
@@ -60,7 +61,7 @@
 	*/
 	void SetCamera(Camera *cam);
-	/** Returns the number entities currently in the queue.
+	/** Returns the number of entries currently in the queue.
 	*/
-	inline int GetSize() const { return (int)mSize; }
+	inline int GetSize() const { return (int)mNumEntries; }
 	/** Renders and clears the queue.
 	*/
@@ -95,5 +96,5 @@
 	std::vector<RenderQueueBucket *> mBuckets;
 
-	int mSize;
+	int mNumEntries;
 };
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp	(revision 2842)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp	(revision 2844)
@@ -1,8 +1,11 @@
 #include "SceneEntity.h"
-#include "glInterface.h"
 #include "Geometry.h"
 #include "Material.h"
 #include "RenderState.h"
 #include "Shape.h"
+#include "Transform3.h"
+#include "Camera.h"
+
+#include "glInterface.h"
 #include <Cg/cg.h>
 #include <Cg/cgGL.h>
@@ -16,6 +19,8 @@
 
 
-SceneEntity::SceneEntity(Transform3 *trafo): mTransform(trafo)
+SceneEntity::SceneEntity(Transform3 *trafo): 
+mTransform(trafo), mCurrentLODLevel(0)
 {
+	mBox.Initialize();
 }
 
@@ -26,35 +31,46 @@
 
 
-void SceneEntity::GetCurrentLODLevel(ShapeContainer &shapes)
+void SceneEntity::UpdateLODs(Camera *cam)
 {
-	ShapeContainer::const_iterator sit, sit_end;
+	const Vector3 pos = GetTransformedBoundingBox().Center();
 
-	if (mLODInfos.empty())
+	const float distance = SqrDistance(pos, cam->GetPosition());
+
+	mCurrentLODLevel = 0;
+
+	int l = (int)mLODLevels.size();
+
+	for (int i = 0; i < l; ++ i)
 	{
-		sit = mShapes.begin(); sit_end = mShapes.end();
+		LODLevel *lod = mLODLevels[i];
+
+		if (lod->mSquaredDistance > distance)
+			break;
+
+		mCurrentLODLevel = i;
 	}
 
-	float mDistance = 0.0f;
+	/*if (mLODLevels.size() > 1)
+	{
+		Debug << "dist: " << distance << " numshapes: " << mLODLevels[mCurrentLODLevel]->mShapes.size() << " lod: " << mCurrentLODLevel << " of " << mLODLevels.size() << endl;
+	}*/
+}
 
-	int i = 0;
+void SceneEntity::GetCurrentLODLevel(ShapeContainer::iterator &start, 
+									 ShapeContainer::iterator &end)
+{
+	start = mLODLevels[mCurrentLODLevel]->mShapes.begin(); 
+	end = mLODLevels[mCurrentLODLevel]->mShapes.end();
+}
 
-	LODInfoContainer::const_iterator lid, lid_end = mLODInfos.end();
 
-	for (lid = mLODInfos.begin(); lid != lid_end; ++ lid)
-	{
-		LODInfo *lodInfo = *lid;
+void SceneEntity::GetLODLevel(int level, 
+							  ShapeContainer::iterator &start, 
+							  ShapeContainer::iterator &end)
+{
+	LODLevel *lod = mLODLevels[level];
 
-		if (lodInfo->mSquaredDistance > mDistance)
-		{
-			sit = lodInfo->mShapes.begin(); 
-			sit_end = lodInfo->mShapes.end();
-			break;
-		}
-	}
-
-	for (; sit != sit_end; ++ sit)
-	{
-		shapes.push_back(*sit);
-	}
+	start = lod->mShapes.begin();
+	end = lod->mShapes.end();
 }
 
@@ -62,15 +78,17 @@
 void SceneEntity::Render(RenderState *state)
 {
-	//if (mMaterial) mMaterial->Render(state);
-	float mDistance = 0.0f;
+	ShapeContainer::iterator sit, sit_end;
 
-	static ShapeContainer shapes;
-	shapes.clear();
+	/*if (mShapes.size() > 8)
+	{
+		sit = mShapes.begin() + 6;
+		sit_end = mShapes.begin() + 6;
+	}
+	else*/
+		GetCurrentLODLevel(sit, sit_end);
 
-	GetCurrentLODLevel(shapes);
-
-	ShapeContainer::const_iterator sit, sit_end = shapes.end();
-
-	for (sit = shapes.begin(); sit != sit_end; ++ sit)
+	//if (mShapes.size() > 1)
+		//mShapes[0]->Render(state);
+	for (; sit != sit_end; ++ sit)
 	{
 		(*sit)->Render(state);
@@ -82,4 +100,5 @@
 {
 	mShapes.push_back(shape);
+	mBox.Include(shape->GetBoundingBox());
 }
 
@@ -103,15 +122,21 @@
 
 
-int SceneEntity::CountNumTriangles()
+int SceneEntity::CountNumTriangles(int lodLevel)
 {
 	int numTriangles = 0;
-	static ShapeContainer shapes;
-	shapes.clear();
+	
+	ShapeContainer::iterator sit, sit_end;
 
-	GetCurrentLODLevel(shapes);
+	if (lodLevel == -1)
+	{
+		GetCurrentLODLevel(sit, sit_end);
+	}
+	else
+	{
+		GetLODLevel(lodLevel, sit, sit_end);
+	}
 
-	ShapeContainer::const_iterator sit, sit_end = shapes.end();
 
-	for (sit = shapes.begin(); sit != sit_end; ++ sit)
+	for (; sit != sit_end; ++ sit)
 	{
 		numTriangles += (*sit)->GetGeometry()->GetNumTriangles();
@@ -122,3 +147,19 @@
 
 
+AxisAlignedBox3 SceneEntity::GetTransformedBoundingBox() const
+{
+	Matrix4x4 *mat = mTransform->GetMatrix();
+
+	if (!mat)
+		return mBox;
+
+	return Transform(mBox, *mat);
 }
+
+
+AxisAlignedBox3 SceneEntity::GetBoundingBox() const
+{
+	return mBox;
+}
+
+}
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp	(revision 2825)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp	(revision 2844)
@@ -25,4 +25,5 @@
 	mTexture = NULL;
 	mAlphaTestEnabled = false;
+	mCullFaceEnabled = true;
 
 	mAmbientColor = RgbaColor(0.2f, 0.2f, 0.2f, 1.0f);
@@ -62,5 +63,5 @@
 void Material::Render(RenderState *state)
 {
-	state->SetState(mTexture != NULL, mAlphaTestEnabled);
+	state->SetState(mTexture != NULL, mAlphaTestEnabled, mCullFaceEnabled);
 
 	if (mTexture)
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2843)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp	(revision 2844)
@@ -854,5 +854,5 @@
 	//glEnable(GL_ALPHA_TEST);
 	glDisable(GL_ALPHA_TEST);
-	glAlphaFunc(GL_GEQUAL, 0.5f);
+	glAlphaFunc(GL_GEQUAL, 0.8f);
 
 	glFrontFace(GL_CCW);
@@ -1195,4 +1195,18 @@
 
 
+	/*state.Reset();
+	state.SetState(RenderState::RENDER);
+	
+	glEnableClientState(GL_VERTEX_ARRAY);
+	glEnableClientState(GL_NORMAL_ARRAY);
+
+	for (int i = 0; i < loader->mSceneEntities.size(); ++ i)
+	{
+		SceneEntity *ent = loader->mSceneEntities[i];
+
+		ent->UpdateLODs(camera);
+		ent->Render(&state);
+	}*/
+
 	// actually render the scene geometry using one of the specified algorithms
 	traverser->RenderScene();
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp	(revision 2838)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp	(revision 2844)
@@ -54,7 +54,8 @@
 	mViewOrientation = mBaseOrientation;
 
-	cout << "right: " << right << endl;
+	/*cout << "right: " << right << endl;
 	cout << "up:    " << up << endl;
 	cout << "dir:   " << direction << endl;
+	*/
 }
 
@@ -248,5 +249,4 @@
 	}
 
-	cout<<"here2 " << DotProd(h1, Vector3(0, 1, 0)) << " " << mPitch << endl;
 	CalculateFromPitchAndYaw();
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/common.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/common.h	(revision 2839)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/common.h	(revision 2844)
@@ -497,16 +497,16 @@
 typedef std::vector<Shape *> ShapeContainer;
 
-struct LODInfo;
-typedef std::vector<LODInfo *> LODInfoContainer;
-
-}
-
-#endif
-
-
-
-
-
-
-
-
+struct LODLevel;
+typedef std::vector<LODLevel *> LODLevelContainer;
+
+}
+
+#endif
+
+
+
+
+
+
+
+
