diff --git a/G3DTest.dsp b/G3DTest.dsp new file mode 100644 index 0000000..4ada96f --- /dev/null +++ b/G3DTest.dsp @@ -0,0 +1,105 @@ +# Microsoft Developer Studio Project File - Name="G3DTest" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=G3DTest - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "G3DTest.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "G3DTest.mak" CFG="G3DTest - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "G3DTest - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "G3DTest - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "G3DTest - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x1009 /d "NDEBUG" +# ADD RSC /l 0x1009 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 + +!ELSEIF "$(CFG)" == "G3DTest - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x1009 /d "_DEBUG" +# ADD RSC /l 0x1009 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "G3DTest - Win32 Release" +# Name "G3DTest - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\main.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/G3DTest.dsw b/G3DTest.dsw new file mode 100644 index 0000000..90964d3 --- /dev/null +++ b/G3DTest.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "G3DTest"=.\G3DTest.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/G3DTest.opt b/G3DTest.opt new file mode 100644 index 0000000..4a8ac1e Binary files /dev/null and b/G3DTest.opt differ diff --git a/G3DTest.plg b/G3DTest.plg new file mode 100644 index 0000000..5c210ef --- /dev/null +++ b/G3DTest.plg @@ -0,0 +1,32 @@ + + +
+

Build Log

+

+--------------------Configuration: G3DTest - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\Users\Andreja\AppData\Local\Temp\RSPFD70.tmp" with contents +[ +/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"Debug/G3DTest.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\USERS\ANDREJA\G3D\G3DTest\main.cpp" +] +Creating command line "cl.exe @C:\Users\Andreja\AppData\Local\Temp\RSPFD70.tmp" +Creating temporary file "C:\Users\Andreja\AppData\Local\Temp\RSPFD71.tmp" with contents +[ +kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/G3DTest.pdb" /debug /machine:I386 /out:"Debug/G3DTest.exe" /pdbtype:sept +.\Debug\main.obj +] +Creating command line "link.exe @C:\Users\Andreja\AppData\Local\Temp\RSPFD71.tmp" +

Output Window

+Compiling... +main.cpp +Linking... + + + +

Results

+G3DTest.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/G3DTest.sln b/G3DTest.sln new file mode 100644 index 0000000..cc42e7a --- /dev/null +++ b/G3DTest.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "G3DTest", "G3DTest.vcproj", "{6C4D6EEF-B1D1-456A-B850-92CAB17124BE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6C4D6EEF-B1D1-456A-B850-92CAB17124BE}.Debug|Win32.ActiveCfg = Debug|Win32 + {6C4D6EEF-B1D1-456A-B850-92CAB17124BE}.Debug|Win32.Build.0 = Debug|Win32 + {6C4D6EEF-B1D1-456A-B850-92CAB17124BE}.Release|Win32.ActiveCfg = Release|Win32 + {6C4D6EEF-B1D1-456A-B850-92CAB17124BE}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/G3DTest.suo b/G3DTest.suo new file mode 100644 index 0000000..ce9ccc6 Binary files /dev/null and b/G3DTest.suo differ diff --git a/G3DTest.vcproj b/G3DTest.vcproj new file mode 100644 index 0000000..d4e1b2b --- /dev/null +++ b/G3DTest.vcproj @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SDL.dll b/SDL.dll new file mode 100644 index 0000000..86975e6 Binary files /dev/null and b/SDL.dll differ diff --git a/g3d-license.txt b/g3d-license.txt new file mode 100644 index 0000000..6da4222 --- /dev/null +++ b/g3d-license.txt @@ -0,0 +1,41 @@ +This program uses the Graphics3D Library ("G3D", http://g3d-cpp.sf.net) +This software is based in part on the PNG Reference Library which is +Copyright (c) 2004 Glenn Randers-Pehrson +This software is based in part on the work of the Independent JPEG Group. +This software uses the Simple DirectMedia Layer library ("SDL", +http://www.libsdl.org), which is included under the terms of the +GNU Lesser General Public License, (http://www.gnu.org/copyleft/lesser.html). + +This program uses the Graphics3D Library ("G3D", http://g3d-cpp.sf.net), which +is licensed under the "BSD" Open Source license. The Graphics3D library +source code is Copyright © 2000-2006, Morgan McGuire, All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +Neither the name of Morgan McGuire, Brown University, nor the names +of its contributors may be used to endorse or promote products derived +from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +G3D VERSION 61000 diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..cc10ab6 --- /dev/null +++ b/main.cpp @@ -0,0 +1,231 @@ +/** + @file demos/main.cpp + + This is a sample main.cpp to get you started with G3D. It is + designed to make writing an application easy. Although the + GApp/GApplet infrastructure is helpful for most projects, + you are not restricted to using it-- choose the level of + support that is best for your project (see the G3D Map in the + documentation). + + @author Morgan McGuire, matrix@graphics3d.com + */ +#include + +#if G3D_VER < 60800 + #error Requires G3D 6.08 +#endif +static const float VNUM = 0.01F; +static const std::string VERSION = "PRE-ALPHA "; +static GFontRef fntdominant = NULL; +static GFontRef fntlighttrek = NULL; +static bool democ = true; +/** + This simple demo applet uses the debug mode as the regular + rendering mode so you can fly around the scene. + */ +class Demo : public GApplet { + +public: + + // Add state that should be visible to this applet. + // If you have multiple applets that need to share + // state, put it in the App. + + class App* app; + + Demo(App* app); + + virtual ~Demo() {} + + virtual void onInit(); + + virtual void onLogic(); + + virtual void onNetwork(); + + virtual void onSimulation(RealTime rdt, SimTime sdt, SimTime idt); + + virtual void onGraphics(RenderDevice* rd); + + virtual void onUserInput(UserInput* ui); + + virtual void onCleanup(); + +}; + + + +class App : public GApp { +protected: + void main(); +public: + SkyRef sky; + + Demo* applet; + + App(const GAppSettings& settings); + + ~App(); +}; + + +Demo::Demo(App* _app) : GApplet(_app), app(_app) { +} + +#include +std::string Convert (float number){ + std::ostringstream buff; + buff<debugCamera.setPosition(Vector3(0, 2, 10)); + app->debugCamera.lookAt(Vector3(0, 2, 0)); + std::string str = "Dynamica Duomillenium 5 Version " + VERSION + Convert(VNUM); + app->renderDevice->setCaption(str); + GApplet::onInit(); +} + + + +void Demo::onCleanup() { + // Called when Demo::run() exits +} + + +void Demo::onLogic() { + // Add non-simulation game logic and AI code here +} + + +void Demo::onNetwork() { + // Poll net messages here +} + + +void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) { + +} + + +void Demo::onUserInput(UserInput* ui) { + if (ui->keyPressed(SDLK_ESCAPE)) { + // Even when we aren't in debug mode, quit on escape. + endApplet = true; + app->endProgram = true; + } + if(ui->keyPressed(SDL_RIGHT_MOUSE_KEY)) + { + app->debugController.setActive(true); + } + else if(ui->keyReleased(SDL_RIGHT_MOUSE_KEY)) + { + app->debugController.setActive(false); + } + if(ui->keyPressed('d')) + { + if(ui->keyDown(SDLK_LCTRL)) + { + app->setDebugMode(!app->debugMode()); + } + } + + // Add other key handling here +} + +std::string ExePath() { + char buffer[MAX_PATH]; + GetModuleFileName( NULL, buffer, MAX_PATH ); + std::string::size_type pos = std::string( buffer ).find_last_of( "\\/" ); + return std::string( buffer ).substr( 0, pos); +} + +void Demo::onGraphics(RenderDevice* rd) { + LightingParameters lighting(G3D::toSeconds(11, 00, 00, AM)); + app->renderDevice->setProjectionAndCameraMatrix(app->debugCamera); + + // Cyan background + app->renderDevice->setColorClearValue(Color3(0.0f, 0.5f, 1.0f)); + + app->renderDevice->clear(app->sky.isNull(), true, true); + if (app->sky.notNull()) { + app->sky->render(app->renderDevice, lighting); + } + + // Setup lighting + app->renderDevice->enableLighting(); + app->renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor)); + app->renderDevice->setAmbientLightColor(lighting.ambient); + + Draw::axes(CoordinateFrame(Vector3(0, 0, 0)), app->renderDevice); + Draw::cylinder(G3D::Cylinder::Cylinder(Vector3(0,0,0),Vector3(0,10,0),1),app->renderDevice,Color4(0,0,1,0.5),Color4(0,0,0,0)); + + app->renderDevice->disableLighting(); + + if (app->sky.notNull()) { + app->sky->renderLensFlare(app->renderDevice, lighting); + } + app->renderDevice->push2D(); + + //std::string str = ; + + int offset = 0; + int offset2 = 0; + if(app->debugMode()) + { + offset = 50; + offset2 = 70; + fntlighttrek->draw2D(rd, "Debug Mode Enabled", Vector2(0,30 + offset), 15, Color3::white(), Color3::black()); + } + + fntdominant->draw2D(rd, "Dynamica 2004-2005 Simulation Client version " + VERSION + Convert(VNUM), Vector2(0,0 + offset), 20, Color3::white(), Color3::black()); + //fntlighttrek->draw2D(rd, "Button: " + button, Vector2(10,30 + offset), 15, Color3::white(), Color3::black()); + + + Draw::box(G3D::Box(Vector3(0,40 + offset2,0),Vector3(80,330+offset2+40,0)),rd,Color4(0.5F,0.5F,0.5F,0.2F), Color4(0,0,0,0)); + Draw::box(G3D::Box(Vector3(0,rd->getHeight() - 120,0),Vector3(80,rd->getHeight(),0)),rd,Color4(0.5F,0.5F,0.5F,0.4F), Color4(0,0,0,0)); + Draw::box(G3D::Box(Vector3(rd->getWidth() - 120,rd->getHeight() - 120,0),Vector3(rd->getWidth(),rd->getHeight(),0)),rd,Color4(0.5F,0.5F,0.5F,0.4F), Color4(0,0,0,0)); + fntlighttrek->draw2D(rd, "CameraMenu", Vector2(rd->getWidth()-(fntlighttrek->get2DStringBounds("CameraMenu", 14).x+1),rd->getHeight() - 120), 14, Color3::white(), Color4(0.5F,0.5F,0.5F,0.5F)); + //G3D::GFont::draw2D("Debug Mode Enabled", Vector2(0,30), 20, Color3::white(), Color3::black()); + //app->debugFont->draw2D("Dynamica 2004-2005 Simulation Client version " + VERSION + str, Vector2(0,0), 20, Color3::white(), Color3::black()); + //app->debugFont->draw2D("Debug Mode Enabled", Vector2(0,30), 20, Color3::white(), Color3::black()); + app->renderDevice->pop2D(); + +} + + + +void App::main() { + setDebugMode(false); + debugController.setActive(false); + // Load objects here + fntdominant = GFont::fromFile(ExePath() + "\\content\\font\\dominant.fnt"); + fntlighttrek = GFont::fromFile(ExePath() + "\\content\\font\\lighttrek.fnt"); + sky = Sky::create(NULL, ExePath() + "/content/sky/"); + applet->run(); +} + + + +App::App(const GAppSettings& settings) : GApp(settings) { + applet = new Demo(this); +} + + +App::~App() { + delete applet; +} + +int main(int argc, char** argv) { + GAppSettings settings; + //settings.debugFontName = "lighttrek.fnt"; + //settings.useNetwork = false; + //settings.window.width = 1024; + //settings.window.height = 768; + settings.window.resizable = true; + App(settings).run(); + return 0; +}