Ver Fonte

Johan is love, Johan is life

Kenneth van Ewijk há 9 anos atrás
pai
commit
7c4ee37867
82 ficheiros alterados com 546 adições e 1246 exclusões
  1. 0 235
      .gitignore
  2. BIN
      .vs/CrystalPoint/v14/.suo
  3. 0 12
      Controller.cpp
  4. 0 10
      Controller.h
  5. 62 0
      CrystalJohan.cpp
  6. 33 0
      CrystalJohan.h
  7. BIN
      CrystalJohan.sdf
  8. 28 0
      CrystalJohan.sln
  9. 28 44
      CrystalJohan.vcxproj
  10. 84 0
      CrystalJohan.vcxproj.filters
  11. 0 28
      CrystalPoint.sln
  12. 0 150
      CrystalPoint.vcxproj.filters
  13. BIN
      Debug/CrystalJohan.exe
  14. BIN
      Debug/CrystalJohan.ilk
  15. 3 0
      Debug/CrystalJohan.log
  16. BIN
      Debug/CrystalJohan.obj
  17. BIN
      Debug/CrystalJohan.pdb
  18. BIN
      Debug/CrystalJohan.tlog/CL.command.1.tlog
  19. BIN
      Debug/CrystalJohan.tlog/CL.read.1.tlog
  20. BIN
      Debug/CrystalJohan.tlog/CL.write.1.tlog
  21. 2 0
      Debug/CrystalJohan.tlog/CrystalJohan.lastbuildstate
  22. BIN
      Debug/CrystalJohan.tlog/link.command.1.tlog
  23. BIN
      Debug/CrystalJohan.tlog/link.read.1.tlog
  24. BIN
      Debug/CrystalJohan.tlog/link.write.1.tlog
  25. BIN
      Debug/Enemy.obj
  26. BIN
      Debug/Entity.obj
  27. BIN
      Debug/LevelObject.obj
  28. BIN
      Debug/Main.obj
  29. BIN
      Debug/Model.obj
  30. BIN
      Debug/Player.obj
  31. BIN
      Debug/Vector.obj
  32. BIN
      Debug/World.obj
  33. BIN
      Debug/vc140.idb
  34. BIN
      Debug/vc140.pdb
  35. 0 2
      Enemy.h
  36. 36 0
      Entity.cpp
  37. 20 0
      Entity.h
  38. 0 22
      Header.h
  39. 0 12
      InitState.cpp
  40. 0 11
      InitState.h
  41. 0 12
      Keyboard.cpp
  42. 0 10
      Keyboard.h
  43. 12 0
      LevelObject.cpp
  44. 8 0
      LevelObject.h
  45. 0 12
      LoadingState.cpp
  46. 0 11
      LoadingState.h
  47. 34 166
      Main.cpp
  48. 0 0
      Main.h
  49. 0 12
      MenuState.cpp
  50. 0 10
      MenuState.h
  51. 43 36
      Model.cpp
  52. 14 9
      Model.h
  53. 0 12
      ModelHandler.cpp
  54. 0 8
      ModelHandler.h
  55. 0 10
      ModelInstance.cpp
  56. 0 16
      ModelInstance.h
  57. 0 12
      Mouse.cpp
  58. 0 10
      Mouse.h
  59. 5 67
      Player.cpp
  60. 13 30
      Player.h
  61. 0 2
      README.md
  62. 40 0
      ReadMe.txt
  63. 0 12
      SettingsState.cpp
  64. 0 11
      SettingsState.h
  65. 13 0
      Singleton.h
  66. 0 40
      State.cpp
  67. 0 26
      State.h
  68. 0 33
      StateHandler.cpp
  69. 0 19
      StateHandler.h
  70. 5 0
      Vector.cpp
  71. 1 1
      Vector.h
  72. 0 28
      Weapon.cpp
  73. 0 16
      Weapon.h
  74. 40 0
      World.cpp
  75. 22 0
      World.h
  76. 0 12
      WorldModel.cpp
  77. 0 10
      WorldModel.h
  78. 0 49
      WorldState.cpp
  79. 0 18
      WorldState.h
  80. BIN
      freeglut/bin/freeglut.dll
  81. BIN
      freeglut/bin/x64/freeglut.dll
  82. BIN
      freeglut/lib/x64/freeglut.lib

+ 0 - 235
.gitignore

@@ -1,235 +0,0 @@
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-
-# User-specific files
-*.suo
-*.user
-*.userosscache
-*.sln.docstates
-
-# User-specific files (MonoDevelop/Xamarin Studio)
-*.userprefs
-
-# Build results
-[Dd]ebug/
-[Dd]ebugPublic/
-[Rr]elease/
-[Rr]eleases/
-x64/
-x86/
-bld/
-[Bb]in/
-[Oo]bj/
-
-# Visual Studio 2015 cache/options directory
-.vs/
-# Uncomment if you have tasks that create the project's static files in wwwroot
-#wwwroot/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-# NUNIT
-*.VisualState.xml
-TestResult.xml
-
-# Build Results of an ATL Project
-[Dd]ebugPS/
-[Rr]eleasePS/
-dlldata.c
-
-# DNX
-project.lock.json
-artifacts/
-
-*_i.c
-*_p.c
-*_i.h
-*.ilk
-*.meta
-*.pch
-*.pdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.svclog
-*.scc
-
-# Chutzpah Test files
-_Chutzpah*
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opendb
-*.opensdf
-*.sdf
-*.cachefile
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-*.sap
-
-# TFS 2012 Local Workspace
-$tf/
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-*.DotSettings.user
-
-# JustCode is a .NET coding add-in
-.JustCode
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# NCrunch
-_NCrunch_*
-.*crunch*.local.xml
-nCrunchTemp_*
-
-# MightyMoose
-*.mm.*
-AutoTest.Net/
-
-# Web workbench (sass)
-.sass-cache/
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.[Pp]ublish.xml
-*.azurePubxml
-# TODO: Comment the next line if you want to checkin your web deploy settings 
-# but database connection strings (with potential passwords) will be unencrypted
-*.pubxml
-*.publishproj
-
-# NuGet Packages
-*.nupkg
-# The packages folder can be ignored because of Package Restore
-**/packages/*
-# except build/, which is used as an MSBuild target.
-!**/packages/build/
-# Uncomment if necessary however generally it will be regenerated when needed
-#!**/packages/repositories.config
-# NuGet v3's project.json files produces more ignoreable files
-*.nuget.props
-*.nuget.targets
-
-# Microsoft Azure Build Output
-csx/
-*.build.csdef
-
-# Microsoft Azure Emulator
-ecf/
-rcf/
-
-# Microsoft Azure ApplicationInsights config file
-ApplicationInsights.config
-
-# Windows Store app package directory
-AppPackages/
-BundleArtifacts/
-
-# Visual Studio cache files
-# files ending in .cache can be ignored
-*.[Cc]ache
-# but keep track of directories ending in .cache
-!*.[Cc]ache/
-
-# Others
-ClientBin/
-~$*
-*~
-*.dbmdl
-*.dbproj.schemaview
-*.pfx
-*.publishsettings
-node_modules/
-orleans.codegen.cs
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file
-# to a newer Visual Studio version. Backup files are not needed,
-# because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-
-# SQL Server files
-*.mdf
-*.ldf
-
-# Business Intelligence projects
-*.rdl.data
-*.bim.layout
-*.bim_*.settings
-
-# Microsoft Fakes
-FakesAssemblies/
-
-# GhostDoc plugin setting file
-*.GhostDoc.xml
-
-# Node.js Tools for Visual Studio
-.ntvs_analysis.dat
-
-# Visual Studio 6 build log
-*.plg
-
-# Visual Studio 6 workspace options file
-*.opt
-
-# Visual Studio LightSwitch build output
-**/*.HTMLClient/GeneratedArtifacts
-**/*.DesktopClient/GeneratedArtifacts
-**/*.DesktopClient/ModelManifest.xml
-**/*.Server/GeneratedArtifacts
-**/*.Server/ModelManifest.xml
-_Pvt_Extensions
-
-# Paket dependency manager
-.paket/paket.exe
-
-# FAKE - F# Make
-.fake/

BIN
.vs/CrystalPoint/v14/.suo


+ 0 - 12
Controller.cpp

@@ -1,12 +0,0 @@
-#include "Controller.h"
-
-
-
-Controller::Controller()
-{
-}
-
-
-Controller::~Controller()
-{
-}

+ 0 - 10
Controller.h

@@ -1,10 +0,0 @@
-#pragma once
-#include "Header.h"
-
-class Controller
-{
-public:
-	Controller();
-	~Controller();
-};
-

+ 62 - 0
CrystalJohan.cpp

@@ -0,0 +1,62 @@
+
+#include "CrystalJohan.h"
+#include <GL/freeglut.h>
+#include "World.h"
+
+void CrystalJohan::init()
+{
+	world = new World();
+	lastFrameTime = 0;
+
+	glClearColor(0.7, 0.7, 1.0, 1.0);
+	glEnable(GL_DEPTH_TEST);
+
+}
+
+
+void CrystalJohan::draw()
+{
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	gluPerspective(70, width / (float)height, 0.1f, 100);
+	glMatrixMode(GL_MODELVIEW);
+	glLoadIdentity();
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+
+
+	world->draw();
+}
+
+
+void CrystalJohan::update()
+{
+	float frameTime = glutGet(GLUT_ELAPSED_TIME) / 1000.0f;
+	float deltaTime = frameTime - lastFrameTime;
+	lastFrameTime = frameTime;
+	
+	//	if(keyboardState.special[GLUT_KEY_LEFT] && !prevKeyboardState.special[GLUT_KEY_LEFT])
+	if (keyboardState.keys[27])
+		exit(0);
+
+
+	world->player.rotation.y += mouseOffset.x/10.0f;
+	world->player.rotation.x += mouseOffset.y/10.0f;
+	if (world->player.rotation.x > 90)
+		world->player.rotation.x = 90;
+	if (world->player.rotation.x < -90)
+		world->player.rotation.x = -90;
+
+
+	mouseOffset = Vec2f(0, 0);
+	prevKeyboardState = keyboardState;
+	glutPostRedisplay();
+}
+
+
+
+KeyboardState::KeyboardState()
+{
+	memset(keys, 0, sizeof(keys));
+	memset(special, 0, sizeof(special));
+}

+ 33 - 0
CrystalJohan.h

@@ -0,0 +1,33 @@
+#pragma once
+
+class World;
+#include "vector.h"
+
+class KeyboardState
+{
+public:
+	bool keys[256];
+	bool special[256];
+	bool control, shift, alt;
+
+	KeyboardState();
+};
+
+class CrystalJohan
+{
+public:
+	void init();
+	void draw();
+	void update();
+
+	World* world;
+
+	int width, height;
+	KeyboardState keyboardState;
+	KeyboardState prevKeyboardState;
+
+	Vec2f mouseOffset;
+
+	float lastFrameTime;
+
+};

BIN
CrystalJohan.sdf


+ 28 - 0
CrystalJohan.sln

@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.24720.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrystalJohan", "CrystalJohan.vcxproj", "{98776A7C-CD7A-4C62-946A-2263C27E9690}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|x64 = Debug|x64
+		Debug|x86 = Debug|x86
+		Release|x64 = Release|x64
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{98776A7C-CD7A-4C62-946A-2263C27E9690}.Debug|x64.ActiveCfg = Debug|x64
+		{98776A7C-CD7A-4C62-946A-2263C27E9690}.Debug|x64.Build.0 = Debug|x64
+		{98776A7C-CD7A-4C62-946A-2263C27E9690}.Debug|x86.ActiveCfg = Debug|Win32
+		{98776A7C-CD7A-4C62-946A-2263C27E9690}.Debug|x86.Build.0 = Debug|Win32
+		{98776A7C-CD7A-4C62-946A-2263C27E9690}.Release|x64.ActiveCfg = Release|x64
+		{98776A7C-CD7A-4C62-946A-2263C27E9690}.Release|x64.Build.0 = Release|x64
+		{98776A7C-CD7A-4C62-946A-2263C27E9690}.Release|x86.ActiveCfg = Release|Win32
+		{98776A7C-CD7A-4C62-946A-2263C27E9690}.Release|x86.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

+ 28 - 44
CrystalPoint.vcxproj → CrystalJohan.vcxproj

@@ -19,11 +19,10 @@
     </ProjectConfiguration>
   </ItemGroup>
   <PropertyGroup Label="Globals">
-    <ProjectGuid>{4986BEC0-4362-46E4-A18D-65587FA97967}</ProjectGuid>
+    <ProjectGuid>{98776A7C-CD7A-4C62-946A-2263C27E9690}</ProjectGuid>
     <Keyword>Win32Proj</Keyword>
-    <RootNamespace>CrystalPoint</RootNamespace>
+    <RootNamespace>CrystalJohan</RootNamespace>
     <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
-    <ProjectName>CrystalPoint</ProjectName>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -84,11 +83,11 @@
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <WarningLevel>Level3</WarningLevel>
       <Optimization>Disabled</Optimization>
       <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PrecompiledHeaderFile />
       <AdditionalIncludeDirectories>freeglut/include</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
@@ -99,11 +98,11 @@
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <ClCompile>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <WarningLevel>Level3</WarningLevel>
       <Optimization>Disabled</Optimization>
       <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PrecompiledHeaderFile />
       <AdditionalIncludeDirectories>freeglut/include</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
@@ -115,12 +114,12 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
       <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <Optimization>MaxSpeed</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
       <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PrecompiledHeaderFile />
       <AdditionalIncludeDirectories>freeglut/include</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
@@ -134,12 +133,12 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <ClCompile>
       <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <Optimization>MaxSpeed</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
       <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PrecompiledHeaderFile />
       <AdditionalIncludeDirectories>freeglut/include</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
@@ -151,46 +150,31 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClInclude Include="Controller.h" />
-    <ClInclude Include="Enemy.h" />
-    <ClInclude Include="Header.h" />
-    <ClInclude Include="InitState.h" />
-    <ClInclude Include="Keyboard.h" />
-    <ClInclude Include="LoadingState.h" />
-    <ClInclude Include="MenuState.h" />
-    <ClInclude Include="Model.h" />
-    <ClInclude Include="ModelHandler.h" />
-    <ClInclude Include="ModelInstance.h" />
-    <ClInclude Include="Mouse.h" />
-    <ClInclude Include="Player.h" />
-    <ClInclude Include="SettingsState.h" />
-    <ClInclude Include="State.h" />
-    <ClInclude Include="StateHandler.h" />
-    <ClInclude Include="Vector.h" />
-    <ClInclude Include="Weapon.h" />
-    <ClInclude Include="WorldModel.h" />
-    <ClInclude Include="WorldState.h" />
+    <Text Include="ReadMe.txt" />
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="Controller.cpp" />
+    <ClCompile Include="CrystalJohan.cpp" />
     <ClCompile Include="Enemy.cpp" />
-    <ClCompile Include="InitState.cpp" />
-    <ClCompile Include="Keyboard.cpp" />
-    <ClCompile Include="LoadingState.cpp" />
+    <ClCompile Include="Entity.cpp" />
+    <ClCompile Include="LevelObject.cpp" />
     <ClCompile Include="Main.cpp" />
-    <ClCompile Include="MenuState.cpp" />
     <ClCompile Include="Model.cpp" />
-    <ClCompile Include="ModelHandler.cpp" />
-    <ClCompile Include="ModelInstance.cpp" />
-    <ClCompile Include="Mouse.cpp" />
     <ClCompile Include="Player.cpp" />
-    <ClCompile Include="SettingsState.cpp" />
-    <ClCompile Include="State.cpp" />
-    <ClCompile Include="StateHandler.cpp" />
     <ClCompile Include="Vector.cpp" />
-    <ClCompile Include="Weapon.cpp" />
-    <ClCompile Include="WorldModel.cpp" />
-    <ClCompile Include="WorldState.cpp" />
+    <ClCompile Include="World.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="CrystalJohan.h" />
+    <ClInclude Include="Enemy.h" />
+    <ClInclude Include="Entity.h" />
+    <ClInclude Include="LevelObject.h" />
+    <ClInclude Include="Main.h" />
+    <ClInclude Include="Model.h" />
+    <ClInclude Include="Player.h" />
+    <ClInclude Include="Singleton.h" />
+    <ClInclude Include="stb_image.h" />
+    <ClInclude Include="vector.h" />
+    <ClInclude Include="World.h" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">

+ 84 - 0
CrystalJohan.vcxproj.filters

@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Resource Files">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <Text Include="ReadMe.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="CrystalJohan.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Main.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="World.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Entity.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Enemy.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="LevelObject.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Model.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Vector.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Player.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="CrystalJohan.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="World.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Entity.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Enemy.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="LevelObject.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="vector.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Model.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="stb_image.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Player.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Singleton.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Main.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+</Project>

+ 0 - 28
CrystalPoint.sln

@@ -1,28 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.24720.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrystalPoint", "CrystalPoint.vcxproj", "{4986BEC0-4362-46E4-A18D-65587FA97967}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|x64 = Debug|x64
-		Debug|x86 = Debug|x86
-		Release|x64 = Release|x64
-		Release|x86 = Release|x86
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{4986BEC0-4362-46E4-A18D-65587FA97967}.Debug|x64.ActiveCfg = Debug|x64
-		{4986BEC0-4362-46E4-A18D-65587FA97967}.Debug|x64.Build.0 = Debug|x64
-		{4986BEC0-4362-46E4-A18D-65587FA97967}.Debug|x86.ActiveCfg = Debug|Win32
-		{4986BEC0-4362-46E4-A18D-65587FA97967}.Debug|x86.Build.0 = Debug|Win32
-		{4986BEC0-4362-46E4-A18D-65587FA97967}.Release|x64.ActiveCfg = Release|x64
-		{4986BEC0-4362-46E4-A18D-65587FA97967}.Release|x64.Build.0 = Release|x64
-		{4986BEC0-4362-46E4-A18D-65587FA97967}.Release|x86.ActiveCfg = Release|Win32
-		{4986BEC0-4362-46E4-A18D-65587FA97967}.Release|x86.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal

+ 0 - 150
CrystalPoint.vcxproj.filters

@@ -1,150 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-    <Filter Include="Source Files\State">
-      <UniqueIdentifier>{6c99658e-2c17-469b-a3d1-2c4d3d61d440}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\Control">
-      <UniqueIdentifier>{e444364a-17f6-4464-a98c-6bd34d3e6263}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\Model">
-      <UniqueIdentifier>{842778c9-ff0f-4a6d-9c86-0a178ad40fcc}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\Model\Enemy">
-      <UniqueIdentifier>{1be14b84-6fa7-4cfb-94b9-666f3ee14198}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\Handler">
-      <UniqueIdentifier>{1b39afb7-b64b-458a-bba3-755631986211}</UniqueIdentifier>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="Model.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Header.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="StateHandler.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="State.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="MenuState.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="LoadingState.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Keyboard.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Mouse.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Controller.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="WorldModel.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="WorldState.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Enemy.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Player.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Weapon.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Vector.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="ModelInstance.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="ModelHandler.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="SettingsState.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="InitState.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="Main.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="State.cpp">
-      <Filter>Source Files\State</Filter>
-    </ClCompile>
-    <ClCompile Include="MenuState.cpp">
-      <Filter>Source Files\State</Filter>
-    </ClCompile>
-    <ClCompile Include="Keyboard.cpp">
-      <Filter>Source Files\Control</Filter>
-    </ClCompile>
-    <ClCompile Include="Mouse.cpp">
-      <Filter>Source Files\Control</Filter>
-    </ClCompile>
-    <ClCompile Include="Controller.cpp">
-      <Filter>Source Files\Control</Filter>
-    </ClCompile>
-    <ClCompile Include="LoadingState.cpp">
-      <Filter>Source Files\State</Filter>
-    </ClCompile>
-    <ClCompile Include="Model.cpp">
-      <Filter>Source Files\Model</Filter>
-    </ClCompile>
-    <ClCompile Include="WorldModel.cpp">
-      <Filter>Source Files\Model</Filter>
-    </ClCompile>
-    <ClCompile Include="WorldState.cpp">
-      <Filter>Source Files\State</Filter>
-    </ClCompile>
-    <ClCompile Include="Enemy.cpp">
-      <Filter>Source Files\Model\Enemy</Filter>
-    </ClCompile>
-    <ClCompile Include="Player.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Weapon.cpp">
-      <Filter>Source Files\Model</Filter>
-    </ClCompile>
-    <ClCompile Include="Vector.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="ModelInstance.cpp">
-      <Filter>Source Files\Model</Filter>
-    </ClCompile>
-    <ClCompile Include="StateHandler.cpp">
-      <Filter>Source Files\Handler</Filter>
-    </ClCompile>
-    <ClCompile Include="ModelHandler.cpp">
-      <Filter>Source Files\Handler</Filter>
-    </ClCompile>
-    <ClCompile Include="SettingsState.cpp">
-      <Filter>Source Files\State</Filter>
-    </ClCompile>
-    <ClCompile Include="InitState.cpp">
-      <Filter>Source Files\State</Filter>
-    </ClCompile>
-  </ItemGroup>
-</Project>

BIN
Debug/CrystalJohan.exe


BIN
Debug/CrystalJohan.ilk


+ 3 - 0
Debug/CrystalJohan.log

@@ -0,0 +1,3 @@
+  World.cpp
+d:\code\c++\crystaljohan\world.cpp(7): warning C4305: '=': truncation from 'double' to 'float'
+  CrystalJohan.vcxproj -> D:\Code\C++\CrystalJohan\Debug\CrystalJohan.exe

BIN
Debug/CrystalJohan.obj


BIN
Debug/CrystalJohan.pdb


BIN
Debug/CrystalJohan.tlog/CL.command.1.tlog


BIN
Debug/CrystalJohan.tlog/CL.read.1.tlog


BIN
Debug/CrystalJohan.tlog/CL.write.1.tlog


+ 2 - 0
Debug/CrystalJohan.tlog/CrystalJohan.lastbuildstate

@@ -0,0 +1,2 @@
+#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
+Debug|Win32|D:\Code\C++\CrystalJohan\|

BIN
Debug/CrystalJohan.tlog/link.command.1.tlog


BIN
Debug/CrystalJohan.tlog/link.read.1.tlog


BIN
Debug/CrystalJohan.tlog/link.write.1.tlog


BIN
Debug/Enemy.obj


BIN
Debug/Entity.obj


BIN
Debug/LevelObject.obj


BIN
Debug/Main.obj


BIN
Debug/Model.obj


BIN
Debug/Player.obj


BIN
Debug/Vector.obj


BIN
Debug/World.obj


BIN
Debug/vc140.idb


BIN
Debug/vc140.pdb


+ 0 - 2
Enemy.h

@@ -1,6 +1,4 @@
 #pragma once
-#include "Header.h"
-
 class Enemy
 {
 public:

+ 36 - 0
Entity.cpp

@@ -0,0 +1,36 @@
+#include "Entity.h"
+
+#include <GL/freeglut.h>
+
+#include "Model.h"
+
+
+Entity::Entity()
+{
+	model = NULL;
+}
+
+
+Entity::~Entity()
+{
+}
+
+
+void Entity::draw()
+{
+	if (model)
+	{
+		glPushMatrix();
+
+		glTranslatef(position.x, position.y, position.z);
+		glRotatef(rotation.x, 1, 0, 0);
+		glRotatef(rotation.y, 0, 1, 0);
+		glRotatef(rotation.z, 0, 0, 1);
+		glScalef(scale, scale, scale);
+
+		model->draw();
+		glPopMatrix();
+	}
+
+}
+

+ 20 - 0
Entity.h

@@ -0,0 +1,20 @@
+#pragma once
+
+#include "Vector.h"
+class Model;
+
+class Entity
+{
+public:
+	Entity();
+	~Entity();
+
+	Model* model;
+
+	virtual void draw();
+	virtual void update(float elapsedTime) {};
+	Vec3f position;
+	Vec3f rotation;
+	float scale;
+};
+

+ 0 - 22
Header.h

@@ -1,22 +0,0 @@
-#pragma once
-
-#include <GL/freeglut.h>
-
-#define _USE_MATH_DEFINES
-#include <cmath>
-#include <math.h>
-
-#include <string>
-#include <vector>
-#include <list>
-#include <fstream>
-#include <iostream>
-#include <algorithm>
-#include <vector>
-
-#include <windows.h>
-#include <gl/GL.h>
-
-#include "Vector.h"
-
-using namespace std;

+ 0 - 12
InitState.cpp

@@ -1,12 +0,0 @@
-#include "InitState.h"
-
-
-
-InitState::InitState()
-{
-}
-
-
-InitState::~InitState()
-{
-}

+ 0 - 11
InitState.h

@@ -1,11 +0,0 @@
-#pragma once
-#include "Header.h"
-#include "State.h"
-
-class InitState : public State
-{
-public:
-	InitState();
-	~InitState();
-};
-

+ 0 - 12
Keyboard.cpp

@@ -1,12 +0,0 @@
-#include "Keyboard.h"
-
-
-
-Keyboard::Keyboard()
-{
-}
-
-
-Keyboard::~Keyboard()
-{
-}

+ 0 - 10
Keyboard.h

@@ -1,10 +0,0 @@
-#pragma once
-#include "Header.h"
-
-class Keyboard
-{
-public:
-	Keyboard();
-	~Keyboard();
-};
-

+ 12 - 0
LevelObject.cpp

@@ -0,0 +1,12 @@
+#include "LevelObject.h"
+
+
+
+LevelObject::LevelObject()
+{
+}
+
+
+LevelObject::~LevelObject()
+{
+}

+ 8 - 0
LevelObject.h

@@ -0,0 +1,8 @@
+#pragma once
+class LevelObject
+{
+public:
+	LevelObject();
+	~LevelObject();
+};
+

+ 0 - 12
LoadingState.cpp

@@ -1,12 +0,0 @@
-#include "LoadingState.h"
-
-
-
-LoadingState::LoadingState()
-{
-}
-
-
-LoadingState::~LoadingState()
-{
-}

+ 0 - 11
LoadingState.h

@@ -1,11 +0,0 @@
-#pragma once
-#include "Header.h"
-#include "State.h"
-
-class LoadingState : public State
-{
-public:
-	LoadingState();
-	~LoadingState();
-};
-

+ 34 - 166
Main.cpp

@@ -1,142 +1,17 @@
-#include "Header.h"
-#include "Model.h"
-#include "Player.h"
-#include "StateHandler.h"
-#include "State.h"
+#include <GL/freeglut.h>
 
-//Prototypes
-void bindFuncOpenGL(void);
-void configureOpenGL(void);
-void loadModels(void);
+#include "CrystalJohan.h"
+#include <stdio.h>
+#include "vector.h"
 
-static int Width;
-static int Height;
+CrystalJohan* app;
 
-float lastFrameTime = 0;
-bool keys[255];
-
-//vector<Model*> models;
-//int currentModel = 0;
-
-
-StateHandler *statehandler;
-
-void display()
-{
-	glClearColor(0.6f, 0.6f, 1, 1);
-	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
-
-	glMatrixMode(GL_PROJECTION);
-	glLoadIdentity();
-	gluPerspective(60.0f, (float)Width / Height, 0.5, 300);
-
-	glMatrixMode(GL_MODELVIEW);
-	glLoadIdentity();
-
-	/*glRotatef(player.eyes.rotX, 1, 0, 0);
-	glRotatef(player.eyes.rotY, 0, 1, 0);
-	glTranslatef(player.eyes.posX, player.eyes.posY, player.eyes.posZ);
-
-	glPushMatrix();
-	glScalef(0.5f, 0.5f, 0.5f);
-	glRotatef(180, 1, 0, 0);
-	glRotatef(45, 0, 0, 1);
-	glRotatef(90, 0, 1, 0);
-	models[currentModel]->draw();
-	glPopMatrix();*/
-
-	//Draw here	
-
-	statehandler->GetCurrentState()->Display();
-
-	//player->Display();
-	
-	//glutSolidCube(10.0);
-
-	glDisable(GL_TEXTURE_2D);
-	glutSwapBuffers();
-}
-
-
-
-void idle()
-{
-	float frameTime = glutGet(GLUT_ELAPSED_TIME) / 1000.0f;
-	float deltaTime = frameTime - lastFrameTime;
-	lastFrameTime = frameTime;
-
-	statehandler->GetCurrentState()->Keyboard(keys,deltaTime);
-	statehandler->GetCurrentState()->Idle(deltaTime);
-
-	glutPostRedisplay();
-}
-
-void mousemotion(int x, int y)
-{
-	int dx = x - Width / 2;
-	int dy = y - Height / 2;
-	if ((dx != 0 || dy != 0) && abs(dx) < 400 && abs(dy) < 400)
-	{
-		statehandler->GetCurrentState()->MouseMove(x, y, dx, dy);
-		glutWarpPointer(Width / 2, Height / 2);
-	}
-}
-
-void mouse(int button, int type, int x, int y)
-{
-	statehandler->GetCurrentState()->MouseClick(button, type, x, y);
-}
-
-void keyboard(unsigned char key, int, int)
-{
-	if (key == 27)
-		exit(0);	
-	//std::cout << key << std::endl;
-	keys[key] = true;
-}
-
-void keyboardup(unsigned char key, int, int)
-{
-	keys[key] = false;
-}
+bool justMoved = false;
 
 int main(int argc, char* argv[])
 {
-	//Init GLUT
+	app = new CrystalJohan();
 	glutInit(&argc, argv);
-
-	//Configre OpenGL and FreeGLut
-	configureOpenGL();
-
-	//Bind functions
-	bindFuncOpenGL();
-
-	//Init models
-	loadModels();
-
-	//Start the main loop
-	glutMainLoop();
-	return 0;
-}
-
-void bindFuncOpenGL()
-{
-	glutDisplayFunc(display);
-	glutIdleFunc(idle);
-	glutReshapeFunc([](int w, int h) { Width = w; Height= h; glViewport(0, 0, w, h); });
-
-	//Keyboard
-	glutKeyboardFunc(keyboard);
-	glutKeyboardUpFunc(keyboardup);
-
-	//Mouse
-	glutMouseFunc(mouse);
-	glutPassiveMotionFunc(mousemotion);
-	
-}
-
-void configureOpenGL()
-{
 	//Init window and glut display mode
 	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
 	glutInitWindowSize(800, 600);
@@ -144,44 +19,37 @@ void configureOpenGL()
 	glutFullScreen();
 	//glutPositionWindow((glutGet(GLUT_SCREEN_WIDTH) / 2) - (glutGet(GLUT_WINDOW_WIDTH) / 2), (glutGet(GLUT_SCREEN_HEIGHT) / 2) - (glutGet(GLUT_WINDOW_HEIGHT) / 2));
 
-	//Depth testing
-	glEnable(GL_DEPTH_TEST);
+	app->init();
 
-	//Alpha blending
-	glEnable(GL_BLEND);
-	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-	
-	//Alpha testing
-	glEnable(GL_ALPHA_TEST);
-	glAlphaFunc(GL_GREATER, 0.01f);
+	glutDisplayFunc([]() { app->draw(); } );
+	glutIdleFunc([]() { app->update(); } );
+	glutReshapeFunc([](int w, int h) { app->width = w; app->height = h; glViewport(0, 0, w, h); });
 
-	//Lighting
-	GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
-	GLfloat mat_shininess[] = { 20.0 };
-	GLfloat light_position[] = { 30.0, 30.0, 30.0, 1.0 };
-	GLfloat light_diffuse[] = { 2.0, 2.0, 2.0, 1.0 };
-	GLfloat light_ambient[] = { 2.0, 2.0, 2.0, 1.0 };
-	glClearColor(0.0, 0.0, 0.0, 0.0);
-	glShadeModel(GL_SMOOTH);
-
-	glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
-	glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
-	glLightfv(GL_LIGHT0, GL_POSITION, light_position);
-	glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
-	glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
+	//Keyboard
+	glutKeyboardFunc([](unsigned char c, int, int) { app->keyboardState.keys[c] = true; });
+	glutKeyboardUpFunc([](unsigned char c, int, int) { app->keyboardState.keys[c] = false; });
 
-	glEnable(GL_LIGHTING);
-	glEnable(GL_LIGHT0);
+	//Mouse
+//	glutMouseFunc(mouse);
+	glutPassiveMotionFunc([](int x, int y)
+	{
+		if (justMoved)
+		{
+			justMoved = false;
+			return;
+		}
+		int dx = x - app->width / 2;
+		int dy = y - app->height / 2;
+		if ((dx != 0 || dy != 0) && abs(dx) < 400 && abs(dy) < 400)
+		{
+			app->mouseOffset = app->mouseOffset + Vec2f(dx,dy);
+			glutWarpPointer(app->width / 2, app->height / 2);
+			justMoved = true;
+		}
+	});
 
-	//Cursor
-	glutWarpPointer(Width / 2, Height / 2);
-	glutSetCursor(GLUT_CURSOR_CROSSHAIR);
-}
+	glutMainLoop();
 
-void loadModels() 
-{	
-	statehandler = new StateHandler();
 
-	statehandler->Navigate(statehandler->WORLD_STATE);
-	//models.push_back(new Model("models/weapons/ZwaardMetTextures/TextureZwaard.obj"));
+	return 0;
 }

+ 0 - 0
Main.h


+ 0 - 12
MenuState.cpp

@@ -1,12 +0,0 @@
-#include "MenuState.h"
-
-
-
-MenuState::MenuState()
-{
-}
-
-
-MenuState::~MenuState()
-{
-}

+ 0 - 10
MenuState.h

@@ -1,10 +0,0 @@
-#pragma once
-#include "Header.h"
-#include "State.h"
-
-class MenuState : public State
-{
-public:
-	MenuState();
-	~MenuState();
-};

+ 43 - 36
Model.cpp

@@ -3,12 +3,17 @@
 #define STB_IMAGE_IMPLEMENTATION
 #include "stb_image.h"
 
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <algorithm>
+
 //Prototypes
-vector<string> split(string str, string sep);
-string replace(string str, string toReplace, string replacement);
-string toLower(string data);
+std::vector<std::string> split(std::string str, std::string sep);
+std::string replace(std::string str, std::string toReplace, std::string replacement);
+std::string toLower(std::string data);
 
-Model::Model(string fileName)
+Model::Model(std::string fileName)
 {
 	std::string dirName = fileName;
 	if (dirName.rfind("/") != std::string::npos)
@@ -117,20 +122,11 @@ Model::Model(string fileName)
 	groups.push_back(currentGroup);
 }
 
-Model::Model(void)
-{
-	Model("models/TextureZwaard.obj");
-}
 
 Model::~Model(void)
 {
 }
 
-void Model::AddInstance(ModelInstance* inst)
-{
-	instances.push_back(inst);
-}
-
 void Model::draw()
 {
 	for (auto &g : groups)
@@ -163,30 +159,18 @@ void Model::draw()
 			}
 		}
 
-		for (auto &instance : instances)
+		glBegin(GL_TRIANGLES);
+		for (auto &f : g->faces)
 		{
-
-			glBegin(GL_TRIANGLES);
-			for (auto &f : g->faces)
+			for (auto &v : f.vertices)
 			{
-				for (auto &v : f.vertices)
-				{
-					glPushMatrix();
-
-					glTranslatef(instance->translation.x, instance->translation.y, instance->translation.z);
-					glRotatef(instance->rotation.x, 1, 0, 0);
-					glRotatef(instance->rotation.y, 0, 1, 0);
-					glRotatef(instance->rotation.z, 0, 0, 1);
-					glScalef(instance->scale.x, instance->scale.y, instance->scale.z);
-
-					glNormal3f(normals[v.normal].x, normals[v.normal].y, normals[v.normal].z);
-					glTexCoord2f(texcoords[v.texcoord].x, texcoords[v.texcoord].y);
-					glVertex3f(vertices[v.position].x, vertices[v.position].y, vertices[v.position].z);
-				}
+				glNormal3f(normals[v.normal].x, normals[v.normal].y, normals[v.normal].z);
+				glTexCoord2f(texcoords[v.texcoord].x, texcoords[v.texcoord].y);
+				glVertex3f(vertices[v.position].x, vertices[v.position].y, vertices[v.position].z);
 			}
-			glEnd();
-
 		}
+		glEnd();
+
 	}
 }
 
@@ -295,7 +279,7 @@ void Model::Texture::bind()
 	glBindTexture(GL_TEXTURE_2D, index);
 }
 
-string replace(string str, string toReplace, string replacement)
+std::string replace(std::string str, std::string toReplace, std::string replacement)
 {
 	size_t index = 0;
 	while (true)
@@ -309,7 +293,7 @@ string replace(string str, string toReplace, string replacement)
 	return str;
 }
 
-vector<string> split(string str, string sep)
+std::vector<std::string> split(std::string str, std::string sep)
 {
 	std::vector<std::string> ret;
 	size_t index;
@@ -325,8 +309,31 @@ vector<string> split(string str, string sep)
 	return ret;
 }
 
-inline string toLower(string data)
+inline std::string toLower(std::string data)
 {
 	std::transform(data.begin(), data.end(), data.begin(), ::tolower);
 	return data;
 }
+
+
+
+std::map<std::string, std::pair<Model*, int>> Model::cache;
+
+Model* Model::load(const std::string &fileName)
+{
+	if (cache.find(fileName) == cache.end())
+		cache[fileName] = std::pair<Model*, int>(new Model(fileName), 0);
+	cache[fileName].second++;
+	return cache[fileName].first;
+}
+
+void Model::unload(const std::string & fileName)
+{
+	assert(cache.find(fileName) != cache.end());
+	cache[fileName].second--;
+	if (cache[fileName].second == 0)
+	{
+		delete cache[fileName].first;
+		cache.erase(cache.find(fileName));
+	}
+}

+ 14 - 9
Model.h

@@ -1,6 +1,10 @@
 #pragma once
-#include "Header.h"
-#include "ModelInstance.h"
+
+#include <GL/freeglut.h>
+#include <list>
+#include <vector>
+#include <map>
+#include "vector.h"
 
 class Model
 {
@@ -16,7 +20,7 @@ private:
 	class Face
 	{
 	public:
-		list<Vertex> vertices;
+		std::list<Vertex> vertices;
 	};
 
 	class Texture
@@ -49,7 +53,7 @@ private:
 	public:
 		std::string name;
 		int materialIndex;
-		list<Face> faces;
+		std::list<Face> faces;
 	};
 
 	std::vector<Vec3f>	vertices;
@@ -58,15 +62,16 @@ private:
 	std::vector<ObjGroup*> groups;
 	std::vector<MaterialInfo*> materials;
 
-	std::vector<ModelInstance*> instances;
-
 	void loadMaterialFile(std::string fileName, std::string dirName);
-public:
+
 	Model(std::string filename);
-	Model(void);
 	~Model(void);
 
-	void AddInstance(ModelInstance* inst);
+public:
+
+	static std::map<std::string, std::pair<Model*, int> > cache;
+	static Model* load(const std::string &fileName);
+	static void unload(const std::string &fileName);
 
 	void draw();
 };

+ 0 - 12
ModelHandler.cpp

@@ -1,12 +0,0 @@
-#include "ModelHandler.h"
-
-
-
-ModelHandler::ModelHandler()
-{
-}
-
-
-ModelHandler::~ModelHandler()
-{
-}

+ 0 - 8
ModelHandler.h

@@ -1,8 +0,0 @@
-#pragma once
-class ModelHandler
-{
-public:
-	ModelHandler();
-	~ModelHandler();
-};
-

+ 0 - 10
ModelInstance.cpp

@@ -1,10 +0,0 @@
-#include "ModelInstance.h"
-
-ModelInstance::ModelInstance()
-{
-}
-
-
-ModelInstance::~ModelInstance()
-{
-}

+ 0 - 16
ModelInstance.h

@@ -1,16 +0,0 @@
-#pragma once
-#include "Header.h"
-
-class ModelInstance
-{
-private:
-public:
-	ModelInstance();
-	~ModelInstance();
-
-	Vec3f translation;
-	Vec3f rotation;
-	Vec3f scale;
-
-};
-

+ 0 - 12
Mouse.cpp

@@ -1,12 +0,0 @@
-#include "Mouse.h"
-
-
-
-Mouse::Mouse()
-{
-}
-
-
-Mouse::~Mouse()
-{
-}

+ 0 - 10
Mouse.h

@@ -1,10 +0,0 @@
-#pragma once
-#include "Header.h"
-
-class Mouse
-{
-public:
-	Mouse();
-	~Mouse();
-};
-

+ 5 - 67
Player.cpp

@@ -1,77 +1,15 @@
 #include "Player.h"
+#include <GL/freeglut.h>
 
 Player::Player()
 {
-	
-}
-
-
-Player::~Player()
-{
-	if(right != nullptr)
-		delete right;
-	if(left != nullptr)
-		delete left;
-	/*if (player != nullptr)
-		delete player;*/
-}
-
-void Player::Display(void)
-{
-	if (right != nullptr)
-	{			
-		right->draw_weapon();		
-	}
-		
-	if (left != nullptr)
-	{		
-		left->draw_weapon();		
-	}
 
-	/*glRotatef(player->eyes.rotX, 1, 0, 0);
-	glRotatef(player->eyes.rotY, 0, 1, 0);
-	glTranslatef(player->eyes.posX, player->eyes.posY, player->eyes.posZ);*/
-	glRotatef(eyes.rotX, 1, 0, 0);
-	glRotatef(eyes.rotY, 0, 1, 0);
-	glTranslatef(eyes.posX, eyes.posY, eyes.posZ);
 }
 
-Player & Player::GetInstance(void)
+void Player::setCamera()
 {
-	static Player instance;
-	return instance;
-}
-
-//Player * Player::GetInstance(void)
-//{
-//	if (player == nullptr)
-//		player = new Player();
-//	return player;
-//}
+	glRotatef(rotation.x, 1, 0, 0);
+	glRotatef(rotation.y, 0, 1, 0);
+	glTranslatef(-position.x, -position.y, -position.z);
 
-void Player::PlayerMoveEyes(float angle, float fac, bool heigth)
-{
-	//player movement
-	
-	/*if (heigth)
-		player->eyes.posY += angle*fac;
-	else
-	{
-		player->eyes.posX += (float)cos((player->eyes.rotY + angle) / 180 * M_PI) * fac;
-		player->eyes.posZ += (float)sin((player->eyes.rotY + angle) / 180 * M_PI) * fac;
-	}*/
-	if (heigth)
-		eyes.posY += angle*fac;
-	else
-	{
-		eyes.posX += (float)cos((eyes.rotY + angle) / 180 * M_PI) * fac;
-		eyes.posZ += (float)sin((eyes.rotY + angle) / 180 * M_PI) * fac;
-	}
 }
-
-void Player::PlayerRotateEyes(int dx, int dy)
-{
-	eyes.rotY += dx / 10.0f;
-	eyes.rotX += dy / 10.0f;
-}
-

+ 13 - 30
Player.h

@@ -1,38 +1,21 @@
 #pragma once
-#include "Header.h"
-#include "Weapon.h"
 
-class Player
-{
-public:
-	~Player();
+#include "Singleton.h"
 
-	struct Eyes
-	{
-		float posX = 0;
-		float posY = 0;
-		float posZ = 0;
-		float rotX = 0;
-		float rotY = 0;
-	} eyes;	
+#include "vector.h"
 
-	void Display(void);
-	//static Player* GetInstance(void);
-	static Player& GetInstance(void);
-	
+class Model;
 
-	void PlayerMoveEyes(const float angle, const float fac, const bool heigth);
-	void PlayerRotateEyes(const int dx, const int dy);
-private:
-	int level;
-	int xp;
-	Weapon* right = nullptr;
-	Weapon* left = nullptr;
-	vector<Weapon> weapons;
+class Player : public Singleton<Player>
+{
+public:
 	Player();
-	Player(Player const&);
-	void operator=(Player const&);
 
-	//static Player* player;
-};
+	void setCamera();
+
+	Vec3f position;
+	Vec2f rotation;
 
+	Model* leftWeapon;
+	Model* rightWeapon;
+};

+ 0 - 2
README.md

@@ -1,2 +0,0 @@
-# CrystalPoint
-Crystal Point: The Elemental Labyrinth

+ 40 - 0
ReadMe.txt

@@ -0,0 +1,40 @@
+========================================================================
+    CONSOLE APPLICATION : CrystalJohan Project Overview
+========================================================================
+
+AppWizard has created this CrystalJohan application for you.
+
+This file contains a summary of what you will find in each of the files that
+make up your CrystalJohan application.
+
+
+CrystalJohan.vcxproj
+    This is the main project file for VC++ projects generated using an Application Wizard.
+    It contains information about the version of Visual C++ that generated the file, and
+    information about the platforms, configurations, and project features selected with the
+    Application Wizard.
+
+CrystalJohan.vcxproj.filters
+    This is the filters file for VC++ projects generated using an Application Wizard. 
+    It contains information about the association between the files in your project 
+    and the filters. This association is used in the IDE to show grouping of files with
+    similar extensions under a specific node (for e.g. ".cpp" files are associated with the
+    "Source Files" filter).
+
+CrystalJohan.cpp
+    This is the main application source file.
+
+/////////////////////////////////////////////////////////////////////////////
+Other standard files:
+
+StdAfx.h, StdAfx.cpp
+    These files are used to build a precompiled header (PCH) file
+    named CrystalJohan.pch and a precompiled types file named StdAfx.obj.
+
+/////////////////////////////////////////////////////////////////////////////
+Other notes:
+
+AppWizard uses "TODO:" comments to indicate parts of the source code you
+should add to or customize.
+
+/////////////////////////////////////////////////////////////////////////////

+ 0 - 12
SettingsState.cpp

@@ -1,12 +0,0 @@
-#include "SettingsState.h"
-
-
-
-SettingsState::SettingsState()
-{
-}
-
-
-SettingsState::~SettingsState()
-{
-}

+ 0 - 11
SettingsState.h

@@ -1,11 +0,0 @@
-#pragma once
-#include "Header.h"
-#include "State.h"
-
-class SettingsState : public State
-{
-public:
-	SettingsState();
-	~SettingsState();
-};
-

+ 13 - 0
Singleton.h

@@ -0,0 +1,13 @@
+#pragma once
+
+
+template <class T>
+class Singleton
+{
+public:
+	static T& getInstance()
+	{
+		static T* t = new T();
+		return *t;
+	}
+};

+ 0 - 40
State.cpp

@@ -1,40 +0,0 @@
-#include "State.h"
-
-
-
-State::State()
-{
-}
-
-
-State::~State()
-{
-}
-
-void State::Entry()
-{
-}
-
-void State::Exit()
-{
-}
-
-void State::Idle(float delta)
-{
-}
-
-void State::Display()
-{
-}
-
-void State::Keyboard(bool keys[255],float deltaTime)
-{
-}
-
-void State::MouseMove(int x, int y, int dx, int dy)
-{
-}
-
-void State::MouseClick(int button, int type, int x, int y)
-{
-}

+ 0 - 26
State.h

@@ -1,26 +0,0 @@
-#pragma once
-#include "Header.h"
-
-class State
-{
-public:
-	State();
-	~State();
-
-	virtual void Entry();
-	virtual void Exit();
-
-	virtual void Idle(float delta);
-	virtual void Display();
-
-	virtual void Keyboard(bool keys[255],float deltaTime);
-	virtual void MouseMove(int x, int y, int dx, int dy);
-	virtual void MouseClick(int button, int type, int x, int y);
-};
-
-#include "InitState.h"
-#include "LoadingState.h"
-#include "MenuState.h"
-#include "SettingsState.h"
-#include "WorldState.h"
-

+ 0 - 33
StateHandler.cpp

@@ -1,33 +0,0 @@
-#include "StateHandler.h"
-
-StateHandler::StateHandler()
-{
-	StateList.push_back(new InitState()); //INIT_STATE
-	StateList.push_back(new LoadingState()); //LOADING_STATE
-	StateList.push_back(new MenuState()); //MENU_STATE
-	StateList.push_back(new SettingsState()); //SETTINGS_STATE
-	StateList.push_back(new WorldState()); //WORLD_STATE
-
-	//CurrentState = INIT_STATE;
-	CurrentState = WORLD_STATE;
-}
-
-
-StateHandler::~StateHandler()
-{
-}
-
-void StateHandler::Navigate(EState state)
-{
-	if (CurrentState == state)
-		return;
-
-	StateList.at(CurrentState)->Exit();
-	CurrentState = state;
-	StateList.at(CurrentState)->Entry();
-}
-
-State* StateHandler::GetCurrentState()
-{
-	return StateList.at(CurrentState);
-}

+ 0 - 19
StateHandler.h

@@ -1,19 +0,0 @@
-#pragma once
-#include "Header.h"
-#include "State.h"
-
-class StateHandler
-{
-public:
-	enum EState { INIT_STATE = 0, LOADING_STATE = 1, MENU_STATE = 2, SETTINGS_STATE = 3, WORLD_STATE = 4 };
-
-	StateHandler();
-	~StateHandler();
-
-	void Navigate(EState state);
-	State* GetCurrentState();
-private:
-	EState CurrentState;
-	vector<State*> StateList;
-};
-

+ 5 - 0
Vector.cpp

@@ -46,3 +46,8 @@ float& Vec2f::operator [](int index)
 {
 	return v[index];
 }
+
+Vec2f Vec2f::operator+(const Vec2f & other)
+{
+	return Vec2f(x + other.x, y+other.y);
+}

+ 1 - 1
Vector.h

@@ -1,5 +1,4 @@
 #pragma once
-#include "Header.h"
 
 class Vec3f
 {
@@ -33,5 +32,6 @@ public:
 	Vec2f(float x, float y);
 	Vec2f(Vec2f &other);
 	float& operator [](int);
+	Vec2f operator + (const Vec2f &other);
 };
 

+ 0 - 28
Weapon.cpp

@@ -1,28 +0,0 @@
-#include "Weapon.h"
-
-Weapon::Weapon(const string &filename)
-{
-	weaponModel = new Model(filename);
-}
-
-Weapon::Weapon()
-{
-
-}
-
-Weapon::~Weapon()
-{
-}
-
-void Weapon::draw_weapon(void)
-{
-	
-	if (weaponModel != nullptr)
-	{				
-		glScalef(scale,scale,scale);
-		glRotatef(135, 1, 0, 0);
-		weaponModel->draw();		
-	}		
-}
-
-

+ 0 - 16
Weapon.h

@@ -1,16 +0,0 @@
-#pragma once
-#include "Header.h"
-#include "Model.h"
-
-class Weapon
-{
-public:	
-	Weapon(const string &filename);
-	Weapon();
-	~Weapon();
-	void draw_weapon(void);
-private:
-	Model *weaponModel = nullptr;
-	float scale = 0.5f;	
-};
-

+ 40 - 0
World.cpp

@@ -0,0 +1,40 @@
+#include "World.h"
+#include <GL/freeglut.h>
+#include "Entity.h"
+
+World::World() : player(Player::getInstance())
+{
+	player.position.y = 1.7;
+
+	//entities.push_back(new LevelObject("tree"));
+}
+
+
+World::~World()
+{
+}
+
+void World::draw()
+{
+	player.setCamera();
+
+
+	glColor3f(0.5f, 0.9f, 0.5f);
+	glBegin(GL_QUADS);
+	glVertex3f(-50, 0, -50);
+	glVertex3f(-50, 0, 50);
+	glVertex3f(50, 0, 50);
+	glVertex3f(50, 0, -50);
+	glEnd();
+
+	for (auto e : entities)
+		e->draw();
+
+	glutSwapBuffers();
+}
+
+void World::update(float elapsedTime)
+{
+	for (auto e : entities)
+		e->update(elapsedTime);
+}

+ 22 - 0
World.h

@@ -0,0 +1,22 @@
+#pragma once
+
+#include <vector>
+#include "Player.h"
+
+class Entity;
+
+class World
+{
+public:
+	World();
+	~World();
+
+
+	Player& player;
+	std::vector<Entity*> entities;
+
+	void draw();
+	void update(float elapsedTime);
+
+};
+

+ 0 - 12
WorldModel.cpp

@@ -1,12 +0,0 @@
-#include "WorldModel.h"
-
-
-
-WorldModel::WorldModel()
-{
-}
-
-
-WorldModel::~WorldModel()
-{
-}

+ 0 - 10
WorldModel.h

@@ -1,10 +0,0 @@
-#pragma once
-#include "Header.h"
-
-class WorldModel
-{
-public:
-	WorldModel();
-	~WorldModel();
-};
-

+ 0 - 49
WorldState.cpp

@@ -1,49 +0,0 @@
-#include "WorldState.h"
-#include "Player.h"
-
-
-
-WorldState::WorldState()
-{
-	/*player = Player::GetInstance();*/
-}
-
-
-WorldState::~WorldState()
-{
-	//if (player != nullptr)
-		//delete player;
-}
-
-void WorldState::Keyboard(bool keys[255],float deltaTime)
-{
-	float speed = 10;
-	std::cout << "Keyboard doet het in de world state" << std::endl;
-	/*if (keys['a']) player->PlayerMoveEyes(0, deltaTime*speed, false);
-	if (keys['d']) player->PlayerMoveEyes(180, deltaTime*speed, false);
-	if (keys['w']) player->PlayerMoveEyes(90, deltaTime*speed, false);
-	if (keys['s']) player->PlayerMoveEyes(270, deltaTime*speed, false);
-	if (keys['q']) player->PlayerMoveEyes(1, deltaTime*speed, true);
-	if (keys['e']) player->PlayerMoveEyes(-1, deltaTime*speed, true);	*/
-
-	if (keys['a']) Player::GetInstance().PlayerMoveEyes(0, deltaTime*speed, false);
-	if (keys['d']) Player::GetInstance().PlayerMoveEyes(180, deltaTime*speed, false);
-	if (keys['w']) Player::GetInstance().PlayerMoveEyes(90, deltaTime*speed, false);
-	if (keys['s']) Player::GetInstance().PlayerMoveEyes(270, deltaTime*speed, false);
-	if (keys['q']) Player::GetInstance().PlayerMoveEyes(1, deltaTime*speed, true);
-	if (keys['e']) Player::GetInstance().PlayerMoveEyes(-1, deltaTime*speed, true);	
-}
-
-void WorldState::MouseMove(int x, int y, int dx, int dy)
-{
-	//player->PlayerRotateEyes(dx, dy);
-	Player::GetInstance().PlayerRotateEyes(dx, dy);
-}
-
-void WorldState::Display()
-{
-	Player::GetInstance().Display();
-
-	glutSolidCube(10.0);
-}
-

+ 0 - 18
WorldState.h

@@ -1,18 +0,0 @@
-#pragma once
-#include "Header.h"
-#include "State.h"
-#include "Player.h"
-
-class WorldState : public State
-{
-public:
-	WorldState();
-	~WorldState();
-
-	void Keyboard(bool keys[255],float deltaTime);
-	void MouseMove(int x, int y, int dx, int dy);
-	void Display();
-private:
-	//Player* player;
-};
-

BIN
freeglut/bin/freeglut.dll


BIN
freeglut/bin/x64/freeglut.dll


BIN
freeglut/lib/x64/freeglut.lib