You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(46) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(185) |
Feb
(242) |
Mar
(237) |
Apr
(180) |
May
(102) |
Jun
(278) |
Jul
(114) |
Aug
(92) |
Sep
(246) |
Oct
(212) |
Nov
(279) |
Dec
(99) |
| 2007 |
Jan
(130) |
Feb
(194) |
Mar
(22) |
Apr
(72) |
May
(40) |
Jun
(111) |
Jul
(114) |
Aug
(154) |
Sep
(114) |
Oct
(2) |
Nov
(1) |
Dec
(5) |
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(51) |
Nov
(34) |
Dec
(130) |
| 2009 |
Jan
(22) |
Feb
(20) |
Mar
(41) |
Apr
(45) |
May
(82) |
Jun
(96) |
Jul
(48) |
Aug
(90) |
Sep
(13) |
Oct
(49) |
Nov
(31) |
Dec
(21) |
| 2010 |
Jan
(25) |
Feb
(9) |
Mar
(7) |
Apr
(28) |
May
(27) |
Jun
(7) |
Jul
(1) |
Aug
|
Sep
(1) |
Oct
(1) |
Nov
(13) |
Dec
(2) |
| 2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <cn...@us...> - 2008-12-30 21:25:25
|
Revision: 108
http://hgengine.svn.sourceforge.net/hgengine/?rev=108&view=rev
Author: cnlohr
Date: 2008-12-30 21:25:22 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
clean up the XML parser and switch to MString
Modified Paths:
--------------
Mercury2/src/XMLParser.cpp
Mercury2/src/XMLParser.h
Modified: Mercury2/src/XMLParser.cpp
===================================================================
--- Mercury2/src/XMLParser.cpp 2008-12-30 21:25:06 UTC (rev 107)
+++ Mercury2/src/XMLParser.cpp 2008-12-30 21:25:22 UTC (rev 108)
@@ -1,4 +1,7 @@
#include <XMLParser.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
//#include <SMOException.h>
XMLNode::XMLNode(xmlNode* node, xmlDoc* doc)
@@ -39,34 +42,34 @@
return XMLNode();
}
-std::string XMLNode::Name() const
+MString XMLNode::Name() const
{
- return std::string((const char*)m_node->name); //XXX fix utf8
+ return MString((const char*)m_node->name); //XXX fix utf8
}
-std::string XMLNode::Content() const
+MString XMLNode::Content() const
{
- string data;
+ MString data;
// xmlChar* d = xmlNodeListGetString(m_doc, m_node->xmlChildrenNode, 1);
xmlChar* d = xmlNodeGetContent(m_node);
if (d)
{
- data = string((const char*)d);
+ data = MString((const char*)d);
xmlFree(d);
}
return data;
}
-std::string XMLNode::Attribute(const std::string& tag) const
+MString XMLNode::Attribute(const MString& tag) const
{
- string data;
+ MString data;
xmlChar* d = xmlGetProp(m_node, (const xmlChar*)tag.c_str());
if (d)
{
- data = string((const char*)d);
+ data = MString((const char*)d);
xmlFree(d);
}
return data;
@@ -88,7 +91,7 @@
if (m_doc) xmlFreeDoc(m_doc);
}
-XMLDocument* XMLDocument::Load(const std::string& file)
+XMLDocument* XMLDocument::Load(const MString& file)
{
XMLDocument* xmldoc = new XMLDocument();
@@ -98,7 +101,7 @@
return xmldoc;
}
-void XMLDocument::LoadFromString(const std::string& xml)
+void XMLDocument::LoadFromString(const MString& xml)
{
xmlInitParser(); //XXX WTF am I supposed to do with this
m_doc = xmlReadMemory(xml.c_str(), xml.length(), "noname.xml", NULL, 0);
Modified: Mercury2/src/XMLParser.h
===================================================================
--- Mercury2/src/XMLParser.h 2008-12-30 21:25:06 UTC (rev 107)
+++ Mercury2/src/XMLParser.h 2008-12-30 21:25:22 UTC (rev 108)
@@ -1,11 +1,13 @@
#ifndef XMLPARSER_H
#define XMLPARSER_H
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <string>
#include <MAutoPtr.h>
+struct _xmlNode;
+typedef struct _xmlNode xmlNode;
+struct _xmlDoc;
+typedef struct _xmlDoc xmlDoc;
+
class XMLElement
{
public:
@@ -23,9 +25,9 @@
XMLNode PreviousNode() const;
XMLNode Child() const;
- std::string Name() const;
- std::string Content() const;
- std::string Attribute(const std::string& tag) const;
+ MString Name() const;
+ MString Content() const;
+ MString Attribute(const MString & tag) const;
inline bool IsValid() const { return m_node!=NULL; }
@@ -40,8 +42,8 @@
XMLDocument();
virtual ~XMLDocument();
- static XMLDocument* Load(const std::string& file);
- void LoadFromString(const std::string& xml);
+ static XMLDocument* Load(const MString& file);
+ void LoadFromString(const MString& xml);
XMLNode GetRootNode();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-30 21:25:12
|
Revision: 107
http://hgengine.svn.sourceforge.net/hgengine/?rev=107&view=rev
Author: cnlohr
Date: 2008-12-30 21:25:06 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
add MercuryString
Added Paths:
-----------
Mercury2/src/MercuryString.cpp
Mercury2/src/MercuryString.h
Added: Mercury2/src/MercuryString.cpp
===================================================================
--- Mercury2/src/MercuryString.cpp (rev 0)
+++ Mercury2/src/MercuryString.cpp 2008-12-30 21:25:06 UTC (rev 107)
@@ -0,0 +1,453 @@
+#include "MercuryString.h"
+#include <stdlib.h>
+#include <string.h>
+
+//For ssprintf.
+#include <stdarg.h>
+#include <stdio.h>
+
+#define BASE_ALLOC 16
+
+#define NEXT_ALLOC( x, y ) ( x + y + BASE_ALLOC )
+
+#define MANAGE_ALLOC( y ) \
+ if ( m_iLen + y + 1 > m_iAlloc ) \
+ { \
+ m_iAlloc = NEXT_ALLOC( m_iLen, y ); \
+ m_sCur = (char*)realloc( m_sCur, m_iAlloc ); \
+ }
+
+MString::MString()
+{
+ m_sCur = (char*)malloc( BASE_ALLOC );
+ m_sCur[0] = '\0';
+ m_iLen = 0;
+ m_iAlloc = BASE_ALLOC;
+}
+
+MString::MString( int iPreAlloc )
+{
+ m_sCur = (char*)malloc( iPreAlloc );
+ m_sCur[0] = '\0';
+ m_iLen = 0;
+ m_iAlloc = iPreAlloc;
+}
+
+MString::MString( const char sIn )
+{
+ m_iLen = 1;
+ m_iAlloc = 2;
+ m_sCur = (char*)malloc( m_iAlloc );
+ m_sCur[0] = sIn;
+ m_sCur[1] = '\0';
+}
+
+MString::MString( const char * sIn )
+{
+ m_iLen = strlen( sIn );
+ m_iAlloc = m_iLen + 1;
+ m_sCur = (char*)malloc( m_iAlloc );
+ memcpy( m_sCur, sIn, m_iAlloc );
+}
+
+MString::MString( const char * sIn, int iSize )
+{
+ m_iLen = iSize;
+ m_iAlloc = m_iLen + 1;
+ m_sCur = (char*)malloc( m_iAlloc );
+ memcpy( m_sCur, sIn, m_iLen );
+ m_sCur[m_iLen] = '\0';
+}
+
+MString::MString( const MString & rhs )
+{
+ m_iLen = rhs.m_iLen;
+ m_iAlloc = rhs.m_iAlloc;
+ m_sCur = (char*)malloc( m_iAlloc );
+ memcpy( m_sCur, rhs.m_sCur, m_iLen );
+ m_sCur[m_iLen] = '\0';
+}
+
+MString::~MString()
+{
+ free(m_sCur);
+}
+
+const MString & MString::operator = ( const MString & rhs )
+{
+ if (&rhs != this)
+ {
+ free (m_sCur);
+ m_iLen = rhs.m_iLen;
+ m_iAlloc = rhs.m_iAlloc;
+ m_sCur = (char*)malloc( m_iAlloc );
+ memcpy( m_sCur, rhs.m_sCur, m_iLen );
+ m_sCur[m_iLen] = '\0';
+ }
+ return (*this);
+}
+
+const MString & MString::operator = ( const char * rhs )
+{
+ if (rhs != m_sCur)
+ {
+ free (m_sCur);
+ m_iLen = strlen( rhs );
+ m_iAlloc = m_iLen + 1;
+ m_sCur = (char*)malloc( m_iAlloc );
+ memcpy( m_sCur, rhs, m_iAlloc );
+ }
+ return (*this);
+}
+
+const MString MString::operator + ( const MString & rhs ) const
+{
+ int iNextMalloc = NEXT_ALLOC( m_iLen, rhs.m_iLen );
+ MString ret( iNextMalloc );
+ ret.m_iLen = m_iLen + rhs.m_iLen;
+ memcpy( ret.m_sCur, m_sCur, m_iLen );
+ memcpy( ret.m_sCur + m_iLen, rhs.m_sCur, rhs.m_iLen );
+ ret.m_sCur[ret.m_iLen] = '\0';
+ return ret;
+}
+
+const MString MString::operator + ( const char * rhs ) const
+{
+ if ( !rhs )
+ return (*this);
+ int iRhsLen = strlen( rhs );
+ int iNextMalloc = NEXT_ALLOC( m_iLen, iRhsLen );
+ MString ret( iNextMalloc );
+ ret.m_iLen = m_iLen + iRhsLen;
+ memcpy( ret.m_sCur, m_sCur, m_iLen );
+ memcpy( ret.m_sCur + m_iLen, rhs, iRhsLen );
+ ret.m_sCur[ret.m_iLen] = '\0';
+ return ret;
+}
+
+const MString MString::operator + ( const char rhs ) const
+{
+ int iNextMalloc = NEXT_ALLOC( m_iLen, 1 );
+ MString ret( iNextMalloc );
+ ret.m_iLen = m_iLen + 1;
+ memcpy( ret.m_sCur, m_sCur, m_iLen );
+ ret.m_sCur[ret.m_iLen - 1] = rhs;
+ ret.m_sCur[ret.m_iLen] = '\0';
+ return ret;
+}
+
+const MString & MString::operator += ( const char * rhs )
+{
+ int iRhsLen = strlen( rhs );
+ MANAGE_ALLOC( iRhsLen )
+ memcpy( m_sCur + m_iLen, rhs, iRhsLen );
+ m_iLen += iRhsLen;
+ m_sCur[m_iLen] = '\0';
+ return (*this);
+}
+
+const MString & MString::operator += ( const MString & rhs )
+{
+ MANAGE_ALLOC( rhs.m_iLen )
+ memcpy( m_sCur + m_iLen, rhs.m_sCur, rhs.m_iLen );
+ m_iLen += rhs.m_iLen;
+ m_sCur[m_iLen] = '\0';
+ return (*this);
+}
+
+const MString & MString::operator += ( const char rhs )
+{
+ MANAGE_ALLOC( 1 )
+ m_sCur[m_iLen] = rhs;
+ m_iLen++;
+ m_sCur[m_iLen] = '\0';
+ return (*this);
+}
+
+bool MString::operator == ( const MString & rhs )
+{
+ return strcmp( m_sCur, rhs.m_sCur ) == 0;
+}
+
+bool MString::operator == ( const char * rhs )
+{
+ return strcmp( m_sCur, rhs ) == 0;
+}
+
+bool MString::operator < ( const MString & rhs )
+{
+ return strcmp( m_sCur, rhs.m_sCur ) < 0;
+}
+
+bool MString::operator > ( const MString & rhs )
+{
+ return strcmp( m_sCur, rhs.m_sCur ) > 0;
+}
+
+void MString::append( const MString & app )
+{
+ MANAGE_ALLOC( app.m_iLen )
+ memcpy( m_sCur + m_iLen, app.m_sCur, app.m_iLen );
+ m_iLen += app.m_iLen;
+ m_sCur[m_iLen] = '\0';
+}
+
+void MString::append( const char app )
+{
+ MANAGE_ALLOC( 1 )
+ m_sCur[m_iLen] = app;
+ m_iLen++;
+ m_sCur[m_iLen] = '\0';
+}
+
+void MString::append( const char * app )
+{
+ int iRhsLen = strlen( app );
+ MANAGE_ALLOC( iRhsLen )
+ memcpy( m_sCur + m_iLen, app, iRhsLen );
+ m_iLen += iRhsLen;
+ m_sCur[m_iLen] = '\0';
+}
+
+void MString::append( const char * app, int len )
+{
+ MANAGE_ALLOC( len )
+ memcpy( m_sCur + m_iLen, app, len );
+ m_iLen += len;
+ m_sCur[m_iLen] = '\0';
+}
+
+void MString::append( const char app, int len )
+{
+ MANAGE_ALLOC( len )
+ memset( m_sCur + m_iLen, app, len );
+ m_iLen += len;
+ m_sCur[m_iLen] = '\0';
+}
+
+void MString::assign( const MString & app )
+{
+ free( m_sCur );
+ m_iLen = app.m_iLen;
+ m_iAlloc = app.m_iAlloc;
+ m_sCur = (char*)malloc( m_iAlloc );
+ memcpy( m_sCur, app.m_sCur, m_iLen );
+ m_sCur[m_iLen] = '\0';
+}
+
+void MString::assign( const char * app )
+{
+ free( m_sCur );
+ m_iLen = strlen( app );
+ m_iAlloc = m_iLen + 1;
+ m_sCur = (char*)malloc( m_iAlloc );
+ memcpy( m_sCur, app, m_iAlloc );
+}
+
+void MString::assign( const char * app, int len )
+{
+ free( m_sCur );
+ m_iLen = len;
+ m_iAlloc = m_iLen + 1;
+ m_sCur = (char*)malloc( m_iAlloc );
+ memcpy( m_sCur, app, m_iLen );
+ m_sCur[m_iLen] = '\0';
+}
+
+int MString::find( const MString & tofind, int start ) const
+{
+ const char * ret = strstr( m_sCur + start, tofind.m_sCur );
+ return (ret)?(ret-m_sCur):npos;
+}
+
+int MString::rfind( const MString & tofind ) const
+{
+ int iLen = tofind.length();
+ int iTarg = m_iLen - iLen;
+
+ while ( iTarg >= 0 )
+ {
+ if ( strncmp( tofind.m_sCur+iTarg, tofind, iLen ) == 0 )
+ return iTarg;
+ iTarg--;
+ }
+ return npos;
+}
+
+int MString::find( const char * tofind, int start ) const
+{
+ const char * ret = strstr( m_sCur + start, tofind );
+ return (ret)?(ret-m_sCur):npos;
+}
+
+int MString::rfind( const char * tofind ) const
+{
+ int iLen = strlen( tofind );
+ int iTarg = m_iLen - iLen;
+
+ while ( iTarg >= 0 )
+ {
+ if ( strncmp( m_sCur+iTarg, tofind, iLen ) == 0 )
+ return iTarg;
+ iTarg--;
+ }
+ return npos;
+}
+
+int MString::find( const char tofind, int start ) const
+{
+ const char * ret = strchr( m_sCur + start, tofind );
+ return (ret)?(ret-m_sCur):npos;
+}
+
+int MString::rfind( const char tofind ) const
+{
+ const char * ret = strrchr( m_sCur, tofind );
+ return (ret)?(ret-m_sCur):npos;
+}
+
+const MString MString::substr( int iStart ) const
+{
+ return MString( m_sCur + iStart, m_iLen - iStart );
+}
+
+const MString MString::substr( int iStart, int iLength ) const
+{
+ return MString( m_sCur + iStart, iLength );
+}
+
+int MString::compare( const MString & cmp ) const
+{
+ return strcmp( m_sCur, cmp.m_sCur );
+}
+
+int MString::compare( const char * cmp ) const
+{
+ return strcmp( m_sCur, cmp );
+}
+
+int MString::compare( int start, int len, const MString & cmp ) const
+{
+ return strncmp( m_sCur + start, cmp.m_sCur, len );
+}
+
+int MString::compare( int start, int len, const char * cmp ) const
+{
+ return strncmp( m_sCur + start, cmp, len );
+}
+
+unsigned int MString::hash() const
+{
+ unsigned int ret = 0;
+ unsigned int i;
+ unsigned int j = size()>>2;
+ for( i = 0; i < j; i++ )
+ ret += ((unsigned int *)m_sCur)[i];
+
+ for( i = j<<2; i < size(); i++ )
+ ret += (unsigned int)(unsigned char)m_sCur[i];
+
+ return ret;
+}
+
+void MString::resize( unsigned int size )
+{
+ if( size <= m_iLen )
+ {
+ m_iLen = size;
+ m_sCur[size] = '\0';
+ } else
+ {
+ MANAGE_ALLOC( size )
+ }
+}
+
+bool operator < ( const MString & lhs, const MString & rhs )
+{
+ return strcmp( lhs.m_sCur, rhs.m_sCur ) < 0;
+}
+
+bool operator > ( const MString & lhs, const MString & rhs )
+{
+ return strcmp( lhs.m_sCur, rhs.m_sCur ) > 0;
+}
+
+//YUCK! This cannot be a friend function becuse of VC6 internal compiler error!
+MString operator + ( const char * lhs, const MString & rhs )
+{
+ return MString( lhs ) + rhs;
+}
+
+MString operator + ( const char lhs, const MString & rhs )
+{
+ return MString( lhs ) + rhs;
+}
+
+#define FMT_BLOCK_SIZE 127
+
+MString ssprintf( const char *fmt, ...)
+{
+ if ( strlen(fmt)==0 )
+ return MString("");
+
+
+ int CurMal = FMT_BLOCK_SIZE;
+ MString ret;
+
+ while ( true )
+ {
+ va_list va;
+ va_start(va, fmt);
+ char * base = (char*)malloc( CurMal + 1 );
+ #if defined(WIN32)
+ int len = _vsnprintf( base, CurMal, fmt, va );
+ #else
+ int len = vsnprintf( base, CurMal, fmt, va );
+ #endif
+
+ va_end( va );
+
+ if (len > CurMal)
+ while (CurMal < len)
+ CurMal*=2;
+ else
+ if ( len > 0 )
+ {
+ ret.assign( base, len );
+ free( base );
+ break;
+ } else
+ CurMal*=2;
+
+ free(base);
+ }
+ return ret;
+}
+
+/*
+ * Copyright (c) 2006,2008, Charles Lohr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Mercury Engine nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
Added: Mercury2/src/MercuryString.h
===================================================================
--- Mercury2/src/MercuryString.h (rev 0)
+++ Mercury2/src/MercuryString.h 2008-12-30 21:25:06 UTC (rev 107)
@@ -0,0 +1,133 @@
+#ifndef _MERCURY_STRING_H
+#define _MERCURY_STRING_H
+
+///Very fast String class
+class MString
+{
+public:
+ MString();
+ MString( int iPreAlloc );
+ MString( const char sIn );
+ MString( const char * sIn );
+ MString( const char * sIn, int iSize );
+ MString( const MString & rhs );
+ ~MString();
+
+ const MString & operator = ( const MString & rhs );
+ const MString & operator = ( const char * rhs );
+ const MString operator + ( const MString & rhs ) const;
+ const MString operator + ( const char * rhs ) const;
+ const MString operator + ( const char rhs ) const;
+ const MString & operator += ( const char * rhs );
+ const MString & operator += ( const MString & rhs );
+ const MString & operator += ( const char rhs );
+
+ bool operator == ( const MString & rhs );
+ bool operator == ( const char * rhs );
+ bool operator < ( const MString & rhs );
+ bool operator > ( const MString & rhs );
+
+ operator const char * () const { return m_sCur; }
+
+ inline const char * c_str() const { return m_sCur; }
+ inline unsigned long length() const { return m_iLen; }
+ inline unsigned long size() const { return m_iLen; }
+ inline bool empty() const { return m_iLen == 0; }
+
+ void append( const MString & app );
+ void append( const char app );
+ void append( const char * app );
+ void append( const char * app, int len );
+
+ ///Special: Append app len times
+ void append( const char app, int len );
+
+ void assign( const MString & app );
+ void assign( const char * app );
+ void assign( const char * app, int len );
+
+ int find( const MString & tofind, int start = 0 ) const;
+ int rfind( const MString & tofind ) const;
+ inline int find_last_of( const MString & tofind ) const { return rfind( tofind ); }
+
+ int find( const char * tofind,int start = 0 ) const;
+ int find( const char tofind, int start = 0 ) const;
+ int rfind( const char * tofind ) const;
+ int rfind( const char tofind ) const;
+ inline int find_last_of( const char * tofind ) const { return rfind( tofind ); }
+
+ const MString substr( int iStart ) const;
+ const MString substr( int iStart, int iLength ) const;
+
+ int compare( const MString & cmp ) const;
+ int compare( const char * cmp ) const;
+
+ int compare( int start, int len, const MString & cmp ) const;
+ int compare( int start, int len, const char * cmp ) const;
+
+ unsigned int hash() const;
+
+ enum
+ {
+ npos = -1
+ };
+
+ void resize( unsigned int size );
+private:
+ char * m_sCur;
+ unsigned int m_iLen;
+ unsigned int m_iAlloc;
+ friend bool operator < ( const MString & lhs, const MString & rhs );
+ friend bool operator > ( const MString & lhs, const MString & rhs );
+};
+
+/* //Keep around incase we need to debug a little and use our old string
+#include "StdString.h"
+typedef StdString::CStdString MString;
+*/
+
+bool operator < ( const MString & lhs, const MString & rhs );
+bool operator > ( const MString & lhs, const MString & rhs );
+inline bool operator == ( const MString & lhs, const char * rhs ) { return lhs.compare( rhs ) == 0; }
+inline bool operator != ( const MString & lhs, const char * rhs ) { return lhs.compare( rhs ) != 0; }
+
+MString operator + ( const char lhs, const MString & rhs );
+MString operator + ( const char * lhs, const MString & rhs );
+
+#if defined(__GNUC__)
+#define PRINTF(a,b) __attribute__((format(__printf__,a,b)))
+#else
+#define PRINTF(a,b)
+#endif
+
+MString ssprintf( const char *fmt, ...) PRINTF(1,2);
+
+#endif
+
+/*
+ * Copyright (c) 2006,2008, Charles Lohr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Mercury Engine nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-30 21:11:32
|
Revision: 106
http://hgengine.svn.sourceforge.net/hgengine/?rev=106&view=rev
Author: axlecrusher
Date: 2008-12-30 21:11:29 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
remove MercuryUtil.h
Modified Paths:
--------------
Mercury2/src/MAutoPtr.h
Modified: Mercury2/src/MAutoPtr.h
===================================================================
--- Mercury2/src/MAutoPtr.h 2008-12-30 20:45:08 UTC (rev 105)
+++ Mercury2/src/MAutoPtr.h 2008-12-30 21:11:29 UTC (rev 106)
@@ -4,7 +4,6 @@
//#include <util.h>
//#include <stdlib.h>
//#include <stdio.h>
-#include <MercuryUtil.h>
#include <MercuryThreads.h>
class RefBase
@@ -130,7 +129,7 @@
{
if ( !m_ptr->m_count ) return;
if (m_ptr->m_count > 0) --(m_ptr->m_count);
- if (m_ptr->m_count == 0) SAFE_DELETE(m_ptr);
+ if (m_ptr->m_count == 0) { if (m_ptr) { delete m_ptr; } m_ptr = NULL; }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-30 20:45:18
|
Revision: 105
http://hgengine.svn.sourceforge.net/hgengine/?rev=105&view=rev
Author: axlecrusher
Date: 2008-12-30 20:45:08 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
add -DHGENGINE
Modified Paths:
--------------
Mercury2/mercury2.kdevelop
Modified: Mercury2/mercury2.kdevelop
===================================================================
--- Mercury2/mercury2.kdevelop 2008-12-30 20:28:34 UTC (rev 104)
+++ Mercury2/mercury2.kdevelop 2008-12-30 20:45:08 UTC (rev 105)
@@ -2,7 +2,7 @@
<kdevelop>
<general>
<author>Joshua Allen</author>
- <email/>
+ <email></email>
<version>2.0</version>
<projectmanagement>KDevAutoProject</projectmanagement>
<primarylanguage>C++</primarylanguage>
@@ -14,14 +14,14 @@
<projectname>Mercury2</projectname>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
- <description/>
- <defaultencoding/>
+ <description></description>
+ <defaultencoding></defaultencoding>
<versioncontrol/>
</general>
<kdevautoproject>
<general>
<activetarget>src/mercury2</activetarget>
- <useconfiguration>debug</useconfiguration>
+ <useconfiguration>optimized</useconfiguration>
</general>
<run>
<mainprogram>/home/josh/Mercury2/debug/src/mercury2</mainprogram>
@@ -43,16 +43,15 @@
<f77compiler>kdevg77options</f77compiler>
<cxxflags>-O2 -g0 -Wall</cxxflags>
<envvars/>
- <configargs/>
- <topsourcedir/>
- <cppflags>-Isrc/ -I/usr/include/libxml2/
-</cppflags>
+ <configargs></configargs>
+ <topsourcedir></topsourcedir>
+ <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE</cppflags>
<ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags>
- <ccompilerbinary/>
- <cxxcompilerbinary/>
- <f77compilerbinary/>
- <cflags/>
- <f77flags/>
+ <ccompilerbinary></ccompilerbinary>
+ <cxxcompilerbinary></cxxcompilerbinary>
+ <f77compilerbinary></f77compilerbinary>
+ <cflags></cflags>
+ <f77flags></f77flags>
</optimized>
<debug>
<configargs>--enable-debug=full</configargs>
@@ -62,15 +61,14 @@
<f77compiler>kdevg77options</f77compiler>
<cxxflags>-O0 -g3 -Wall</cxxflags>
<envvars/>
- <topsourcedir/>
- <cppflags>-Isrc/ -I/usr/include/libxml2/
-</cppflags>
+ <topsourcedir></topsourcedir>
+ <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE</cppflags>
<ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags>
- <ccompilerbinary/>
- <cxxcompilerbinary/>
- <f77compilerbinary/>
- <cflags/>
- <f77flags/>
+ <ccompilerbinary></ccompilerbinary>
+ <cxxcompilerbinary></cxxcompilerbinary>
+ <f77compilerbinary></f77compilerbinary>
+ <cflags></cflags>
+ <f77flags></f77flags>
</debug>
</configurations>
<make>
@@ -207,7 +205,7 @@
<includePaths>.;</includePaths>
</codecompletion>
<creategettersetter>
- <prefixGet/>
+ <prefixGet></prefixGet>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>
@@ -228,11 +226,11 @@
</cppsupportpart>
<kdevdebugger>
<general>
- <gdbpath/>
+ <gdbpath></gdbpath>
<dbgshell>libtool</dbgshell>
- <configGdbScript/>
- <runShellScript/>
- <runGdbScript/>
+ <configGdbScript></configGdbScript>
+ <runShellScript></runShellScript>
+ <runGdbScript></runGdbScript>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-30 20:28:38
|
Revision: 104
http://hgengine.svn.sourceforge.net/hgengine/?rev=104&view=rev
Author: axlecrusher
Date: 2008-12-30 20:28:34 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
add vertex structure
Modified Paths:
--------------
Mercury2/docs/MercuryBinaryModelFormat.odt
Modified: Mercury2/docs/MercuryBinaryModelFormat.odt
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-30 19:56:46
|
Revision: 103
http://hgengine.svn.sourceforge.net/hgengine/?rev=103&view=rev
Author: axlecrusher
Date: 2008-12-30 19:56:41 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
update
Modified Paths:
--------------
Mercury2/scenegraph.xml
Mercury2/src/HGMDLModel.cpp
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2008-12-30 19:49:26 UTC (rev 102)
+++ Mercury2/scenegraph.xml 2008-12-30 19:56:41 UTC (rev 103)
@@ -20,7 +20,7 @@
<asset type="quad"/>
</node>
</node>
- <node type="rotatornode" movz="-3" scalex="0.05" scaley="0.05" scalez="0.05" >
+ <node type="rotatornode" movz="-2" scalex="0.05" scaley="0.05" scalez="0.05" >
<node type="renderablenode">
<asset type="texture" imagefile="test.bmp"/>
<asset type="hgmdlmodel" file="beerhall.hgmdl"/>
Modified: Mercury2/src/HGMDLModel.cpp
===================================================================
--- Mercury2/src/HGMDLModel.cpp 2008-12-30 19:49:26 UTC (rev 102)
+++ Mercury2/src/HGMDLModel.cpp 2008-12-30 19:56:41 UTC (rev 103)
@@ -18,8 +18,7 @@
fingerPrint[4] = 0;
fread(fingerPrint, 4, 1, hgmdl);
- string p(fingerPrint);
- if (p != "MBMF")
+ if (string(fingerPrint) != "MBMF")
{
printf("Not a HGMDL file.\n");
return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-30 19:49:28
|
Revision: 102
http://hgengine.svn.sourceforge.net/hgengine/?rev=102&view=rev
Author: axlecrusher
Date: 2008-12-30 19:49:26 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
warn when an asset type is not found
Modified Paths:
--------------
Mercury2/src/MercuryAsset.cpp
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2008-12-30 19:40:22 UTC (rev 101)
+++ Mercury2/src/MercuryAsset.cpp 2008-12-30 19:49:26 UTC (rev 102)
@@ -30,6 +30,7 @@
std::list< std::pair< std::string, Callback0R< MAutoPtr<MercuryAsset> > > >::iterator i;
for (i = m_factoryCallbacks.begin(); i != m_factoryCallbacks.end(); ++i)
if (i->first == t) return i->second();
+ printf("WARNING: Asset type %s not found.\n", type.c_str());
return NULL;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-30 19:40:26
|
Revision: 101
http://hgengine.svn.sourceforge.net/hgengine/?rev=101&view=rev
Author: axlecrusher
Date: 2008-12-30 19:40:22 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
enable depth test
Modified Paths:
--------------
Mercury2/src/X11Window.cpp
Modified: Mercury2/src/X11Window.cpp
===================================================================
--- Mercury2/src/X11Window.cpp 2008-12-30 19:40:00 UTC (rev 100)
+++ Mercury2/src/X11Window.cpp 2008-12-30 19:40:22 UTC (rev 101)
@@ -72,6 +72,7 @@
m_window = win;
m_renderCtx = ctx;
+ glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-30 19:40:03
|
Revision: 100
http://hgengine.svn.sourceforge.net/hgengine/?rev=100&view=rev
Author: cnlohr
Date: 2008-12-30 19:40:00 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
include models
Modified Paths:
--------------
Mercury2/adv_set.c
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2008-12-30 19:36:06 UTC (rev 99)
+++ Mercury2/adv_set.c 2008-12-30 19:40:00 UTC (rev 100)
@@ -12,7 +12,8 @@
src/Texture.cpp src/RawImageData.cpp src/BMPLoader.cpp \
src/PNGLoader.cpp src/ImageLoader.cpp \
src/MercuryVBO.cpp src/MSemaphore.cpp \
- src/UpdateThreader.cpp"
+ src/UpdateThreader.cpp src/HGMDLMesh.cpp \
+ src/HGMDLModel.cpp"
#ifdef USE_LIBXML
SOURCES="$SOURCES src/XMLParser.cpp"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-30 19:36:15
|
Revision: 99
http://hgengine.svn.sourceforge.net/hgengine/?rev=99&view=rev
Author: cnlohr
Date: 2008-12-30 19:36:06 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
correctly truncate fingerprint
Modified Paths:
--------------
Mercury2/src/HGMDLModel.cpp
Modified: Mercury2/src/HGMDLModel.cpp
===================================================================
--- Mercury2/src/HGMDLModel.cpp 2008-12-30 19:21:53 UTC (rev 98)
+++ Mercury2/src/HGMDLModel.cpp 2008-12-30 19:36:06 UTC (rev 99)
@@ -15,7 +15,7 @@
void HGMDLModel::LoadModel(FILE* hgmdl)
{
char fingerPrint[5];
- fingerPrint[5] = 0;
+ fingerPrint[4] = 0;
fread(fingerPrint, 4, 1, hgmdl);
string p(fingerPrint);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-30 19:22:00
|
Revision: 98
http://hgengine.svn.sourceforge.net/hgengine/?rev=98&view=rev
Author: axlecrusher
Date: 2008-12-30 19:21:53 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
updates
Modified Paths:
--------------
Mercury2/docs/MercuryBinaryModelFormat.odt
Mercury2/mercury2.kdevelop
Mercury2/scenegraph.xml
Mercury2/src/HGMDLModel.cpp
Mercury2/src/HGMDLModel.h
Mercury2/src/TransformNode.cpp
Mercury2/src/TransformNode.h
Mercury2/src/X11Window.cpp
Added Paths:
-----------
Mercury2/beerhall.hgmdl
Added: Mercury2/beerhall.hgmdl
===================================================================
(Binary files differ)
Property changes on: Mercury2/beerhall.hgmdl
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: Mercury2/docs/MercuryBinaryModelFormat.odt
===================================================================
(Binary files differ)
Modified: Mercury2/mercury2.kdevelop
===================================================================
--- Mercury2/mercury2.kdevelop 2008-12-30 15:25:26 UTC (rev 97)
+++ Mercury2/mercury2.kdevelop 2008-12-30 19:21:53 UTC (rev 98)
@@ -41,7 +41,18 @@
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
- <cxxflags>-O2 -g0</cxxflags>
+ <cxxflags>-O2 -g0 -Wall</cxxflags>
+ <envvars/>
+ <configargs/>
+ <topsourcedir/>
+ <cppflags>-Isrc/ -I/usr/include/libxml2/
+</cppflags>
+ <ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags>
+ <ccompilerbinary/>
+ <cxxcompilerbinary/>
+ <f77compilerbinary/>
+ <cflags/>
+ <f77flags/>
</optimized>
<debug>
<configargs>--enable-debug=full</configargs>
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2008-12-30 15:25:26 UTC (rev 97)
+++ Mercury2/scenegraph.xml 2008-12-30 19:21:53 UTC (rev 98)
@@ -20,4 +20,10 @@
<asset type="quad"/>
</node>
</node>
+ <node type="rotatornode" movz="-3" scalex="0.05" scaley="0.05" scalez="0.05" >
+ <node type="renderablenode">
+ <asset type="texture" imagefile="test.bmp"/>
+ <asset type="hgmdlmodel" file="beerhall.hgmdl"/>
+ </node>
+ </node>
</SceneGraph>
Modified: Mercury2/src/HGMDLModel.cpp
===================================================================
--- Mercury2/src/HGMDLModel.cpp 2008-12-30 15:25:26 UTC (rev 97)
+++ Mercury2/src/HGMDLModel.cpp 2008-12-30 19:21:53 UTC (rev 98)
@@ -46,9 +46,8 @@
void HGMDLModel::Render(MercuryNode* node)
{
- list< MAutoPtr< HGMDLMesh > >::iterator i = m_meshes.begin();
- for(;i != m_meshes.end(); ++i)
- (*i)->Render(node);
+ for(uint16_t i = 0; i < m_meshes.size(); ++i)
+ m_meshes[i]->Render(node);
}
HGMDLModel* HGMDLModel::Generate()
Modified: Mercury2/src/HGMDLModel.h
===================================================================
--- Mercury2/src/HGMDLModel.h 2008-12-30 15:25:26 UTC (rev 97)
+++ Mercury2/src/HGMDLModel.h 2008-12-30 19:21:53 UTC (rev 98)
@@ -4,6 +4,8 @@
#include <MercuryAsset.h>
#include <HGMDLMesh.h>
+#include <vector>
+
class HGMDLModel : public MercuryAsset
{
public:
@@ -16,7 +18,7 @@
virtual void Render(MercuryNode* node);
private:
- std::list< MAutoPtr< HGMDLMesh > > m_meshes;
+ std::vector< MAutoPtr< HGMDLMesh > > m_meshes;
};
#endif
Modified: Mercury2/src/TransformNode.cpp
===================================================================
--- Mercury2/src/TransformNode.cpp 2008-12-30 15:25:26 UTC (rev 97)
+++ Mercury2/src/TransformNode.cpp 2008-12-30 19:21:53 UTC (rev 98)
@@ -1,6 +1,7 @@
#include <TransformNode.h>
REGISTER_NODE_TYPE(TransformNode);
+REGISTER_NODE_TYPE(RotatorNode);
TransformNode::TransformNode()
:m_scale( MercuryPoint(1,1,1) )
@@ -143,6 +144,17 @@
}
}
+void RotatorNode::Update(float dTime)
+{
+ MercuryPoint r = GetRotation();
+ r.x += (dTime)*2.5;
+ r.y += (dTime)*5;
+
+ SetRotation( r );
+
+ TransformNode::Update(dTime);
+}
+
/****************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/TransformNode.h
===================================================================
--- Mercury2/src/TransformNode.h 2008-12-30 15:25:26 UTC (rev 97)
+++ Mercury2/src/TransformNode.h 2008-12-30 19:21:53 UTC (rev 98)
@@ -12,7 +12,7 @@
public:
TransformNode();
- void Update(float dTime);
+ virtual void Update(float dTime);
void SetScale( const MercuryPoint& scale );
void SetPosition( const MercuryPoint& position );
@@ -41,13 +41,20 @@
MercuryPoint m_scale;
MercuryPoint m_position;
MercuryPoint m_rotation;
-
+
// MercuryMatrix m_localMatrix;
MercuryMatrix m_globalMatrix;
bool m_tainted;
};
+class RotatorNode : public TransformNode
+{
+ public:
+ virtual void Update(float dTime);
+ GENRTTI(TransformNode);
+};
+
#endif
/****************************************************************************
Modified: Mercury2/src/X11Window.cpp
===================================================================
--- Mercury2/src/X11Window.cpp 2008-12-30 15:25:26 UTC (rev 97)
+++ Mercury2/src/X11Window.cpp 2008-12-30 19:21:53 UTC (rev 98)
@@ -125,11 +125,13 @@
case KeyPress:
{
XKeyEvent* e = (XKeyEvent*)&event;
+ e->keycode;
break;
}
case KeyRelease:
{
XKeyEvent* e = (XKeyEvent*)&event;
+ e->keycode;
break;
}
case MotionNotify:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-30 15:25:31
|
Revision: 97
http://hgengine.svn.sourceforge.net/hgengine/?rev=97&view=rev
Author: axlecrusher
Date: 2008-12-30 15:25:26 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
OBJ to HGMDL converter
Added Paths:
-----------
Mercury2/tools/
Mercury2/tools/obj2hgmdl/
Mercury2/tools/obj2hgmdl/Makefile
Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp
Added: Mercury2/tools/obj2hgmdl/Makefile
===================================================================
--- Mercury2/tools/obj2hgmdl/Makefile (rev 0)
+++ Mercury2/tools/obj2hgmdl/Makefile 2008-12-30 15:25:26 UTC (rev 97)
@@ -0,0 +1,2 @@
+all:
+ g++ obj2hgmdl.cpp ../../src/MercuryPoint.cpp -I../../src -o obj2hgmdl
Added: Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp
===================================================================
--- Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp (rev 0)
+++ Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp 2008-12-30 15:25:26 UTC (rev 97)
@@ -0,0 +1,162 @@
+#include <iostream>
+#include <fstream>
+#include <vector>
+#include <stdint.h>
+#include <MercuryPoint.h>
+#include <map>
+
+using namespace std;
+
+vector< MercuryPoint > v;
+vector< MercuryPoint > vt;
+vector< MercuryPoint > vn;
+
+struct Vertex
+{
+ MercuryPoint uv;
+ MercuryPoint normal;
+ MercuryPoint position;
+
+ inline bool operator==(const Vertex& rhs)
+ {
+ return (position == rhs.position) && (uv == rhs.uv) && (normal == rhs.normal);
+ }
+};
+
+vector< Vertex > vertice;
+vector< uint16_t > indice;
+/*
+struct Mesh
+{
+ uint32_t nameLength;
+ char* name;
+
+ bool bCache;
+
+ //Mercury2 imposes a limit of 65535 vertice in one VBO mesh
+ uint32_t vertexDataLength; //in bytes
+ char* vertexData;
+
+ //Mercury2 imposes a limit of 65535 indices in one VBO mesh
+ uint16_t numberOfIndices;
+ uint16_t* indices;
+};
+
+Mesh currentMesh;
+*/
+void LineParser(const string &line)
+{
+ string token = line.substr(0,2);
+ if (token == "v ")
+ {
+ MercuryPoint tv;
+ sscanf(line.c_str(), "v %f %f %f", &tv.x, &tv.y, &tv.z);
+ v.push_back(tv);
+ }
+ else if (token == "vt")
+ {
+ MercuryPoint tv;
+ sscanf(line.c_str(), "vt %f %f", &tv.x, &tv.y);
+ vt.push_back(tv);
+ }
+ else if (token == "vn")
+ {
+ MercuryPoint tv;
+ sscanf(line.c_str(), "vn %f %f %f", &tv.x, &tv.y, &tv.z);
+ vn.push_back(tv);
+ }
+ else if (token == "f ")
+ {
+ uint32_t iv[3], ivt[3], ivn[3];
+ sscanf(line.c_str(), "f %d/%d/%d %d/%d/%d %d/%d/%d", &iv[0], &ivt[0], &ivn[0], &iv[1], &ivt[1], &ivn[1], &iv[2], &ivt[2], &ivn[2]);
+
+ Vertex tv[3];
+
+ for (int i=0; i < 3; ++i)
+ {
+ bool found = false;
+ tv[i].position = v[ iv[i]-1 ];
+ tv[i].normal = vn[ ivn[i]-1 ];
+ tv[i].uv = vt[ ivt[i]-1 ];
+
+ for (unsigned long j = 0; j < vertice.size(); ++j)
+ {
+ if (tv[i] == vertice[j])
+ {
+ indice.push_back( j );
+ found = true;
+ break;
+ }
+ }
+
+ if ( !found )
+ {
+ indice.push_back( vertice.size() );
+ vertice.push_back(tv[i]);
+ }
+ }
+ }
+}
+
+void WriteMBMF( FILE *mbmf )
+{
+ uint32_t tmp32;
+ uint16_t tmp16;
+ bool b;
+
+ fwrite("MBMF", 4, 1, mbmf);
+ tmp32 = 200; fwrite(&tmp32, sizeof(uint32_t), 1, mbmf);
+
+ tmp16 = 1; fwrite(&tmp16, sizeof(uint16_t), 1, mbmf);
+
+ //mesh
+ {
+ tmp32 = 4; fwrite(&tmp32, sizeof(uint32_t), 1, mbmf);
+ fwrite("test", 4, 1, mbmf);
+
+ b = false; fwrite(&b, sizeof(bool), 1, mbmf);
+
+ tmp32 = vertice.size()*sizeof(float)*8; fwrite(&tmp32, sizeof(uint32_t), 1, mbmf);
+ cout << tmp32 << endl;
+ for (uint32_t i = 0; i < vertice.size(); ++i)
+ {
+ fwrite(&vertice[i].uv, sizeof(float)*2, 1, mbmf);
+ fwrite(&vertice[i].normal, sizeof(MercuryPoint), 1, mbmf);
+ fwrite(&vertice[i].position, sizeof(MercuryPoint), 1, mbmf);
+ }
+
+ tmp16 = indice.size(); fwrite(&tmp16, sizeof(uint16_t), 1, mbmf);
+ for (uint16_t i = 0; i < indice.size(); ++i)
+ fwrite(&indice[i], sizeof(uint16_t), 1, mbmf);
+ }
+
+ tmp32 = 0;
+
+ fwrite(&tmp32, sizeof(uint32_t), 1, mbmf);
+ fwrite(&tmp32, sizeof(uint32_t), 1, mbmf);
+ fwrite(&tmp32, sizeof(uint32_t), 1, mbmf);
+ fwrite(&tmp32, sizeof(uint32_t), 1, mbmf);
+}
+
+int main(int argc, char** argv)
+{
+ FILE *mbmf;
+ ifstream obj;
+
+ obj.open(argv[1]);
+ mbmf = fopen(argv[2], "wb");
+
+ string line;
+
+
+ while ( getline(obj, line) )
+ {
+ if (line.length() > 0) LineParser(line);
+ }
+
+ WriteMBMF( mbmf );
+
+ fclose( mbmf );
+
+ return 0;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-30 15:15:12
|
Revision: 96
http://hgengine.svn.sourceforge.net/hgengine/?rev=96&view=rev
Author: axlecrusher
Date: 2008-12-30 15:15:02 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
use MAutoPtr
Modified Paths:
--------------
Mercury2/src/HGMDLModel.cpp
Mercury2/src/HGMDLModel.h
Modified: Mercury2/src/HGMDLModel.cpp
===================================================================
--- Mercury2/src/HGMDLModel.cpp 2008-12-30 15:08:53 UTC (rev 95)
+++ Mercury2/src/HGMDLModel.cpp 2008-12-30 15:15:02 UTC (rev 96)
@@ -38,7 +38,7 @@
fread(&numMeshes, sizeof(uint16_t), 1, hgmdl);
for (uint16_t i = 0; i < numMeshes; ++i)
{
- HGMDLMesh *mesh = new HGMDLMesh();
+ MAutoPtr< HGMDLMesh > mesh( new HGMDLMesh() );
mesh->LoadFromFile( hgmdl );
m_meshes.push_back(mesh);
}
@@ -46,11 +46,9 @@
void HGMDLModel::Render(MercuryNode* node)
{
- list< HGMDLMesh* >::iterator i = m_meshes.begin();
+ list< MAutoPtr< HGMDLMesh > >::iterator i = m_meshes.begin();
for(;i != m_meshes.end(); ++i)
- {
(*i)->Render(node);
- }
}
HGMDLModel* HGMDLModel::Generate()
Modified: Mercury2/src/HGMDLModel.h
===================================================================
--- Mercury2/src/HGMDLModel.h 2008-12-30 15:08:53 UTC (rev 95)
+++ Mercury2/src/HGMDLModel.h 2008-12-30 15:15:02 UTC (rev 96)
@@ -16,7 +16,7 @@
virtual void Render(MercuryNode* node);
private:
- std::list< HGMDLMesh* > m_meshes;
+ std::list< MAutoPtr< HGMDLMesh > > m_meshes;
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-30 15:09:03
|
Revision: 95
http://hgengine.svn.sourceforge.net/hgengine/?rev=95&view=rev
Author: axlecrusher
Date: 2008-12-30 15:08:53 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
fix header defines
Modified Paths:
--------------
Mercury2/src/AlignedBuffer.h
Mercury2/src/HGMDLMesh.h
Mercury2/src/HGMDLModel.h
Mercury2/src/MercuryPoint.h
Mercury2/src/MercuryVBO.cpp
Mercury2/src/MercuryVBO.h
Mercury2/src/Quad.h
Mercury2/src/Texture.h
Mercury2/src/TransformNode.h
Mercury2/src/Viewport.h
Mercury2/src/X11Window.h
Modified: Mercury2/src/AlignedBuffer.h
===================================================================
--- Mercury2/src/AlignedBuffer.h 2008-12-30 14:53:52 UTC (rev 94)
+++ Mercury2/src/AlignedBuffer.h 2008-12-30 15:08:53 UTC (rev 95)
@@ -1,3 +1,5 @@
+#ifndef ALIGNEDBUFFER_H
+#define ALIGNEDBUFFER_H
template <typename T>
class AlignedBuffer
@@ -38,6 +40,8 @@
T* m_data, *m_mem;
};
+#endif
+
/****************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/HGMDLMesh.h
===================================================================
--- Mercury2/src/HGMDLMesh.h 2008-12-30 14:53:52 UTC (rev 94)
+++ Mercury2/src/HGMDLMesh.h 2008-12-30 15:08:53 UTC (rev 95)
@@ -1,3 +1,6 @@
+#ifndef HGMDLMESH_H
+#define HGMDLMESH_H
+
#include <MercuryVBO.h>
class HGMDLMesh : public MercuryVBO
@@ -9,6 +12,8 @@
bool m_cachable;
};
+#endif
+
/****************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/HGMDLModel.h
===================================================================
--- Mercury2/src/HGMDLModel.h 2008-12-30 14:53:52 UTC (rev 94)
+++ Mercury2/src/HGMDLModel.h 2008-12-30 15:08:53 UTC (rev 95)
@@ -1,3 +1,6 @@
+#ifndef HGMDLMODEL_H
+#define HGMDLMODEL_H
+
#include <MercuryAsset.h>
#include <HGMDLMesh.h>
@@ -16,6 +19,8 @@
std::list< HGMDLMesh* > m_meshes;
};
+#endif
+
/****************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/MercuryPoint.h
===================================================================
--- Mercury2/src/MercuryPoint.h 2008-12-30 14:53:52 UTC (rev 94)
+++ Mercury2/src/MercuryPoint.h 2008-12-30 15:08:53 UTC (rev 95)
@@ -1,3 +1,6 @@
+#ifndef MERCURYPOINT_H
+#define MERCURYPOINT_H
+
///A point in space/vector
class MercuryPoint
{
@@ -77,6 +80,8 @@
float z;
};
+#endif
+
/***************************************************************************
* Copyright (C) 2008 by Joshua Allen, Charles Lohr *
* *
Modified: Mercury2/src/MercuryVBO.cpp
===================================================================
--- Mercury2/src/MercuryVBO.cpp 2008-12-30 14:53:52 UTC (rev 94)
+++ Mercury2/src/MercuryVBO.cpp 2008-12-30 15:08:53 UTC (rev 95)
@@ -23,8 +23,8 @@
void MercuryVBO::Render(MercuryNode* node)
{
- unsigned short numTextures = Texture::NumberActiveTextures();
- unsigned short stride = sizeof(float)*8;
+ uint8_t numTextures = Texture::NumberActiveTextures();
+ uint16_t stride = sizeof(float)*8;
if ( m_initiated )
{
Modified: Mercury2/src/MercuryVBO.h
===================================================================
--- Mercury2/src/MercuryVBO.h 2008-12-30 14:53:52 UTC (rev 94)
+++ Mercury2/src/MercuryVBO.h 2008-12-30 15:08:53 UTC (rev 95)
@@ -1,3 +1,6 @@
+#ifndef MERCURYVBO_H
+#define MERCURYVBO_H
+
#include <MercuryAsset.h>
#include <AlignedBuffer.h>
@@ -24,6 +27,8 @@
AlignedBuffer<uint16_t> m_indexData;
};
+#endif
+
/****************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/Quad.h
===================================================================
--- Mercury2/src/Quad.h 2008-12-30 14:53:52 UTC (rev 94)
+++ Mercury2/src/Quad.h 2008-12-30 15:08:53 UTC (rev 95)
@@ -1,5 +1,7 @@
+#ifndef MERCURYQUAD_H
+#define MERCURYQUAD_H
+
#include <MercuryAsset.h>
-
#include <MercuryVBO.h>
class Quad : public MercuryVBO
@@ -14,6 +16,8 @@
static Quad* m_myInstance;
};
+#endif
+
/***************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/Texture.h
===================================================================
--- Mercury2/src/Texture.h 2008-12-30 14:53:52 UTC (rev 94)
+++ Mercury2/src/Texture.h 2008-12-30 15:08:53 UTC (rev 95)
@@ -1,3 +1,6 @@
+#ifndef TEXTURE_H
+#define TEXTURE_H
+
#include <MercuryAsset.h>
#include <RawImageData.h>
@@ -31,6 +34,8 @@
static unsigned short m_activeTextures;
};
+#endif
+
/***************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/TransformNode.h
===================================================================
--- Mercury2/src/TransformNode.h 2008-12-30 14:53:52 UTC (rev 94)
+++ Mercury2/src/TransformNode.h 2008-12-30 15:08:53 UTC (rev 95)
@@ -1,3 +1,6 @@
+#ifndef TRANSFORMNODE_H
+#define TRANSFORMNODE_H
+
#include <MercuryNode.h>
#include <MercuryPoint.h>
#include <MercuryMatrix.h>
@@ -45,6 +48,8 @@
bool m_tainted;
};
+#endif
+
/****************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/Viewport.h
===================================================================
--- Mercury2/src/Viewport.h 2008-12-30 14:53:52 UTC (rev 94)
+++ Mercury2/src/Viewport.h 2008-12-30 15:08:53 UTC (rev 95)
@@ -1,3 +1,6 @@
+#ifndef VIEWPORT_H
+#define VIEWPORT_H
+
#include <RenderableNode.h>
#include <MercuryMatrix.h>
class Viewport : public RenderableNode
@@ -14,6 +17,8 @@
MercuryMatrix m_frustum;
};
+#endif
+
/***************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/X11Window.h
===================================================================
--- Mercury2/src/X11Window.h 2008-12-30 14:53:52 UTC (rev 94)
+++ Mercury2/src/X11Window.h 2008-12-30 15:08:53 UTC (rev 95)
@@ -1,3 +1,6 @@
+#ifndef X11WINDOW_H
+#define X11WINDOW_H
+
#include <MercuryWindow.h>
#include <X11/Xlib.h>
#include <GL/glx.h>
@@ -23,6 +26,8 @@
Atom m_wmDeleteMessage;
};
+#endif
+
/***************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-30 14:53:55
|
Revision: 94
http://hgengine.svn.sourceforge.net/hgengine/?rev=94&view=rev
Author: axlecrusher
Date: 2008-12-30 14:53:52 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
fix multitextures with VBOs
Modified Paths:
--------------
Mercury2/src/MercuryVBO.cpp
Modified: Mercury2/src/MercuryVBO.cpp
===================================================================
--- Mercury2/src/MercuryVBO.cpp 2008-12-30 14:52:16 UTC (rev 93)
+++ Mercury2/src/MercuryVBO.cpp 2008-12-30 14:53:52 UTC (rev 94)
@@ -23,7 +23,7 @@
void MercuryVBO::Render(MercuryNode* node)
{
-// unsigned short numTextures = Texture::NumberActiveTextures();
+ unsigned short numTextures = Texture::NumberActiveTextures();
unsigned short stride = sizeof(float)*8;
if ( m_initiated )
@@ -40,8 +40,13 @@
if ( this != m_lastVBOrendered)
glVertexPointer(3, GL_FLOAT, stride, BUFFER_OFFSET(sizeof(float)*5));
- //XXX This seems to apply texture coordinates to all active texture units
- glTexCoordPointer(2, GL_FLOAT, stride, BUFFER_OFFSET(sizeof(float)*0));
+ //apply all the active textures
+ for (uint8_t i = 0; i < numTextures; ++i)
+ {
+ glActiveTexture( GL_TEXTURE0+i );
+ glClientActiveTextureARB(GL_TEXTURE0+i);
+ glTexCoordPointer(2, GL_FLOAT, stride, BUFFER_OFFSET(sizeof(float)*0));
+ }
glDrawRangeElements(GL_TRIANGLES, 0, m_indexData.Length()-1, m_indexData.Length(), GL_UNSIGNED_SHORT, NULL);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-30 14:52:19
|
Revision: 93
http://hgengine.svn.sourceforge.net/hgengine/?rev=93&view=rev
Author: axlecrusher
Date: 2008-12-30 14:52:16 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
Add models
Added Paths:
-----------
Mercury2/src/HGMDLMesh.cpp
Mercury2/src/HGMDLMesh.h
Mercury2/src/HGMDLModel.cpp
Mercury2/src/HGMDLModel.h
Added: Mercury2/src/HGMDLMesh.cpp
===================================================================
--- Mercury2/src/HGMDLMesh.cpp (rev 0)
+++ Mercury2/src/HGMDLMesh.cpp 2008-12-30 14:52:16 UTC (rev 93)
@@ -0,0 +1,65 @@
+#include <HGMDLMesh.h>
+
+void HGMDLMesh::LoadFromFile(FILE* hgmdl)
+{
+ uint32_t nameLength;
+ fread(&nameLength, sizeof(uint32_t), 1, hgmdl);
+
+ if (nameLength > 0)
+ {
+ char* name = new char[nameLength+1];
+ name[nameLength] = 0;
+ fread(name, nameLength, 1, hgmdl);
+ m_name = name;
+ }
+
+ fread(&m_cachable, sizeof(bool), 1, hgmdl);
+
+ uint32_t dataLength;
+ fread(&dataLength, sizeof(uint32_t), 1, hgmdl);
+ if (dataLength > 0)
+ {
+ m_vertexData.Allocate( dataLength/sizeof(float) ); //they are all floats
+ fread(m_vertexData.Buffer(), dataLength, 1, hgmdl);
+ }
+
+ uint16_t numIndices;
+ fread(&numIndices, sizeof(uint16_t), 1, hgmdl);
+ if (numIndices > 0)
+ {
+ m_indexData.Allocate( numIndices );
+ fread(m_indexData.Buffer(), numIndices*sizeof(uint16_t), 1, hgmdl);
+ }
+}
+
+/****************************************************************************
+ * Copyright (C) 2008 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
Added: Mercury2/src/HGMDLMesh.h
===================================================================
--- Mercury2/src/HGMDLMesh.h (rev 0)
+++ Mercury2/src/HGMDLMesh.h 2008-12-30 14:52:16 UTC (rev 93)
@@ -0,0 +1,44 @@
+#include <MercuryVBO.h>
+
+class HGMDLMesh : public MercuryVBO
+{
+ public:
+ void LoadFromFile(FILE* hgmdl);
+ private:
+ string m_name;
+ bool m_cachable;
+};
+
+/****************************************************************************
+ * Copyright (C) 2008 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+
+
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
Added: Mercury2/src/HGMDLModel.cpp
===================================================================
--- Mercury2/src/HGMDLModel.cpp (rev 0)
+++ Mercury2/src/HGMDLModel.cpp 2008-12-30 14:52:16 UTC (rev 93)
@@ -0,0 +1,91 @@
+#include <HGMDLModel.h>
+
+REGISTER_ASSET_TYPE(HGMDLModel);
+
+void HGMDLModel::LoadFromXML(const XMLNode& node)
+{
+ if ( !node.Attribute("file").empty() )
+ {
+ FILE* f = fopen( node.Attribute("file").c_str(), "rb" );
+ LoadModel( f );
+ fclose( f );
+ }
+}
+
+void HGMDLModel::LoadModel(FILE* hgmdl)
+{
+ char fingerPrint[5];
+ fingerPrint[5] = 0;
+ fread(fingerPrint, 4, 1, hgmdl);
+
+ string p(fingerPrint);
+ if (p != "MBMF")
+ {
+ printf("Not a HGMDL file.\n");
+ return;
+ }
+
+ uint32_t version;
+ fread(&version, 4, 1, hgmdl);
+
+ if (version != 200)
+ {
+ printf("Invalid HGMDL version %d\n", version);
+ return;
+ }
+
+ uint16_t numMeshes;
+ fread(&numMeshes, sizeof(uint16_t), 1, hgmdl);
+ for (uint16_t i = 0; i < numMeshes; ++i)
+ {
+ HGMDLMesh *mesh = new HGMDLMesh();
+ mesh->LoadFromFile( hgmdl );
+ m_meshes.push_back(mesh);
+ }
+}
+
+void HGMDLModel::Render(MercuryNode* node)
+{
+ list< HGMDLMesh* >::iterator i = m_meshes.begin();
+ for(;i != m_meshes.end(); ++i)
+ {
+ (*i)->Render(node);
+ }
+}
+
+HGMDLModel* HGMDLModel::Generate()
+{
+ return new HGMDLModel();
+}
+
+/****************************************************************************
+ * Copyright (C) 2008 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
Added: Mercury2/src/HGMDLModel.h
===================================================================
--- Mercury2/src/HGMDLModel.h (rev 0)
+++ Mercury2/src/HGMDLModel.h 2008-12-30 14:52:16 UTC (rev 93)
@@ -0,0 +1,49 @@
+#include <MercuryAsset.h>
+#include <HGMDLMesh.h>
+
+class HGMDLModel : public MercuryAsset
+{
+ public:
+
+ virtual void LoadFromXML(const XMLNode& node);
+
+ void LoadModel(FILE* hgmdl);
+
+ static HGMDLModel* Generate();
+ virtual void Render(MercuryNode* node);
+
+ private:
+ std::list< HGMDLMesh* > m_meshes;
+};
+
+/****************************************************************************
+ * Copyright (C) 2008 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-30 05:11:45
|
Revision: 92
http://hgengine.svn.sourceforge.net/hgengine/?rev=92&view=rev
Author: cnlohr
Date: 2008-12-30 05:11:42 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
fix warnings
Modified Paths:
--------------
Mercury2/src/BMPLoader.cpp
Mercury2/src/RenderableNode.cpp
Mercury2/src/Texture.cpp
Modified: Mercury2/src/BMPLoader.cpp
===================================================================
--- Mercury2/src/BMPLoader.cpp 2008-12-30 04:59:37 UTC (rev 91)
+++ Mercury2/src/BMPLoader.cpp 2008-12-30 05:11:42 UTC (rev 92)
@@ -140,7 +140,7 @@
unsigned long row, pixel;
unsigned char* rowPtr;
- for (unsigned int x = 0; !feof(file) && (x+3 < rawlength); x += 3)
+ for (unsigned int x = 0; !feof(file) && (x+3 < (unsigned)rawlength); x += 3)
{
memset(b, 0, sizeof(unsigned char) * 3);
// file->Read((char*)&b, sizeof(unsigned char) * 3);
Modified: Mercury2/src/RenderableNode.cpp
===================================================================
--- Mercury2/src/RenderableNode.cpp 2008-12-30 04:59:37 UTC (rev 91)
+++ Mercury2/src/RenderableNode.cpp 2008-12-30 05:11:42 UTC (rev 92)
@@ -111,7 +111,7 @@
{
static unsigned long waitTime = 0;
RenderableNode* rn;
- if ( rn = Cast(n) )
+ if ( ( rn = Cast(n) ) )
{
MSemaphoreDecOnDestroy s( &(rn->m_semaphore) );
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2008-12-30 04:59:37 UTC (rev 91)
+++ Mercury2/src/Texture.cpp 2008-12-30 05:11:42 UTC (rev 92)
@@ -52,6 +52,11 @@
break;
case RGBA:
ByteType = GL_RGBA;
+ break;
+ default:
+ printf( "Unsupported byte type (%d) in Texture::LoadFromRaw\n", m_raw->m_ColorByteType );
+ ByteType = GL_RGB;
+ break;
}
glBindTexture(GL_TEXTURE_2D, m_textureID);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2008-12-30 04:59:41
|
Revision: 91
http://hgengine.svn.sourceforge.net/hgengine/?rev=91&view=rev
Author: cnlohr
Date: 2008-12-30 04:59:37 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
fix configure&compile
Modified Paths:
--------------
Mercury2/adv_set.c
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2008-12-29 03:39:37 UTC (rev 90)
+++ Mercury2/adv_set.c 2008-12-30 04:59:37 UTC (rev 91)
@@ -10,7 +10,9 @@
src/TransformNode.cpp src/MercuryMatrix.cpp \
src/Viewport.cpp src/Quad.cpp src/MercuryUtil.cpp \
src/Texture.cpp src/RawImageData.cpp src/BMPLoader.cpp \
- src/PNGLoader.cpp src/ImageLoader.cpp"
+ src/PNGLoader.cpp src/ImageLoader.cpp \
+ src/MercuryVBO.cpp src/MSemaphore.cpp \
+ src/UpdateThreader.cpp"
#ifdef USE_LIBXML
SOURCES="$SOURCES src/XMLParser.cpp"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Charles L. <cn...@us...> - 2008-12-29 06:27:35
|
Update of /cvsroot/hgengine/Mercury/src In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv7705 Modified Files: ScreenMapEditor.cpp Log Message: Add two new features - . selects closest object to camrea, / points camera at selected object Index: ScreenMapEditor.cpp =================================================================== RCS file: /cvsroot/hgengine/Mercury/src/ScreenMapEditor.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** ScreenMapEditor.cpp 25 Nov 2008 19:42:59 -0000 1.47 --- ScreenMapEditor.cpp 29 Dec 2008 06:27:29 -0000 1.48 *************** *** 79,83 **** Position Normally (When Button1 is pressed) Ctrl: Control Rotation ! Shift: Control Z ---Piece Only Commands--- --- 79,87 ---- Position Normally (When Button1 is pressed) Ctrl: Control Rotation ! ! X/Y/Z control exclusively X/Y/Z axiz ! ! / = point camera at object ! . = select object closest to camera ---Piece Only Commands--- *************** *** 675,678 **** --- 679,729 ---- switch ( data.PeekItem( 1 ).GetValueI() ) { + case '/': + { + MercuryPoint Selected; + if ( GetSelectedHandleVis() ) Selected = GetSelectedHandleVis()->GetPosition(); + else if ( GetSelectedHandleODE() ) Selected = GetSelectedHandleODE()->GetPosition(); + else + { + NotifyMessage( "No piece selected." ); + } + MercuryPoint pAt = m_pCameraPos - Selected; + pAt.NormalizeSelf(); + m_pCameraRot = MercuryPoint( atan2( -pAt.y, -pAt.x ), atan( pAt.z ) * 1.5, 0 ); + } + break; + case '.': + { + MercuryPoint ClosestPV = m_pCameraPos; + float fClosestVal = 10000000.; + int iClosestIndex = -1; + + if (m_bWorldLoaded) + { + for( int i = 0; i < m_vVisObjs.size(); i++ ) + if( m_vVisObjs[i] ) + if( (m_vVisObjs[i]->GetPosition() - ClosestPV).Magnitude() < fClosestVal ) + { + fClosestVal = (m_vVisObjs[i]->GetPosition() - ClosestPV).Magnitude(); + iClosestIndex = i; + } + } + else if(m_bObjectLoaded) + { + for( int i = 0; i < m_vLastVis.size(); i++ ) + if( m_vLastVis[i] ) + if( (m_vLastVis[i]->GetPosition() - ClosestPV).Magnitude() < fClosestVal ) + { + fClosestVal = (m_vLastVis[i]->GetPosition() - ClosestPV).Magnitude(); + iClosestIndex = i; + } + } + + if( iClosestIndex >= 0 ) + SelectObject( iClosestIndex ); + else + NotifyMessage( "No piece selected." ); + } + break; case 'b': if ( m_bWorldLoaded ) |
|
From: Charles L. <cn...@us...> - 2008-12-29 06:26:42
|
Update of /cvsroot/hgengine/Mercury/src In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv7685 Modified Files: Mercury.cpp MercuryUtil.cpp Log Message: Fix compile for new crash handler Index: MercuryUtil.cpp =================================================================== RCS file: /cvsroot/hgengine/Mercury/src/MercuryUtil.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** MercuryUtil.cpp 1 Dec 2008 05:32:46 -0000 1.28 --- MercuryUtil.cpp 29 Dec 2008 06:26:35 -0000 1.29 *************** *** 209,213 **** { char buff[2048]; ! cnget_backtrace( 1, buff, 2048 ); puts( buff ); printf( "Forced crash (%s) Bactrace follows\n%s\n", reason, buff ); --- 209,213 ---- { char buff[2048]; ! cnget_backtrace( 1, buff, 2048, 0 ); puts( buff ); printf( "Forced crash (%s) Bactrace follows\n%s\n", reason, buff ); Index: Mercury.cpp =================================================================== RCS file: /cvsroot/hgengine/Mercury/src/Mercury.cpp,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -d -r1.120 -r1.121 *** Mercury.cpp 1 Dec 2008 05:32:46 -0000 1.120 --- Mercury.cpp 29 Dec 2008 06:26:35 -0000 1.121 *************** *** 68,76 **** ! int MyCrash( int i ) { char buff[2048]; printf( "Signal: %d (%s)\n", i, cn_get_crash_description( i ) ); ! cnget_backtrace( 1, buff, 2048 ); puts( buff ); return 0; --- 68,76 ---- ! int MyCrash( int i, struct BacktraceContext * ctx ) { char buff[2048]; printf( "Signal: %d (%s)\n", i, cn_get_crash_description( i ) ); ! cnget_backtrace( 1, buff, 2048, ctx ); puts( buff ); return 0; |
|
From: <axl...@us...> - 2008-12-29 03:39:40
|
Revision: 90
http://hgengine.svn.sourceforge.net/hgengine/?rev=90&view=rev
Author: axlecrusher
Date: 2008-12-29 03:39:37 +0000 (Mon, 29 Dec 2008)
Log Message:
-----------
give space in version for 3 minor version numbers
Modified Paths:
--------------
Mercury2/docs/MercuryBinaryModelFormat.odt
Modified: Mercury2/docs/MercuryBinaryModelFormat.odt
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-29 03:25:54
|
Revision: 89
http://hgengine.svn.sourceforge.net/hgengine/?rev=89&view=rev
Author: axlecrusher
Date: 2008-12-29 03:25:51 +0000 (Mon, 29 Dec 2008)
Log Message:
-----------
add documentation on the MBMF v2 format
Added Paths:
-----------
Mercury2/docs/
Mercury2/docs/MercuryBinaryModelFormat.odt
Added: Mercury2/docs/MercuryBinaryModelFormat.odt
===================================================================
(Binary files differ)
Property changes on: Mercury2/docs/MercuryBinaryModelFormat.odt
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-29 03:15:57
|
Revision: 88
http://hgengine.svn.sourceforge.net/hgengine/?rev=88&view=rev
Author: axlecrusher
Date: 2008-12-29 03:15:55 +0000 (Mon, 29 Dec 2008)
Log Message:
-----------
add normals
Modified Paths:
--------------
Mercury2/src/MercuryVBO.cpp
Mercury2/src/Quad.cpp
Modified: Mercury2/src/MercuryVBO.cpp
===================================================================
--- Mercury2/src/MercuryVBO.cpp 2008-12-25 01:20:29 UTC (rev 87)
+++ Mercury2/src/MercuryVBO.cpp 2008-12-29 03:15:55 UTC (rev 88)
@@ -24,7 +24,7 @@
void MercuryVBO::Render(MercuryNode* node)
{
// unsigned short numTextures = Texture::NumberActiveTextures();
- unsigned short stride = sizeof(float)*5;
+ unsigned short stride = sizeof(float)*8;
if ( m_initiated )
{
@@ -38,10 +38,10 @@
InitVBO();
if ( this != m_lastVBOrendered)
- glVertexPointer(3, GL_FLOAT, stride, 0);
+ glVertexPointer(3, GL_FLOAT, stride, BUFFER_OFFSET(sizeof(float)*5));
//XXX This seems to apply texture coordinates to all active texture units
- glTexCoordPointer(2, GL_FLOAT, stride, BUFFER_OFFSET(sizeof(float)*3));
+ glTexCoordPointer(2, GL_FLOAT, stride, BUFFER_OFFSET(sizeof(float)*0));
glDrawRangeElements(GL_TRIANGLES, 0, m_indexData.Length()-1, m_indexData.Length(), GL_UNSIGNED_SHORT, NULL);
@@ -67,7 +67,7 @@
void MercuryVBO::AllocateVertexSpace(unsigned int count)
{
- m_vertexData.Allocate(count*5);
+ m_vertexData.Allocate(count*8);
}
void MercuryVBO::AllocateIndexSpace(unsigned int count)
Modified: Mercury2/src/Quad.cpp
===================================================================
--- Mercury2/src/Quad.cpp 2008-12-25 01:20:29 UTC (rev 87)
+++ Mercury2/src/Quad.cpp 2008-12-29 03:15:55 UTC (rev 88)
@@ -15,17 +15,21 @@
// float* buffer = m_vertexData.m_vertexData();
int i = 0;
+ m_vertexData[i++] = 0; m_vertexData[i++] = 1;
+ m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
m_vertexData[i++] = -0.5; m_vertexData[i++] = -0.5; m_vertexData[i++] = 0.0;
- m_vertexData[i++] = 0; m_vertexData[i++] = 1;
+ m_vertexData[i++] = 1; m_vertexData[i++] = 1;
+ m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
m_vertexData[i++] = 0.5; m_vertexData[i++] = -0.5; m_vertexData[i++] = 0.0;
- m_vertexData[i++] = 1; m_vertexData[i++] = 1;
+ m_vertexData[i++] = 1; m_vertexData[i++] = 0;
+ m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
m_vertexData[i++] = 0.5; m_vertexData[i++] = 0.5; m_vertexData[i++] = 0.0;
- m_vertexData[i++] = 1; m_vertexData[i++] = 0;
+ m_vertexData[i++] = 0; m_vertexData[i++] = 0;
+ m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
m_vertexData[i++] = -0.5; m_vertexData[i++] = 0.5; m_vertexData[i++] = 0.0;
- m_vertexData[i++] = 0; m_vertexData[i++] = 0;
m_indexData[5] = m_indexData[0] = 0;
m_indexData[1] = 1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-25 01:20:31
|
Revision: 87
http://hgengine.svn.sourceforge.net/hgengine/?rev=87&view=rev
Author: axlecrusher
Date: 2008-12-25 01:20:29 +0000 (Thu, 25 Dec 2008)
Log Message:
-----------
Clean up how VBO and quads work using the AlignedBuffer
Modified Paths:
--------------
Mercury2/src/AlignedBuffer.h
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryVBO.cpp
Mercury2/src/MercuryVBO.h
Mercury2/src/Quad.cpp
Modified: Mercury2/src/AlignedBuffer.h
===================================================================
--- Mercury2/src/AlignedBuffer.h 2008-12-25 01:15:26 UTC (rev 86)
+++ Mercury2/src/AlignedBuffer.h 2008-12-25 01:20:29 UTC (rev 87)
@@ -31,10 +31,7 @@
inline T* Buffer() { return m_data; }
- T& operator[](unsigned long x)
- {
- return m_data[x];
- }
+ inline T& operator[](unsigned long x) { return m_data[x]; }
private:
unsigned long m_length;
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2008-12-25 01:15:26 UTC (rev 86)
+++ Mercury2/src/Mercury2.cpp 2008-12-25 01:20:29 UTC (rev 87)
@@ -16,6 +16,7 @@
MercuryNode* n = (MercuryNode*)node;
n->RecursiveUpdate(0.01f);
}
+ return NULL;
}
int main()
Modified: Mercury2/src/MercuryVBO.cpp
===================================================================
--- Mercury2/src/MercuryVBO.cpp 2008-12-25 01:15:26 UTC (rev 86)
+++ Mercury2/src/MercuryVBO.cpp 2008-12-25 01:20:29 UTC (rev 87)
@@ -10,16 +10,13 @@
#define BUFFER_OFFSET(i) ((char*)NULL + (i))
MercuryVBO::MercuryVBO()
- :MercuryAsset(), m_vertexData(NULL), m_vMem(NULL), m_vertexIndexList(NULL), m_iMem(NULL), m_initiated(false)
+ :MercuryAsset(), m_initiated(false)
{
m_bufferIDs[0] = m_bufferIDs[1] = 0;
}
MercuryVBO::~MercuryVBO()
{
- SAFE_FREE(m_vMem);
- SAFE_FREE(m_iMem);
-
if (m_bufferIDs[0]) glDeleteBuffersARB(2, m_bufferIDs);
m_bufferIDs[0] = m_bufferIDs[1] = 0;
}
@@ -46,7 +43,7 @@
//XXX This seems to apply texture coordinates to all active texture units
glTexCoordPointer(2, GL_FLOAT, stride, BUFFER_OFFSET(sizeof(float)*3));
- glDrawRangeElements(GL_TRIANGLES, 0, m_bufferLength[1], m_bufferLength[1], GL_UNSIGNED_SHORT, NULL);
+ glDrawRangeElements(GL_TRIANGLES, 0, m_indexData.Length()-1, m_indexData.Length(), GL_UNSIGNED_SHORT, NULL);
m_lastVBOrendered = this;
}
@@ -57,36 +54,25 @@
//vertex VBO
glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferIDs[0]);
- glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_bufferLength[0], m_vertexData, GL_STATIC_DRAW_ARB);
+ glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_vertexData.LengthInBytes(), m_vertexData.Buffer(), GL_STATIC_DRAW_ARB);
//indices VBO
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_bufferIDs[1]);
- glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(uint16_t)*m_bufferLength[1], m_vertexIndexList, GL_STATIC_DRAW_ARB);
-
- SAFE_FREE(m_vMem);
- SAFE_FREE(m_iMem);
-
+ glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_indexData.LengthInBytes(), m_indexData.Buffer(), GL_STATIC_DRAW_ARB);
+
glEnableClientState(GL_VERTEX_ARRAY);
m_initiated = true;
}
-void MercuryVBO::AllocateVertexSpace(unsigned int count, unsigned int elementSize)
+void MercuryVBO::AllocateVertexSpace(unsigned int count)
{
- SAFE_FREE(m_vMem);
- void* mem = NULL;
- m_vertexData = (char*)mmemalign(32, elementSize*count, mem);
- m_vMem = (char*)mem;
- m_bufferLength[0] = elementSize*count;
+ m_vertexData.Allocate(count*5);
}
void MercuryVBO::AllocateIndexSpace(unsigned int count)
{
- SAFE_FREE(m_iMem);
- void* mem = NULL;
- m_vertexIndexList = (uint16_t*)mmemalign(32, sizeof(uint16_t)*count, mem);
- m_iMem = (uint16_t*)mem;
- m_bufferLength[1] = count;
+ m_indexData.Allocate(count);
}
void* MercuryVBO::m_lastVBOrendered = NULL;
Modified: Mercury2/src/MercuryVBO.h
===================================================================
--- Mercury2/src/MercuryVBO.h 2008-12-25 01:15:26 UTC (rev 86)
+++ Mercury2/src/MercuryVBO.h 2008-12-25 01:20:29 UTC (rev 87)
@@ -1,4 +1,5 @@
#include <MercuryAsset.h>
+#include <AlignedBuffer.h>
class MercuryVBO : public MercuryAsset
{
@@ -8,23 +9,19 @@
virtual void Render(MercuryNode* node);
- void AllocateVertexSpace(unsigned int count, unsigned int elementSize);
+ void AllocateVertexSpace(unsigned int count);
void AllocateIndexSpace(unsigned int count);
-
- inline char* Buffer() { return m_vertexData; }
- inline uint16_t* IndexBuffer() { return m_vertexIndexList; }
+
private:
virtual void InitVBO();
-
+
unsigned int m_bufferIDs[2];
- unsigned int m_bufferLength[2];
-
- char *m_vertexData, *m_vMem;
- uint16_t *m_vertexIndexList, *m_iMem;
-
- bool m_initiated;
-
+ bool m_initiated;
static void* m_lastVBOrendered;
+
+ protected:
+ AlignedBuffer<float> m_vertexData;
+ AlignedBuffer<uint16_t> m_indexData;
};
/****************************************************************************
Modified: Mercury2/src/Quad.cpp
===================================================================
--- Mercury2/src/Quad.cpp 2008-12-25 01:15:26 UTC (rev 86)
+++ Mercury2/src/Quad.cpp 2008-12-25 01:20:29 UTC (rev 87)
@@ -10,36 +10,33 @@
Quad::Quad()
{
AllocateIndexSpace(6);
- AllocateVertexSpace(4, sizeof(float)*5);
+ AllocateVertexSpace(4);
- float* buffer = (float*)Buffer();
+// float* buffer = m_vertexData.m_vertexData();
int i = 0;
- buffer[i++] = -0.5; buffer[i++] = -0.5; buffer[i++] = 0.0;
- buffer[i++] = 0; buffer[i++] = 1;
+ m_vertexData[i++] = -0.5; m_vertexData[i++] = -0.5; m_vertexData[i++] = 0.0;
+ m_vertexData[i++] = 0; m_vertexData[i++] = 1;
- buffer[i++] = 0.5; buffer[i++] = -0.5; buffer[i++] = 0.0;
- buffer[i++] = 1; buffer[i++] = 1;
+ m_vertexData[i++] = 0.5; m_vertexData[i++] = -0.5; m_vertexData[i++] = 0.0;
+ m_vertexData[i++] = 1; m_vertexData[i++] = 1;
- buffer[i++] = 0.5; buffer[i++] = 0.5; buffer[i++] = 0.0;
- buffer[i++] = 1; buffer[i++] = 0;
+ m_vertexData[i++] = 0.5; m_vertexData[i++] = 0.5; m_vertexData[i++] = 0.0;
+ m_vertexData[i++] = 1; m_vertexData[i++] = 0;
- buffer[i++] = -0.5; buffer[i++] = 0.5; buffer[i++] = 0.0;
- buffer[i++] = 0; buffer[i++] = 0;
+ m_vertexData[i++] = -0.5; m_vertexData[i++] = 0.5; m_vertexData[i++] = 0.0;
+ m_vertexData[i++] = 0; m_vertexData[i++] = 0;
- uint16_t* indice = IndexBuffer();
- indice[0] = 0;
- indice[1] = 1;
- indice[2] = 2;
-
- indice[3] = 2;
- indice[4] = 3;
- indice[5] = 0;
+ m_indexData[5] = m_indexData[0] = 0;
+ m_indexData[1] = 1;
+ m_indexData[3] = m_indexData[2] = 2;
+ m_indexData[4] = 3;
}
Quad::~Quad()
{
- m_myInstance = NULL;
+ if (m_myInstance == this)
+ m_myInstance = NULL;
}
Quad* Quad::Generate()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2008-12-25 01:15:30
|
Revision: 86
http://hgengine.svn.sourceforge.net/hgengine/?rev=86&view=rev
Author: axlecrusher
Date: 2008-12-25 01:15:26 +0000 (Thu, 25 Dec 2008)
Log Message:
-----------
Aligned buffer template
Added Paths:
-----------
Mercury2/src/AlignedBuffer.h
Added: Mercury2/src/AlignedBuffer.h
===================================================================
--- Mercury2/src/AlignedBuffer.h (rev 0)
+++ Mercury2/src/AlignedBuffer.h 2008-12-25 01:15:26 UTC (rev 86)
@@ -0,0 +1,74 @@
+
+template <typename T>
+class AlignedBuffer
+{
+ public:
+ AlignedBuffer()
+ :m_length(0), m_data(NULL), m_mem(NULL)
+ {};
+
+ ~AlignedBuffer()
+ {
+ Free();
+ }
+
+ void Allocate(unsigned long count)
+ {
+ SAFE_FREE(m_mem);
+ m_data = (T*)mmemalign(32, sizeof(T)*count, (void*&)m_mem);
+ m_length = count;
+ }
+
+ void Free()
+ {
+ SAFE_FREE(m_mem);
+ m_data = NULL;
+ m_length = 0;
+ }
+
+ inline unsigned long Length() { return m_length; }
+ inline unsigned long LengthInBytes() { return m_length*sizeof(T); }
+
+ inline T* Buffer() { return m_data; }
+
+ T& operator[](unsigned long x)
+ {
+ return m_data[x];
+ }
+
+ private:
+ unsigned long m_length;
+ T* m_data, *m_mem;
+};
+
+/****************************************************************************
+ * Copyright (C) 2008 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|