From: <axl...@us...> - 2008-12-05 12:21:43
|
Revision: 49 http://hgengine.svn.sourceforge.net/hgengine/?rev=49&view=rev Author: axlecrusher Date: 2008-12-05 11:53:20 +0000 (Fri, 05 Dec 2008) Log Message: ----------- test texture Modified Paths: -------------- Mercury2/scenegraph.xml Added Paths: ----------- Mercury2/test.bmp Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2008-12-05 11:51:29 UTC (rev 48) +++ Mercury2/scenegraph.xml 2008-12-05 11:53:20 UTC (rev 49) @@ -4,6 +4,7 @@ </node> <node type="transformnode" movz="-3"> <node type="renderablenode"> + <asset type="texture" imagefile="test.bmp"/> <asset type="quad"/> </node> </node> Added: Mercury2/test.bmp =================================================================== (Binary files differ) Property changes on: Mercury2/test.bmp ___________________________________________________________________ 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: <cn...@us...> - 2008-12-06 22:48:39
|
Revision: 56 http://hgengine.svn.sourceforge.net/hgengine/?rev=56&view=rev Author: cnlohr Date: 2008-12-06 21:58:06 +0000 (Sat, 06 Dec 2008) Log Message: ----------- fix auto build scripts Modified Paths: -------------- Mercury2/adv_set.c Mercury2/base_set.sh Mercury2/cnconfigure Modified: Mercury2/adv_set.c =================================================================== --- Mercury2/adv_set.c 2008-12-06 21:56:38 UTC (rev 55) +++ Mercury2/adv_set.c 2008-12-06 21:58:06 UTC (rev 56) @@ -8,18 +8,23 @@ src/MercuryThreads.cpp src/MercuryMath.cpp \ src/MercuryWindow.cpp src/RenderableNode.cpp \ src/TransformNode.cpp src/MercuryMatrix.cpp \ - src/Viewport.cpp src/Quad.cpp" + src/Viewport.cpp src/Quad.cpp src/MercuryUtil.cpp \ + src/Texture.cpp" +#ifdef USE_LIBXML +SOURCES="$SOURCES src/XMLParser.cpp" +#endif + #ifdef USE_X11 SOURCES="$SOURCES src/X11Window.cpp" #endif PROJ="mercury" -CFLAGS="-DHAVE_CONFIG -fno-exceptions -fPIC -Isrc" -LDFLAGS="-rdynamic -g -fPIC" +CFLAGS="$CFLAGS -DHAVE_CONFIG -fno-exceptions -fPIC -Isrc" +LDFLAGS="$LDFLAGS -rdynamic -g -fPIC" /* - * (c) 2007 Charles Lohr + * (c) 2007-2008 Charles Lohr * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a Modified: Mercury2/base_set.sh =================================================================== --- Mercury2/base_set.sh 2008-12-06 21:56:38 UTC (rev 55) +++ Mercury2/base_set.sh 2008-12-06 21:58:06 UTC (rev 56) @@ -8,9 +8,10 @@ ISMAC=1; fi -OPTIONS="X11" +OPTIONS="X11 libxml OGL" OPT_X11=1 OPT_OGL=1 +OPT_libxml=1 DEFINES="WAS_CONFIGURED USE_MSTRING" CC_BASE="-O2 -g" @@ -44,6 +45,14 @@ NEED_L="m c z pthread png pthread"; +if test $OPT_libxml = 1; then + CC_BASE="$CC_BASE -I/usr/include/libxml2" + NEED_H="$NEED_H libxml/parser.h" + NEED_L="$NEED_L xml2" + DEFINES="$DEFINES USE_LIBXML" +fi + + if test $OPT_X11 = 1; then NEED_L="$NEED_L X11" NEED_H="$NEED_H X11/Xlib.h" Modified: Mercury2/cnconfigure =================================================================== --- Mercury2/cnconfigure 2008-12-06 21:56:38 UTC (rev 55) +++ Mercury2/cnconfigure 2008-12-06 21:58:06 UTC (rev 56) @@ -1,5 +1,5 @@ -#!/bin/sh -echo "Mercury mini-configurator (C) 2007-2008 Charles Lohr under the MIT/x11 License" +#!/bin/bash +echo "Mercury mini-configurator (C) 2007 Charles Lohr under the MIT/x11 License" if source ./base_set.sh $*; then echo "Source Base Set Ok." @@ -11,7 +11,7 @@ { echo -n "Checking for <$1>... " echo -e "#include <$1>\n" > tmp.c - +#echo gcc $CC_BASE -E tmp.c if gcc $CC_BASE -E tmp.c 1> foo 2> foo; then # rm ./tmp.c rm ./foo @@ -29,6 +29,7 @@ { echo -n "Checking for -l$1... " echo -e "int main() { return 0; }" > tmp.c +#echo gcc $CC_BASE $LD_BASE -o bar tmp.c -l$1 if gcc $CC_BASE $LD_BASE -o bar tmp.c -l$1 1> foo 2> foo; then rm ./tmp.c rm ./foo @@ -57,6 +58,35 @@ echo "#define $i" >> configuration.h done +echo "Compile line used: cc $CC_BASE" + +echo -n "Checking to make sure standard cflags and compile are acceptable... " +echo -e "\n" > tmp.c +if cc $CC_BASE -E tmp.c 1> foo 2> foo; then + rm ./foo + echo "yes" +else + rm ./foo + echo "no" + exit -1 +fi + +echo "Link line used: g++ $CC_BASE $LD_BASE" +echo -n "Checking to make sure ldflags and linker are acceptable... " +echo -e "int main() { return 0; }" > tmp.c +if gcc $CC_BASE $LD_BASE -o bar tmp.c 1> foo 2> foo; then + rm ./tmp.c + rm ./foo + rm ./bar + echo "yes" +else + rm ./tmp.c + rm ./foo + echo "no" + exit -1; +fi + + for i in $NEED_H; do if CheckForInclude "$i"; then echo "#define _HAVE_$i" | sed "s/\./_/;s/\//_/g" >> configuration.h; else echo "Configure failed."; exit -1; fi done @@ -154,17 +184,25 @@ LDFLAGS="$LDFLAGS $LD_BASE" +echo "Final compile line: cc \$(CC_BASE) \$(CFLAGS) -c -o \$@ \$<" +echo "Final link line: g++ -o \$@ \$^ \$(LDFLAGS)" + echo "PROJ=$PROJ" >> Makefile echo "CFLAGS=$CC_BASE $CFLAGS" >> Makefile echo "LDFLAGS=$LDFLAGS" >> Makefile echo "">>Makefile -echo -e "all : \$(PROJ) Library" +echo -e "all : \$(PROJ) library" >> Makefile echo -e "\$(PROJ) : \$(OBJ)" >> Makefile -echo -e "\tg++ \$(LDFLAGS) -o \$@ \$^" >> Makefile +echo -e "\tg++ -o \$@ \$^ \$(LDFLAGS)" >> Makefile echo -e "help : " >> Makefile echo -e " echo \"Available: <\$(PROJ)> <clean> <library> <help>\"" >> Makefile -echo -e "library : \$(OBJ)" >> Makefile -echo -e "\tg++ \$(LDFLAGS) -shared -o \$(PROJ).so \$^" >> Makefile +if test `uname -s` == "Darwin" ; then + echo -e "library : \$(OBJ)" >> Makefile + echo -e "\tg++ -dynamiclib -o \$(PROJ).dylib \$^ \$(LDFLAGS)" >> Makefile +else + echo -e "library : \$(OBJ)" >> Makefile + echo -e "\tg++ -shared -o \$(PROJ).so \$^ \$(LDFLAGS)" >> Makefile +fi echo "" >> Makefile for i in $SOURCES; do echo "Processing: $i" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2008-12-06 22:55:36
|
Revision: 55 http://hgengine.svn.sourceforge.net/hgengine/?rev=55&view=rev Author: axlecrusher Date: 2008-12-06 21:56:38 +0000 (Sat, 06 Dec 2008) Log Message: ----------- update Modified Paths: -------------- Mercury2/scenegraph.xml Added Paths: ----------- Mercury2/test2.bmp Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2008-12-06 20:19:59 UTC (rev 54) +++ Mercury2/scenegraph.xml 2008-12-06 21:56:38 UTC (rev 55) @@ -1,5 +1,5 @@ <SceneGraph> - <node type="transformnode" movz="-1"> + <node type="transformnode" movz="-1" roty="13"> <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100"/> </node> <node type="transformnode" movz="-3"> @@ -8,4 +8,16 @@ <asset type="quad"/> </node> </node> + <node type="transformnode" movz="-3" movx="-1" movy="-1"> + <node type="renderablenode"> + <asset type="quad"/> + </node> + </node> + <node type="transformnode" movz="-3" movx="1" movy="-1"> + <node type="renderablenode"> + <asset type="texture" imagefile="test2.bmp"/> + <asset type="texture" imagefile="test.bmp"/> + <asset type="quad"/> + </node> + </node> </SceneGraph> Added: Mercury2/test2.bmp =================================================================== (Binary files differ) Property changes on: Mercury2/test2.bmp ___________________________________________________________________ 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-07 17:01:29
|
Revision: 63 http://hgengine.svn.sourceforge.net/hgengine/?rev=63&view=rev Author: axlecrusher Date: 2008-12-07 17:01:19 +0000 (Sun, 07 Dec 2008) Log Message: ----------- update Modified Paths: -------------- Mercury2/mercury2.kdevelop Mercury2/scenegraph.xml Added Paths: ----------- Mercury2/test2.png Modified: Mercury2/mercury2.kdevelop =================================================================== --- Mercury2/mercury2.kdevelop 2008-12-07 15:53:43 UTC (rev 62) +++ Mercury2/mercury2.kdevelop 2008-12-07 17:01:19 UTC (rev 63) @@ -2,7 +2,7 @@ <kdevelop> <general> <author>Joshua Allen</author> - <email></email> + <email/> <version>2.0</version> <projectmanagement>KDevAutoProject</projectmanagement> <primarylanguage>C++</primarylanguage> @@ -14,9 +14,9 @@ <projectname>Mercury2</projectname> <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> - <description></description> - <defaultencoding></defaultencoding> - <versioncontrol></versioncontrol> + <description/> + <defaultencoding/> + <versioncontrol/> </general> <kdevautoproject> <general> @@ -26,8 +26,8 @@ <run> <mainprogram>/home/josh/Mercury2/debug/src/mercury2</mainprogram> <terminal>false</terminal> - <programargs></programargs> - <globaldebugarguments></globaldebugarguments> + <programargs/> + <globaldebugarguments/> <globalcwd>/home/josh/Mercury2</globalcwd> <useglobalprogram>true</useglobalprogram> <autocompile>false</autocompile> @@ -51,15 +51,15 @@ <f77compiler>kdevg77options</f77compiler> <cxxflags>-O0 -g3 -Wall</cxxflags> <envvars/> - <topsourcedir></topsourcedir> + <topsourcedir/> <cppflags>-Isrc/ -I/usr/include/libxml2/ </cppflags> - <ldflags>-lpthread -lX11 -lGL -lxml2</ldflags> - <ccompilerbinary></ccompilerbinary> - <cxxcompilerbinary></cxxcompilerbinary> - <f77compilerbinary></f77compilerbinary> - <cflags></cflags> - <f77flags></f77flags> + <ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags> + <ccompilerbinary/> + <cxxcompilerbinary/> + <f77compilerbinary/> + <cflags/> + <f77flags/> </debug> </configurations> <make> @@ -71,7 +71,7 @@ <runmultiplejobs>true</runmultiplejobs> <numberofjobs>3</numberofjobs> <dontact>false</dontact> - <makebin></makebin> + <makebin/> <prio>0</prio> </make> </kdevautoproject> @@ -122,6 +122,7 @@ </ignoredoxygen> </kdevdoctreeview> <kdevfilecreate> + <filetypes/> <useglobaltypes> <type ext="cpp" /> <type ext="h" /> @@ -143,7 +144,7 @@ <projectdoc> <docsystem>Doxygen Documentation Collection</docsystem> <docurl>mercury2.tag</docurl> - <usermanualurl></usermanualurl> + <usermanualurl/> </projectdoc> </kdevdocumentation> <substmap> @@ -195,7 +196,7 @@ <includePaths>.;</includePaths> </codecompletion> <creategettersetter> - <prefixGet></prefixGet> + <prefixGet/> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> <parameterName>theValue</parameterName> @@ -216,11 +217,11 @@ </cppsupportpart> <kdevdebugger> <general> - <gdbpath></gdbpath> + <gdbpath/> <dbgshell>libtool</dbgshell> - <configGdbScript></configGdbScript> - <runShellScript></runShellScript> - <runGdbScript></runGdbScript> + <configGdbScript/> + <runShellScript/> + <runGdbScript/> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> <floatingtoolbar>false</floatingtoolbar> Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2008-12-07 15:53:43 UTC (rev 62) +++ Mercury2/scenegraph.xml 2008-12-07 17:01:19 UTC (rev 63) @@ -15,7 +15,7 @@ </node> <node type="transformnode" movz="-3" movx="1" movy="-1"> <node type="renderablenode"> - <asset type="texture" imagefile="test2.bmp"/> + <asset type="texture" imagefile="test2.png"/> <asset type="texture" imagefile="test.bmp"/> <asset type="quad"/> </node> Added: Mercury2/test2.png =================================================================== (Binary files differ) Property changes on: Mercury2/test2.png ___________________________________________________________________ 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: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-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 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: <cn...@us...> - 2008-12-31 00:12:59
|
Revision: 120 http://hgengine.svn.sourceforge.net/hgengine/?rev=120&view=rev Author: cnlohr Date: 2008-12-31 00:12:56 +0000 (Wed, 31 Dec 2008) Log Message: ----------- use MercuryFiles for images Modified Paths: -------------- Mercury2/scenegraph.xml Mercury2/src/BMPLoader.cpp Mercury2/src/ImageLoader.cpp Mercury2/src/ImageLoader.h Mercury2/src/MercuryUtil.cpp Mercury2/src/PNGLoader.cpp Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2008-12-30 23:50:34 UTC (rev 119) +++ Mercury2/scenegraph.xml 2008-12-31 00:12:56 UTC (rev 120) @@ -4,7 +4,7 @@ </node> <node type="transformnode" movz="-3"> <node type="renderablenode"> - <asset type="texture" imagefile="test.bmp"/> + <asset type="texture" imagefile="test2.png"/> <asset type="quad"/> </node> </node> @@ -16,7 +16,7 @@ <node type="transformnode" movz="-3" movx="1" movy="-1"> <node type="renderablenode"> <asset type="texture" imagefile="test2.png"/> - <asset type="texture" imagefile="test.bmp"/> + <asset type="texture" imagefile="test2.png"/> <asset type="quad"/> </node> </node> Modified: Mercury2/src/BMPLoader.cpp =================================================================== --- Mercury2/src/BMPLoader.cpp 2008-12-30 23:50:34 UTC (rev 119) +++ Mercury2/src/BMPLoader.cpp 2008-12-31 00:12:56 UTC (rev 120) @@ -4,7 +4,7 @@ using namespace std; -RawImageData* LoadBMP( FILE* file ) +RawImageData* LoadBMP( MercuryFile * file ) { int offset; char* tmp = new char[sizeof(int)]; @@ -15,7 +15,6 @@ unsigned char b[3]; unsigned int res_x, res_y; -// FILE* file = fopen(filename.c_str(), "rb"); printf( "BMP Load Start\n" ); if (file==NULL) { @@ -26,8 +25,8 @@ //Get the type of file and test memset(tmp, 0, 4); -// file->Read(tmp, sizeof(char) * 2); - fread(tmp, sizeof(char) * 2, 1, file); + file->Read(tmp, sizeof(char) * 2); +// fread(tmp, sizeof(char) * 2, 1, file); MString type(tmp); if (type != "BM") @@ -37,33 +36,33 @@ return NULL; } //Offset of bitmap data. - fseek(file, 10, SEEK_SET); -// file->Seek(10); - fread(tmp, 4, 1, file); -// file->Read(tmp, 4); +// fseek(file, 10, SEEK_SET); + file->Seek(10); +// fread(tmp, 4, 1, file); + file->Read(tmp, 4); memcpy(&offset, tmp, 4); TO_ENDIAN( offset ); RawImageData* image = new RawImageData; //width & width - fseek(file, 18, SEEK_SET); -// file->Seek(18); - fread(tmp, sizeof(int), 1, file); -// file->Read(tmp, sizeof(int)); +// fseek(file, 18, SEEK_SET); + file->Seek(18); +// fread(tmp, sizeof(int), 1, file); + file->Read(tmp, sizeof(int)); memcpy(&image->m_width, tmp, sizeof(int)); TO_ENDIAN( image->m_width ); - fread(tmp, sizeof(int), 1, file); -// file->Read(tmp, sizeof(int)); +// fread(tmp, sizeof(int), 1, file); + file->Read(tmp, sizeof(int)); memcpy(&image->m_height, tmp, sizeof(int)); TO_ENDIAN( image->m_height ); //bits per pixel memset(tmp, 0, sizeof(int)); - fseek(file, 28, SEEK_SET); -// file->Seek(28); -// file->Read(tmp, sizeof(int)); - fread(tmp, sizeof(int), 1, file); +// fseek(file, 28, SEEK_SET); + file->Seek(28); +// fread(tmp, sizeof(int), 1, file); + file->Read(tmp, sizeof(int)); memcpy(&bitsapix, tmp, sizeof(int)); TO_ENDIAN( bitsapix ); @@ -76,10 +75,10 @@ } //compression -// file->Seek(30); - fseek(file, 30, SEEK_SET); -// file->Read(tmp, sizeof(int)); - fread(tmp, sizeof(int), 1, file); + file->Seek(30); +// fseek(file, 30, SEEK_SET); + file->Read(tmp, sizeof(int)); +// fread(tmp, sizeof(int), 1, file); memcpy(&compression, tmp, sizeof(int)); TO_ENDIAN(compression); @@ -93,19 +92,19 @@ //pix/m X memset(tmp, 0, sizeof(int)); -// file->Seek(38); - fseek(file, 38, SEEK_SET); -// file->Read(tmp, sizeof(int)); - fread(tmp, sizeof(int), 1, file); +// fseek(file, 38, SEEK_SET); + file->Seek(38); +// fread(tmp, sizeof(int), 1, file); + file->Read(tmp, sizeof(int)); memcpy(&res_x, tmp, sizeof(int)); TO_ENDIAN(res_x); //pix/m Y memset(tmp, 0, sizeof(int)); - fseek(file, 42, SEEK_SET); -// file->Seek(42); -// file->Read(tmp, sizeof(int)); - fread(tmp, sizeof(int), 1, file); +// fseek(file, 42, SEEK_SET); + file->Seek(42); +// fread(tmp, sizeof(int), 1, file); + file->Read(tmp, sizeof(int)); memcpy(&res_y, tmp, sizeof(int)); TO_ENDIAN(res_y); @@ -120,9 +119,9 @@ } //Get the file length -// length = file->Length(); - fseek(file,0,SEEK_END); - length = ftell(file); + length = file->Length(); +// fseek(file,0,SEEK_END); +// length = ftell(file); rawlength = (length) - (offset-1); //Remember to subtract 1 from the offset. //Allocate space @@ -132,19 +131,19 @@ memset(image->m_data, 0, rawlength); //Get raw data and convert BGR->RGB -// file->Seek(offset); - fseek(file, offset, SEEK_SET); + file->Seek(offset); +// fseek(file, offset, SEEK_SET); image->m_ColorByteType = RGB; unsigned long row, pixel; unsigned char* rowPtr; - for (unsigned int x = 0; !feof(file) && (x+3 < (unsigned)rawlength); x += 3) + for (unsigned int x = 0; !file->Eof() && (x+3 < (unsigned)rawlength); x += 3) { memset(b, 0, sizeof(unsigned char) * 3); -// file->Read((char*)&b, sizeof(unsigned char) * 3); - fread(&b, sizeof(unsigned char) * 3, 1, file); + file->Read((char*)&b, sizeof(unsigned char) * 3); +// fread(&b, sizeof(unsigned char) * 3, 1, file); row = image->m_height - (x/3)/image->m_width - 1; //current row pixel = (x/3)%image->m_width; //which pixel in the row Modified: Mercury2/src/ImageLoader.cpp =================================================================== --- Mercury2/src/ImageLoader.cpp 2008-12-30 23:50:34 UTC (rev 119) +++ Mercury2/src/ImageLoader.cpp 2008-12-31 00:12:56 UTC (rev 120) @@ -11,35 +11,41 @@ return *instance; } -bool ImageLoader::RegisterFactoryCallback(const MString& type, Callback1R< FILE*, RawImageData* > functor) +bool ImageLoader::RegisterFactoryCallback(const MString& type, Callback1R< MercuryFile*, RawImageData* > functor) { MString t = ToUpper( type ); - std::pair<MString, Callback1R< FILE*, RawImageData* > > pp(t, functor); + std::pair<MString, Callback1R< MercuryFile*, RawImageData* > > pp(t, functor); m_factoryCallbacks.push_back( pp ); return true; } RawImageData* ImageLoader::LoadImage(const MString& filename) { - FILE* f = fopen(filename.c_str(), "rb"); + MercuryFile* f = FILEMAN.Open( filename ); char fingerprint[4]; fingerprint[3] = 0; + + if( !f ) + { + printf( "Error opening image: %s\n", filename.c_str() ); + return 0; + } + + f->Read( fingerprint, 3 ); + f->Seek( 0 ); - fread(fingerprint, sizeof(char)*3, 1, f); - fseek(f, 0, SEEK_SET); - MString t(fingerprint);// = ToUpper( type ); - std::list< std::pair< MString, Callback1R< FILE*, RawImageData* > > >::iterator i; + std::list< std::pair< MString, Callback1R< MercuryFile*, RawImageData* > > >::iterator i; for (i = m_factoryCallbacks.begin(); i != m_factoryCallbacks.end(); ++i) { if (i->first == t) { RawImageData* d = i->second(f); - fclose(f); + delete f; return d; } } - fclose(f); + delete f; return NULL; } Modified: Mercury2/src/ImageLoader.h =================================================================== --- Mercury2/src/ImageLoader.h 2008-12-30 23:50:34 UTC (rev 119) +++ Mercury2/src/ImageLoader.h 2008-12-31 00:12:56 UTC (rev 120) @@ -2,6 +2,7 @@ #define IMAGELOADER_H #include <RawImageData.h> +#include <MercuryFile.h> #include <Callback.h> #include <list> #include <MercuryUtil.h> @@ -10,17 +11,17 @@ { public: static ImageLoader& GetInstance(); - bool RegisterFactoryCallback(const MString& type, Callback1R< FILE*, RawImageData* >); + bool RegisterFactoryCallback(const MString& type, Callback1R< MercuryFile *, RawImageData* >); RawImageData* LoadImage(const MString& filename); private: - std::list< std::pair< MString, Callback1R< FILE*, RawImageData* > > > m_factoryCallbacks; + std::list< std::pair< MString, Callback1R< MercuryFile*, RawImageData* > > > m_factoryCallbacks; }; static InstanceCounter<ImageLoader> ILcounter("ImageLoader"); #define REGISTER_IMAGE_TYPE(fingerprint,functor)\ - Callback1R< FILE*, RawImageData* > factoryclbk##functor( functor ); \ + Callback1R< MercuryFile*, RawImageData* > factoryclbk##functor( functor ); \ bool GlobalImageRegisterSuccess##functor = ImageLoader::GetInstance().RegisterFactoryCallback(#fingerprint, factoryclbk##functor); Modified: Mercury2/src/MercuryUtil.cpp =================================================================== --- Mercury2/src/MercuryUtil.cpp 2008-12-30 23:50:34 UTC (rev 119) +++ Mercury2/src/MercuryUtil.cpp 2008-12-31 00:12:56 UTC (rev 120) @@ -58,11 +58,14 @@ if( !data ) { data = 0; + delete f; return -1; } int r = f->Read( data, length ); + delete f; + if( r != length ) { free( data ); Modified: Mercury2/src/PNGLoader.cpp =================================================================== --- Mercury2/src/PNGLoader.cpp 2008-12-30 23:50:34 UTC (rev 119) +++ Mercury2/src/PNGLoader.cpp 2008-12-31 00:12:56 UTC (rev 120) @@ -6,10 +6,10 @@ void PNGRead( png_struct *png, png_byte *p, png_size_t size ) { - FILE* f = (FILE*)png->io_ptr; + MercuryFile * f = (MercuryFile*)png->io_ptr; -// int got = f->Read( p, size ); - int got = fread(p, size, 1, f ); + int got = f->Read( p, size ); +// int got = fread(p, size, 1, f ); if( got == -1 ) png_error( png, "Error reading from file"); @@ -17,7 +17,7 @@ // png_error( png, "Unexpected EOF" ); } -RawImageData* LoadPNG( FILE * fp ) +RawImageData* LoadPNG( MercuryFile * fp ) { png_structp png_ptr; png_infop info_ptr; @@ -31,8 +31,8 @@ //open file and test for it being a png if (!fp) assert("[read_png_file] File %s could not be opened for reading"); -// fp->Read(header, 8 ); - fread(header, 8, 1, fp); + fp->Read(header, 8 ); +// fread(header, 8, 1, fp); if (png_sig_cmp(header, 0, 8)) assert("[read_png_file] File %s is not recognized as a PNG file"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2008-12-31 04:52:38
|
Revision: 125 http://hgengine.svn.sourceforge.net/hgengine/?rev=125&view=rev Author: axlecrusher Date: 2008-12-31 04:52:33 +0000 (Wed, 31 Dec 2008) Log Message: ----------- updates Modified Paths: -------------- Mercury2/mercury2.kdevelop Mercury2/scenegraph.xml Modified: Mercury2/mercury2.kdevelop =================================================================== --- Mercury2/mercury2.kdevelop 2008-12-31 04:49:29 UTC (rev 124) +++ Mercury2/mercury2.kdevelop 2008-12-31 04:52:33 UTC (rev 125) @@ -21,13 +21,13 @@ <kdevautoproject> <general> <activetarget>src/mercury2</activetarget> - <useconfiguration>optimized</useconfiguration> + <useconfiguration>debug</useconfiguration> </general> <run> <mainprogram>/home/josh/Mercury2/debug/src/mercury2</mainprogram> <terminal>false</terminal> - <programargs/> - <globaldebugarguments/> + <programargs></programargs> + <globaldebugarguments></globaldebugarguments> <globalcwd>/home/josh/Mercury2</globalcwd> <useglobalprogram>true</useglobalprogram> <autocompile>false</autocompile> @@ -45,7 +45,7 @@ <envvars/> <configargs></configargs> <topsourcedir></topsourcedir> - <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE</cppflags> + <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER</cppflags> <ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags> <ccompilerbinary></ccompilerbinary> <cxxcompilerbinary></cxxcompilerbinary> @@ -62,7 +62,7 @@ <cxxflags>-O0 -g3 -Wall</cxxflags> <envvars/> <topsourcedir></topsourcedir> - <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE</cppflags> + <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER</cppflags> <ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags> <ccompilerbinary></ccompilerbinary> <cxxcompilerbinary></cxxcompilerbinary> @@ -70,6 +70,9 @@ <cflags></cflags> <f77flags></f77flags> </debug> + <default> + <envvars/> + </default> </configurations> <make> <envvars> @@ -80,7 +83,7 @@ <runmultiplejobs>true</runmultiplejobs> <numberofjobs>3</numberofjobs> <dontact>false</dontact> - <makebin/> + <makebin></makebin> <prio>0</prio> </make> </kdevautoproject> Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2008-12-31 04:49:29 UTC (rev 124) +++ Mercury2/scenegraph.xml 2008-12-31 04:52:33 UTC (rev 125) @@ -4,7 +4,7 @@ </node> <node type="transformnode" movz="-3"> <node type="renderablenode"> - <asset type="texture" imagefile="test.bmp"/> + <asset type="texture" file="test.bmp"/> <asset type="quad"/> </node> </node> @@ -15,14 +15,14 @@ </node> <node type="transformnode" movz="-3" movx="1" movy="-1"> <node type="renderablenode"> - <asset type="texture" imagefile="test2.png"/> - <asset type="texture" imagefile="test.bmp"/> + <asset type="texture" file="test2.png"/> + <asset type="texture" file="test.bmp"/> <asset type="quad"/> </node> </node> <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="texture" file="test.bmp"/> <asset type="hgmdlmodel" file="beerhall.hgmdl"/> </node> </node> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-01-04 19:56:51
|
Revision: 148 http://hgengine.svn.sourceforge.net/hgengine/?rev=148&view=rev Author: axlecrusher Date: 2009-01-04 19:56:47 +0000 (Sun, 04 Jan 2009) Log Message: ----------- updates Modified Paths: -------------- Mercury2/adv_set.c Mercury2/base_set.sh Mercury2/mercury2.kdevelop Modified: Mercury2/adv_set.c =================================================================== --- Mercury2/adv_set.c 2009-01-04 19:10:52 UTC (rev 147) +++ Mercury2/adv_set.c 2009-01-04 19:56:47 UTC (rev 148) @@ -9,7 +9,7 @@ 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/HGMDLMesh.cpp \ src/HGMDLModel.cpp src/MercuryString.cpp src/MercuryCrash.c src/MercuryBacktrace.c \ - src/MercuryFile.cpp" + src/MercuryFile.cpp src/MercuryTimer.cpp src/MercuryMessageManager.cpp" SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \ Modified: Mercury2/base_set.sh =================================================================== --- Mercury2/base_set.sh 2009-01-04 19:10:52 UTC (rev 147) +++ Mercury2/base_set.sh 2009-01-04 19:56:47 UTC (rev 148) @@ -14,7 +14,7 @@ OPT_libxml=1 DEFINES="WAS_CONFIGURED USE_MSTRING" -CC_BASE="-O2 -g0 -Wall" +CC_BASE="-O2 -g0 -Wall -DUSE_SSE" for i in $*; do if test $i = "--help"; then Modified: Mercury2/mercury2.kdevelop =================================================================== --- Mercury2/mercury2.kdevelop 2009-01-04 19:10:52 UTC (rev 147) +++ Mercury2/mercury2.kdevelop 2009-01-04 19:56:47 UTC (rev 148) @@ -2,7 +2,7 @@ <kdevelop> <general> <author>Joshua Allen</author> - <email/> + <email></email> <version>2.0</version> <projectmanagement>KDevAutoProject</projectmanagement> <primarylanguage>C++</primarylanguage> @@ -14,8 +14,8 @@ <projectname>Mercury2</projectname> <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> - <description/> - <defaultencoding/> + <description></description> + <defaultencoding></defaultencoding> <versioncontrol/> </general> <kdevautoproject> @@ -26,8 +26,8 @@ <run> <mainprogram>/home/josh/Mercury2/debug/src/mercury2</mainprogram> <terminal>false</terminal> - <programargs/> - <globaldebugarguments/> + <programargs></programargs> + <globaldebugarguments></globaldebugarguments> <globalcwd>/home/josh/Mercury2</globalcwd> <useglobalprogram>true</useglobalprogram> <autocompile>false</autocompile> @@ -41,17 +41,17 @@ <ccompiler>kdevgccoptions</ccompiler> <cxxcompiler>kdevgppoptions</cxxcompiler> <f77compiler>kdevg77options</f77compiler> - <cxxflags>-O2 -g0 -Wall</cxxflags> + <cxxflags>-O2 -g -Wall</cxxflags> <envvars/> - <configargs/> - <topsourcedir/> - <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER</cppflags> + <configargs></configargs> + <topsourcedir></topsourcedir> + <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER -DUSE_SSE</cppflags> <ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags> - <ccompilerbinary/> - <cxxcompilerbinary/> - <f77compilerbinary/> - <cflags/> - <f77flags/> + <ccompilerbinary></ccompilerbinary> + <cxxcompilerbinary></cxxcompilerbinary> + <f77compilerbinary></f77compilerbinary> + <cflags>-O2 -g -Wall</cflags> + <f77flags></f77flags> </optimized> <debug> <configargs>--enable-debug=full</configargs> @@ -59,19 +59,33 @@ <ccompiler>kdevgccoptions</ccompiler> <cxxcompiler>kdevgppoptions</cxxcompiler> <f77compiler>kdevg77options</f77compiler> - <cxxflags>-O0 -g3 -Wall</cxxflags> + <cxxflags>-O2 -g -Wall</cxxflags> <envvars/> + <topsourcedir></topsourcedir> + <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER -DUSE_SSE</cppflags> + <ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags> + <ccompilerbinary></ccompilerbinary> + <cxxcompilerbinary></cxxcompilerbinary> + <f77compilerbinary></f77compilerbinary> + <cflags>-O2 -g -Wall</cflags> + <f77flags></f77flags> + </debug> + <default> + <envvars/> + <configargs/> + <builddir/> <topsourcedir/> - <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER</cppflags> - <ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags> + <cppflags/> + <ldflags/> + <ccompiler>kdevgccoptions</ccompiler> + <cxxcompiler>kdevgppoptions</cxxcompiler> + <f77compiler>kdevg77options</f77compiler> <ccompilerbinary/> <cxxcompilerbinary/> <f77compilerbinary/> <cflags/> + <cxxflags/> <f77flags/> - </debug> - <default> - <envvars/> </default> </configurations> <make> @@ -208,7 +222,7 @@ <includePaths>.;</includePaths> </codecompletion> <creategettersetter> - <prefixGet/> + <prefixGet></prefixGet> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> <parameterName>theValue</parameterName> @@ -229,11 +243,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...> - 2009-03-02 19:46:14
|
Revision: 160 http://hgengine.svn.sourceforge.net/hgengine/?rev=160&view=rev Author: axlecrusher Date: 2009-03-02 19:46:08 +0000 (Mon, 02 Mar 2009) Log Message: ----------- update everything Modified Paths: -------------- Mercury2/mercury2.kdevelop Mercury2/scenegraph.xml Mercury2/src/BoundingBox.cpp Mercury2/src/BoundingBox.h Mercury2/src/MercuryAsset.cpp Mercury2/src/MercuryAsset.h Mercury2/src/MercuryMath.cpp Mercury2/src/MercuryMath.h Mercury2/src/MercuryMatrix.cpp Mercury2/src/MercuryMatrix.h Mercury2/src/RenderableNode.cpp Mercury2/src/RenderableNode.h Mercury2/src/Viewport.cpp Mercury2/src/Viewport.h Modified: Mercury2/mercury2.kdevelop =================================================================== --- Mercury2/mercury2.kdevelop 2009-03-02 19:41:32 UTC (rev 159) +++ Mercury2/mercury2.kdevelop 2009-03-02 19:46:08 UTC (rev 160) @@ -26,8 +26,8 @@ <run> <mainprogram>/home/josh/Mercury2/debug/src/mercury2</mainprogram> <terminal>false</terminal> - <programargs/> - <globaldebugarguments/> + <programargs></programargs> + <globaldebugarguments></globaldebugarguments> <globalcwd>/home/josh/Mercury2</globalcwd> <useglobalprogram>true</useglobalprogram> <autocompile>false</autocompile> @@ -59,16 +59,16 @@ <ccompiler>kdevgccoptions</ccompiler> <cxxcompiler>kdevgppoptions</cxxcompiler> <f77compiler>kdevg77options</f77compiler> - <cxxflags>-O2 -g -Wall</cxxflags> + <cxxflags>-O0 -g -Wall</cxxflags> <envvars/> - <topsourcedir/> - <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER -DUSE_SSE</cppflags> + <topsourcedir></topsourcedir> + <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER</cppflags> <ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags> - <ccompilerbinary/> - <cxxcompilerbinary/> - <f77compilerbinary/> - <cflags>-O2 -g -Wall</cflags> - <f77flags/> + <ccompilerbinary></ccompilerbinary> + <cxxcompilerbinary></cxxcompilerbinary> + <f77compilerbinary></f77compilerbinary> + <cflags>-O0 -g -Wall</cflags> + <f77flags></f77flags> </debug> <default> <envvars/> Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-03-02 19:41:32 UTC (rev 159) +++ Mercury2/scenegraph.xml 2009-03-02 19:46:08 UTC (rev 160) @@ -1,5 +1,5 @@ <SceneGraph> - <node type="transformnode" movz="-1" roty="13"> + <node type="transformnode" movz="0" roty="0"> <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100"/> </node> <node type="transformnode" movz="-3"> @@ -20,14 +20,8 @@ <asset type="quad"/> </node> </node> - <node type="rotatornode" movz="-2" scalex="0.25" scaley="0.25" scalez="0.25" > + <node type="rotatornode" movy="0" movz="-2" scalex="0.25" scaley="0.25" scalez="0.25" > <node type="renderablenode"> - <asset type="texture" file="test.bmp"/> - <asset type="hgmdlmodel" file="beerhall.hgmdl"/> - </node> - </node> - <node type="rotatornode" movz="-2" movx="2" scalex="0.25" scaley="0.25" scalez="0.25" > - <node type="renderablenode"> <asset type="texture" file="gunther.png"/> <asset type="hgmdlmodel" file="gunther.hgmdl"/> </node> Modified: Mercury2/src/BoundingBox.cpp =================================================================== --- Mercury2/src/BoundingBox.cpp 2009-03-02 19:41:32 UTC (rev 159) +++ Mercury2/src/BoundingBox.cpp 2009-03-02 19:46:08 UTC (rev 160) @@ -2,6 +2,8 @@ #include <GL/glext.h> #include <BoundingBox.h> +#include <Viewport.h> + void BoundingBox::LoadFromBinary(char* data) { memcpy(m_center, data, sizeof(float)*3); @@ -15,6 +17,17 @@ void RenderableBoundingBox::Render(MercuryNode* node) { + const BoundingBox& bb = *m_bb; + + MercuryVertex c = GetGlobalMatrix() * m_bb->GetCenter(); + +// GetGlobalMatrix().Print(); +// c.Print(); + + BoundingBox gbb( c, bb.GetExtend() ); + +// printf("clip %d\n", FRUSTUM->Clip(gbb) ); + const float* center = m_bb->GetCenter(); const float* extend = m_bb->GetExtend(); Modified: Mercury2/src/BoundingBox.h =================================================================== --- Mercury2/src/BoundingBox.h 2009-03-02 19:41:32 UTC (rev 159) +++ Mercury2/src/BoundingBox.h 2009-03-02 19:46:08 UTC (rev 160) @@ -2,16 +2,24 @@ #define BOUNDINGBOX_H #include <MercuryAsset.h> +#include <MercuryVertex.h> class BoundingBox { public: + BoundingBox() {}; + BoundingBox(const MercuryVertex& center, const MercuryVertex& extend) + :m_center(center), m_extend(extend) + {}; + void LoadFromBinary(char* data); - inline const float* GetCenter() const { return m_center; } - inline const float* GetExtend() const { return m_extend; } + + inline const MercuryVertex& GetCenter() const { return m_center; } + inline const MercuryVertex& GetExtend() const { return m_extend; } + private: - float m_center[3]; - float m_extend[3]; + MercuryVertex m_center; + MercuryVertex m_extend; }; class RenderableBoundingBox : public MercuryAsset Modified: Mercury2/src/MercuryAsset.cpp =================================================================== --- Mercury2/src/MercuryAsset.cpp 2009-03-02 19:41:32 UTC (rev 159) +++ Mercury2/src/MercuryAsset.cpp 2009-03-02 19:46:08 UTC (rev 160) @@ -65,8 +65,14 @@ m_assetInstances.erase( asset ); printf("removed asset %s\n", key.c_str()); } + } +const MercuryMatrix& MercuryAsset::GetGlobalMatrix() const +{ + return GLOBALMATRIX; +} + std::map<MString, MercuryAsset*> AssetFactory::m_assetInstances; /*************************************************************************** Modified: Mercury2/src/MercuryAsset.h =================================================================== --- Mercury2/src/MercuryAsset.h 2009-03-02 19:41:32 UTC (rev 159) +++ Mercury2/src/MercuryAsset.h 2009-03-02 19:46:08 UTC (rev 160) @@ -5,6 +5,7 @@ #include <MercuryNode.h> #include <MessageHandler.h> #include <map> +#include <MercuryMatrix.h> class MercuryAsset : public RefBase, MessageHandler { @@ -22,6 +23,7 @@ virtual void LoadFromXML(const XMLNode& node) {}; inline void IsInstanced(bool b) { m_isInstanced = b; } + const MercuryMatrix& GetGlobalMatrix() const; protected: bool m_isInstanced; }; Modified: Mercury2/src/MercuryMath.cpp =================================================================== --- Mercury2/src/MercuryMath.cpp 2009-03-02 19:41:32 UTC (rev 159) +++ Mercury2/src/MercuryMath.cpp 2009-03-02 19:46:08 UTC (rev 160) @@ -170,6 +170,22 @@ out[3] = p[0] * m[12] + p[1] * m[13] + p[2] * m[14] + p[3] * m[15]; } +void Float2FloatRow(const float* f, FloatRow* r) +{ + *r[0] = f[0]; + *r[1] = f[1]; + *r[2] = f[2]; + *r[3] = f[3]; +} + +void FloatRow2Float( const FloatRow* fr, float* f) +{ + f[0] = (*fr)[0]; + f[1] = (*fr)[1]; + f[2] = (*fr)[2]; + f[3] = (*fr)[3]; +} + #else //inline __m128 Hadd4(__m128 x); @@ -289,6 +305,16 @@ r = (FloatRow)_mm_setzero_ps(); } +FloatRow Float2FloatRow(const float* f, , FloatRow* r) +{ + r = _mm_load_ps( f ); +} + +void FloatRow2Float( const FloatRow* fr, float* f) +{ + _mm_store_ps( f, *fr ); +} + #endif /* Modified: Mercury2/src/MercuryMath.h =================================================================== --- Mercury2/src/MercuryMath.h 2009-03-02 19:41:32 UTC (rev 159) +++ Mercury2/src/MercuryMath.h 2009-03-02 19:46:08 UTC (rev 160) @@ -42,7 +42,7 @@ #define SQ(x) ((x)*(x)); -#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) +//#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) void Mul4f(const FloatRow* first, const FloatRow* second, FloatRow* out); void Div4f(const FloatRow* first, const FloatRow* second, FloatRow* out); @@ -55,6 +55,9 @@ void VectorMultiply4f(const FloatRow* matrix, const FloatRow* p, FloatRow* out ); void TransposeMatrix( FloatRow* m ); +void Float2FloatRow(const float* f, FloatRow* r); +void FloatRow2Float( const FloatRow* fr, float* f); + const FloatRow gfrZero = { 0.f, 0.f, 0.f, 0.f }; #endif Modified: Mercury2/src/MercuryMatrix.cpp =================================================================== --- Mercury2/src/MercuryMatrix.cpp 2009-03-02 19:41:32 UTC (rev 159) +++ Mercury2/src/MercuryMatrix.cpp 2009-03-02 19:46:08 UTC (rev 160) @@ -39,27 +39,6 @@ 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; Copy16f(&m_matrix[0], Identity ); -/* - (*this)[0][0] = 1; - (*this)[0][1] = 0; - (*this)[0][2] = 0; - (*this)[0][3] = 0; - - (*this)[1][0] = 0; - (*this)[1][1] = 1; - (*this)[1][2] = 0; - (*this)[1][3] = 0; - - (*this)[2][0] = 0; - (*this)[2][1] = 0; - (*this)[2][2] = 1; - (*this)[2][3] = 0; - - (*this)[3][0] = 0; - (*this)[3][1] = 0; - (*this)[3][2] = 0; - (*this)[3][3] = 1; - */ } void MercuryMatrix::Translate(float x, float y, float z) @@ -207,7 +186,7 @@ return *this; } -void MercuryMatrix::Print() +void MercuryMatrix::Print() const { for (int i = 0; i < 4; ++i) { @@ -216,6 +195,19 @@ printf("\n"); } +MercuryVector MercuryMatrix::operator*(const MercuryVector& v) const +{ + float tmp[4]; + v.ConvertToVector4( tmp ); + FloatRow r, tvo; + Float2FloatRow( tmp, &r ); + VectorMultiply4f( m_matrix, &r, &tvo); + FloatRow2Float( &tvo, tmp ); + MercuryVertex(tmp).Print(); + return MercuryVertex(tmp); +} + + /* * Copyright (c) 2006 Joshua Allen * All rights reserved. Modified: Mercury2/src/MercuryMatrix.h =================================================================== --- Mercury2/src/MercuryMatrix.h 2009-03-02 19:41:32 UTC (rev 159) +++ Mercury2/src/MercuryMatrix.h 2009-03-02 19:46:08 UTC (rev 160) @@ -4,6 +4,7 @@ //This matrix will work identically to float[16] #include "MercuryMath.h" #include "MercuryUtil.h" +#include <MercuryVertex.h> class MercuryMatrix; @@ -27,6 +28,8 @@ MercuryMatrix operator*(const MercuryMatrix& m) const; MercuryMatrix& operator*=(const MercuryMatrix& m); + + MercuryVector operator*(const MercuryVertex& v) const; void Translate(float x, float y, float z); ///Rotate along the 3 primariy axes by given amounts (in deg) @@ -40,7 +43,7 @@ void Zero(); void Identity(); - void Print(); + void Print() const; } #if !defined( WIN32 ) || defined( _MSC_VER ) M_ALIGN(64); Modified: Mercury2/src/RenderableNode.cpp =================================================================== --- Mercury2/src/RenderableNode.cpp 2009-03-02 19:41:32 UTC (rev 159) +++ Mercury2/src/RenderableNode.cpp 2009-03-02 19:46:08 UTC (rev 160) @@ -10,6 +10,8 @@ uint64_t RenderWaited = 0; uint64_t UpdateWaited = 0; +MercuryMatrix GLOBALMATRIX; + RenderableNode::RenderableNode() :m_hidden(false) { @@ -45,7 +47,7 @@ if (m_hidden || IsCulled()) return; - MercuryMatrix m = FindGlobalMatrix(); + MercuryMatrix m = GLOBALMATRIX = FindGlobalMatrix(); m.Transpose(); glLoadMatrixf( m.Ptr() ); Modified: Mercury2/src/RenderableNode.h =================================================================== --- Mercury2/src/RenderableNode.h 2009-03-02 19:41:32 UTC (rev 159) +++ Mercury2/src/RenderableNode.h 2009-03-02 19:46:08 UTC (rev 160) @@ -11,6 +11,7 @@ extern uint64_t RenderWaited; extern uint64_t UpdateWaited; +extern MercuryMatrix GLOBALMATRIX; class RenderableNode : public MercuryNode { Modified: Mercury2/src/Viewport.cpp =================================================================== --- Mercury2/src/Viewport.cpp 2009-03-02 19:41:32 UTC (rev 159) +++ Mercury2/src/Viewport.cpp 2009-03-02 19:46:08 UTC (rev 160) @@ -3,15 +3,22 @@ REGISTER_NODE_TYPE(Viewport); +const Frustum* FRUSTUM = NULL; + void Viewport::Render() { + FRUSTUM = &m_frustum; + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); MercuryMatrix m = FindGlobalMatrix(); m.Transpose(); + + MercuryMatrix f = m_frustum.GetMatrix(); + f.Transpose(); - glLoadMatrixf( (m * m_frustum.GetMatrix()).Ptr() ); + glLoadMatrixf( (m * f).Ptr() ); //The following 2 are equivelent to above // glLoadMatrixf( m_frustum.Ptr() ); // glMultMatrixf( m.Ptr() ); @@ -76,7 +83,7 @@ m_frustum[2][3] = D; m_frustum[3][2] = -1; - m_frustum.Transpose(); //XXX fix it to remove this +// m_frustum.Transpose(); //XXX fix it to remove this } void Frustum::LookAt(const MercuryVertex& eye, const MercuryVector& look, const MercuryVector& up) @@ -117,6 +124,17 @@ m_planes[PRIGHT].Setup(m_nc+X*m_nw,normal); } +bool Frustum::Clip(const BoundingBox& bb) const +{ + bool inView = false; + for (uint8_t i = 0; (i < 6) && !inView; ++i) + { + inView = m_planes[i].IsBehindPlane( bb )?inView:true; + } + + return !inView; +}; + /* void Frustum::LookAt() { Modified: Mercury2/src/Viewport.h =================================================================== --- Mercury2/src/Viewport.h 2009-03-02 19:41:32 UTC (rev 159) +++ Mercury2/src/Viewport.h 2009-03-02 19:46:08 UTC (rev 160) @@ -6,17 +6,18 @@ #include <MercuryVertex.h> #include <MercuryPlane.h> +enum PlanePos +{ + PTOP = 0, + PBOTTOM, + PLEFT, + PRIGHT, + PNEAR, + PFAR +}; + class Frustum { - enum PlanePos - { - PTOP = 0, - PBOTTOM, - PLEFT, - PRIGHT, - PNEAR, - PFAR - }; public: void SetPerspective( float fov, float aspect, float znear, float zfar ); @@ -24,6 +25,10 @@ void ComputeFrustum(float left, float right, float bottom, float top, float zNear, float zFar); void LookAt(const MercuryVertex& eye, const MercuryVector& look, const MercuryVector& up); + + bool Clip(const BoundingBox& bb) const; + + MercuryPlane m_planes[6]; private: MercuryMatrix m_frustum; @@ -31,9 +36,10 @@ float m_nh, m_nw, m_fh, m_fw; MercuryVector m_nc, m_fc; - MercuryPlane m_planes[6]; }; +extern const Frustum* FRUSTUM; + class Viewport : public RenderableNode { public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-03-08 04:19:59
|
Revision: 177 http://hgengine.svn.sourceforge.net/hgengine/?rev=177&view=rev Author: axlecrusher Date: 2009-03-08 04:19:56 +0000 (Sun, 08 Mar 2009) Log Message: ----------- Update to fix compile on ubuntu Modified Paths: -------------- Mercury2/mercury2.kdevelop Mercury2/scenegraph.xml Mercury2/src/AlignedBuffer.h Mercury2/src/BMPLoader.cpp Mercury2/src/BoundingBox.cpp Mercury2/src/BoundingBox.h Mercury2/src/MercuryFileDriverDirect.cpp Mercury2/src/MercuryFileDriverPacked.cpp Mercury2/src/MercuryFileDriverZipped.cpp Mercury2/src/MercuryMessageManager.h Mercury2/src/RenderableNode.cpp Mercury2/src/RenderableNode.h Modified: Mercury2/mercury2.kdevelop =================================================================== --- Mercury2/mercury2.kdevelop 2009-03-04 00:46:51 UTC (rev 176) +++ Mercury2/mercury2.kdevelop 2009-03-08 04:19:56 UTC (rev 177) @@ -2,7 +2,7 @@ <kdevelop> <general> <author>Joshua Allen</author> - <email></email> + <email/> <version>2.0</version> <projectmanagement>KDevAutoProject</projectmanagement> <primarylanguage>C++</primarylanguage> @@ -14,8 +14,8 @@ <projectname>Mercury2</projectname> <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> - <description></description> - <defaultencoding></defaultencoding> + <description/> + <defaultencoding/> <versioncontrol/> </general> <kdevautoproject> @@ -24,10 +24,10 @@ <useconfiguration>debug</useconfiguration> </general> <run> - <mainprogram>/home/josh/Mercury2/debug/src/mercury2</mainprogram> + <mainprogram/> <terminal>false</terminal> - <programargs></programargs> - <globaldebugarguments></globaldebugarguments> + <programargs/> + <globaldebugarguments/> <globalcwd>/home/josh/Mercury2</globalcwd> <useglobalprogram>true</useglobalprogram> <autocompile>false</autocompile> @@ -59,16 +59,16 @@ <ccompiler>kdevgccoptions</ccompiler> <cxxcompiler>kdevgppoptions</cxxcompiler> <f77compiler>kdevg77options</f77compiler> - <cxxflags>-O0 -g -Wall</cxxflags> + <cxxflags>-O2 -g -Wall</cxxflags> <envvars/> - <topsourcedir></topsourcedir> - <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER</cppflags> + <topsourcedir/> + <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER -DUSE_SSE</cppflags> <ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags> - <ccompilerbinary></ccompilerbinary> - <cxxcompilerbinary></cxxcompilerbinary> - <f77compilerbinary></f77compilerbinary> + <ccompilerbinary/> + <cxxcompilerbinary/> + <f77compilerbinary/> <cflags>-O0 -g -Wall</cflags> - <f77flags></f77flags> + <f77flags/> </debug> <default> <envvars/> @@ -193,8 +193,8 @@ <includestyle>3</includestyle> <root>/usr/qt/3</root> <designerintegration>EmbeddedKDevDesigner</designerintegration> - <qmake>/usr/qt/3/bin/qmake</qmake> - <designer>/usr/qt/3/bin/designer</designer> + <qmake></qmake> + <designer></designer> <designerpluginpaths/> </qt> <references/> @@ -222,7 +222,7 @@ <includePaths>.;</includePaths> </codecompletion> <creategettersetter> - <prefixGet></prefixGet> + <prefixGet/> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> <parameterName>theValue</parameterName> @@ -243,11 +243,11 @@ </cppsupportpart> <kdevdebugger> <general> - <gdbpath></gdbpath> + <gdbpath/> <dbgshell>libtool</dbgshell> - <configGdbScript></configGdbScript> - <runShellScript></runShellScript> - <runGdbScript></runGdbScript> + <configGdbScript/> + <runShellScript/> + <runGdbScript/> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> <floatingtoolbar>false</floatingtoolbar> Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-03-04 00:46:51 UTC (rev 176) +++ Mercury2/scenegraph.xml 2009-03-08 04:19:56 UTC (rev 177) @@ -22,8 +22,8 @@ </node> <node type="rotatornode" movy="0" movz="-2" scalex="0.25" scaley="0.25" scalez="0.25" > <node type="renderablenode"> - <asset type="texture" file="gunther.png"/> - <asset type="hgmdlmodel" file="gunther.hgmdl"/> + <asset type="texture" file="test.bmp"/> + <asset type="hgmdlmodel" file="beerhall.hgmdl"/> </node> </node> </SceneGraph> Modified: Mercury2/src/AlignedBuffer.h =================================================================== --- Mercury2/src/AlignedBuffer.h 2009-03-04 00:46:51 UTC (rev 176) +++ Mercury2/src/AlignedBuffer.h 2009-03-08 04:19:56 UTC (rev 177) @@ -1,6 +1,8 @@ #ifndef ALIGNEDBUFFER_H #define ALIGNEDBUFFER_H +#include <stdint.h> + template <typename T> class AlignedBuffer { Modified: Mercury2/src/BMPLoader.cpp =================================================================== --- Mercury2/src/BMPLoader.cpp 2009-03-04 00:46:51 UTC (rev 176) +++ Mercury2/src/BMPLoader.cpp 2009-03-08 04:19:56 UTC (rev 177) @@ -1,6 +1,7 @@ #include <RawImageData.h> #include <MercuryUtil.h> #include <ImageLoader.h> +#include <string.h> using namespace std; Modified: Mercury2/src/BoundingBox.cpp =================================================================== --- Mercury2/src/BoundingBox.cpp 2009-03-04 00:46:51 UTC (rev 176) +++ Mercury2/src/BoundingBox.cpp 2009-03-08 04:19:56 UTC (rev 177) @@ -1,7 +1,7 @@ #include <GL/gl.h> #include <GL/glext.h> #include <BoundingBox.h> - +#include <string.h> #include <Viewport.h> BoundingBox::BoundingBox(const MercuryVertex& center, const MercuryVertex& extend) @@ -50,8 +50,6 @@ void RenderableBoundingBox::Render(MercuryNode* node) { - const BoundingBox& bb = *m_bb; - BoundingBox gbb = m_bb->Transform( GetGlobalMatrix() ); if ( FRUSTUM->Clip( gbb ) ) return; Modified: Mercury2/src/BoundingBox.h =================================================================== --- Mercury2/src/BoundingBox.h 2009-03-04 00:46:51 UTC (rev 176) +++ Mercury2/src/BoundingBox.h 2009-03-08 04:19:56 UTC (rev 177) @@ -4,6 +4,7 @@ #include <MercuryAsset.h> #include <MercuryVertex.h> #include <MercuryMatrix.h> +#include <stdint.h> class BoundingBox { Modified: Mercury2/src/MercuryFileDriverDirect.cpp =================================================================== --- Mercury2/src/MercuryFileDriverDirect.cpp 2009-03-04 00:46:51 UTC (rev 176) +++ Mercury2/src/MercuryFileDriverDirect.cpp 2009-03-08 04:19:56 UTC (rev 177) @@ -14,6 +14,8 @@ #define FSHEADER "" #endif +#include <string.h> + //Core base only. MercuryFile::MercuryFile() { Modified: Mercury2/src/MercuryFileDriverPacked.cpp =================================================================== --- Mercury2/src/MercuryFileDriverPacked.cpp 2009-03-04 00:46:51 UTC (rev 176) +++ Mercury2/src/MercuryFileDriverPacked.cpp 2009-03-08 04:19:56 UTC (rev 177) @@ -1,4 +1,5 @@ #include <MercuryFileDriverPacked.h> +#include <string.h> const MString PackagePrefix = "Packages/"; Modified: Mercury2/src/MercuryFileDriverZipped.cpp =================================================================== --- Mercury2/src/MercuryFileDriverZipped.cpp 2009-03-04 00:46:51 UTC (rev 176) +++ Mercury2/src/MercuryFileDriverZipped.cpp 2009-03-08 04:19:56 UTC (rev 177) @@ -3,6 +3,7 @@ //For the store compression on zips #include <zlib.h> +#include <string.h> const MString PackagePrefix = "Packages/"; Modified: Mercury2/src/MercuryMessageManager.h =================================================================== --- Mercury2/src/MercuryMessageManager.h 2009-03-04 00:46:51 UTC (rev 176) +++ Mercury2/src/MercuryMessageManager.h 2009-03-08 04:19:56 UTC (rev 177) @@ -7,6 +7,7 @@ #include <PriorityQueue.h> #include <MercuryString.h> #include <MercuryUtil.h> +#include <stdint.h> /* This message system uses absolute integer time values to fire off events. This ensures accuarate firing times while eliminating floating point error. Modified: Mercury2/src/RenderableNode.cpp =================================================================== --- Mercury2/src/RenderableNode.cpp 2009-03-04 00:46:51 UTC (rev 176) +++ Mercury2/src/RenderableNode.cpp 2009-03-08 04:19:56 UTC (rev 177) @@ -2,6 +2,7 @@ #include <assert.h> #include <GL/gl.h> #include <TransformNode.h> +#include <unistd.h> using namespace std; Modified: Mercury2/src/RenderableNode.h =================================================================== --- Mercury2/src/RenderableNode.h 2009-03-04 00:46:51 UTC (rev 176) +++ Mercury2/src/RenderableNode.h 2009-03-08 04:19:56 UTC (rev 177) @@ -6,6 +6,7 @@ #include <MercuryAsset.h> #include <MercuryMatrix.h> #include <MSemaphore.h> +#include <stdint.h> #define MCHECKASSETS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-03-21 02:18:47
|
Revision: 189 http://hgengine.svn.sourceforge.net/hgengine/?rev=189&view=rev Author: axlecrusher Date: 2009-03-21 02:18:27 +0000 (Sat, 21 Mar 2009) Log Message: ----------- add more XML fallback Modified Paths: -------------- Mercury2/mercury2.kdevelop Mercury2/scenegraph.xml Mercury2/src/XMLParser.cpp Mercury2/src/XMLParser.h Modified: Mercury2/mercury2.kdevelop =================================================================== --- Mercury2/mercury2.kdevelop 2009-03-20 04:03:50 UTC (rev 188) +++ Mercury2/mercury2.kdevelop 2009-03-21 02:18:27 UTC (rev 189) @@ -24,7 +24,7 @@ <useconfiguration>debug</useconfiguration> </general> <run> - <mainprogram/> + <mainprogram>/home/josh/Mercury2/debug/src/mercury2</mainprogram> <terminal>false</terminal> <programargs/> <globaldebugarguments/> @@ -37,7 +37,7 @@ </run> <configurations> <optimized> - <builddir>optimized</builddir> + <builddir>/home/josh/Mercury2/optimized</builddir> <ccompiler>kdevgccoptions</ccompiler> <cxxcompiler>kdevgppoptions</cxxcompiler> <f77compiler>kdevg77options</f77compiler> @@ -55,14 +55,14 @@ </optimized> <debug> <configargs>--enable-debug=full</configargs> - <builddir>debug</builddir> + <builddir>/home/josh/Mercury2/debug</builddir> <ccompiler>kdevgccoptions</ccompiler> <cxxcompiler>kdevgppoptions</cxxcompiler> <f77compiler>kdevg77options</f77compiler> - <cxxflags>-O2 -g -Wall</cxxflags> + <cxxflags>-O0 -g -Wall</cxxflags> <envvars/> <topsourcedir/> - <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER -DUSE_SSE</cppflags> + <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER</cppflags> <ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags> <ccompilerbinary/> <cxxcompilerbinary/> @@ -259,4 +259,33 @@ <outputradix>10</outputradix> </display> </kdevdebugger> + <dist> + <custom>false</custom> + <bzip>false</bzip> + <archname/> + <appname>Mercury2</appname> + <version>2.0</version> + <release/> + <vendor/> + <licence/> + <summary/> + <group/> + <packager/> + <description/> + <changelog/> + <devpackage>false</devpackage> + <docspackage>false</docspackage> + <appicon>false</appicon> + <arch>2</arch> + <genHTML>false</genHTML> + <useRPM>false</useRPM> + <ftpkde>false</ftpkde> + <appskde>false</appskde> + <url/> + </dist> + <ctagspart> + <customArguments/> + <customTagfilePath>/home/josh/Mercury2/tags</customTagfilePath> + <activeTagsFiles/> + </ctagspart> </kdevelop> Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-03-20 04:03:50 UTC (rev 188) +++ Mercury2/scenegraph.xml 2009-03-21 02:18:27 UTC (rev 189) @@ -7,28 +7,24 @@ <asset type="texture" file="test.bmp"/> <asset type="quad"/> </node> - <node type="transformnode" movx="-1" movy="-1" fallback="fallbackTest"> - <node type="renderablenode"> - <asset type="quad"/> - </node> - </node> </node> - <node type="transformnode" movx="-1" movy="-1" fallback="fallbackTest"> + <node type="transformnode" movz="-3" movx="-1" movy="-1"> <node type="renderablenode"> <asset type="quad"/> </node> </node> - <node type="transformnode" movx="1" movy="-1" fallback="fallbackTest"> + <node type="transformnode" movz="-3" movx="1" movy="-1" > <node type="renderablenode"> <asset type="texture" file="test2.png"/> <asset type="texture" file="test.bmp"/> <asset type="quad"/> </node> </node> - <node type="rotatornode" movy="0" movz="-2" scalex="0.25" scaley="0.25" scalez="0.25" > - <node type="renderablenode"> - <asset type="texture" file="test.bmp"/> - <asset type="hgmdlmodel" file="beerhall.hgmdl"/> + <node type="transformnode" movx="1" movy="1" fallback="fallbackTest"> + <node type="transformnode" movx="-2"> + <node type="renderablenode"> + <asset type="quad"/> + </node> </node> </node> </SceneGraph> Modified: Mercury2/src/XMLParser.cpp =================================================================== --- Mercury2/src/XMLParser.cpp 2009-03-20 04:03:50 UTC (rev 188) +++ Mercury2/src/XMLParser.cpp 2009-03-21 02:18:27 UTC (rev 189) @@ -12,13 +12,14 @@ } XMLNode::XMLNode(const XMLNode& n) - :m_node(n.m_node) + :m_node(n.m_node), m_doc(n.m_doc) { } XMLNode::~XMLNode() { m_node = NULL; + m_doc = NULL; } XMLNode XMLNode::NextNode() const @@ -29,9 +30,9 @@ if (node->type == XML_ELEMENT_NODE) return XMLNode(node,m_doc); -//falling back here seem like a bad idea, high chance of infinite loops? -// XMLNode fall = FindFallbackNode(); -// return fall.NextNode(); + XMLNode parent(m_node->parent, m_doc); + XMLNode fall = parent.FindFallbackNode(); + return fall.Child(); } return XMLNode(); } @@ -43,10 +44,6 @@ for (xmlNode* node = m_node->prev; node; node=node->prev) if (node->type == XML_ELEMENT_NODE) return XMLNode(node,m_doc); - -//falling back here seem like a bad idea, high chance of infinite loops? -// XMLNode fall = FindFallbackNode(); -// return fall.PreviousNode(); } return XMLNode(); } @@ -58,9 +55,8 @@ for (xmlNode* node = m_node->children; node; node=node->next) if (node->type == XML_ELEMENT_NODE) return XMLNode(node,m_doc); -//falling back here seem like a bad idea, high chance of infinite loops? -// XMLNode fall = FindFallbackNode(); -// return fall.Child(); + XMLNode fall = FindFallbackNode(); + return fall.Child(); } return XMLNode(); } @@ -147,6 +143,12 @@ return *this; } +const XMLNode& XMLNode::operator=(const XMLNode& n) +{ + m_node = n.m_node; + m_doc = n.m_doc; +} + XMLDocument::XMLDocument() :m_doc(NULL) { Modified: Mercury2/src/XMLParser.h =================================================================== --- Mercury2/src/XMLParser.h 2009-03-20 04:03:50 UTC (rev 188) +++ Mercury2/src/XMLParser.h 2009-03-21 02:18:27 UTC (rev 189) @@ -33,6 +33,8 @@ inline bool IsValid() const { return m_node!=NULL; } XMLNode FindFallbackNode() const; + + const XMLNode& operator=(const XMLNode& n); private: XMLNode RecursiveFindFallbackNode(const MString& path) const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-05-16 13:03:28
|
Revision: 258 http://hgengine.svn.sourceforge.net/hgengine/?rev=258&view=rev Author: axlecrusher Date: 2009-05-16 13:03:19 +0000 (Sat, 16 May 2009) Log Message: ----------- Cylindrical Billboards looks like it works Modified Paths: -------------- Mercury2/scenegraph.xml Mercury2/src/BillboardNode.cpp Mercury2/src/Viewport.cpp Mercury2/src/Viewport.h Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-05-16 04:36:19 UTC (rev 257) +++ Mercury2/scenegraph.xml 2009-05-16 13:03:19 UTC (rev 258) @@ -1,35 +1,35 @@ <SceneGraph> - <node type="transformnode" movy="0" rotx="90"> - <node type="transformnode" movy="-8" movz="5"> + <node type="transformnode" rotx="0" roty="-90"> + <node type="transformnode" movx="-6" movz="5"> <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100"/> </node> </node> <node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5"> - <node type="renderablenode"> - <asset type="texture" file="map.png"/> - <asset type="hgmdlmodel" file="map.hgmdl" /> - </node> + <node type="renderablenode"> + <asset type="texture" file="map.png"/> + <asset type="hgmdlmodel" file="map.hgmdl" /> </node> - <node type="renderablenode" name="lampForest"> - <asset type="texture" file="lamp.png"/> - <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" > - <node type="transformnode" rotx="-90" name="lamp"> - <node type="renderablenode" > - <asset type="hgmdlmodel" file="lamp.hgmdl" /> - </node> + </node> + <node type="renderablenode" name="lampForest"> + <asset type="texture" file="lamp.png"/> + <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" > + <node type="transformnode" rotx="-90" name="lamp"> + <node type="billboard" > + <asset type="hgmdlmodel" file="lamp.hgmdl" /> </node> - <node type="transformnode" movx="1" fallback="lampForest.lamprow.lamp" /> - <node type="transformnode" movx="2" fallback="lampForest.lamprow.lamp" /> - <node type="transformnode" movx="3" fallback="lampForest.lamprow.lamp" /> - <node type="transformnode" movx="-1" fallback="lampForest.lamprow.lamp" /> - <node type="transformnode" movx="-2" fallback="lampForest.lamprow.lamp" /> - <node type="transformnode" movx="-3" fallback="lampForest.lamprow.lamp" /> </node> - <node type="transformnode" movz="-6" fallback="lampForest.lamprow"/> - <node type="transformnode" movz="-7" fallback="lampForest.lamprow"/> - <node type="transformnode" movz="-8" fallback="lampForest.lamprow"/> - <node type="transformnode" movz="-9" fallback="lampForest.lamprow"/> - <node type="transformnode" movz="-4" fallback="lampForest.lamprow"/> - <node type="transformnode" movz="-3" fallback="lampForest.lamprow"/> + <node type="transformnode" movx="1" fallback="lampForest.lamprow.lamp" /> + <node type="transformnode" movx="2" fallback="lampForest.lamprow.lamp" /> + <node type="transformnode" movx="3" fallback="lampForest.lamprow.lamp" /> + <node type="transformnode" movx="-1" fallback="lampForest.lamprow.lamp" /> + <node type="transformnode" movx="-2" fallback="lampForest.lamprow.lamp" /> + <node type="transformnode" movx="-3" fallback="lampForest.lamprow.lamp" /> </node> + <node type="transformnode" movz="-6" fallback="lampForest.lamprow"/> + <node type="transformnode" movz="-7" fallback="lampForest.lamprow"/> + <node type="transformnode" movz="-8" fallback="lampForest.lamprow"/> + <node type="transformnode" movz="-9" fallback="lampForest.lamprow"/> + <node type="transformnode" movz="-4" fallback="lampForest.lamprow"/> + <node type="transformnode" movz="-3" fallback="lampForest.lamprow"/> + </node> </SceneGraph> Modified: Mercury2/src/BillboardNode.cpp =================================================================== --- Mercury2/src/BillboardNode.cpp 2009-05-16 04:36:19 UTC (rev 257) +++ Mercury2/src/BillboardNode.cpp 2009-05-16 13:03:19 UTC (rev 258) @@ -8,23 +8,30 @@ { MercuryMatrix m = RenderableNode::ManipulateMatrix( matrix ); - MercuryVertex center(m.Ptr()[3], m.Ptr()[7], m.Ptr()[11]); + //Compute the object's center point (position?) in world space + MercuryVertex center(0,0,0,1); + center = matrix * center; -// printf( "%f %f %f %f %f %f\n", center[0], center[1], center[2], EYE[0], EYE[1], EYE[2] ); -// MercuryVector v = center.Normalize() *-1; + //vector from object to eye projected on XZ + MercuryVector objToEye = (EYE - center); objToEye[1] = 0; objToEye.NormalizeSelf(); + + MercuryVector objLookAt(0,0,1); //origional look vector of object + objLookAt = matrix * objLookAt; //convert to world space + objLookAt.NormalizeSelf(); +// objLookAt.Print(); + +// MercuryVector up = (objLookAt.CrossProduct( objToEye )).Normalize(); +// up = objLookAt; +// up.Print(); + MercuryVector up(0,0,1); //we wan't the camera's up + + float angleCos = LOOKAT.DotProduct(objToEye); - MercuryVector v = (EYE - center).Normalize(); - MercuryVector up = (LOOKAT.CrossProduct( v )).Normalize(); - - float angleCos = LOOKAT.DotProduct(v); - - if ((angleCos < 0.99990) && (angleCos > -0.9999)) { float f = ACOS(angleCos)*RADDEG; - MercuryMatrix mtmp; - mtmp.RotateAngAxis(-f, up[0], up[1], up[2]); + mtmp.RotateAngAxis(f, up[0], up[1], up[2]); m = m * mtmp; } Modified: Mercury2/src/Viewport.cpp =================================================================== --- Mercury2/src/Viewport.cpp 2009-05-16 04:36:19 UTC (rev 257) +++ Mercury2/src/Viewport.cpp 2009-05-16 13:03:19 UTC (rev 258) @@ -29,15 +29,23 @@ glMatrixMode(GL_MODELVIEW); + //compute the position of the eye + EYE = MercuryVertex(0,0,0,1); + EYE = matrix * EYE; + EYE *= -1; + +// VIEWMATRIX = MercuryMatrix::Identity(); +// VIEWMATRIX.Scale(1,1,1); +// VIEWMATRIX.Translate( EYE[0], EYE[1], EYE[2] ); +// VIEWMATRIX.RotateXYZ( matrix[0][0], matrix[1][1], matrix[2][2] ); VIEWMATRIX = matrix; - EYE[0] = matrix[0][3]; // same as float* [3] - EYE[1] = matrix[1][3]; // same as float* [7] - EYE[2] = matrix[2][3]; // same as float* [11] - EYE *= -1; +// matrix.Print(); MercuryVector l(0,0,1); LOOKAT = (matrix * l).Normalize(); -// LOOKAT.Print(); + + //Sets up the clipping frustum + m_frustum.LookAt(EYE, LOOKAT, MercuryVertex(0,1,0)); } void Viewport::LoadFromXML(const XMLNode& node) @@ -54,8 +62,6 @@ // StrToFloat(node.Attribute("aspect")), StrToFloat(node.Attribute("near")), StrToFloat(node.Attribute("far"))); - - m_frustum.LookAt(MercuryVertex(), MercuryVertex(0,0,1), MercuryVertex(0,1,0)); RenderableNode::LoadFromXML(node); } Modified: Mercury2/src/Viewport.h =================================================================== --- Mercury2/src/Viewport.h 2009-05-16 04:36:19 UTC (rev 257) +++ Mercury2/src/Viewport.h 2009-05-16 13:03:19 UTC (rev 258) @@ -19,7 +19,7 @@ virtual void PreRender(const MercuryMatrix& matrix); virtual void LoadFromXML(const XMLNode& node); - + GENRTTI(Viewport); private: Frustum m_frustum; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-05-22 01:29:36
|
Revision: 272 http://hgengine.svn.sourceforge.net/hgengine/?rev=272&view=rev Author: axlecrusher Date: 2009-05-22 01:29:34 +0000 (Fri, 22 May 2009) Log Message: ----------- quaternion Modified Paths: -------------- Mercury2/adv_set.c Mercury2/scenegraph.xml Modified: Mercury2/adv_set.c =================================================================== --- Mercury2/adv_set.c 2009-05-22 01:28:54 UTC (rev 271) +++ Mercury2/adv_set.c 2009-05-22 01:29:34 UTC (rev 272) @@ -11,7 +11,7 @@ src/HGMDLModel.cpp src/MercuryString.cpp src/MercuryCrash.c src/MercuryBacktrace.c \ src/MercuryFile.cpp src/MercuryTimer.cpp src/MercuryMessageManager.cpp src/MercuryVertex.cpp \ src/MercuryPlane.cpp src/BoundingBox.cpp src/Shader.cpp src/RenderGraph.cpp src/Frustum.cpp \ - src/BillboardNode.cpp src/Camera.cpp" + src/BillboardNode.cpp src/Camera.cpp src/MercuryInput.cpp src/MQuaternion.cpp" SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \ src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp" Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-05-22 01:28:54 UTC (rev 271) +++ Mercury2/scenegraph.xml 2009-05-22 01:29:34 UTC (rev 272) @@ -1,7 +1,10 @@ <SceneGraph> - <node type="cameranode" movx="6" movz="-5.5" movy="3" rotx="-45" roty="90"> +<!-- <node type="cameranode" movx="6" movz="-5.5" movy="3" rotx="-45" roty="90"> <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100"/> </node> +--> <node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0"> + <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100"/> + </node> <node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5"> <node type="renderablenode"> <asset type="texture" file="map.png"/> @@ -12,7 +15,7 @@ <asset type="texture" file="lamp.png"/> <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" > <node type="transformnode" rotx="-90" name="lamp"> - <node type="billboard" > + <node type="renderablenode" > <asset type="hgmdlmodel" file="lamp.hgmdl" /> </node> </node> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-06-13 21:30:15
|
Revision: 316 http://hgengine.svn.sourceforge.net/hgengine/?rev=316&view=rev Author: axlecrusher Date: 2009-06-13 21:30:11 +0000 (Sat, 13 Jun 2009) Log Message: ----------- FBO works Modified Paths: -------------- Mercury2/scenegraph.xml Mercury2/src/MercuryFBO.cpp Mercury2/src/MercuryFBO.h Mercury2/src/RenderBuffer.cpp Mercury2/src/Texture.cpp Mercury2/src/Texture.h Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-06-13 02:35:10 UTC (rev 315) +++ Mercury2/scenegraph.xml 2009-06-13 21:30:11 UTC (rev 316) @@ -11,9 +11,13 @@ <asset type="texture" file="map.png"/> <asset type="hgmdlmodel" file="map.hgmdl" /> </node> + <node type="renderablenode"> + <asset type="texture" file="screenFBO" dynamic="true"/> + <asset type="quad"/> + </node> </node> - <node type="mercuryfbo" > - <asset type="renderbuffer" buffertype="texture" /> + <node type="mercuryfbo" width="512" height="512" depth="false" tnum="1" name="screenFBO"> +<!-- <asset type="renderbuffer" buffertype="texture" /> --> <node type="renderablenode" name="lampForest"> <asset type="texture" file="lamp.png"/> <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" > Modified: Mercury2/src/MercuryFBO.cpp =================================================================== --- Mercury2/src/MercuryFBO.cpp 2009-06-13 02:35:10 UTC (rev 315) +++ Mercury2/src/MercuryFBO.cpp 2009-06-13 21:30:11 UTC (rev 316) @@ -4,15 +4,57 @@ REGISTER_NODE_TYPE(MercuryFBO); MercuryFBO::MercuryFBO() - :m_fboID(0), m_initiated(false) + :m_fboID(0), m_depthBufferID(0), m_initiated(false), m_useDepth(false), m_numTextures(0) { + for (uint8_t i = 0; i < 4; ++i) m_textures[i] = NULL; } MercuryFBO::~MercuryFBO() { + Clean(); +} + +void MercuryFBO::Clean() +{ if (m_fboID != 0) glDeleteFramebuffersEXT(1, &m_fboID); + if (m_depthBufferID != 0) glDeleteRenderbuffersEXT( 1, &m_depthBufferID ); + m_fboID = m_depthBufferID = 0; + m_initiated = false; + for (uint8_t i = 0; i < 4; ++i) m_textures[i] = NULL; } +void MercuryFBO::Setup() +{ + Clean(); + + m_initiated = true; + + if( m_useDepth ) glGenRenderbuffersEXT( 1, &m_depthBufferID ); + glGenFramebuffersEXT( 1, &m_fboID ); + + for (uint8_t i = 0; i < m_numTextures; ++i) + { + m_textures[i] = Texture::LoadDynamicTexture(m_name); + m_textures[i]->MakeDynamic(m_width, m_height,m_name); + } + + if( m_useDepth ) + { + glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, m_fboID ); + glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, m_width, m_height ); + } + glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_fboID ); + + for (uint8_t i = 0; i < m_numTextures; ++i) + glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + i, GL_TEXTURE_2D, m_textures[i]->TextureID(), 0 ); + + + if( m_useDepth ) + glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthBufferID ); + + CHECKFBO; //Incomplete FBO +} +/* void MercuryFBO::InitFBOBeforeRender() { m_initiated = true; @@ -20,10 +62,10 @@ CHECKFBO; GLERRORCHECK; } - +*/ void MercuryFBO::PreRender(const MercuryMatrix& matrix) { - if ( !m_initiated ) InitFBOBeforeRender(); + if ( !m_initiated ) Setup(); RenderableNode::PreRender(matrix); } @@ -38,15 +80,17 @@ // m_lastInStask = m_lastRendered; } -// glPushAttrib(GL_VIEWPORT_BIT); - // glViewport(0,0,width, height); + glClear(GL_COLOR_BUFFER_BIT ); + + glPushAttrib(GL_VIEWPORT_BIT); + glViewport(0,0,m_width, m_width); RenderableNode::Render(matrix); } void MercuryFBO::PostRender(const MercuryMatrix& matrix) { -// glPopAttrib(); + glPopAttrib(); // glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_lastInStask); // m_lastRendered = m_lastInStask; @@ -61,6 +105,26 @@ m_lastRendered = 0; } +void MercuryFBO::LoadFromXML(const XMLNode& node) +{ + printf("load\n"); + if ( !node.Attribute("width").empty() ) + SetWidth( StrToInt(node.Attribute("width")) ); + + if ( !node.Attribute("height").empty() ) + SetHeight( StrToInt(node.Attribute("height")) ); + + if ( !node.Attribute("depth").empty() ) + SetUseDepth( node.Attribute("depth") == "true"?true:false ); + + if ( !node.Attribute("tnum").empty() ) + SetNumTextures( StrToInt(node.Attribute("tnum")) ); + + printf("%d %d %d %d\n", m_width, m_height, m_useDepth, m_numTextures); + + RenderableNode::LoadFromXML(node); +} + uint32_t MercuryFBO::m_lastRendered = NULL; /**************************************************************************** Modified: Mercury2/src/MercuryFBO.h =================================================================== --- Mercury2/src/MercuryFBO.h 2009-06-13 02:35:10 UTC (rev 315) +++ Mercury2/src/MercuryFBO.h 2009-06-13 21:30:11 UTC (rev 316) @@ -2,6 +2,7 @@ #define MERCURYFBO_H #include <RenderableNode.h> +#include <Texture.h> class MercuryFBO : public RenderableNode { @@ -13,16 +14,31 @@ virtual void Render(const MercuryMatrix& matrix); virtual void PostRender(const MercuryMatrix& matrix); + virtual void LoadFromXML(const XMLNode& node); + + inline void SetWidth(uint16_t width) { m_width = width; } + inline void SetHeight(uint16_t height) { m_height = height; } + inline void SetUseDepth(bool toggle) { m_useDepth = toggle; } + inline void SetNumTextures(uint8_t x) { m_numTextures = x; } + + GENRTTI(MercuryFBO); private: - void InitFBOBeforeRender(); + void Setup(); + void Clean(); +// void InitFBOBeforeRender(); - uint32_t m_fboID; - bool m_initiated; + uint32_t m_fboID, m_depthBufferID; + bool m_initiated, m_useDepth; + uint16_t m_width, m_height; +// uint32_t m_textureID[4]; + Texture *m_textures[4]; + uint8_t m_numTextures; + static uint32_t m_lastRendered; - uint32_t m_lastInStask; +// uint32_t m_lastInStask; protected: // AlignedBuffer<float> m_vertexData; Modified: Mercury2/src/RenderBuffer.cpp =================================================================== --- Mercury2/src/RenderBuffer.cpp 2009-06-13 02:35:10 UTC (rev 315) +++ Mercury2/src/RenderBuffer.cpp 2009-06-13 21:30:11 UTC (rev 316) @@ -37,24 +37,20 @@ void RenderBuffer::Render(const MercuryNode* node) { glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_bufferID); -// CHECKFBO; //missing attachment - GLERRORCHECK; if ( NeedResize() ) AllocateSpace(); - - //attach to FBO -// if ( !m_bound ) + + if ( m_type == TEXTURE ) { - m_bound = true; - if ( m_type == TEXTURE ) - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GLAttachPoint(), GL_TEXTURE_2D, m_textureID, 0); - else - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GLAttachPoint(), GL_RENDERBUFFER_EXT, m_bufferID); - CHECKFBO; - GLERRORCHECK; + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GLAttachPoint(), GL_TEXTURE_2D, m_textureID, 0); } - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + else + { + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GLAttachPoint(), GL_RENDERBUFFER_EXT, m_bufferID); + } + CHECKFBO; + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT ); GLERRORCHECK; } @@ -134,6 +130,8 @@ { m_width = MercuryWindow::GetCurrentWindow()->Width(); m_height = MercuryWindow::GetCurrentWindow()->Height(); + m_width = 512; + m_height = 512; if (m_type == TEXTURE) { Modified: Mercury2/src/Texture.cpp =================================================================== --- Mercury2/src/Texture.cpp 2009-06-13 02:35:10 UTC (rev 315) +++ Mercury2/src/Texture.cpp 2009-06-13 21:30:11 UTC (rev 316) @@ -21,12 +21,17 @@ { REMOVE_ASSET_INSTANCE(TEXTURE, m_path); - if (m_textureID) glDeleteTextures(1, &m_textureID); - m_textureID = 0; + Clean(); SAFE_DELETE(m_raw); } +void Texture::Clean() +{ + if (m_textureID) glDeleteTextures(1, &m_textureID); + m_textureID = 0; +} + void Texture::Init(MercuryNode* node) { MercuryAsset::Init( node ); @@ -101,7 +106,16 @@ void Texture::LoadFromXML(const XMLNode& node) { - LoadImagePath( node.Attribute("file") ); + bool dynamic = false; + if ( !node.Attribute("dynamic").empty() ) + dynamic = node.Attribute("dynamic")=="true"?true:false; + + MString file = node.Attribute("file"); + + if ( dynamic ) + MakeDynamic( 0, 0, file ); + else + LoadImagePath( file ); } void Texture::BindTexture() @@ -151,6 +165,27 @@ m_raw = raw; } +void Texture::MakeDynamic(uint16_t width, uint16_t height, const MString& name) +{ + Clean(); + + SetLoadState(LOADED); + + REMOVE_ASSET_INSTANCE(TEXTURE, m_path); + m_path = "DYNATEXT"+name; + ADD_ASSET_INSTANCE(Texture, m_path, this); + + glGenTextures( 1, &m_textureID ); + printf("booo %d\n", m_textureID); + glBindTexture( GL_TEXTURE_2D, m_textureID ); + glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, width, height, 0 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glBindTexture( GL_TEXTURE_2D, 0 ); + + GLERRORCHECK; +} + Texture* Texture::Generate() { return new Texture(); @@ -164,6 +199,14 @@ return a; } +MAutoPtr< Texture > Texture::LoadDynamicTexture(const MString& name) +{ + MAutoPtr< MercuryAsset > t( AssetFactory::GetInstance().Generate("Texture", "DYNATEXT"+name) ); + Texture *a = (Texture*)t.Ptr(); +// a->LoadImagePath( path ); + return a; +} + bool Texture::m_initTextureSuccess = false; uint8_t Texture::m_activeTextures = 0; uint32_t Texture::m_textureBinds = 0; Modified: Mercury2/src/Texture.h =================================================================== --- Mercury2/src/Texture.h 2009-06-13 02:35:10 UTC (rev 315) +++ Mercury2/src/Texture.h 2009-06-13 21:30:11 UTC (rev 316) @@ -10,6 +10,8 @@ Texture(); virtual ~Texture(); + void Clean(); + virtual void Init(MercuryNode* node); virtual void Render(const MercuryNode* node); @@ -21,9 +23,14 @@ inline static uint8_t NumberActiveTextures() { return m_activeTextures; } inline static uint32_t ReadAndResetBindCount() { uint32_t t = m_textureBinds; m_textureBinds = 0; return t; } + inline uint32_t TextureID() const { return m_textureID; } + void MakeDynamic(uint16_t width, uint16_t height, const MString& name); + + static Texture* Generate(); static MAutoPtr< Texture > LoadFromFile(const MString& path); + static MAutoPtr< Texture > LoadDynamicTexture(const MString& name); void SetRawData(RawImageData* raw); private: @@ -33,8 +40,8 @@ void UnbindTexture(); const RawImageData* m_raw; - unsigned int m_textureID; - unsigned int m_textureResource; + uint32_t m_textureID; + uint32_t m_textureResource; static bool m_initTextureSuccess; static uint8_t m_activeTextures; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-06-21 02:53:19
|
Revision: 351 http://hgengine.svn.sourceforge.net/hgengine/?rev=351&view=rev Author: axlecrusher Date: 2009-06-21 01:49:41 +0000 (Sun, 21 Jun 2009) Log Message: ----------- no more renderable node Modified Paths: -------------- Mercury2/adv_set.c Mercury2/scenegraph.xml Modified: Mercury2/adv_set.c =================================================================== --- Mercury2/adv_set.c 2009-06-21 01:49:14 UTC (rev 350) +++ Mercury2/adv_set.c 2009-06-21 01:49:41 UTC (rev 351) @@ -4,7 +4,7 @@ SOURCES="src/Mercury2.cpp src/MercuryAsset.cpp src/MercuryNode.cpp \ - src/MercuryThreads.cpp src/MercuryMath.cpp src/MercuryWindow.cpp src/RenderableNode.cpp \ + src/MercuryThreads.cpp src/MercuryMath.cpp src/MercuryWindow.cpp\ 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/MercuryVBO.cpp src/MSemaphore.cpp src/UpdateThreader.cpp src/HGMDLMesh.cpp \ Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-06-21 01:49:14 UTC (rev 350) +++ Mercury2/scenegraph.xml 2009-06-21 01:49:41 UTC (rev 351) @@ -1,46 +1,40 @@ -<SceneGraph> +<SceneGraph name="root"> <!-- <node type="cameranode" movx="6" movz="-5.5" movy="3" rotx="-45" roty="90"> <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100"/> </node> --> - <node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0"> - <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100"/> + <node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera"> + <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp"/> </node> - <node type="renderablenode"> - <asset type="texture" file="screenFBO_0" dynamic="true"/> - <asset type="fullscreenquad"/> - </node> - <node type="mercuryfbo" width="640" height="480" depth="true" tnum="2" name="screenFBO" usescreensize="true"> - <asset type="shader" file="testShader"/> +<!-- <asset type="texture" file="screenFBO_0" dynamic="true"/> --> +<!-- <asset type="fullscreenquad"/> --> +<!-- <node type="mercuryfbo" width="640" height="480" depth="true" tnum="2" name="screenFBO" usescreensize="true"> --> +<!-- <asset type="shader" file="testShader"/> --> <node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5"> - <node type="renderablenode"> - <asset type="texture" file="map.png"/> - <asset type="hgmdlmodel" file="map.hgmdl" /> - </node> + <asset type="texture" file="map.png"/> + <asset type="hgmdlmodel" file="map.hgmdl" /> </node> - <node type="renderablenode" name="lampForest"> - <asset type="texture" file="lamp.png"/> - <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" > - <node type="transformnode" rotx="-90" name="lamp"> - <node type="billboardnode" billboardaxis="0,0,1" spheremode="true" > - <node type="renderablenode"> + <node type="mercurynode" name="lampForest" > + <asset type="texture" file="lamp.png"/> + <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" > + <node type="transformnode" rotx="-90" name="lamp"> + <node type="billboardnode" billboardaxis="0,0,1" spheremode="true" > <asset type="hgmdlmodel" file="lampN.hgmdl" /> </node> </node> + <node type="transformnode" movx="1" fallback="lamprow.lamp" /> + <node type="transformnode" movx="2" fallback="lamprow.lamp" /> + <node type="transformnode" movx="3" fallback="lamprow.lamp" /> + <node type="transformnode" movx="-1" fallback="lamprow.lamp" /> + <node type="transformnode" movx="-2" fallback="lamprow.lamp" /> + <node type="transformnode" movx="-3" fallback="lamprow.lamp" /> </node> - <node type="transformnode" movx="1" fallback="lamprow.lamp" /> - <node type="transformnode" movx="2" fallback="lamprow.lamp" /> - <node type="transformnode" movx="3" fallback="lamprow.lamp" /> - <node type="transformnode" movx="-1" fallback="lamprow.lamp" /> - <node type="transformnode" movx="-2" fallback="lamprow.lamp" /> - <node type="transformnode" movx="-3" fallback="lamprow.lamp" /> - </node> <node type="transformnode" movz="-6" fallback="lampForest.lamprow"/> <node type="transformnode" movz="-7" fallback="lampForest.lamprow"/> <node type="transformnode" movz="-8" fallback="lampForest.lamprow"/> <node type="transformnode" movz="-9" fallback="lampForest.lamprow"/> <node type="transformnode" movz="-4" fallback="lampForest.lamprow"/> <node type="transformnode" movz="-3" fallback="lampForest.lamprow"/> - </node> - </node> + </node>--> +<!-- </node> --> </SceneGraph> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-06-23 00:59:32
|
Revision: 358 http://hgengine.svn.sourceforge.net/hgengine/?rev=358&view=rev Author: axlecrusher Date: 2009-06-23 00:23:23 +0000 (Tue, 23 Jun 2009) Log Message: ----------- add transparent pass Modified Paths: -------------- Mercury2/scenegraph.xml Mercury2/src/Mercury2.cpp Mercury2/src/MercuryNode.cpp Mercury2/src/MercuryNode.h Mercury2/src/RenderGraph.cpp Mercury2/src/RenderGraph.h Mercury2/src/Texture.cpp Mercury2/src/Texture.h Mercury2/src/X11Window.cpp Added Paths: ----------- Mercury2/flame.png Added: Mercury2/flame.png =================================================================== (Binary files differ) Property changes on: Mercury2/flame.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-06-21 13:49:48 UTC (rev 357) +++ Mercury2/scenegraph.xml 2009-06-23 00:23:23 UTC (rev 358) @@ -6,21 +6,27 @@ <node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera"> <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp"/> </node> - <asset type="texture" file="screenFBO_0" dynamic="true"/> +<!-- <asset type="texture" file="screenFBO_0" dynamic="true"/> <asset type="fullscreenquad"/> <node type="mercuryfbo" width="640" height="480" depth="true" tnum="2" name="screenFBO" usescreensize="true"> <asset type="shader" file="testShader"/> - <node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5"> +--> <node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5"> <asset type="texture" file="map.png"/> <asset type="hgmdlmodel" file="map.hgmdl" /> </node> <node type="mercurynode" name="lampForest" > - <asset type="texture" file="lamp.png"/> <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" > - <node type="transformnode" rotx="-90" name="lamp"> - <node type="billboardnode" billboardaxis="0,0,1" spheremode="true" > + <node type="mercurynode" name="lamp"> + <node type="transformnode" rotx="-90" > + <asset type="texture" file="lamp.png"/> <asset type="hgmdlmodel" file="lampN.hgmdl" /> </node> + <node type="billboardnode" billboardaxis="0,1,0" spheremode="true" > + <node type="transformnode" roty="180" scalex="0.1" scaley="0.1" alphaPath="true"> + <asset type="texture" file="flame.png"/> + <asset type="quad"/> + </node> + </node> </node> <node type="transformnode" movx="1" fallback="lamprow.lamp" /> <node type="transformnode" movx="2" fallback="lamprow.lamp" /> @@ -36,5 +42,5 @@ <node type="transformnode" movz="-4" fallback="lampForest.lamprow"/> <node type="transformnode" movz="-3" fallback="lampForest.lamprow"/> </node> - </node> +<!-- </node> --> </SceneGraph> Modified: Mercury2/src/Mercury2.cpp =================================================================== --- Mercury2/src/Mercury2.cpp 2009-06-21 13:49:48 UTC (rev 357) +++ Mercury2/src/Mercury2.cpp 2009-06-23 00:23:23 UTC (rev 358) @@ -6,7 +6,7 @@ #include <XMLParser.h> -//#include <RenderableNode.h> +#include <RenderGraph.h> #include <MercuryCrash.h> #include <MercuryBacktrace.h> @@ -76,6 +76,7 @@ MESSAGEMAN::GetInstance().PumpMessages( timer.MicrosecondsSinceInit() ); root->RecursiveUpdate( timer.Age() ); //comment to use threads + CURRENTRENDERGRAPH = &renderGraph; if ( MercuryNode::NeedsRebuild() ) { renderGraph.Build(root); @@ -86,6 +87,7 @@ // RenderableNode::RecursiveRender(root); // printf("\n"); root->RecursiveRender(); + renderGraph.RenderAlpha(); w->SwapBuffers(); ++m_count; Modified: Mercury2/src/MercuryNode.cpp =================================================================== --- Mercury2/src/MercuryNode.cpp 2009-06-21 13:49:48 UTC (rev 357) +++ Mercury2/src/MercuryNode.cpp 2009-06-23 00:23:23 UTC (rev 358) @@ -7,13 +7,14 @@ #include <GLHeaders.h> #include <Shader.h> +#include <RenderGraph.h> using namespace std; REGISTER_NODE_TYPE(MercuryNode); MercuryNode::MercuryNode() - :m_parent(NULL), m_prevSibling(NULL), m_nextSibling(NULL), m_hidden(false) + :m_parent(NULL), m_prevSibling(NULL), m_nextSibling(NULL), m_hidden(false), m_useAlphaPath(false) { } @@ -104,7 +105,7 @@ child->RecursiveUpdate(dTime); } -void MercuryNode::RecursiveRender() +void MercuryNode::RecursiveRender(bool doAlpha) { MercuryMatrix modelView; ShaderAttribute sa; @@ -126,7 +127,12 @@ //call render on other render graph entries under me for (MercuryNode* child = FirstChild(); child != NULL; child = NextChild(child)) - child->RecursiveRender(); + { + if (child->m_useAlphaPath && !doAlpha) + CURRENTRENDERGRAPH->AddAlphaNode(child); + else + child->RecursiveRender(); + } glLoadMatrixf( modelView.Ptr() ); Shader::SetAttribute("HG_ModelMatrix", sa); @@ -150,6 +156,9 @@ if ( !node.Attribute("hidden").empty() ) m_hidden = node.Attribute("hidden")=="true"?true:false; + if ( !node.Attribute("alphaPath").empty() ) + m_useAlphaPath = node.Attribute("alphaPath")=="true"?true:false; + //Not much to do here except run through all the children nodes for (XMLNode child = node.Child(); child.IsValid(); child = child.NextNode()) { Modified: Mercury2/src/MercuryNode.h =================================================================== --- Mercury2/src/MercuryNode.h 2009-06-21 13:49:48 UTC (rev 357) +++ Mercury2/src/MercuryNode.h 2009-06-23 00:23:23 UTC (rev 358) @@ -47,7 +47,7 @@ void ThreadedUpdate(float dTime); - void RecursiveRender(); + void RecursiveRender(bool doAlpha = false); ///Run on parent when a child is added virtual void OnAddChild() {}; @@ -98,6 +98,7 @@ static bool m_rebuildRenderGraph; MString m_name; bool m_hidden; + bool m_useAlphaPath; private: bool IsInAssetList(MercuryAsset* asset) const; Modified: Mercury2/src/RenderGraph.cpp =================================================================== --- Mercury2/src/RenderGraph.cpp 2009-06-21 13:49:48 UTC (rev 357) +++ Mercury2/src/RenderGraph.cpp 2009-06-23 00:23:23 UTC (rev 358) @@ -4,7 +4,11 @@ #include <GLHeaders.h> #include <Shader.h> +#include <Viewport.h> +#include <Texture.h> +RenderGraph* CURRENTRENDERGRAPH = NULL; + void RenderGraphEntry::Render() { MercuryMatrix modelView; @@ -65,6 +69,60 @@ // entry = lastEntry; } +void RenderGraph::AddAlphaNode( MercuryNode* node ) +{ + StoreRenderState srs; + srs.Save(); + srs.Matrix = node->FindGlobalMatrix(); + srs.Node = node; + + MercuryVertex p = srs.Matrix * MercuryVertex(0,0,0,1); + + //order from back to front (ensure furthest has lowest number and is first) + float length = (p - EYE).Length() * -1; + m_alphaNodesQueue.Insert(length, srs); +} + +void RenderGraph::RenderAlpha() +{ + while ( !m_alphaNodesQueue.empty() ) + { + StoreRenderState& srs = m_alphaNodesQueue.GetNext(); + + std::list< MercuryAsset* >::iterator i = srs.Assets.begin(); + for (;i != srs.Assets.end(); ++i) + { + (*i)->PreRender(srs.Node); + (*i)->Render(srs.Node); + } + + srs.Node->RecursiveRender(true); + + for (i = srs.Assets.begin();i != srs.Assets.end(); ++i) + (*i)->PostRender(srs.Node); + + m_alphaNodesQueue.PopNext(); + } +} + +StoreRenderState::StoreRenderState() + :Node(NULL) +{ +} + +void StoreRenderState::Save() +{ + //get assets for current textures + const std::list< Texture* >& textures = Texture::GetActiveTextures(); + std::list< Texture* >::const_iterator i = textures.begin(); + for (;i != textures.end(); ++i) + Assets.push_back( *i ); + + //save the active shader + Shader* s = Shader::GetCurrentShader(); + if (s) Assets.push_back(s); +} + /**************************************************************************** * Copyright (C) 2009 by Joshua Allen * * * Modified: Mercury2/src/RenderGraph.h =================================================================== --- Mercury2/src/RenderGraph.h 2009-06-21 13:49:48 UTC (rev 357) +++ Mercury2/src/RenderGraph.h 2009-06-23 00:23:23 UTC (rev 358) @@ -3,6 +3,7 @@ #include <MercuryNode.h> //#include <RenderableNode.h> +#include <PriorityQueue.h> class RenderGraphEntry { @@ -26,16 +27,38 @@ const MercuryMatrix* m_matrix; }; +/** Tries to get pointers to all assets needed to rebuild an accurate render state. +This will only work for restoring the render state within the same render loop. +**/ +class StoreRenderState +{ + public: + StoreRenderState(); + void Save(); + MercuryNode* Node; + MercuryMatrix Matrix; +// private: + std::list< MercuryAsset* > Assets; +}; + class RenderGraph { public: void Build( MercuryNode* node ); inline void Render() { m_root.Render(); } + + void AddAlphaNode( MercuryNode* node ); + void RenderAlpha(); private: void Build( MercuryNode* node, RenderGraphEntry& entry ); RenderGraphEntry m_root; + + //nodes that use alpha, ordered from farthest to nearest from the camera + PriorityQueue<float, StoreRenderState > m_alphaNodesQueue; }; +extern RenderGraph* CURRENTRENDERGRAPH; + #endif /**************************************************************************** Modified: Mercury2/src/Texture.cpp =================================================================== --- Mercury2/src/Texture.cpp 2009-06-21 13:49:48 UTC (rev 357) +++ Mercury2/src/Texture.cpp 2009-06-23 00:23:23 UTC (rev 358) @@ -15,7 +15,7 @@ if (!m_initTextureSuccess) { m_initTextureSuccess = true; - m_activeTextures = 0; + m_numActiveTextures = 0; } } @@ -76,7 +76,7 @@ GL_UNSIGNED_BYTE, m_raw->m_data); */ - gluBuild2DMipmaps( GL_TEXTURE_2D, 3, m_raw->m_width, m_raw->m_height, ByteType, GL_UNSIGNED_BYTE, m_raw->m_data ); + gluBuild2DMipmaps( GL_TEXTURE_2D, ByteType, m_raw->m_width, m_raw->m_height, ByteType, GL_UNSIGNED_BYTE, m_raw->m_data ); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); @@ -121,7 +121,7 @@ void Texture::BindTexture() { - m_textureResource = GL_TEXTURE0+m_activeTextures; + m_textureResource = GL_TEXTURE0+m_numActiveTextures; glActiveTexture( m_textureResource ); glClientActiveTextureARB(m_textureResource); glEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -134,9 +134,11 @@ ShaderAttribute sa; sa.type = ShaderAttribute::TYPE_SAMPLER; sa.value.iSampler = m_textureResource; - Shader::SetAttribute( ssprintf("HG_Texture%d", m_activeTextures), sa); + Shader::SetAttribute( ssprintf("HG_Texture%d", m_numActiveTextures), sa); - ++m_activeTextures; + m_activeTextures.push_back(this); + + ++m_numActiveTextures; ++m_textureBinds; } @@ -148,9 +150,10 @@ glDisable( GL_TEXTURE_2D ); GLERRORCHECK; - Shader::RemoveAttribute( ssprintf("HG_Texture%d", m_activeTextures) ); + Shader::RemoveAttribute( ssprintf("HG_Texture%d", m_numActiveTextures) ); + m_activeTextures.pop_back(); - --m_activeTextures; + --m_numActiveTextures; } void Texture::LoadImagePath(const MString& path) @@ -220,8 +223,9 @@ } bool Texture::m_initTextureSuccess = false; -uint8_t Texture::m_activeTextures = 0; +uint8_t Texture::m_numActiveTextures = 0; uint32_t Texture::m_textureBinds = 0; +std::list< Texture* > Texture::m_activeTextures; /*************************************************************************** * Copyright (C) 2008 by Joshua Allen * Modified: Mercury2/src/Texture.h =================================================================== --- Mercury2/src/Texture.h 2009-06-21 13:49:48 UTC (rev 357) +++ Mercury2/src/Texture.h 2009-06-23 00:23:23 UTC (rev 358) @@ -21,7 +21,7 @@ void LoadFromRaw(); - inline static uint8_t NumberActiveTextures() { return m_activeTextures; } + inline static uint8_t NumberActiveTextures() { return m_numActiveTextures; } inline static uint32_t ReadAndResetBindCount() { uint32_t t = m_textureBinds; m_textureBinds = 0; return t; } inline uint32_t TextureID() const { return m_textureID; } @@ -31,6 +31,7 @@ static Texture* Generate(); static MAutoPtr< Texture > LoadFromFile(const MString& path); static MAutoPtr< Texture > LoadDynamicTexture(const MString& name); + static const std::list< Texture* >& GetActiveTextures() { return m_activeTextures; } void SetRawData(RawImageData* raw); private: @@ -44,8 +45,10 @@ uint32_t m_textureResource; static bool m_initTextureSuccess; - static uint8_t m_activeTextures; + static uint8_t m_numActiveTextures; static uint32_t m_textureBinds; + static std::list< Texture* > m_activeTextures; + // MString m_filename; }; Modified: Mercury2/src/X11Window.cpp =================================================================== --- Mercury2/src/X11Window.cpp 2009-06-21 13:49:48 UTC (rev 357) +++ Mercury2/src/X11Window.cpp 2009-06-23 00:23:23 UTC (rev 358) @@ -77,6 +77,8 @@ glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glEnable(GL_NORMALIZE); + + glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } X11Window::~X11Window() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-07-26 02:53:03
|
Revision: 441 http://hgengine.svn.sourceforge.net/hgengine/?rev=441&view=rev Author: axlecrusher Date: 2009-07-26 02:52:54 +0000 (Sun, 26 Jul 2009) Log Message: ----------- tweak how RecursiveRender and RecursivePreRender. Orthographic view works. Modified Paths: -------------- Mercury2/Themes/default/File/scenegraph.xml Mercury2/src/MercuryNode.cpp Mercury2/src/MercuryNode.h Mercury2/src/TransformNode.cpp Mercury2/src/TransformNode.h Mercury2/src/Viewport.h Modified: Mercury2/Themes/default/File/scenegraph.xml =================================================================== --- Mercury2/Themes/default/File/scenegraph.xml 2009-07-26 02:13:48 UTC (rev 440) +++ Mercury2/Themes/default/File/scenegraph.xml 2009-07-26 02:52:54 UTC (rev 441) @@ -38,7 +38,7 @@ </node> </node> </node> -<!-- <node type="orthographic" left="0" right="1" top="0" bottom="1" near="-1" far="1"> + <node type="orthographic" left="0" right="1" top="1" bottom="0" near="-1" far="1"> <asset type="quad"/> - </node> --> + </node> </SceneGraph> Modified: Mercury2/src/MercuryNode.cpp =================================================================== --- Mercury2/src/MercuryNode.cpp 2009-07-26 02:13:48 UTC (rev 440) +++ Mercury2/src/MercuryNode.cpp 2009-07-26 02:52:54 UTC (rev 441) @@ -141,11 +141,8 @@ { if ( IsHidden() ) return; - MercuryMatrix matrix = FindGlobalMatrix(); - MercuryMatrix modelView = ManipulateMatrix( matrix ); + const MercuryMatrix& matrix = FindGlobalMatrix(); - glLoadMatrix( modelView ); - PreRender( matrix ); //calls on children assets for (MercuryNode* child = FirstChild(); child != NULL; child = NextChild(child)) @@ -156,17 +153,21 @@ { if ( IsHidden() || m_occlusionResult.IsOccluded() || IsCulled() ) return; - MercuryMatrix matrix = FindGlobalMatrix(); - MercuryMatrix modelView = ManipulateMatrix( matrix ); -// if ( IsHidden() || IsCulled(modelView) ) return; + const MercuryMatrix& matrix = FindGlobalMatrix(); + const MercuryMatrix& modelView = FindModelViewMatrix(); //get the one computed in the last transform + + //A lot of this stuff could be moved into the transform node, BUT + //the alpha render path requires that all things things happen, so + //it is just easier to leave it here than to duplicate this code in + //RenderGraph::RenderAlpha glLoadMatrix( modelView ); ShaderAttribute sa; sa.type = ShaderAttribute::TYPE_MATRIX; sa.value.matrix = matrix.Ptr(); Shader::SetAttribute("HG_ModelMatrix", sa); - + Render( modelView ); //calls on children assets //call render on other render graph entries under me @@ -266,6 +267,20 @@ return MercuryMatrix::Identity(); } +const MercuryMatrix& MercuryNode::FindModelViewMatrix() const +{ + const MercuryNode* n = NULL; + const TransformNode* tn; + for (n = this; n; n = n->Parent()) + { + tn = TransformNode::Cast(n); + if ( tn ) + return tn->GetModelViewMatrix(); + } + + return MercuryMatrix::Identity(); +} + void MercuryNode::AddPreRender(MercuryAsset* asset) { #ifdef MCHECKASSETS Modified: Mercury2/src/MercuryNode.h =================================================================== --- Mercury2/src/MercuryNode.h 2009-07-26 02:13:48 UTC (rev 440) +++ Mercury2/src/MercuryNode.h 2009-07-26 02:52:54 UTC (rev 441) @@ -57,8 +57,8 @@ void ThreadedUpdate(float dTime); - void RecursivePreRender(); - void RecursiveRender(); + virtual void RecursivePreRender(); + virtual void RecursiveRender(); ///Run on parent when a child is added virtual void OnAddChild() {}; @@ -93,6 +93,7 @@ ///This will get the world space matrix const MercuryMatrix& FindGlobalMatrix() const; + const MercuryMatrix& FindModelViewMatrix() const; virtual bool IsCulled(const MercuryMatrix& matrix); inline bool IsHidden() { return m_hidden; } Modified: Mercury2/src/TransformNode.cpp =================================================================== --- Mercury2/src/TransformNode.cpp 2009-07-26 02:13:48 UTC (rev 440) +++ Mercury2/src/TransformNode.cpp 2009-07-26 02:52:54 UTC (rev 441) @@ -1,4 +1,6 @@ #include <TransformNode.h> +#include <GLHeaders.h> +#include <Shader.h> REGISTER_NODE_TYPE(TransformNode); REGISTER_NODE_TYPE(RotatorNode); @@ -14,6 +16,18 @@ if (m_tainted) ComputeMatrix(); } +void TransformNode::RecursivePreRender() +{ + if ( IsHidden() ) return; + + const MercuryMatrix& matrix = FindGlobalMatrix(); + m_modelView = ManipulateMatrix( matrix ); + + glLoadMatrix( m_modelView ); + + MercuryNode::RecursivePreRender(); +} + void TransformNode::SetScale( const MercuryVertex& scale ) { if (scale != m_scale) Modified: Mercury2/src/TransformNode.h =================================================================== --- Mercury2/src/TransformNode.h 2009-07-26 02:13:48 UTC (rev 440) +++ Mercury2/src/TransformNode.h 2009-07-26 02:52:54 UTC (rev 441) @@ -25,6 +25,7 @@ // inline const MercuryMatrix& GetGlobalMatrix() const { return m_globalMatrix; } virtual const MercuryMatrix& GetGlobalMatrix() const; + inline const MercuryMatrix& GetModelViewMatrix() const { return m_modelView; } const MercuryMatrix& GetParentMatrix() const; void SetTaint(bool taint); @@ -34,6 +35,8 @@ virtual void LoadFromXML(const XMLNode& node); virtual void OnAdded(); + + virtual void RecursivePreRender(); GENRTTI(TransformNode); @@ -47,7 +50,7 @@ // MercuryMatrix m_localMatrix; protected: - + MercuryMatrix m_modelView; MercuryMatrix m_globalMatrix; bool m_tainted; Modified: Mercury2/src/Viewport.h =================================================================== --- Mercury2/src/Viewport.h 2009-07-26 02:13:48 UTC (rev 440) +++ Mercury2/src/Viewport.h 2009-07-26 02:52:54 UTC (rev 441) @@ -13,6 +13,7 @@ Viewport(); virtual void PreRender(const MercuryMatrix& matrix); virtual void Render(const MercuryMatrix& matrix); + virtual void PostRender(const MercuryMatrix& matrix); virtual void LoadFromXML(const XMLNode& node); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-08-05 02:01:49
|
Revision: 458 http://hgengine.svn.sourceforge.net/hgengine/?rev=458&view=rev Author: axlecrusher Date: 2009-08-05 02:01:40 +0000 (Wed, 05 Aug 2009) Log Message: ----------- much improved look to lighting Modified Paths: -------------- Mercury2/Themes/default/Graphic/differedStep2.frag Mercury2/src/Light.cpp Mercury2/src/Light.h Modified: Mercury2/Themes/default/Graphic/differedStep2.frag =================================================================== --- Mercury2/Themes/default/Graphic/differedStep2.frag 2009-08-05 00:46:35 UTC (rev 457) +++ Mercury2/Themes/default/Graphic/differedStep2.frag 2009-08-05 02:01:40 UTC (rev 458) @@ -5,52 +5,41 @@ uniform ivec4 HG_ViewPort; uniform vec4 HG_LightPos; uniform vec4 HG_LightAtten; +uniform vec4 HG_LightColor; void main() { vec2 coord = gl_FragCoord.xy / vec2(HG_ViewPort.zw); vec3 pos = texture2D(HG_Texture0, coord).xyz; vec3 norm = texture2D(HG_Texture1, coord).xyz; - float att; - vec3 color, hv, diffuse, ambient; - diffuse = vec3(1.0); - ambient = vec3(0.0); + norm = normalize(norm); vec3 eyeVec = normalize(HG_EyePos.xyz - pos); vec3 lightDir = HG_LightPos.xyz - pos; - float dist = length(lightDir); - if(dist > HG_LightAtten.w) discard; - - lightDir = normalize(lightDir); - + float dist = length(lightDir); + lightDir /= dist; //normalize float NdotL = max(dot(norm, lightDir),0.0); - color = vec3(0.0); - hv = normalize(eyeVec - lightDir); - float NdotHV; + if((dist > HG_LightAtten.w) || (NdotL <= 0.0)) discard; vec3 materialSpec = vec3(1.0,1.0,1.0); vec3 lightSpec = vec3(1.0,1.0,1.0); - float shine = 0.0; //x = constant, y = linear, z = quad - att = 1.0 / (HG_LightAtten.x + + float att = 1.0 / (HG_LightAtten.x + HG_LightAtten.y * dist + HG_LightAtten.z * dist * dist); - vec3 c = att * (diffuse * NdotL + ambient); - color += att * (diffuse * NdotL + ambient); + vec3 color = att * (HG_LightColor.rgb * NdotL); - NdotHV = max(dot(norm,hv),0.0); + vec3 hv = normalize( lightDir+(HG_EyePos.xyz-pos) ); + float NdotHV = max(dot(norm,hv),0.0); - color += att * materialSpec * lightSpec * pow(NdotHV, shine); + //pow(max(dot(H, normal.xyz), 0.0) - color *= float(NdotL > 0.0); - gl_FragColor = vec4(color, 1.0); - -// gl_FragColor = vec4(1.0); -// gl_FragColor = vec4(lightDir,1.0); + color += att * materialSpec * lightSpec * pow(max(NdotHV, 0.0), 100.0); + gl_FragColor.rgb = clamp(color, 0.0, 1.0); } Modified: Mercury2/src/Light.cpp =================================================================== --- Mercury2/src/Light.cpp 2009-08-05 00:46:35 UTC (rev 457) +++ Mercury2/src/Light.cpp 2009-08-05 02:01:40 UTC (rev 458) @@ -13,6 +13,7 @@ :MercuryAsset() { m_atten[0] = m_atten[1] = m_atten[2] = 0.0f; + m_color[0] = m_color[1] = m_color[2] = 1.0f; m_radius = 1.0f; m_fullscreen = false; } @@ -116,6 +117,11 @@ sa.value.fFloatV4[3] = m_radius; Shader::SetAttribute("HG_LightAtten", sa); + sa.value.fFloatV4[0] = m_color[0]; + sa.value.fFloatV4[1] = m_color[1]; + sa.value.fFloatV4[2] = m_color[2]; + Shader::SetAttribute("HG_LightColor", sa); + if (m_fullscreen) { glCullFace(GL_BACK); Modified: Mercury2/src/Light.h =================================================================== --- Mercury2/src/Light.h 2009-08-05 00:46:35 UTC (rev 457) +++ Mercury2/src/Light.h 2009-08-05 02:01:40 UTC (rev 458) @@ -31,6 +31,7 @@ void ComputeRadius(); float m_atten[3]; + float m_color[3]; float m_radius; MercuryMatrix m_worldPosition; MercuryMatrix m_worldPosition2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cn...@us...> - 2009-10-02 06:49:45
|
Revision: 549 http://hgengine.svn.sourceforge.net/hgengine/?rev=549&view=rev Author: cnlohr Date: 2009-10-02 06:49:36 +0000 (Fri, 02 Oct 2009) Log Message: ----------- 1) disable SSE by default since SSE produces broken code as of now. 2) actually allow for enabling of the GL_PROFILE ing of the code. Modified Paths: -------------- Mercury2/base_set.sh Mercury2/modules/Makefile Modified: Mercury2/base_set.sh =================================================================== --- Mercury2/base_set.sh 2009-10-02 06:48:51 UTC (rev 548) +++ Mercury2/base_set.sh 2009-10-02 06:49:36 UTC (rev 549) @@ -8,12 +8,13 @@ ISMAC=1; fi -OPTIONS="X11 libxml OGL sse gprof" +OPTIONS="X11 libxml OGL sse gprof glprofile" OPT_X11=1 OPT_OGL=1 OPT_libxml=1 -OPT_sse=1 +OPT_sse=0 OPT_gprof=0 +OPT_glprofile=0 DEFINES="WAS_CONFIGURED USE_MSTRING" CC_BASE="-O2 -g0 -Wall" @@ -44,9 +45,11 @@ NEED_H="stdio.h stdlib.h" WANT_H="time.h" +CC_BASE="$CC_BASE -I." NEED_L="m c z pthread png pthread"; + if test $OPT_libxml = 1; then CC_BASE="$CC_BASE -I/usr/include/libxml2" NEED_H="$NEED_H libxml/parser.h" @@ -67,6 +70,10 @@ LD_BASE="$LD_BASE -pg" fi +if test $OPT_glprofile = 1; then + DEFINES="$DEFINES GL_PROFILE" +fi + if test $OPT_OGL = 1; then NEED_H="GL/gl.h" NEED_L="$NEED_L GL GLU" @@ -84,5 +91,9 @@ ARCH=`uname -m` if test $ARCH = "i686" || test $ARCH = "i586"; then - CC_BASE="$CC_BASE -march=pentium" + if test $OPT_sse = 1; then + CC_BASE="$CC_BASE -march=pentium3" + else + CC_BASE="$CC_BASE -march=pentium" + fi fi Modified: Mercury2/modules/Makefile =================================================================== --- Mercury2/modules/Makefile 2009-10-02 06:48:51 UTC (rev 548) +++ Mercury2/modules/Makefile 2009-10-02 06:49:36 UTC (rev 549) @@ -1,4 +1,4 @@ -CFLAGS=-O2 -g0 -Wall -I/usr/include/libxml2 -DHAVE_CONFIG -DHGENGINE -fno-exceptions -fPIC -I../src -g +CFLAGS=-O2 -g0 -Wall -I/usr/include/libxml2 -I.. -msse2 -DHAVE_CONFIG -DHGENGINE -fno-exceptions -fPIC -I../src -g CXXFLAGS=${CFLAGS} LDFLAGS=-shared This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-10-13 01:40:37
|
Revision: 569 http://hgengine.svn.sourceforge.net/hgengine/?rev=569&view=rev Author: axlecrusher Date: 2009-10-13 01:40:18 +0000 (Tue, 13 Oct 2009) Log Message: ----------- use terrain module Modified Paths: -------------- Mercury2/adv_set.c Mercury2/modules.xml Modified: Mercury2/adv_set.c =================================================================== --- Mercury2/adv_set.c 2009-10-12 23:56:39 UTC (rev 568) +++ Mercury2/adv_set.c 2009-10-13 01:40:18 UTC (rev 569) @@ -14,7 +14,7 @@ src/Camera.cpp src/MercuryInput.cpp src/MQuaternion.cpp src/ModuleManager.cpp src/MercuryFBO.cpp \ src/GLHelpers.cpp src/FullscreenQuad.cpp src/MercuryNamedResource.cpp src/MercuryPrefs.cpp \ src/MercuryTheme.cpp src/Orthographic.cpp src/Light.cpp src/RenderDifferedLights.cpp \ - src/MercuryLog.cpp src/MercuryCTA.cpp" + src/MercuryLog.cpp src/MercuryCTA.cpp src/DataTypes/MTriangle.cpp" SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \ src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp" @@ -31,7 +31,7 @@ #endif PROJ="mercury" -CFLAGS="$CFLAGS -DHAVE_CONFIG -DHGENGINE -fno-exceptions -fPIC -Isrc -g " +CFLAGS="$CFLAGS -DHAVE_CONFIG -DHGENGINE -fno-exceptions -fPIC -Isrc -Isrc/DataStructures -Isrc/DataTypes -g " LDFLAGS="$LDFLAGS -rdynamic -g -fPIC " /* Modified: Mercury2/modules.xml =================================================================== --- Mercury2/modules.xml 2009-10-12 23:56:39 UTC (rev 568) +++ Mercury2/modules.xml 2009-10-13 01:40:18 UTC (rev 569) @@ -1,4 +1,5 @@ <Modules> <Module src="modules/TextNode.cpp" obj="modules/TextNode" func="InstallTextNode" /> <Module src="modules/BillboardNode.cpp" obj="modules/BillboardNode" func="InstallBillboardNode"/> + <Module src="modules/Terrain.cpp" obj="modules/Terrain" func="InstallTerrainNode"/> </Modules> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-10-17 01:34:32
|
Revision: 573 http://hgengine.svn.sourceforge.net/hgengine/?rev=573&view=rev Author: axlecrusher Date: 2009-10-17 01:34:21 +0000 (Sat, 17 Oct 2009) Log Message: ----------- make it more difficult to modify message data in the message handlers Modified Paths: -------------- Mercury2/modules/Terrain.cpp Mercury2/modules/Terrain.h Mercury2/src/Camera.cpp Mercury2/src/Camera.h Mercury2/src/MercuryMessageManager.cpp Mercury2/src/MessageHandler.h Modified: Mercury2/modules/Terrain.cpp =================================================================== --- Mercury2/modules/Terrain.cpp 2009-10-16 22:56:32 UTC (rev 572) +++ Mercury2/modules/Terrain.cpp 2009-10-17 01:34:21 UTC (rev 573) @@ -170,14 +170,14 @@ UNREGISTER_FOR_MESSAGE("QueryTerrainPoint"); } -void TerrainAssetInstance::HandleMessage(const MString& message, const MessageData* data) +void TerrainAssetInstance::HandleMessage(const MString& message, const MessageData& data) { if (message == "QueryTerrainPoint") { - VertexDataMessage* v = (VertexDataMessage*)data; + const VertexDataMessage& v( dynamic_cast<const VertexDataMessage&>(data) ); //compute local space position - MercuryVertex local = v->Vertex * m_parentNode->GetGlobalMatrix(); + MercuryVertex local = v.Vertex * m_parentNode->GetGlobalMatrix(); local[3] = 1; //no W Terrain* t = (Terrain*)m_asset.Ptr(); Modified: Mercury2/modules/Terrain.h =================================================================== --- Mercury2/modules/Terrain.h 2009-10-16 22:56:32 UTC (rev 572) +++ Mercury2/modules/Terrain.h 2009-10-17 01:34:21 UTC (rev 573) @@ -38,7 +38,7 @@ public: TerrainAssetInstance(MercuryAsset* asset, MercuryNode* parentNode); ~TerrainAssetInstance(); - virtual void HandleMessage(const MString& message, const MessageData* data); + virtual void HandleMessage(const MString& message, const MessageData& data); private: CLASS_HELPERS( MercuryAssetInstance ); }; Modified: Mercury2/src/Camera.cpp =================================================================== --- Mercury2/src/Camera.cpp 2009-10-16 22:56:32 UTC (rev 572) +++ Mercury2/src/Camera.cpp 2009-10-17 01:34:21 UTC (rev 573) @@ -79,14 +79,14 @@ // EYE.Print(); } -void CameraNode::HandleMessage(const MString& message, const MessageData* data) +void CameraNode::HandleMessage(const MString& message, const MessageData& data) { if (message == INPUTEVENT_MOUSE) { - MouseInput* m = (MouseInput*)data; + const MouseInput& m( dynamic_cast<const MouseInput&>( data ) ); - m_y += m->dy/1200.0f; - m_x += m->dx/1200.0f; + m_y += m.dy/1200.0f; + m_x += m.dx/1200.0f; m_y = Clamp((-Q_PI/2.0f)+0.00001f, (Q_PI/2.0f)-0.00001f, m_y); @@ -106,8 +106,8 @@ else if (message == "SetCameraPosition") { // LOG.Write("SetCamPosition"); - VertexDataMessage* m = (VertexDataMessage*)data; - SetPosition(m->Vertex); + const VertexDataMessage& m( dynamic_cast<const VertexDataMessage&>( data ) ); + SetPosition(m.Vertex); // Update(0); // ComputeMatrix(); // m->Vertex.Print(); Modified: Mercury2/src/Camera.h =================================================================== --- Mercury2/src/Camera.h 2009-10-16 22:56:32 UTC (rev 572) +++ Mercury2/src/Camera.h 2009-10-17 01:34:21 UTC (rev 573) @@ -9,7 +9,7 @@ public: CameraNode(); virtual void ComputeMatrix(); - virtual void HandleMessage(const MString& message, const MessageData* data); + virtual void HandleMessage(const MString& message, const MessageData& data); virtual void Update(float dTime); virtual void PreRender(const MercuryMatrix& matrix); virtual void Render(const MercuryMatrix& matrix); Modified: Mercury2/src/MercuryMessageManager.cpp =================================================================== --- Mercury2/src/MercuryMessageManager.cpp 2009-10-16 22:56:32 UTC (rev 572) +++ Mercury2/src/MercuryMessageManager.cpp 2009-10-17 01:34:21 UTC (rev 573) @@ -68,7 +68,7 @@ std::list< MessageHandler* >::iterator recipients = ref->begin(); for (; recipients != ref->end(); ++recipients) - (*recipients)->HandleMessage(message.message, message.data); + (*recipients)->HandleMessage(message.message, *(message.data) ); } } Modified: Mercury2/src/MessageHandler.h =================================================================== --- Mercury2/src/MessageHandler.h 2009-10-16 22:56:32 UTC (rev 572) +++ Mercury2/src/MessageHandler.h 2009-10-17 01:34:21 UTC (rev 573) @@ -25,7 +25,7 @@ { public: virtual ~MessageHandler() {}; - virtual void HandleMessage(const MString& message, const MessageData* data) {}; + virtual void HandleMessage(const MString& message, const MessageData& data) {}; }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cn...@us...> - 2009-10-22 18:10:28
|
Revision: 576 http://hgengine.svn.sourceforge.net/hgengine/?rev=576&view=rev Author: cnlohr Date: 2009-10-22 18:10:20 +0000 (Thu, 22 Oct 2009) Log Message: ----------- tweak RTTI, since you can't use it in constructors or destructors... Will we have a DeleteNode() virtual function? Also, make module manager smarter and able to reload modules Modified Paths: -------------- Mercury2/base_set.sh Mercury2/src/MercuryNode.cpp Mercury2/src/MercuryNode.h Mercury2/src/ModuleManager.cpp Mercury2/src/ModuleManager.h Modified: Mercury2/base_set.sh =================================================================== --- Mercury2/base_set.sh 2009-10-22 18:07:20 UTC (rev 575) +++ Mercury2/base_set.sh 2009-10-22 18:10:20 UTC (rev 576) @@ -8,13 +8,14 @@ ISMAC=1; fi -OPTIONS="X11 libxml OGL sse gprof glprofile" +OPTIONS="X11 libxml OGL sse gprof glprofile instancewatch" OPT_X11=1 OPT_OGL=1 OPT_libxml=1 OPT_sse=0 OPT_gprof=0 OPT_glprofile=0 +OPT_instancewatch=1 DEFINES="WAS_CONFIGURED USE_MSTRING" CC_BASE="-O2 -g0 -Wall" @@ -88,6 +89,10 @@ LD_BASE="-Lsrc/maclib -framework OpenGL -lobjc -framework GLUT -framework ApplicationServices" fi +if test $OPT_instancewatch = 1; then + DEFINES="$DEFINES INSTANCE_WATCH" +fi + ARCH=`uname -m` if test $ARCH = "i686" || test $ARCH = "i586"; then Modified: Mercury2/src/MercuryNode.cpp =================================================================== --- Mercury2/src/MercuryNode.cpp 2009-10-22 18:07:20 UTC (rev 575) +++ Mercury2/src/MercuryNode.cpp 2009-10-22 18:10:20 UTC (rev 576) @@ -9,12 +9,14 @@ #include <Shader.h> #include <RenderGraph.h> +#include <ModuleManager.h> + using namespace std; REGISTER_NODE_TYPE(MercuryNode); MercuryNode::MercuryNode() - :m_parent(NULL), m_prevSibling(NULL), + :Type( 0 ), m_parent(NULL), m_prevSibling(NULL), m_nextSibling(NULL), m_hidden(false), m_useAlphaPath(false), m_culled(false), m_iPasses( DEFAULT_PASSES ), m_iForcePasses( 0 ) @@ -23,6 +25,12 @@ MercuryNode::~MercuryNode() { + +#ifdef INSTANCE_WATCH + if( Type ) + DEL_INSTANCE(this, Type); +#endif + m_parent = NULL; list< MercuryNode* >::iterator i; @@ -399,7 +407,14 @@ MString t = ToUpper( type ); std::list< std::pair< MString, Callback0R<MercuryNode*> > >::iterator i; for (i = m_factoryCallbacks.begin(); i != m_factoryCallbacks.end(); ++i) - if (i->first == t) return i->second(); + if (i->first == t) + { + MercuryNode * n = i->second(); +#ifdef INSTANCE_WATCH + NEW_INSTANCE(n, n->GetType()); +#endif + return n; + } LOG.Write( "WARNING: Node type " + type + " not found." ); return NULL; } Modified: Mercury2/src/MercuryNode.h =================================================================== --- Mercury2/src/MercuryNode.h 2009-10-22 18:07:20 UTC (rev 575) +++ Mercury2/src/MercuryNode.h 2009-10-22 18:10:20 UTC (rev 576) @@ -21,7 +21,7 @@ { if (n==NULL) return NULL; return dynamic_cast<const x*>(n); } \ static x* Cast(MercuryNode* n) \ { if (n==NULL) return NULL; return dynamic_cast<x*>(n); } \ -virtual const char * GetType() { return #x; } +virtual const char * GetType() { if( !Type ) Type = #x; return #x; } /* #define GENRTTI(x) static bool IsMyType(const MercuryNode* n) \ @@ -117,6 +117,8 @@ const MercuryMatrix & GetModelViewMatrix() const { return m_pModelViewMatrix[g_iViewportID]; } inline unsigned short GetPasses() const { return m_iPasses; } + + const char * Type; protected: std::list< MercuryNode* > m_children; //These nodes are unique, not instanced MercuryNode* m_parent; @@ -171,7 +173,13 @@ MercuryNode* FactoryFunct##class() { return new class(); } \ Callback0R<MercuryNode*> factoryclbk##class( FactoryFunct##class ); \ bool GlobalRegisterSuccess##class = NodeFactory::GetInstance().RegisterFactoryCallback(#class, factoryclbk##class); \ - extern "C" { int Install##class() { LOG.Write("Installing "#class ); NodeFactory::GetInstance().RegisterFactoryCallback(#class, factoryclbk##class); return 0; } } + extern "C" { void * Install##class() { LOG.Write("Installing "#class ); \ + NodeFactory::GetInstance().RegisterFactoryCallback(#class, factoryclbk##class); \ + class * t = new class(); \ + void * vtable = *((void**)t); \ + delete t; \ + return vtable; \ + } } #endif Modified: Mercury2/src/ModuleManager.cpp =================================================================== --- Mercury2/src/ModuleManager.cpp 2009-10-22 18:07:20 UTC (rev 575) +++ Mercury2/src/ModuleManager.cpp 2009-10-22 18:10:20 UTC (rev 576) @@ -19,7 +19,7 @@ extern "C" { -typedef int (*LoaderFunction)(); +typedef void * (*LoaderFunction)(); //Returns vtable pointer }; ModuleManager::ModuleManager() @@ -37,6 +37,7 @@ void ModuleManager::InitializeAllModules() { + m_mHandleMutex.Wait(); XMLDocument* doc = XMLDocument::Load("modules.xml"); XMLNode r = doc->GetRootNode(); for (XMLNode child = r.Child(); child.IsValid(); child = child.NextNode()) @@ -51,9 +52,15 @@ #else MString ModuleName = child.Attribute( "obj" ) + ".so"; #endif + MString LoadFunct = child.Attribute( "func" ); + + m_hModuleMatching[child.Attribute( "obj" )] = child.Attribute( "class" ); + m_hClassMatching[child.Attribute( "class" )] = ModuleName; + m_hClassMFunction[child.Attribute( "class" )] = LoadFunct; LoadModule( ModuleName, LoadFunct ); } + m_mHandleMutex.UnLock(); delete doc; } @@ -63,8 +70,10 @@ dlclose( m_hAllHandles[ModuleName] ); } -bool ModuleManager::LoadModule( const MString & ModuleName, const MString & LoadFunction ) +void * ModuleManager::LoadModule( const MString & ModuleName, const MString & LoadFunction ) { + m_mHandleMutex.Wait(); + if( m_hAllHandles[ModuleName] ) UnloadModule( ModuleName ); void * v = dlopen( ModuleName.c_str(), RTLD_NOW | RTLD_GLOBAL ); @@ -81,9 +90,11 @@ return false; } + m_mHandleMutex.UnLock(); + //If no load funct, just exit early. if( LoadFunction == "" ) - return true; + return 0; LoaderFunction T = (LoaderFunction)dlsym( m_hAllHandles[ModuleName], LoadFunction.c_str() ); if( !T ) @@ -92,16 +103,50 @@ return false; } - int ret = T(); - if( ret ) + void * ret = T(); + if( !ret ) { - fprintf( stderr, "Error executing (Returned error %d): %s() in %s\n", ret, LoadFunction.c_str(), ModuleName.c_str() ); + fprintf( stderr, "Error executing (Returned error %p): %s() in %s\n", ret, LoadFunction.c_str(), ModuleName.c_str() ); return false; } - return true; + return ret; } + +#ifdef INSTANCE_WATCH + +void ModuleManager::ReloadModule( const MString & sClass ) +{ + m_mHandleMutex.Wait(); + + std::set< void * > & s = m_hAllInstances[sClass]; + std::set< void * >::iterator i = s.begin(); + + void * newvtable = LoadModule( m_hClassMatching[sClass], m_hClassMFunction[sClass] ); + + for( ; i != s.end(); i++ ) + *((void**)(*i)) = newvtable; + + m_mHandleMutex.UnLock(); +} + +void ModuleManager::RegisterInstance( void * instance, const char * sClass ) +{ + m_hAllInstances[sClass].insert( instance ); +} + +void ModuleManager::UnregisterInstance( void * instance, const char * sClass ) +{ + std::set< void * > & s = m_hAllInstances[sClass]; + std::set< void * >::iterator i = s.find( instance ); + + if( i != s.end() ) + s.erase( i ); +} + +#endif + /**************************************************************************** * Copyright (C) 2009 by Charles Lohr * * * Modified: Mercury2/src/ModuleManager.h =================================================================== --- Mercury2/src/ModuleManager.h 2009-10-22 18:07:20 UTC (rev 575) +++ Mercury2/src/ModuleManager.h 2009-10-22 18:10:20 UTC (rev 576) @@ -3,6 +3,8 @@ #include <MercuryUtil.h> #include <MercuryHash.h> +#include <MercuryThreads.h> +#include <set> /* This is the module loader mechanism. This allows for run-time loading of new modules. Eventually, it will allow for run-time re-loading of modules. @@ -15,15 +17,44 @@ static ModuleManager & GetInstance(); void InitializeAllModules(); - bool LoadModule( const MString & ModuleName, const MString & LoadFunction ); + void * LoadModule( const MString & ModuleName, const MString & LoadFunction ); void UnloadModule( const MString & ModuleName ); + +#ifdef INSTANCE_WATCH + void ReloadModule( const MString & sClass ); + + void RegisterInstance( void * instance, const char * sClass ); + void UnregisterInstance( void * instance, const char * sClass ); +#endif + +private: + + MercuryMutex m_mHandleMutex; + +#ifdef INSTANCE_WATCH + MHash< std::set< void * > > m_hAllInstances; +#endif + MHash< void * > m_hAllHandles; + MHash< MString > m_hModuleMatching; + MHash< MString > m_hClassMatching; + MHash< MString > m_hClassMFunction; }; static InstanceCounter<ModuleManager> ModMancounter("ModuleManager"); +#ifdef INSTANCE_WATCH +#define NEW_INSTANCE( node, t ) ModuleManager::GetInstance().RegisterInstance( node, t ); +#define DEL_INSTANCE( node, t ) ModuleManager::GetInstance().UnregisterInstance( node, t ); +#else + +#define NEW_INSTANCE( t ) +#define DEL_INSTANCE( t ) + +#endif + /**************************************************************************** * Copyright (C) 2009 by Charles Lohr * * * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cn...@us...> - 2009-10-26 02:00:45
|
Revision: 584 http://hgengine.svn.sourceforge.net/hgengine/?rev=584&view=rev Author: cnlohr Date: 2009-10-26 02:00:33 +0000 (Mon, 26 Oct 2009) Log Message: ----------- make camera go to right place in first frame Modified Paths: -------------- Mercury2/modules/Terrain.cpp Mercury2/src/Camera.cpp Mercury2/src/MercuryAsset.h Modified: Mercury2/modules/Terrain.cpp =================================================================== --- Mercury2/modules/Terrain.cpp 2009-10-26 01:49:06 UTC (rev 583) +++ Mercury2/modules/Terrain.cpp 2009-10-26 02:00:33 UTC (rev 584) @@ -57,8 +57,6 @@ yMax = MAX<float>(v.GetY(),yMax); zMax = MAX<float>(v.GetZ(),zMax); } - - printf("%f %f %f\n", xMax, yMax, zMax); m_hash.Allocate(10, 1); for(uint16_t i = 0; i < length; i+=3) @@ -163,6 +161,11 @@ { if (message == "QueryTerrainPoint") { + if( Asset().GetLoadState() == LOADING ) + { + POST_MESSAGE( "QueryTerrainPoint", new VertexDataMessage( dynamic_cast<const VertexDataMessage&>(data) ), 0.0001 ); + return; + } const VertexDataMessage& v( dynamic_cast<const VertexDataMessage&>(data) ); //compute local space position Modified: Mercury2/src/Camera.cpp =================================================================== --- Mercury2/src/Camera.cpp 2009-10-26 01:49:06 UTC (rev 583) +++ Mercury2/src/Camera.cpp 2009-10-26 02:00:33 UTC (rev 584) @@ -13,6 +13,7 @@ m_lookAt = MercuryVector(0,0,-1); REGISTER_FOR_MESSAGE( INPUTEVENT_MOUSE ); REGISTER_FOR_MESSAGE( "SetCameraPosition" ); + POST_MESSAGE("QueryTerrainPoint", new VertexDataMessage(m_origionalPosition), 0.00001); } void CameraNode::PreRender(const MercuryMatrix& matrix) Modified: Mercury2/src/MercuryAsset.h =================================================================== --- Mercury2/src/MercuryAsset.h 2009-10-26 01:49:06 UTC (rev 583) +++ Mercury2/src/MercuryAsset.h 2009-10-26 02:00:33 UTC (rev 584) @@ -64,9 +64,10 @@ inline void SetPasses( unsigned short p ) { m_iPasses = p; } virtual MercuryAssetInstance* GenerateInstanceData(MercuryNode* parentNode); + + LoadState GetLoadState(); //thread safe protected: void SetLoadState(LoadState ls); //thread safe - LoadState GetLoadState(); //thread safe bool m_isInstanced; BoundingVolume* m_boundingVolume; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |