Commit 52dfff70af9540137cde1aae73abbbe0597534fc

Authored by Olav Kjartan Larseng
1 parent ab49d95f

added models, textures is still not working

Showing 40 changed files with 5552 additions and 11 deletions   Show diff stats
SpaceShooterV4/SpaceShooterV4.vcxproj
... ... @@ -162,9 +162,11 @@
162 162 <ClInclude Include="include\Spotlight.h" />
163 163 <ClInclude Include="include\Text.h" />
164 164 <ClInclude Include="include\Water.hpp" />
  165 + <ClInclude Include="SpaceshipModelTest.h" />
165 166 </ItemGroup>
166 167 <ItemGroup>
167 168 <ClCompile Include="app\main.cpp" />
  169 + <ClCompile Include="SpaceshipModelTest.cpp" />
168 170 <ClCompile Include="src\BattleField.cpp" />
169 171 <ClCompile Include="src\Bullet.cpp" />
170 172 <ClCompile Include="src\Camera.cpp" />
... ... @@ -188,6 +190,8 @@
188 190 <None Include="assets\shaders\red.vert" />
189 191 <None Include="assets\shaders\skybox.frag" />
190 192 <None Include="assets\shaders\skybox.vert" />
  193 + <None Include="assets\shaders\spaceship.frag" />
  194 + <None Include="assets\shaders\spaceship.vert" />
191 195 <None Include="assets\shaders\terrain.frag" />
192 196 <None Include="assets\shaders\terrain.vert" />
193 197 <None Include="assets\shaders\water.frag" />
... ...
SpaceShooterV4/SpaceShooterV4.vcxproj.filters
... ... @@ -68,6 +68,9 @@
68 68 <ClInclude Include="include\Water.hpp">
69 69 <Filter>Header Files</Filter>
70 70 </ClInclude>
  71 + <ClInclude Include="SpaceshipModelTest.h">
  72 + <Filter>Header Files</Filter>
  73 + </ClInclude>
71 74 </ItemGroup>
72 75 <ItemGroup>
73 76 <ClCompile Include="app\main.cpp">
... ... @@ -112,6 +115,9 @@
112 115 <ClCompile Include="src\Water.cpp">
113 116 <Filter>Source Files</Filter>
114 117 </ClCompile>
  118 + <ClCompile Include="SpaceshipModelTest.cpp">
  119 + <Filter>Source Files</Filter>
  120 + </ClCompile>
115 121 </ItemGroup>
116 122 <ItemGroup>
117 123 <None Include="assets\shaders\chess.frag">
... ... @@ -150,5 +156,11 @@
150 156 <None Include="assets\shaders\water.vert">
151 157 <Filter>Shaders</Filter>
152 158 </None>
  159 + <None Include="assets\shaders\spaceship.frag">
  160 + <Filter>Shaders</Filter>
  161 + </None>
  162 + <None Include="assets\shaders\spaceship.vert">
  163 + <Filter>Shaders</Filter>
  164 + </None>
153 165 </ItemGroup>
154 166 </Project>
155 167 \ No newline at end of file
... ...
SpaceShooterV4/SpaceshipModelTest.cpp 0 → 100644
  1 +#include "SpaceshipModelTest.h"
  2 +#include "include/OBJ_Loader.h"
  3 +
  4 +SpaceshipModelTest::SpaceshipModelTest()
  5 +{
  6 +
  7 +
  8 +}
  9 +
  10 +SpaceshipModelTest::~SpaceshipModelTest()
  11 +{
  12 +}
  13 +
  14 +void SpaceshipModelTest::privateInit()
  15 +{
  16 + spaceshipShader.initShaders("assets/shaders/spaceship");
  17 +
  18 + _texture = SOIL_load_OGL_texture
  19 + (
  20 + "assets/models/SS1_OBJ/HULL.jpg",
  21 + SOIL_LOAD_AUTO,
  22 + SOIL_CREATE_NEW_ID,
  23 + SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
  24 + );
  25 +
  26 + if (0 == _texture)
  27 + {
  28 + printf("SOIL loading error: '%s'\n", SOIL_last_result());
  29 + }
  30 +
  31 +
  32 + objl::Loader Loader;
  33 + bool loadout = Loader.LoadFile("assets/models/SS1_OBJ/SS1.obj");
  34 +
  35 + if (loadout)
  36 + {
  37 + for (int i = 0; i < Loader.LoadedMeshes.size(); i++)
  38 + {
  39 + objl::Mesh curMesh = Loader.LoadedMeshes[i];
  40 + for (int j = 0; j < curMesh.Vertices.size(); j++)
  41 + {
  42 + _VERT.push_back(glm::vec3(curMesh.Vertices[j].Position.X, curMesh.Vertices[j].Position.Y, curMesh.Vertices[j].Position.Z));
  43 + _NORM.push_back(glm::vec3(curMesh.Vertices[j].Normal.X, curMesh.Vertices[j].Normal.Y, curMesh.Vertices[j].Normal.Z));
  44 + _TEXC.push_back(glm::vec2(curMesh.Vertices[j].TextureCoordinate.X, curMesh.Vertices[j].TextureCoordinate.Y));
  45 + }
  46 +
  47 + for (int j = 0; j < curMesh.Indices.size(); j += 3)
  48 + {
  49 + _INDI.push_back(curMesh.Indices[j]);
  50 + _INDI.push_back(curMesh.Indices[j+1]);
  51 + _INDI.push_back(curMesh.Indices[j+2]);
  52 + }
  53 +
  54 + }
  55 + } else {
  56 + std::cout << "Could not load file!" << std::endl;
  57 + }
  58 +
  59 + spaceshipShader.enable();
  60 + _texColormapSampler = glGetUniformLocation(spaceshipShader.getProg(), "tex_colormap");
  61 + glUniform1i(_texColormapSampler, 0);
  62 + spaceshipShader.disable();
  63 +
  64 +}
  65 +
  66 +void SpaceshipModelTest::privateRender()
  67 +{
  68 + spaceshipShader.enable();
  69 +
  70 + glDisable(GL_COLOR_MATERIAL);
  71 +
  72 + //glColor4f(1, 1, 1, 1);
  73 +
  74 + glActiveTexture(GL_TEXTURE0);
  75 + glEnable(GL_TEXTURE_2D);
  76 + glBindTexture(GL_TEXTURE_2D, _texture);
  77 +
  78 + glEnableClientState(GL_VERTEX_ARRAY);
  79 + glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  80 +
  81 + glEnable(GL_PRIMITIVE_RESTART);
  82 +
  83 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  84 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  85 + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
  86 + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  87 +
  88 + glVertexPointer(3, GL_FLOAT, 0, &_VERT[0]);
  89 + glTexCoordPointer(2, GL_FLOAT, 0, &_TEXC[0]);
  90 +
  91 +
  92 + glDrawElements(GL_TRIANGLES,
  93 + _INDI.size(),
  94 + GL_UNSIGNED_INT,
  95 + &_INDI[0]);
  96 +
  97 + glDisable(GL_PRIMITIVE_RESTART);
  98 +
  99 + glClearColor(0.0, 0.0, 0.0, 0.0);
  100 +
  101 + glActiveTexture(GL_TEXTURE0);
  102 + glDisable(GL_TEXTURE_2D);
  103 + glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  104 + glDisableClientState(GL_VERTEX_ARRAY);
  105 + spaceshipShader.disable();
  106 +}
  107 +
  108 +void SpaceshipModelTest::privateUpdate()
  109 +{
  110 +}
  111 +
  112 +bool SpaceshipModelTest::markedForDeletion()
  113 +{
  114 + return _markDelete;
  115 +}
... ...
SpaceShooterV4/SpaceshipModelTest.h 0 → 100644
  1 +#pragma once
  2 +
  3 +#include <GL/glew.h>
  4 +#include <windows.h>
  5 +#include <GL/gl.h>
  6 +#include <GL/glu.h>
  7 +#include "include/SceneObject.hpp"
  8 +#include "include/Shader.hpp"
  9 +#include "include\soil\SOIL.h"
  10 +#include "include/glm/gtc/matrix_transform.hpp"
  11 +
  12 +
  13 +class SpaceshipModelTest : public SceneObject
  14 +{
  15 +public:
  16 +
  17 + SpaceshipModelTest();
  18 + ~SpaceshipModelTest();
  19 +
  20 + bool markedForDeletion();
  21 +
  22 +
  23 +private:
  24 + void privateInit();
  25 + void privateRender();
  26 + void privateUpdate();
  27 +
  28 + bool _markDelete = false;
  29 +
  30 + GLuint _texture;
  31 + GLint _texColormapSampler;
  32 +
  33 + /*
  34 + std::vector<glm::vec3> vertices;
  35 + std::vector<glm::vec3> normal;
  36 + std::vector<glm::vec2> texCoords;
  37 + std::vector<glm::uint> indices;
  38 + */
  39 + std::vector<glm::vec3> _VERT;
  40 + std::vector<glm::vec3> _NORM;
  41 + std::vector<glm::vec2> _TEXC;
  42 + std::vector<glm::uint> _INDI;
  43 +
  44 + Shader spaceshipShader;
  45 +
  46 +};
  47 +
... ...
SpaceShooterV4/assets/models/SS1_OBJ/HULL-I.jpg 0 → 100644

51.6 KB

SpaceShooterV4/assets/models/SS1_OBJ/HULL-N.jpg 0 → 100644