Commits

dbacchet committed df8beea

updated logger and started working on geometry prerequisites

  • Participants
  • Parent commits e39ac5a

Comments (0)

Files changed (28)

File temp/test_hordefiles/Horde3D.cpp

 // General functions
 // =================================================================================================
 
-const char *h3dGetMessage( int *level, float *time )
-{
-	static string msgText;
-	static LogMessage msg;
-	
-	if( Modules::log().get_message( msg ) )
-	{
-		if( level != 0x0 ) *level = msg.level;
-		if( time != 0x0 ) *time = msg.time;
-		return msg.text.c_str();
-	}
-	else
-		return emptyCString;
-}
-
 
 float h3dGetOption( EngineOptions::List param )
 {

File temp/test_hordefiles/Horde3D.h

 
 
 // --- General functions ---
-/* Function: h3dGetMessage
-		Gets the next message from the message queue.
-	
-	Details:
-		This function returns the next message string from the message queue and writes additional information
-		to the specified variables. If no message is left over in the queue an empty string is returned.
-	
-	Parameters:
-		level  - pointer to variable for storing message level indicating importance (can be NULL)
-		time   - pointer to variable for storing time when message was added (can be NULL)
-		
-	Returns:
-		message string or empty string if no message is in queue
-*/
-const char *h3dGetMessage( int *level, float *time );
 
 /* Function: h3dGetOption
 		Gets an option parameter of the engine.

File temp/test_hordefiles/Horde3DUtils.h

 */
 void h3dutFreeMem( char **ptr );
 
-/*	Function: h3dutDumpMessages
-		Writes all messages in the queue to a log file.
-	
-	Details:
-		This utility function pops all messages from the message queue and writes them to a HTML formated
-		log file 'Horde3D_Log.html'.
-	
-	Parameters:
-		none
-		
-	Returns:
-		true in case of success, otherwise false
-*/
-bool h3dutDumpMessages();
-
-
 
 /*	Group: Resource management */
 /* Function: h3dutGetResourcePath

File temp/test_hordefiles/chicago/app.cpp

 {	
 	// Initialize engine
 	if( !h3dInit() )
-	{	
-		h3dutDumpMessages();
 		return false;
-	}
 
 	// Set options
 	h3dSetOption( Horde3D::EngineOptions::LoadTextures, 1 );
 	// Remove all overlays
 	h3dClearOverlays();
 
-	// Write all messages to log file
-	h3dutDumpMessages();
 }
 
 

File temp/test_hordefiles/config.h

-// *************************************************************************************************
-//
-// Horde3D
-//   Next-Generation Graphics Engine
-// --------------------------------------
-// Copyright (C) 2006-2011 Nicolas Schulz
-//
-// This software is distributed under the terms of the Eclipse Public License v1.0.
-// A copy of the license may be obtained at: http://www.eclipse.org/legal/epl-v10.html
-//
-// *************************************************************************************************
-
-#ifndef _h3d_config_H_
-#define _h3d_config_H_
-
-// =================================================================================================
-// Compile Time Configuration
-// =================================================================================================
-
-// Validate input arguments of Horde3D API calls
-#define H3D_API_VALIDATION
-
-// Send log messages to the output channel of the attached debugger
-#define H3D_DEBUGGER_OUTPUT
-
-// Check for errors and invalid data during each drawcall (requires DEBUG config)
-//#define H3D_VALIDATE_DRAWCALLS
-
-
-#endif // _h3d_config_H_

File temp/test_hordefiles/egCom.cpp

 	{
 	case EngineOptions::MaxLogLevel:
 		return (float)maxLogLevel;
-	case EngineOptions::MaxNumMessages:
-		return (float)Modules::log().getMaxNumMessages();
 	case EngineOptions::TrilinearFiltering:
 		return trilinearFiltering ? 1.0f : 0.0f;
 	case EngineOptions::MaxAnisotropy:
 	case EngineOptions::MaxLogLevel:
 		maxLogLevel = ftoi_r( value );
 		return true;
-	case EngineOptions::MaxNumMessages:
-		Modules::log().setMaxNumMessages( (uint32_t)ftoi_r( value ) );
-		return true;
 	case EngineOptions::TrilinearFiltering:
 		trilinearFiltering = (value != 0);
 		return true;

File temp/test_hordefiles/egCom.h

 	BatchCount        - Number of batches (draw calls)
 	LightPassCount    - Number of lighting passes
 	FrameTime         - Time in ms between two h3dFinalizeFrame calls
-	AnimationTime     - CPU time in ms spent for animation
-	SkinningTime      - CPU time in ms spent for software skinning and morphing
-	ParticleSimTime   - CPU time in ms spent for particle simulation and updates
 	TextureVMem       - Estimated amount of video memory used by textures (in Mb)
 	GeometryVMem      - Estimated amount of video memory used by geometry (in Mb)
 */
 		BatchCount,
 		LightPassCount,
 		FrameTime,
-		AnimationTime,
-		SkinningTime,
-		ParticleSimTime,
 		TextureVMem,
 		GeometryVMem
 	};

File temp/test_hordefiles/egGeometry.h

 
 #include "egPrerequisites.h"
 #include "egResource.h"
-#include "egPrimitives.h"
+#include "engine_math_primitives.h"
 #include "utMath.h"
 
 

File temp/test_hordefiles/egModules.cpp

 bool Modules::init()
 {
 	// Create modules (order is important because of dependencies)
-	if( _engineLog == 0x0 ) _engineLog = new Logger();
+	if( _engineLog == 0x0 ) _engineLog = new Logger(true, "Horde3D.log");
 	if( _engineConfig == 0x0 ) _engineConfig = new EngineConfig();
 	if( _sceneManager == 0x0 ) _sceneManager = new SceneManager();
 	if( _resourceManager == 0x0 ) _resourceManager = new ResourceManager();

File temp/test_hordefiles/egModules.h

 // Useful macros for API functions
 // =================================================================================================
 
-#ifdef H3D_API_VALIDATION
+#ifdef __Debug__
 	#define APIFUNC_VALIDATE_RES( res, func, retVal ) if( res == 0x0 ) { \
 		Modules::setError( "Invalid resource handle in ", func ); return retVal; }
 	#define APIFUNC_VALIDATE_RES_TYPE( res, type, func, retVal ) if( res == 0x0 || res->get_type() != type ) { \

File temp/test_hordefiles/egPrerequisites.h

 #define _egPrerequisites_H_
 
 #include "utPlatform.h"
-#include "config.h"
+// #include "config.h"
 
 #include "engine_basic_types.h"
 

File temp/test_hordefiles/egPrimitives.cpp

-// *************************************************************************************************
-//
-// Horde3D
-//   Next-Generation Graphics Engine
-// --------------------------------------
-// Copyright (C) 2006-2011 Nicolas Schulz
-//
-// This software is distributed under the terms of the Eclipse Public License v1.0.
-// A copy of the license may be obtained at: http://www.eclipse.org/legal/epl-v10.html
-//
-// *************************************************************************************************
-
-#include "egPrimitives.h"
-
-
-
-namespace Horde3D {
-
-// *************************************************************************************************
-// Frustum
-// *************************************************************************************************
-
-void Frustum::buildViewFrustum( const Matrix4f &transMat, float fov, float aspect, float nearPlane, float farPlane )
-{
-	float ymax = nearPlane * tanf( degToRad( fov / 2 ) );
-	float xmax = ymax * aspect;
-	
-	buildViewFrustum( transMat, -xmax, xmax, -ymax, ymax, nearPlane, farPlane );
-}
-
-
-void Frustum::buildViewFrustum( const Matrix4f &transMat, float left, float right,
-							    float bottom, float top, float nearPlane, float farPlane ) 
-{
-	// Use intercept theorem to get params for far plane
-	float left_f = left * farPlane / nearPlane;
-	float right_f = right * farPlane / nearPlane;
-	float bottom_f = bottom * farPlane / nearPlane;
-	float top_f = top * farPlane / nearPlane;
-
-	// Get points on near plane
-	_corners[0] = Vec3f( left, bottom, -nearPlane );
-	_corners[1] = Vec3f( right, bottom, -nearPlane );
-	_corners[2] = Vec3f( right, top, -nearPlane );
-	_corners[3] = Vec3f( left, top, -nearPlane );
-
-	// Get points on far plane
-	_corners[4] = Vec3f( left_f, bottom_f, -farPlane );
-	_corners[5] = Vec3f( right_f, bottom_f, -farPlane );
-	_corners[6] = Vec3f( right_f, top_f, -farPlane );
-	_corners[7] = Vec3f( left_f, top_f, -farPlane );
-
-	// Transform points to fit camera position and rotation
-	_origin = transMat * Vec3f( 0, 0, 0 );
-	for( uint32_t i = 0; i < 8; ++i )
-		_corners[i] = transMat * _corners[i];
-
-	// Build planes
-	_planes[0] = Plane( _origin, _corners[3], _corners[0] );		// Left
-	_planes[1] = Plane( _origin, _corners[1], _corners[2] );		// Right
-	_planes[2] = Plane( _origin, _corners[0], _corners[1] );		// Bottom
-	_planes[3] = Plane( _origin, _corners[2], _corners[3] );		// Top
-	_planes[4] = Plane( _corners[0], _corners[1], _corners[2] );	// Near
-	_planes[5] = Plane( _corners[5], _corners[4], _corners[7] );	// Far
-}
-
-
-void Frustum::buildViewFrustum( const Matrix4f &viewMat, const Matrix4f &projMat )
-{
-	// This routine works with the OpenGL projection matrix
-	// The view matrix is the inverse camera transformation matrix
-	// Note: Frustum corners are not updated!
-	
-	Matrix4f m = projMat * viewMat;
-	
-	_planes[0] = Plane( -(m.c[0][3] + m.c[0][0]), -(m.c[1][3] + m.c[1][0]),
-						-(m.c[2][3] + m.c[2][0]), -(m.c[3][3] + m.c[3][0]) );	// Left
-	_planes[1] = Plane( -(m.c[0][3] - m.c[0][0]), -(m.c[1][3] - m.c[1][0]),
-						-(m.c[2][3] - m.c[2][0]), -(m.c[3][3] - m.c[3][0]) );	// Right
-	_planes[2] = Plane( -(m.c[0][3] + m.c[0][1]), -(m.c[1][3] + m.c[1][1]),
-						-(m.c[2][3] + m.c[2][1]), -(m.c[3][3] + m.c[3][1]) );	// Bottom
-	_planes[3] = Plane( -(m.c[0][3] - m.c[0][1]), -(m.c[1][3] - m.c[1][1]),
-						-(m.c[2][3] - m.c[2][1]), -(m.c[3][3] - m.c[3][1]) );	// Top
-	_planes[4] = Plane( -(m.c[0][3] + m.c[0][2]), -(m.c[1][3] + m.c[1][2]),
-						-(m.c[2][3] + m.c[2][2]), -(m.c[3][3] + m.c[3][2]) );	// Near
-	_planes[5] = Plane( -(m.c[0][3] - m.c[0][2]), -(m.c[1][3] - m.c[1][2]),
-						-(m.c[2][3] - m.c[2][2]), -(m.c[3][3] - m.c[3][2]) );	// Far
-
-	_origin = viewMat.inverted() * Vec3f( 0, 0, 0 );
-
-	// Calculate corners
-	Matrix4f mm = m.inverted();
-	Vec4f corner = mm * Vec4f( -1, -1,  -1, 1 );
-	_corners[0] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
-	corner = mm * Vec4f( 1, -1,  -1, 1 );
-	_corners[1] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
-	corner = mm * Vec4f( 1,  1,  -1, 1 );
-	_corners[2] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
-	corner = mm * Vec4f( -1,  1,  -1, 1 );
-	_corners[3] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
-	corner = mm * Vec4f( -1, -1, 1, 1 );
-	_corners[4] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
-	corner = mm * Vec4f( 1, -1, 1, 1 );
-	_corners[5] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
-	corner = mm * Vec4f( 1, 1, 1, 1 );
-	_corners[6] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
-	corner = mm * Vec4f( -1, 1, 1, 1 );
-	_corners[7] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
-}
-
-
-void Frustum::buildBoxFrustum( const Matrix4f &transMat, float left, float right,
-							   float bottom, float top, float front, float back ) 
-{
-	// Get points on front plane
-	_corners[0] = Vec3f( left, bottom, front );
-	_corners[1] = Vec3f( right, bottom, front );
-	_corners[2] = Vec3f( right, top, front );
-	_corners[3] = Vec3f( left, top, front );
-
-	// Get points on far plane
-	_corners[4] = Vec3f( left, bottom, back );
-	_corners[5] = Vec3f( right, bottom, back );
-	_corners[6] = Vec3f( right, top, back );
-	_corners[7] = Vec3f( left, top, back );
-
-	// Transform points to fit camera position and rotation
-	_origin = transMat * Vec3f( 0, 0, 0 );
-	for( uint32_t i = 0; i < 8; ++i )
-		_corners[i] = transMat * _corners[i];
-
-	// Build planes
-	_planes[0] = Plane( _corners[0], _corners[3], _corners[7] );	// Left
-	_planes[1] = Plane( _corners[2], _corners[1], _corners[6] );	// Right
-	_planes[2] = Plane( _corners[0], _corners[4], _corners[5] );	// Bottom
-	_planes[3] = Plane( _corners[3], _corners[2], _corners[6] );	// Top
-	_planes[4] = Plane( _corners[0], _corners[1], _corners[2] );	// Front
-	_planes[5] = Plane( _corners[4], _corners[7], _corners[6] );	// Back
-}
-
-
-bool Frustum::cullSphere( Vec3f pos, float rad ) const
-{
-	// Check the distance of the center to the planes
-	for( uint32_t i = 0; i < 6; ++i )
-	{
-		if( _planes[i].distToPoint( pos ) > rad ) return true;
-	}
-
-	return false;
-}
-
-
-bool Frustum::cullBox( BoundingBox &b ) const
-{
-	// Idea for optimized AABB testing from www.lighthouse3d.com
-	for( uint32_t i = 0; i < 6; ++i )
-	{
-		const Vec3f &n = _planes[i].normal;
-		
-		Vec3f positive = b.min;
-		if( n.x <= 0 ) positive.x = b.max.x;
-		if( n.y <= 0 ) positive.y = b.max.y;
-		if( n.z <= 0 ) positive.z = b.max.z;
-
-		if( _planes[i].distToPoint( positive ) > 0 ) return true;
-	}
-	
-	return false;
-}
-
-
-bool Frustum::cullFrustum( const Frustum &frust ) const
-{
-	for( uint32_t i = 0; i < 6; ++i )
-	{
-		bool allOut = true;
-		
-		for( uint32_t j = 0; j < 8; ++j )
-		{
-			if( _planes[i].distToPoint( frust._corners[j] ) < 0 )
-			{
-				allOut = false;
-				break;
-			}
-		}
-
-		if( allOut ) return true;
-	}
-
-	return false;
-}
-
-
-void Frustum::calcAABB( Vec3f &mins, Vec3f &maxs ) const
-{
-	mins.x = Math::MaxFloat; mins.y = Math::MaxFloat; mins.z = Math::MaxFloat;
-	maxs.x = -Math::MaxFloat; maxs.y = -Math::MaxFloat; maxs.z = -Math::MaxFloat;
-	
-	for( uint32_t i = 0; i < 8; ++i )
-	{
-		if( _corners[i].x < mins.x ) mins.x = _corners[i].x;
-		if( _corners[i].y < mins.y ) mins.y = _corners[i].y;
-		if( _corners[i].z < mins.z ) mins.z = _corners[i].z;
-		if( _corners[i].x > maxs.x ) maxs.x = _corners[i].x;
-		if( _corners[i].y > maxs.y ) maxs.y = _corners[i].y;
-		if( _corners[i].z > maxs.z ) maxs.z = _corners[i].z;
-	}
-}
-
-}  // namespace

File temp/test_hordefiles/egPrimitives.h

-// *************************************************************************************************
-//
-// Horde3D
-//   Next-Generation Graphics Engine
-// --------------------------------------
-// Copyright (C) 2006-2011 Nicolas Schulz
-//
-// This software is distributed under the terms of the Eclipse Public License v1.0.
-// A copy of the license may be obtained at: http://www.eclipse.org/legal/epl-v10.html
-//
-// *************************************************************************************************
-
-#ifndef _egPrimitives_H_
-#define _egPrimitives_H_
-
-#include "egPrerequisites.h"
-#include "utMath.h"
-
-
-namespace Horde3D {
-
-// =================================================================================================
-// Bounding Box
-// =================================================================================================
-
-struct BoundingBox
-{	
-	Vec3f  min, max;
-
-	
-	void clear()
-	{
-		min = Vec3f( 0, 0, 0 );
-		max = Vec3f( 0, 0, 0 );
-	}
-
-	Vec3f getCorner( uint32_t index ) const
-	{
-		switch( index )
-		{
-		case 0:
-			return Vec3f( min.x, min.y, max.z );
-		case 1:
-			return Vec3f( max.x, min.y, max.z );
-		case 2:
-			return Vec3f( max.x, max.y, max.z );
-		case 3:
-			return Vec3f( min.x, max.y, max.z );
-		case 4:
-			return Vec3f( min.x, min.y, min.z );
-		case 5:
-			return Vec3f( max.x, min.y, min.z );
-		case 6:
-			return Vec3f( max.x, max.y, min.z );
-		case 7:
-			return Vec3f( min.x, max.y, min.z );
-		default:
-			return Vec3f();
-		}
-	}
-
-
-	void transform( const Matrix4f &m )
-	{
-		// Efficient algorithm for transforming an AABB, taken from Graphics Gems
-		
-		float minA[3] = { min.x, min.y, min.z }, minB[3];
-		float maxA[3] = { max.x, max.y, max.z }, maxB[3];
-
-		for( uint32_t i = 0; i < 3; ++i )
-		{
-			minB[i] = m.c[3][i];
-			maxB[i] = m.c[3][i];
-			
-			for( uint32_t j = 0; j < 3; ++j )
-			{
-				float x = minA[j] * m.c[j][i];
-				float y = maxA[j] * m.c[j][i];
-				minB[i] += minf( x, y );
-				maxB[i] += maxf( x, y );
-			}
-		}
-
-		min = Vec3f( minB[0], minB[1], minB[2] );
-		max = Vec3f( maxB[0], maxB[1], maxB[2] );
-	}
-
-
-	bool makeUnion( BoundingBox &b )
-	{
-		bool changed = false;
-
-		// Ignore zero-size boxes
-		if( min == max )
-		{
-			changed = true;
-			min = b.min;
-			max = b.max;
-		}
-		else if( b.min != b.max )
-		{
-			if( b.min.x < min.x ) { changed = true; min.x = b.min.x; }
-			if( b.min.y < min.y ) { changed = true; min.y = b.min.y; }
-			if( b.min.z < min.z ) { changed = true; min.z = b.min.z; }
-
-			if( b.max.x > max.x ) { changed = true; max.x = b.max.x; }
-			if( b.max.y > max.y ) { changed = true; max.y = b.max.y; }
-			if( b.max.z > max.z ) { changed = true; max.z = b.max.z; }
-		}
-
-		return changed;
-	}
-};
-
-
-// =================================================================================================
-// Frustum
-// =================================================================================================
-
-class Frustum
-{
-public:
-	const Vec3f &getOrigin() const { return _origin; }
-	const Vec3f &getCorner( uint32_t index ) const { return _corners[index]; }
-	
-	void buildViewFrustum( const Matrix4f &transMat, float fov, float aspect, float nearPlane, float farPlane );
-	void buildViewFrustum( const Matrix4f &transMat, float left, float right,
-	                       float bottom, float top, float nearPlane, float farPlane );
-	void buildViewFrustum( const Matrix4f &viewMat, const Matrix4f &projMat );
-	void buildBoxFrustum( const Matrix4f &transMat, float left, float right,
-	                      float bottom, float top, float front, float back );
-	bool cullSphere( Vec3f pos, float rad ) const;
-	bool cullBox( BoundingBox &b ) const;
-	bool cullFrustum( const Frustum &frust ) const;
-
-	void calcAABB( Vec3f &mins, Vec3f &maxs ) const;
-
-private:
-	Plane  _planes[6];  // Planes of frustum
-	Vec3f  _origin;
-	Vec3f  _corners[8];  // Corner points
-};
-
-}
-#endif // _egPrimitives_H_

File temp/test_hordefiles/egRenderer.cpp

 	Timer *timer = Modules::stats().getTimer();
 	ASSERT( timer != 0x0 );
 	Modules::stats().getStat( EngineStats::FrameTime, true );  // Reset
-	Modules::stats().incStat( EngineStats::FrameTime, timer->get_elapsed_time_in_ms() );
+	Modules::stats().incStat( EngineStats::FrameTime, timer->elapsed_time_in_ms() );
 	timer->reset();
 }
 

File temp/test_hordefiles/egRenderer.h

 
 #include "egPrerequisites.h"
 #include "egRendererBase.h"
-#include "egPrimitives.h"
+// #include "egPrimitives.h"
 #include "egModel.h"
 #include <vector>
 #include <algorithm>

File temp/test_hordefiles/egScene.h

 
 #include "egPrerequisites.h"
 #include "utMath.h"
-#include "egPrimitives.h"
+#include "engine_math_primitives.h"
 #include "egPipeline.h"
 #include <map>
 

File temp/test_hordefiles/engine_basic_types.h

 #pragma once
 
+#include <stdint.h>     // fixed size int types
+
 
 // engine basic types
 

File temp/test_hordefiles/engine_logger.cpp

 
 #include "engine_logger.h"
-// #include "utMath.h"
-// #include "egModules.h"
-// #include "egRenderer.h"
-// #include <stdarg.h>
-// #include <stdio.h>
 
 
 
 // Class Logger
 // *************************************************************************************************
 
-Logger::Logger()
+Logger::Logger(bool toScreen, const std::string &filename)
 {
 	_timer.start();
-	_maxNumMessages = 512;
+	_to_screen = toScreen;
+	fp = NULL;
+	if (filename!="")
+		fp = fopen(filename.c_str(),"w");
+
 }
 
 
-void Logger::pushMessage( int level, const char *msg, va_list args )
+void Logger::push_message( int level, const char *msg, va_list args )
 {
-	float time = _timer.get_elapsed_time_in_ms() / 1000.0f;
+	float _time = _timer.elapsed_time_in_ms() / 1000.0f;
 
 #if defined( PLATFORM_WIN )
 #pragma warning( push )
 #else
 	vsnprintf( _textBuf, 2048, msg, args );
 #endif
-	
-	if( _messages.size() < _maxNumMessages - 1 )
+
+	if (_to_screen)
+		printf("[%7.3f] %s\n",_time,_textBuf);
+	if (fp)
 	{
-		_messages.push( LogMessage( _textBuf, level, time ) );
+		fprintf(fp,"[%7.3f] %s\n",_time,_textBuf);
+		fflush(fp);
 	}
-	else if( _messages.size() == _maxNumMessages - 1 )
-	{
-		_messages.push( LogMessage( "Message queue is full", 1, time ) );
-	}
+}
 
-#if defined( PLATFORM_WIN ) && defined( H3D_DEBUGGER_OUTPUT )
-	const TCHAR *headers[6] = { TEXT(""), TEXT("  [h3d-err] "), TEXT("  [h3d-warn] "), TEXT("[h3d] "), TEXT("  [h3d-dbg] "), TEXT("[h3d- ] ")};
-	
-	OutputDebugString( headers[std::min( (uint32_t)level, (uint32_t)5 )] );
-	OutputDebugStringA( _textBuf );
-	OutputDebugString( TEXT("\r\n") );
-#endif
+void Logger::debug( const char *msg, ... )
+{
+	// if( Modules::config().maxLogLevel < 4 ) return;
+
+	va_list args;
+	va_start( args, msg );
+	push_message( LOG_DEBUG, msg, args );
+	va_end( args );
+}
+
+
+void Logger::info( const char *msg, ... )
+{
+	// if( Modules::config().maxLogLevel < 3 ) return;
+
+	va_list args;
+	va_start( args, msg );
+	push_message( LOG_INFO, msg, args );
+	va_end( args );
+}
+
+
+void Logger::message( const char *msg, ... )
+{
+	// if( Modules::config().maxLogLevel < 3 ) return;
+
+	va_list args;
+	va_start( args, msg );
+	push_message( LOG_MESSAGE, msg, args );
+	va_end( args );
+}
+
+
+void Logger::warning( const char *msg, ... )
+{
+	// if( Modules::config().maxLogLevel < 2 ) return;
+
+	va_list args;
+	va_start( args, msg );
+	push_message( LOG_WARNING, msg, args );
+	va_end( args );
 }
 
 
 
 	va_list args;
 	va_start( args, msg );
-	pushMessage( 1, msg, args );
+	push_message( LOG_ERROR, msg, args );
 	va_end( args );
 }
 
 
-void Logger::warning( const char *msg, ... )
-{
-	// if( Modules::config().maxLogLevel < 2 ) return;
-
-	va_list args;
-	va_start( args, msg );
-	pushMessage( 2, msg, args );
-	va_end( args );
-}
-
-
-void Logger::info( const char *msg, ... )
-{
-	// if( Modules::config().maxLogLevel < 3 ) return;
-
-	va_list args;
-	va_start( args, msg );
-	pushMessage( 3, msg, args );
-	va_end( args );
-}
-
-
-void Logger::debug( const char *msg, ... )
-{
-	// if( Modules::config().maxLogLevel < 4 ) return;
-
-	va_list args;
-	va_start( args, msg );
-	pushMessage( 4, msg, args );
-	va_end( args );
-}
-
-
-bool Logger::get_message( LogMessage &msg )
-{
-	if( !_messages.empty() )
-	{
-		msg = _messages.front();
-		_messages.pop();
-		return true;
-	}
-	else
-		return false;
-}
-
-
 
 
 }  // namespace

File temp/test_hordefiles/engine_logger.h

 class Logger
 {
 public:
-	Logger();
+	enum LogLevel 
+	{
+		LOG_DEBUG,
+		LOG_INFO,
+		LOG_MESSAGE,
+		LOG_WARNING,
+		LOG_ERROR
+	};
+public:
+	Logger(bool toScreen, const std::string &filename="");
 
+	void debug( const char *msg, ... );
+	void info( const char *msg, ... );
+	void message( const char *msg, ... );
+	void warning( const char *msg, ... );
 	void error( const char *msg, ... );
-	void warning( const char *msg, ... );
-	void info( const char *msg, ... );
-	void debug( const char *msg, ... );
 
-	bool get_message( LogMessage &msg );
-
-	uint32_t getMaxNumMessages() { return _maxNumMessages; }
-	void setMaxNumMessages( uint32_t maxNumMessages ) { _maxNumMessages = maxNumMessages; }
-	
 protected:
-	void pushMessage( const std::string &text, uint32_t level );
-	void pushMessage( int level, const char *msg, va_list ap );
+	void push_message( int level, const char *msg, va_list ap );
 
 protected:
 	Timer                     _timer;
 	char                      _textBuf[2048];
-	uint32_t                    _maxNumMessages;
 	std::queue< LogMessage >  _messages;
+
+	bool					  _to_screen;
+	FILE 					  *fp;
 };
 
 

File temp/test_hordefiles/engine_math_primitives.cpp

+#include "engine_math_primitives.h"
+
+
+
+namespace Horde3D {
+
+// *************************************************************************************************
+// Frustum
+// *************************************************************************************************
+
+void Frustum::buildViewFrustum( const Matrix4f &transMat, float fov, float aspect, float nearPlane, float farPlane )
+{
+	float ymax = nearPlane * tanf( degToRad( fov / 2 ) );
+	float xmax = ymax * aspect;
+	
+	buildViewFrustum( transMat, -xmax, xmax, -ymax, ymax, nearPlane, farPlane );
+}
+
+
+void Frustum::buildViewFrustum( const Matrix4f &transMat, float left, float right,
+							    float bottom, float top, float nearPlane, float farPlane ) 
+{
+	// Use intercept theorem to get params for far plane
+	float left_f = left * farPlane / nearPlane;
+	float right_f = right * farPlane / nearPlane;
+	float bottom_f = bottom * farPlane / nearPlane;
+	float top_f = top * farPlane / nearPlane;
+
+	// Get points on near plane
+	_corners[0] = Vec3f( left, bottom, -nearPlane );
+	_corners[1] = Vec3f( right, bottom, -nearPlane );
+	_corners[2] = Vec3f( right, top, -nearPlane );
+	_corners[3] = Vec3f( left, top, -nearPlane );
+
+	// Get points on far plane
+	_corners[4] = Vec3f( left_f, bottom_f, -farPlane );
+	_corners[5] = Vec3f( right_f, bottom_f, -farPlane );
+	_corners[6] = Vec3f( right_f, top_f, -farPlane );
+	_corners[7] = Vec3f( left_f, top_f, -farPlane );
+
+	// Transform points to fit camera position and rotation
+	_origin = transMat * Vec3f( 0, 0, 0 );
+	for( unsigned int i = 0; i < 8; ++i )
+		_corners[i] = transMat * _corners[i];
+
+	// Build planes
+	_planes[0] = Plane( _origin, _corners[3], _corners[0] );		// Left
+	_planes[1] = Plane( _origin, _corners[1], _corners[2] );		// Right
+	_planes[2] = Plane( _origin, _corners[0], _corners[1] );		// Bottom
+	_planes[3] = Plane( _origin, _corners[2], _corners[3] );		// Top
+	_planes[4] = Plane( _corners[0], _corners[1], _corners[2] );	// Near
+	_planes[5] = Plane( _corners[5], _corners[4], _corners[7] );	// Far
+}
+
+
+void Frustum::buildViewFrustum( const Matrix4f &viewMat, const Matrix4f &projMat )
+{
+	// This routine works with the OpenGL projection matrix
+	// The view matrix is the inverse camera transformation matrix
+	// Note: Frustum corners are not updated!
+	
+	Matrix4f m = projMat * viewMat;
+	
+	_planes[0] = Plane( -(m.c[0][3] + m.c[0][0]), -(m.c[1][3] + m.c[1][0]),
+						-(m.c[2][3] + m.c[2][0]), -(m.c[3][3] + m.c[3][0]) );	// Left
+	_planes[1] = Plane( -(m.c[0][3] - m.c[0][0]), -(m.c[1][3] - m.c[1][0]),
+						-(m.c[2][3] - m.c[2][0]), -(m.c[3][3] - m.c[3][0]) );	// Right
+	_planes[2] = Plane( -(m.c[0][3] + m.c[0][1]), -(m.c[1][3] + m.c[1][1]),
+						-(m.c[2][3] + m.c[2][1]), -(m.c[3][3] + m.c[3][1]) );	// Bottom
+	_planes[3] = Plane( -(m.c[0][3] - m.c[0][1]), -(m.c[1][3] - m.c[1][1]),
+						-(m.c[2][3] - m.c[2][1]), -(m.c[3][3] - m.c[3][1]) );	// Top
+	_planes[4] = Plane( -(m.c[0][3] + m.c[0][2]), -(m.c[1][3] + m.c[1][2]),
+						-(m.c[2][3] + m.c[2][2]), -(m.c[3][3] + m.c[3][2]) );	// Near
+	_planes[5] = Plane( -(m.c[0][3] - m.c[0][2]), -(m.c[1][3] - m.c[1][2]),
+						-(m.c[2][3] - m.c[2][2]), -(m.c[3][3] - m.c[3][2]) );	// Far
+
+	_origin = viewMat.inverted() * Vec3f( 0, 0, 0 );
+
+	// Calculate corners
+	Matrix4f mm = m.inverted();
+	Vec4f corner = mm * Vec4f( -1, -1,  -1, 1 );
+	_corners[0] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
+	corner = mm * Vec4f( 1, -1,  -1, 1 );
+	_corners[1] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
+	corner = mm * Vec4f( 1,  1,  -1, 1 );
+	_corners[2] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
+	corner = mm * Vec4f( -1,  1,  -1, 1 );
+	_corners[3] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
+	corner = mm * Vec4f( -1, -1, 1, 1 );
+	_corners[4] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
+	corner = mm * Vec4f( 1, -1, 1, 1 );
+	_corners[5] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
+	corner = mm * Vec4f( 1, 1, 1, 1 );
+	_corners[6] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
+	corner = mm * Vec4f( -1, 1, 1, 1 );
+	_corners[7] = Vec3f( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w );
+}
+
+
+void Frustum::buildBoxFrustum( const Matrix4f &transMat, float left, float right,
+							   float bottom, float top, float front, float back ) 
+{
+	// Get points on front plane
+	_corners[0] = Vec3f( left, bottom, front );
+	_corners[1] = Vec3f( right, bottom, front );
+	_corners[2] = Vec3f( right, top, front );
+	_corners[3] = Vec3f( left, top, front );
+
+	// Get points on far plane
+	_corners[4] = Vec3f( left, bottom, back );
+	_corners[5] = Vec3f( right, bottom, back );
+	_corners[6] = Vec3f( right, top, back );
+	_corners[7] = Vec3f( left, top, back );
+
+	// Transform points to fit camera position and rotation
+	_origin = transMat * Vec3f( 0, 0, 0 );
+	for( unsigned int i = 0; i < 8; ++i )
+		_corners[i] = transMat * _corners[i];
+
+	// Build planes
+	_planes[0] = Plane( _corners[0], _corners[3], _corners[7] );	// Left
+	_planes[1] = Plane( _corners[2], _corners[1], _corners[6] );	// Right
+	_planes[2] = Plane( _corners[0], _corners[4], _corners[5] );	// Bottom
+	_planes[3] = Plane( _corners[3], _corners[2], _corners[6] );	// Top
+	_planes[4] = Plane( _corners[0], _corners[1], _corners[2] );	// Front
+	_planes[5] = Plane( _corners[4], _corners[7], _corners[6] );	// Back
+}
+
+
+bool Frustum::cullSphere( Vec3f pos, float rad ) const
+{
+	// Check the distance of the center to the planes
+	for( unsigned int i = 0; i < 6; ++i )
+	{
+		if( _planes[i].distToPoint( pos ) > rad ) return true;
+	}
+
+	return false;
+}
+
+
+bool Frustum::cullBox( BoundingBox &b ) const
+{
+	// Idea for optimized AABB testing from www.lighthouse3d.com
+	for( unsigned int i = 0; i < 6; ++i )
+	{
+		const Vec3f &n = _planes[i].normal;
+		
+		Vec3f positive = b.min;
+		if( n.x <= 0 ) positive.x = b.max.x;
+		if( n.y <= 0 ) positive.y = b.max.y;
+		if( n.z <= 0 ) positive.z = b.max.z;
+
+		if( _planes[i].distToPoint( positive ) > 0 ) return true;
+	}
+	
+	return false;
+}
+
+
+bool Frustum::cullFrustum( const Frustum &frust ) const
+{
+	for( unsigned int i = 0; i < 6; ++i )
+	{
+		bool allOut = true;
+		
+		for( unsigned int j = 0; j < 8; ++j )
+		{
+			if( _planes[i].distToPoint( frust._corners[j] ) < 0 )
+			{
+				allOut = false;
+				break;
+			}
+		}
+
+		if( allOut ) return true;
+	}
+
+	return false;
+}
+
+
+void Frustum::calcAABB( Vec3f &mins, Vec3f &maxs ) const
+{
+	mins.x = Math::MaxFloat; mins.y = Math::MaxFloat; mins.z = Math::MaxFloat;
+	maxs.x = -Math::MaxFloat; maxs.y = -Math::MaxFloat; maxs.z = -Math::MaxFloat;
+	
+	for( unsigned int i = 0; i < 8; ++i )
+	{
+		if( _corners[i].x < mins.x ) mins.x = _corners[i].x;
+		if( _corners[i].y < mins.y ) mins.y = _corners[i].y;
+		if( _corners[i].z < mins.z ) mins.z = _corners[i].z;
+		if( _corners[i].x > maxs.x ) maxs.x = _corners[i].x;
+		if( _corners[i].y > maxs.y ) maxs.y = _corners[i].y;
+		if( _corners[i].z > maxs.z ) maxs.z = _corners[i].z;
+	}
+}
+
+}  // namespace

File temp/test_hordefiles/engine_math_primitives.h

+#pragma once
+
+// #include "engine_basic_types.h"
+#include "utMath.h"
+
+
+namespace Horde3D {
+
+
+// -------------------------------------------------------------------------------------------------
+// Plane
+// -------------------------------------------------------------------------------------------------
+
+class Plane
+{
+public:
+	Vec3f normal; 
+	float dist;
+
+	// ------------
+	// Constructors
+	// ------------
+	Plane() 
+	{ 
+		normal.x = 0; normal.y = 0; normal.z = 0; dist = 0; 
+	};
+
+	explicit Plane( const float a, const float b, const float c, const float d )
+	{
+		normal = Vec3f( a, b, c );
+		float invLen = 1.0f / normal.length();
+		normal *= invLen;	// Normalize
+		dist = d * invLen;
+	}
+
+	Plane( const Vec3f &v0, const Vec3f &v1, const Vec3f &v2 )
+	{
+		normal = v1 - v0;
+		normal = normal.cross( v2 - v0 );
+		normal.normalize();
+		dist = -normal.dot( v0 );
+	}
+
+	// ----------------
+	// Other operations
+	// ----------------
+	float distToPoint( const Vec3f &v ) const
+	{
+		return normal.dot( v ) + dist;
+	}
+};
+
+
+// =================================================================================================
+// Bounding Box
+// =================================================================================================
+
+struct BoundingBox
+{	
+	Vec3f  min, max;
+
+	
+	void clear()
+	{
+		min = Vec3f( 0, 0, 0 );
+		max = Vec3f( 0, 0, 0 );
+	}
+
+	Vec3f getCorner( unsigned int index ) const
+	{
+		switch( index )
+		{
+		case 0:
+			return Vec3f( min.x, min.y, max.z );
+		case 1:
+			return Vec3f( max.x, min.y, max.z );
+		case 2:
+			return Vec3f( max.x, max.y, max.z );
+		case 3:
+			return Vec3f( min.x, max.y, max.z );
+		case 4:
+			return Vec3f( min.x, min.y, min.z );
+		case 5:
+			return Vec3f( max.x, min.y, min.z );
+		case 6:
+			return Vec3f( max.x, max.y, min.z );
+		case 7:
+			return Vec3f( min.x, max.y, min.z );
+		default:
+			return Vec3f();
+		}
+	}
+
+
+	void transform( const Matrix4f &m )
+	{
+		// Efficient algorithm for transforming an AABB, taken from Graphics Gems
+		
+		float minA[3] = { min.x, min.y, min.z }, minB[3];
+		float maxA[3] = { max.x, max.y, max.z }, maxB[3];
+
+		for( unsigned int i = 0; i < 3; ++i )
+		{
+			minB[i] = m.c[3][i];
+			maxB[i] = m.c[3][i];
+			
+			for( unsigned int j = 0; j < 3; ++j )
+			{
+				float x = minA[j] * m.c[j][i];
+				float y = maxA[j] * m.c[j][i];
+				minB[i] += minf( x, y );
+				maxB[i] += maxf( x, y );
+			}
+		}
+
+		min = Vec3f( minB[0], minB[1], minB[2] );
+		max = Vec3f( maxB[0], maxB[1], maxB[2] );
+	}
+
+
+	bool makeUnion( BoundingBox &b )
+	{
+		bool changed = false;
+
+		// Ignore zero-size boxes
+		if( min == max )
+		{
+			changed = true;
+			min = b.min;
+			max = b.max;
+		}
+		else if( b.min != b.max )
+		{
+			if( b.min.x < min.x ) { changed = true; min.x = b.min.x; }
+			if( b.min.y < min.y ) { changed = true; min.y = b.min.y; }
+			if( b.min.z < min.z ) { changed = true; min.z = b.min.z; }
+
+			if( b.max.x > max.x ) { changed = true; max.x = b.max.x; }
+			if( b.max.y > max.y ) { changed = true; max.y = b.max.y; }
+			if( b.max.z > max.z ) { changed = true; max.z = b.max.z; }
+		}
+
+		return changed;
+	}
+};
+
+
+// =================================================================================================
+// Frustum
+// =================================================================================================
+
+class Frustum
+{
+public:
+	const Vec3f &getOrigin() const { return _origin; }
+	const Vec3f &getCorner( unsigned int index ) const { return _corners[index]; }
+	
+	void buildViewFrustum( const Matrix4f &transMat, float fov, float aspect, float nearPlane, float farPlane );
+	void buildViewFrustum( const Matrix4f &transMat, float left, float right,
+	                       float bottom, float top, float nearPlane, float farPlane );
+	void buildViewFrustum( const Matrix4f &viewMat, const Matrix4f &projMat );
+	void buildBoxFrustum( const Matrix4f &transMat, float left, float right,
+	                      float bottom, float top, float front, float back );
+	bool cullSphere( Vec3f pos, float rad ) const;
+	bool cullBox( BoundingBox &b ) const;
+	bool cullFrustum( const Frustum &frust ) const;
+
+	void calcAABB( Vec3f &mins, Vec3f &maxs ) const;
+
+private:
+	Plane  _planes[6];  // Planes of frustum
+	Vec3f  _origin;
+	Vec3f  _corners[8];  // Corner points
+};
+
+}
+

File temp/test_hordefiles/engine_timer.___h.h

-#pragma once
-
-#include "utPlatform.h"
-
-#ifndef PLATFORM_WIN
-	#include <sys/time.h>
-#endif
-
-
-namespace Horde3D {
-
-
-class Timer
-{
-public:
-    Timer();                      // default constructor
-    ~Timer();                     // default destructor
-
-    void   start();               // start timer
-    void   stop();                // stop the timer
-    void   enable(bool flag);     // enable/disable time measurement
-    double elapsed_time();        // get elapsed time in second
-    double elapsed_time_in_sec(); // get elapsed time in second (same as elapsed_time)
-    double elapsed_time_in_ms();  // get elapsed time in milli-second
-    double elapsed_time_in_us();  // get elapsed time in micro-second
-
-
-protected:
-
-
-private:
-    double _startTimeInMicroSec;  // starting time in micro-second
-    double _elapsedTimeInMicroSec;// ending time in micro-second
-    int    _enabled;              // activation flag
-#ifdef WIN32
-    LARGE_INTEGER frequency;    
-    LARGE_INTEGER startCount;     
-    LARGE_INTEGER endCount;       
-#else
-    timeval startCount;           
-    timeval endCount;             
-#endif
-};
-
-
-
-///////////////////////////////////////////////////////////////////////////////
-//  class implementation
-///////////////////////////////////////////////////////////////////////////////
-Timer::Timer()
-{
-#ifdef WIN32
-    QueryPerformanceFrequency(&frequency);
-    startCount.QuadPart = 0;
-    endCount.QuadPart = 0;
-#else
-    startCount.tv_sec = startCount.tv_usec = 0;
-    endCount.tv_sec = endCount.tv_usec = 0;
-#endif
-
-    _enabled = true;
-    _startTimeInMicroSec = 0;
-    _elapsedTimeInMicroSec = 0;
-}
-
-Timer::~Timer()
-{
-}
-
-void Timer::start()
-{
-    _enabled = true;
-#ifdef WIN32
-    QueryPerformanceCounter(&startCount);
-#else
-    gettimeofday(&startCount, NULL);
-#endif
-}
-
-void Timer::stop()
-{
-    _enabled = false;
-
-#ifdef WIN32
-    QueryPerformanceCounter(&endCount);
-#else
-    gettimeofday(&endCount, NULL);
-#endif
-}
-
-void Timer::enable( bool flag )
-{	
-	if( flag && !_enabled )
-	{
-		_startTimeInMicroSec = elapsed_time_in_us();
-		_enabled = true;
-	}
-	else if( !flag && _enabled )
-	{
-		double endTime = elapsed_time_in_us();
-		_elapsedTimeInMicroSec += endTime - _startTimeInMicroSec;
-		_enabled = false;
-	}
-}
-
-double Timer::elapsed_time_in_us()
-{
-	if (_enabled)
-	{
-	#ifdef WIN32
-    	QueryPerformanceCounter(&endCount);
-    	startTimeInMicroSec = startCount.QuadPart * (1000000.0 / frequency.QuadPart);
-    	endTimeInMicroSec = endCount.QuadPart * (1000000.0 / frequency.QuadPart);
-	#else
-       	gettimeofday(&endCount, NULL);
-    	startTimeInMicroSec = (startCount.tv_sec * 1000000.0) + startCount.tv_usec;
-    	endTimeInMicroSec = (endCount.tv_sec * 1000000.0) + endCount.tv_usec;
-	#endif
-
-    	_elapsedTimeInMicroSec = endTimeInMicroSec - startTimeInMicroSec;		
-	}
-
-    return _elapsedTimeInMicroSec;
-}
-
-double Timer::elapsed_time_in_ms()
-{
-    return this->elapsed_time_in_us() * 0.001;
-}
-
-double Timer::elapsed_time_in_sec()
-{
-    return this->elapsed_time_in_us() * 0.000001;
-}
-
-double Timer::elapsed_time()
-{
-    return this->elapsed_time_in_sec();
-}
-
-
-}	// namespace
-

File temp/test_hordefiles/engine_timer.h

 #include "utPlatform.h"
 
 #ifndef PLATFORM_WIN
-    #include <sys/time.h>
+	#include <sys/time.h>
 #endif
 
 
 namespace Horde3D {
 
+
 class Timer
 {
 public:
+    Timer()                       // default constructor
+    {
+    #ifdef WIN32
+        QueryPerformanceFrequency(&frequency);
+        startCount.QuadPart = 0;
+        endCount.QuadPart = 0;
+    #else
+        startCount.tv_sec = startCount.tv_usec = 0;
+        endCount.tv_sec = endCount.tv_usec = 0;
+    #endif
 
-    Timer();
-    
-    void start();
-    void set_enabled( bool flag );
-    void reset();
-    
-    // get timing
-    double get_current_time_in_us();
+        _enabled = true;
+        _startTimeInMicroSec = 0.0;
+        _elapsedTimeInMicroSec = 0.0;
+    }
+    ~Timer()                      // default destructor
+    {}
 
-    double get_elapsed_time_in_sec();
-    double get_elapsed_time_in_ms();
-    double get_elapsed_time_in_us();
+    inline void   start();               // start timer
+    inline void   stop();                // stop the timer
+    inline void   reset();               // reset internal counters (does not change the enabled/disabled state)
+    inline void   set_enabled(bool flag);// enable/disable time measurement
+    inline double get_tick_in_us();      // get the tick count in microseconds
+    inline double elapsed_time_in_sec(); // get elapsed time in second (same as elapsed_time)
+    inline double elapsed_time_in_ms();  // get elapsed time in milli-second
+    inline double elapsed_time_in_us();  // get elapsed time in micro-second
 
-    // member variables
-    bool           _enabled;
-    double         _startTime;
-    double         _elapsedTime;
 
-#ifdef PLATFORM_WIN
-    LARGE_INTEGER  _timerFreq;
+protected:
+
+
+private:
+    double _startTimeInMicroSec;  // starting time in micro-second
+    double _elapsedTimeInMicroSec;// ending time in micro-second
+    int    _enabled;              // activation flag
+#ifdef WIN32
+    LARGE_INTEGER frequency;    
+    LARGE_INTEGER startCount;     
+    LARGE_INTEGER endCount;       
+#else
+    timeval startCount;           
+    timeval endCount;             
 #endif
-
 };
 
 
 //  class implementation
 ///////////////////////////////////////////////////////////////////////////////
 
-Timer::Timer() 
-: _elapsedTime( 0 ), _enabled( false )
-{
-#if defined( PLATFORM_WIN ) 
-    // Get timer frequency
-    QueryPerformanceFrequency( &_timerFreq );
-#endif
-}
-    
 
 void Timer::start()
 {
-    _elapsedTime = 0;
+    _startTimeInMicroSec = get_tick_in_us();
     _enabled = true;
-    _startTime = get_current_time_in_us();
 }
 
-void Timer::set_enabled( bool flag )
-{   
-    if( flag && !_enabled )
-    {
-        _startTime = get_current_time_in_us();
-        _enabled = true;
-    }
-    else if( !flag && _enabled )
-    {
-        double endTime = get_current_time_in_us();
-        _elapsedTime += endTime - _startTime;
-        _enabled = false;
-    }
+void Timer::stop()
+{
+    double endTime = get_tick_in_us();
+    _elapsedTimeInMicroSec += endTime - _startTimeInMicroSec;
+    _enabled = false;
 }
 
-
 void Timer::reset()
 {
-    _elapsedTime = 0;
-    if( _enabled ) _startTime = get_current_time_in_us();
-}
-    
-
-double Timer::get_elapsed_time_in_sec()
-{
-    return get_elapsed_time_in_us() * 0.000001;
+    _elapsedTimeInMicroSec = 0.0;
+    if( _enabled ) _startTimeInMicroSec = get_tick_in_us();
 }
 
 
-double Timer::get_elapsed_time_in_ms()
-{
-    return get_elapsed_time_in_us() * 0.001;
+void Timer::set_enabled( bool flag )
+{	
+	if( flag && !_enabled )
+	{
+        start();
+	}
+	else if( !flag && _enabled )
+	{
+        stop();
+	}
 }
 
 
-double Timer::get_elapsed_time_in_us()
+double Timer::get_tick_in_us()
 {
-    if( _enabled )
-    {
-        double endTime = get_current_time_in_us();
-        _elapsedTime += endTime - _startTime;
-        _startTime = endTime;
-    }
-
-    return _elapsedTime;
-}
-
-
-double Timer::get_current_time_in_us()
-{
-#if defined( PLATFORM_WIN ) || defined( PLATFORM_WIN_CE )
+#ifdef WIN32
     // Read high performance counter
     LARGE_INTEGER curTick;
     QueryPerformanceCounter( &curTick );
 #else
     timeval tv;
     gettimeofday( &tv, 0x0 );
-    return (double)tv.tv_sec * 1000000.0 + (double)tv.tv_usec / 1000000.0;
+    return (double)tv.tv_sec * 1000000.0 + (double)tv.tv_usec;
 #endif
 }
 
 
+double Timer::elapsed_time_in_us()
+{
+	if (_enabled)
+	{
+        double endTime = get_tick_in_us();
+        _elapsedTimeInMicroSec += endTime - _startTimeInMicroSec;
+        _startTimeInMicroSec = endTime;
+    }
 
-} // namespace
+    return _elapsedTimeInMicroSec;
+}
 
+double Timer::elapsed_time_in_ms()
+{
+    return this->elapsed_time_in_us() * 0.001;
+}
+
+double Timer::elapsed_time_in_sec()
+{
+    return this->elapsed_time_in_us() * 0.000001;
+}
+
+
+}	// namespace
+

File temp/test_hordefiles/knight/app.cpp

 {	
 	// Initialize engine
 	if( !h3dInit() )
-	{	
-		h3dutDumpMessages();
 		return false;
-	}
 
 	// Set options
 	h3dSetOption( Horde3D::EngineOptions::LoadTextures, 1 );
 
 	// Remove all overlays
 	h3dClearOverlays();
-
-	// Write all messages to log file
-	h3dutDumpMessages();
 }
 
 

File temp/test_hordefiles/samba/app.cpp

 {	
 	// Initialize engine
 	if( !h3dInit() )
-	{	
-		h3dutDumpMessages();
 		return false;
-	}
 
 	// Set options
 	h3dSetOption( Horde3D::EngineOptions::LoadTextures, 1 );
 
 	// Remove all overlays
 	h3dClearOverlays();
-
-	// Write all messages to log file
-	h3dutDumpMessages();
 }
 
 

File temp/test_hordefiles/utMath.h

 	{ 
 	}
 
-	explicit Vec3f( Math::NoInitHint )
-	{
-		// Constructor without default initialization
-	}
+	// explicit Vec3f( Math::NoInitHint )
+	// {
+	// 	// Constructor without default initialization
+	// }
 	
 	Vec3f( const float x, const float y, const float z ) : x( x ), y( y ), z( z ) 
 	{
 };
 
 
-// -------------------------------------------------------------------------------------------------
-// Plane
-// -------------------------------------------------------------------------------------------------
-
-class Plane
-{
-public:
-	Vec3f normal; 
-	float dist;
-
-	// ------------
-	// Constructors
-	// ------------
-	Plane() 
-	{ 
-		normal.x = 0; normal.y = 0; normal.z = 0; dist = 0; 
-	};
-
-	explicit Plane( const float a, const float b, const float c, const float d )
-	{
-		normal = Vec3f( a, b, c );
-		float invLen = 1.0f / normal.length();
-		normal *= invLen;	// Normalize
-		dist = d * invLen;
-	}
-
-	Plane( const Vec3f &v0, const Vec3f &v1, const Vec3f &v2 )
-	{
-		normal = v1 - v0;
-		normal = normal.cross( v2 - v0 );
-		normal.normalize();
-		dist = -normal.dot( v0 );
-	}
-
-	// ----------------
-	// Other operations
-	// ----------------
-	float distToPoint( const Vec3f &v ) const
-	{
-		return normal.dot( v ) + dist;
-	}
-};
-
 
 // -------------------------------------------------------------------------------------------------
 // Intersection

File temp/test_hordefiles/utPlatform.h

 #ifndef _utPlatform_H_
 #define _utPlatform_H_
 
-#include <stdint.h>		// fixed size int types
 
 #if defined( _DEBUG )
 	#include <assert.h>

File temp/test_hordefiles/utils_main.cpp

 }
 
 
-bool h3dutDumpMessages()
-{
-	if( !outf.is_open() )
-	{
-		// Reset log file
-		outf.setf( ios::fixed );
-		outf.precision( 3 );
-		outf.open( "Horde3D_Log.html", ios::out );
-		if( !outf ) return false;
-
-		outf << "<html>\n";
-		outf << "<head>\n";
-		outf << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
-		outf << "<title>Horde3D Log</title>\n";
-		outf << "<style type=\"text/css\">\n";
-		
-		outf << "body, html {\n";
-		outf << "background: #000000;\n";
-		outf << "width: 1000px;\n";
-		outf << "font-family: Arial;\n";
-		outf << "font-size: 16px;\n";
-		outf << "color: #C0C0C0;\n";
-		outf << "}\n";
-
-		outf << "h1 {\n";
-		outf << "color : #FFFFFF;\n";
-		outf << "border-bottom : 1px dotted #888888;\n";
-		outf << "}\n";
-
-		outf << "pre {\n";
-		outf << "font-family : arial;\n";
-		outf << "margin : 0;\n";
-		outf << "}\n";
-
-		outf << ".box {\n";
-		outf << "border : 1px dotted #818286;\n";
-		outf << "padding : 5px;\n";
-		outf << "margin: 5px;\n";
-		outf << "width: 950px;\n";
-		outf << "background-color : #292929;\n";
-		outf << "}\n";
-
-		outf << ".err {\n";
-		outf << "color: #EE1100;\n";
-		outf << "font-weight: bold\n";
-		outf << "}\n";
-
-		outf << ".warn {\n";
-		outf << "color: #FFCC00;\n";
-		outf << "font-weight: bold\n";
-		outf << "}\n";
-
-		outf << ".info {\n";
-		outf << "color: #C0C0C0;\n";
-		outf << "}\n";
-
-		outf << ".debug {\n";
-		outf << "color: #CCA0A0;\n";
-		outf << "}\n";
-
-		outf << "</style>\n";
-		outf << "</head>\n\n";
-
-		outf << "<body>\n";
-		outf << "<h1>Horde3D Log</h1>\n";
-		outf << "<h3>" << h3dGetVersionString() << "</h3>\n";
-		outf << "<div class=\"box\">\n";
-		outf << "<table>\n";
-
-		outf.flush();
-	}
-
-	int level;
-	float time;
-	string text = h3dGetMessage( &level, &time );
-	
-	while( text != "" )
-	{
-		outf << "<tr>\n";
-		outf << "<td width=\"100\">";
-		outf << time;
-		outf << "</td>\n";
-		outf << "<td class=\"";
-		
-		switch( level )
-		{
-		case 1:
-			outf << "err";
-			break;
-		case 2:
-			outf << "warn";
-			break;
-		case 3:
-			outf << "info";
-			break;
-		default:
-			outf << "debug";
-		}
-		
-		outf << "\"><pre>\n";
-		outf << text.c_str();
-		outf << "\n</pre></td>\n";
-		outf << "</tr>\n";
-
-		outf.flush();
-		
-		text = h3dGetMessage( &level, &time );
-	}
-	
-	return true;
-}
-
-
 void h3dutShowText( const char *text, float x, float y, float size, float colR,
                            float colG, float colB, ResHandle fontMaterialRes )
 {
 	{	
 		fps = curFPS;
 		frameTime = curFrameTime;
-		animTime = h3dGetStat( Horde3D::EngineStats::AnimationTime, true );
-		geoUpdateTime = h3dGetStat( Horde3D::EngineStats::SkinningTime, true );
-		particleSimTime = h3dGetStat( Horde3D::EngineStats::ParticleSimTime, true );
 		timer = 0;
 	}
-	else
-	{
-		// Reset accumulative counters
-		h3dGetStat( Horde3D::EngineStats::AnimationTime, true );
-		h3dGetStat( Horde3D::EngineStats::SkinningTime, true );
-		h3dGetStat( Horde3D::EngineStats::ParticleSimTime, true );
-	}
 	
 	if( mode > 0 )
 	{