Compare commits
15 Commits
dcac2713f6
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e7a73f9b6 | |||
| 45d324a9ec | |||
| 7342507fe8 | |||
| cec9ecb561 | |||
| afc842baae | |||
| 7fa3d76fe1 | |||
| 3de9e9af4b | |||
| 9eeb2f89b2 | |||
| 76e38e0606 | |||
| 190e2c7445 | |||
| 6aa1dec552 | |||
| 76c7e1808c | |||
| 1215e7d8a5 | |||
| c3fa504c29 | |||
| 4efefa976a |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
bin
|
|
||||||
obj
|
|
||||||
7
Camera.cpp
Normal file
7
Camera.cpp
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#include "include/Camera.h"
|
||||||
|
|
||||||
|
const glm::mat4& Camera::get_view()
|
||||||
|
{
|
||||||
|
const glm::mat4& matrix = glm::lookAt(glm::vec3(0, 10, 0), glm::vec3(0, 1, 0), glm::vec3(0, 1, 0));
|
||||||
|
return matrix;
|
||||||
|
}
|
||||||
102
GUI.cpp
102
GUI.cpp
@@ -1,51 +1,51 @@
|
|||||||
#include "GUI.h"
|
#include "GUI.h"
|
||||||
|
|
||||||
// Code contributed by Kacperks
|
// Code contributed by Kacperks
|
||||||
// COMMENTED OUT BECAUSE IT DOESN'T WORK!
|
// COMMENTED OUT BECAUSE IT DOESN'T WORK!
|
||||||
/*
|
/*
|
||||||
Button::Button(sf::Image* normal, sf::Image* clicked, std::string words, Position2D location) {
|
Button::Button(sf::Image* normal, sf::Image* clicked, std::string words, Position2D location) {
|
||||||
this->normal.SetImage(*normal);
|
this->normal.SetImage(*normal);
|
||||||
this->clicked.SetImage(*clicked);
|
this->clicked.SetImage(*clicked);
|
||||||
this->currentSpr=&this->normal;
|
this->currentSpr=&this->normal;
|
||||||
current =false;
|
current =false;
|
||||||
this->normal.SetPosition(location);
|
this->normal.SetPosition(location);
|
||||||
this->clicked.SetPosition(location);
|
this->clicked.SetPosition(location);
|
||||||
String.SetText(words);
|
String.SetText(words);
|
||||||
String.SetPosition(location.x+3,location.y+3);
|
String.SetPosition(location.x+3,location.y+3);
|
||||||
String.SetSize(14);
|
String.SetSize(14);
|
||||||
}
|
}
|
||||||
void Button::checkClick (sf::Vector2f mousePos)
|
void Button::checkClick (sf::Vector2f mousePos)
|
||||||
{
|
{
|
||||||
if (mousePos.x>currentSpr->GetPosition().x && mousePos.x<(currentSpr->GetPosition().x + currentSpr->GetSize().x)) {
|
if (mousePos.x>currentSpr->GetPosition().x && mousePos.x<(currentSpr->GetPosition().x + currentSpr->GetSize().x)) {
|
||||||
if(mousePos.y>currentSpr->GetPosition().y && mousePos.y<(currentSpr->GetPosition().y + currentSpr->GetSize().y)) {
|
if(mousePos.y>currentSpr->GetPosition().y && mousePos.y<(currentSpr->GetPosition().y + currentSpr->GetSize().y)) {
|
||||||
setState(!current);
|
setState(!current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::setState(bool which)
|
void Button::setState(bool which)
|
||||||
{
|
{
|
||||||
current = which;
|
current = which;
|
||||||
if (current) {
|
if (current) {
|
||||||
currentSpr=&clicked;
|
currentSpr=&clicked;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
currentSpr=&normal;
|
currentSpr=&normal;
|
||||||
}
|
}
|
||||||
void Button::setText(std::string words)
|
void Button::setText(std::string words)
|
||||||
{
|
{
|
||||||
String.SetText(words);
|
String.SetText(words);
|
||||||
}
|
}
|
||||||
bool Button::getVar()
|
bool Button::getVar()
|
||||||
{
|
{
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
sf::Sprite* Button::getSprite()
|
sf::Sprite* Button::getSprite()
|
||||||
{
|
{
|
||||||
return currentSpr;
|
return currentSpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::String * Button::getText()
|
sf::String * Button::getText()
|
||||||
{
|
{
|
||||||
return &String;
|
return &String;
|
||||||
}*/
|
}*/
|
||||||
|
|||||||
14
LICENSE.TXT
14
LICENSE.TXT
@@ -1,7 +1,7 @@
|
|||||||
Copyright (c) 2022 MCL and CubeSoftware
|
Copyright (c) 2022-2023 MCL and CubeSoftware
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|||||||
@@ -1,43 +1,139 @@
|
|||||||
#include "LevelGenerator.h"
|
#include "LevelGenerator.h"
|
||||||
|
#include "Base.h"
|
||||||
FastNoiseLite perlin, os, cellular;
|
#include <time.h>
|
||||||
int seed = 138;
|
#include <random>
|
||||||
|
|
||||||
perlin.SetSeed(seed);
|
FastNoiseLite perlin, os, cellular;
|
||||||
perlin.SetNoiseType(FastNoiseLite::NoiseType_Perlin);
|
int seed = 138;
|
||||||
perlin.SetFrequency(.01F);
|
|
||||||
|
|
||||||
os.SetSeed(seed);
|
|
||||||
os.SetNoiseType(FastNoiseLite::NoiseType_OpenSimplex2);
|
LevelGenerator::LevelGenerator()
|
||||||
os.SetFrequency(.01F);
|
{
|
||||||
|
perlin.SetSeed(seed);
|
||||||
cellular.SetSeed(seed);
|
perlin.SetNoiseType(FastNoiseLite::NoiseType_Perlin);
|
||||||
cellular.SetNoiseType(FastNoiseLite::NoiseType_Cellular);
|
perlin.SetFrequency(.01F);
|
||||||
cellular.SetFrequency(.1F);
|
|
||||||
|
os.SetSeed(seed);
|
||||||
LevelGenerator::LevelGenerator()
|
os.SetNoiseType(FastNoiseLite::NoiseType_OpenSimplex2);
|
||||||
{
|
os.SetFrequency(.01F);
|
||||||
|
|
||||||
}
|
cellular.SetSeed(seed);
|
||||||
|
cellular.SetNoiseType(FastNoiseLite::NoiseType_Cellular);
|
||||||
void LevelGenerator::generateBlock()
|
cellular.SetFrequency(.1F);
|
||||||
{
|
}
|
||||||
for(int bx = 0; bx < 8; bx++)
|
|
||||||
{
|
// Change seed midgame - not for production use
|
||||||
for(int bz = 0; bz < 8; bz++)
|
void LevelGenerator::setSeed()
|
||||||
{
|
{
|
||||||
for(int x = 0; x < 16; x++)
|
perlin.SetSeed(time(0));
|
||||||
{
|
os.SetSeed(time(0));
|
||||||
for(int z = 0; z < 16; z++)
|
cellular.SetSeed(time(0));
|
||||||
{
|
}
|
||||||
float cX = (float)x + (16 * bx);
|
|
||||||
float cZ = (float)z + (16 * bz);
|
void LevelGenerator::generateBlock()
|
||||||
for(int y = 0; y < 48 * abs(perlin.GetNoise(cX, cZ)) / 2 + abs(cellular.GetNoise(cX, cZ)) * 2 + abs(os.GetNoise(cX, cZ)) * 4 + 10; y++)
|
{
|
||||||
{
|
for(int x = 0; x < 256; x++)
|
||||||
blockManager.mapBlocks[bx][bz].addNode(y > 20 ? 1 : 2, 0, x, y, z);
|
{
|
||||||
}
|
for(int z = 0; z < 256; z++)
|
||||||
}
|
{
|
||||||
}
|
for(int y = 0; y < 256; y++)
|
||||||
}
|
{
|
||||||
}
|
blockManager.addNode(0, 0, x, y, z);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for(int x = 0; x < 256; x++)
|
||||||
|
{
|
||||||
|
for(int z = 0; z < 256; z++)
|
||||||
|
{
|
||||||
|
float cX = (float)x;
|
||||||
|
float cZ = (float)z;
|
||||||
|
for(int y = 0; y < 48 * abs(perlin.GetNoise(cX, cZ)) / 2 + abs(cellular.GetNoise(cX, cZ)) * 2 + abs(os.GetNoise(cX, cZ)) * 4 + 10; y++)
|
||||||
|
{
|
||||||
|
blockManager.addNode(1, 0, x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
terraformBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LevelGenerator::terraformBlock()
|
||||||
|
{
|
||||||
|
for(int x = 0; x < 256; x++)
|
||||||
|
{
|
||||||
|
for(int z = 0; z < 256; z++)
|
||||||
|
{
|
||||||
|
for(int y = 0; y < 256; y++)
|
||||||
|
{
|
||||||
|
int currentNode = blockManager.getNodeAt(x, y, z);
|
||||||
|
if(currentNode != 0)
|
||||||
|
{
|
||||||
|
if(y == 15 && (blockManager.getNodeAt(x, y + 1, z) == 0 || blockManager.getNodeAt(x, y + 1, z) == 20))
|
||||||
|
{
|
||||||
|
currentNode = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(y < 15)
|
||||||
|
{
|
||||||
|
currentNode = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockManager.addNode(currentNode, 0, x, y, z);
|
||||||
|
}
|
||||||
|
else if(y < 16)
|
||||||
|
{
|
||||||
|
blockManager.addNode(20, 0, x, y, z); // Water
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
populate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LevelGenerator::populate()
|
||||||
|
{
|
||||||
|
for(int counter = 0; counter < 30; counter++)
|
||||||
|
{
|
||||||
|
int x = rand() % 256;
|
||||||
|
int z = rand() % 256;
|
||||||
|
|
||||||
|
for(int y = 10; y < 256; y++)
|
||||||
|
{
|
||||||
|
if(blockManager.getNodeAt(x, y, z) == 0)
|
||||||
|
{
|
||||||
|
if(blockManager.getNodeAt(x, y - 1, z) == 20)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
counter -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int y1 = y; y1 < y + 6; y1++)
|
||||||
|
{
|
||||||
|
blockManager.addNode(12, 0, x, y1, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < 3; j++)
|
||||||
|
{
|
||||||
|
for(int k = 0; k < 3; k++)
|
||||||
|
{
|
||||||
|
blockManager.addNode(13, 0, x + i - 1, y + j + 6, z + k - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
144
MapBlock.cpp
144
MapBlock.cpp
@@ -1,67 +1,77 @@
|
|||||||
#include "MapBlock.h"
|
#include "MapBlock.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int mapBlock[65536];
|
int mapBlock[65536];
|
||||||
|
|
||||||
MapBlock::MapBlock()
|
MapBlock::MapBlock()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO; Make this function work with global coordinates and move it to BlockManager
|
void BlockManager::addNode(int id, int meta, int x, int y, int z)
|
||||||
void MapBlock::addNode(int id, int meta, int x, int y, int z)
|
{
|
||||||
{
|
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
|
||||||
mapBlock[256 * y + z * 16 + x] = id;
|
|
||||||
}
|
int localX = x - block.x * 16;
|
||||||
|
int localZ = z - block.z * 16;
|
||||||
|
|
||||||
|
mapBlocks[block.x][block.z].mapBlock[256 * y + localZ * 16 + localX] = id;
|
||||||
|
}
|
||||||
MapBlock mapBlocks[16][16];
|
|
||||||
|
MapBlock mapBlocks[16][16];
|
||||||
BlockManager::BlockManager()
|
|
||||||
{
|
BlockManager::BlockManager()
|
||||||
|
{
|
||||||
}
|
|
||||||
|
}
|
||||||
int BlockManager::getNodeAt(int x, int y, int z)
|
|
||||||
{
|
int BlockManager::getNodeAt(int x, int y, int z)
|
||||||
// Math explanation for future reference:
|
{
|
||||||
// The x and z coordinates need to be have block.[AXIS] * 16 subtracted from them
|
// Math explanation for future reference:
|
||||||
// so that the coordinates passed to the function are local block coordinates instead
|
// The x and z coordinates need to be have block.[AXIS] * 16 subtracted from them
|
||||||
// of global node coordinates (e.g. 1, and not 17)
|
// so that the coordinates passed to the function are local block coordinates instead
|
||||||
|
// of global node coordinates (e.g. 1, and not 17)
|
||||||
if(x < 0 || y < 0 || z < 0)
|
|
||||||
{
|
if(x < 0 || y < 0 || z < 0)
|
||||||
return 0;
|
{
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
|
|
||||||
|
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
|
||||||
int localX = x - block.x * 16;
|
|
||||||
int localZ = z - block.z * 16;
|
int localX = x - block.x * 16;
|
||||||
|
int localZ = z - block.z * 16;
|
||||||
return mapBlocks[block.x][block.z].mapBlock[256 * y + localZ * 16 + localX];
|
|
||||||
}
|
return mapBlocks[block.x][block.z].mapBlock[256 * y + localZ * 16 + localX];
|
||||||
|
}
|
||||||
bool BlockManager::isAir(int x, int y, int z)
|
|
||||||
{
|
bool BlockManager::isAir(int x, int y, int z)
|
||||||
return getNodeAt(x, y, z) == 0;
|
{
|
||||||
}
|
return getNodeAt(x, y, z) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BlockManager::isNodeClear(int x, int y, int z)
|
||||||
|
{
|
||||||
BlockUtilities::BlockUtilities()
|
if(getNodeAt(x, y, z) == 0)
|
||||||
{
|
return true;
|
||||||
|
if(getNodeAt(x, y, z) == 20)
|
||||||
}
|
return true;
|
||||||
|
|
||||||
Position2D BlockUtilities::getBlockFromNodeCoordinates(int x, int z)
|
return false;
|
||||||
{
|
}
|
||||||
Position2D pos2d;
|
|
||||||
pos2d.x = floor(x / 16);
|
BlockUtilities::BlockUtilities()
|
||||||
pos2d.z = floor(z / 16);
|
{
|
||||||
return pos2d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Position2D BlockUtilities::getBlockFromNodeCoordinates(int x, int z)
|
||||||
|
{
|
||||||
|
Position2D pos2d;
|
||||||
|
//pos2d.x = floor(x / 16);
|
||||||
|
//pos2d.z = floor(z / 16);
|
||||||
|
pos2d.x = x >> 4;
|
||||||
|
pos2d.z = z >> 4;
|
||||||
|
return pos2d;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
===============
|
||||||
|
XtreemNodes 0.3
|
||||||
|
(2023-08-27)
|
||||||
|
===============
|
||||||
|
|
||||||
XtreemNodes is a modern 3-D game engine by MCL Software made in collaboration with Cube Software.
|
XtreemNodes is a modern 3-D game engine by MCL Software made in collaboration with Cube Software.
|
||||||
|
|
||||||
The project was started on 2022-10-15 by a mysterious man sitting at his desk at 3 a.m.
|
The project was started on 2022-10-15 by a mysterious man sitting at his desk at 3 a.m.
|
||||||
|
|||||||
19
TitleMenu.cpp
Normal file
19
TitleMenu.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "include/TitleMenu.h"
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
void TitleMenu::renderGUI()
|
||||||
|
{
|
||||||
|
glTranslatef(.0F, .0F, .0F);
|
||||||
|
|
||||||
|
glColor3f(1.0F, .0F, .0F);
|
||||||
|
|
||||||
|
glBegin(GL_TRIANGLES);
|
||||||
|
|
||||||
|
glVertex2f(.0F, -500.0F);
|
||||||
|
|
||||||
|
glVertex2f(.0F, 500.0F);
|
||||||
|
|
||||||
|
glVertex2f(500.0F, .0F);
|
||||||
|
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
# depslib dependency file v1.0
|
|
||||||
1672097148 source:c:\development\xtreemminer\main.cpp
|
|
||||||
<stdlib.h>
|
|
||||||
<GL/glut.h>
|
|
||||||
"Utilities.h"
|
|
||||||
"MapBlock.h"
|
|
||||||
"Base.h"
|
|
||||||
"NodeRenderer.h"
|
|
||||||
"TextureHandler.h"
|
|
||||||
<math.h>
|
|
||||||
<cstdio>
|
|
||||||
<random>
|
|
||||||
<SFML/Window.hpp>
|
|
||||||
|
|
||||||
1667160597 c:\development\xtreemminer\include\noderenderer.h
|
|
||||||
"Base.h"
|
|
||||||
"MapBlock.h"
|
|
||||||
<GL/glut.h>
|
|
||||||
|
|
||||||
1667164077 c:\development\xtreemminer\include\mapblock.h
|
|
||||||
"Base.h"
|
|
||||||
<math.h>
|
|
||||||
<cstdio>
|
|
||||||
|
|
||||||
1667065840 c:\development\xtreemminer\include\base.h
|
|
||||||
|
|
||||||
1666531672 source:c:\development\xtreemminer\base.cpp
|
|
||||||
"MapBlock.h"
|
|
||||||
"Base.h"
|
|
||||||
|
|
||||||
1672105046 c:\development\xtreemminer\include\texturehandler.h
|
|
||||||
"stb_image.h"
|
|
||||||
"Base.h"
|
|
||||||
|
|
||||||
1666445333 c:\development\xtreemminer\include\stb_image.h
|
|
||||||
"stb_image.h"
|
|
||||||
<stdio.h>
|
|
||||||
<stdlib.h>
|
|
||||||
<stdarg.h>
|
|
||||||
<stddef.h>
|
|
||||||
<stdlib.h>
|
|
||||||
<string.h>
|
|
||||||
<limits.h>
|
|
||||||
<math.h>
|
|
||||||
<stdio.h>
|
|
||||||
<assert.h>
|
|
||||||
<stdint.h>
|
|
||||||
<emmintrin.h>
|
|
||||||
<intrin.h>
|
|
||||||
<arm_neon.h>
|
|
||||||
|
|
||||||
1667065840 c:\development\xtreemminer\include\utilities.h
|
|
||||||
|
|
||||||
1667079584 c:\development\xtreemminer\include\fastnoiselite.h
|
|
||||||
<cmath>
|
|
||||||
|
|
||||||
1667350805 source:c:\development\xtreemminer\mapblock.cpp
|
|
||||||
"MapBlock.h"
|
|
||||||
|
|
||||||
1667294728 source:/home/kacperks/projects/XtreemNodes/MapBlock.cpp
|
|
||||||
"MapBlock.h"
|
|
||||||
|
|
||||||
1667294728 /home/kacperks/projects/XtreemNodes/include/MapBlock.h
|
|
||||||
"Base.h"
|
|
||||||
<math.h>
|
|
||||||
<cstdio>
|
|
||||||
|
|
||||||
1667294728 /home/kacperks/projects/XtreemNodes/include/Base.h
|
|
||||||
|
|
||||||
1667294728 source:/home/kacperks/projects/XtreemNodes/main.cpp
|
|
||||||
<stdlib.h>
|
|
||||||
<GL/glut.h>
|
|
||||||
"Utilities.h"
|
|
||||||
"MapBlock.h"
|
|
||||||
"Base.h"
|
|
||||||
"NodeRenderer.h"
|
|
||||||
"TextureHandler.h"
|
|
||||||
<math.h>
|
|
||||||
<cstdio>
|
|
||||||
"FastNoiseLite.h"
|
|
||||||
<random>
|
|
||||||
<SFML/Window.hpp>
|
|
||||||
|
|
||||||
1667294728 /home/kacperks/projects/XtreemNodes/include/Utilities.h
|
|
||||||
|
|
||||||
1667294728 /home/kacperks/projects/XtreemNodes/include/NodeRenderer.h
|
|
||||||
"Base.h"
|
|
||||||
"MapBlock.h"
|
|
||||||
<GL/glut.h>
|
|
||||||
|
|
||||||
1667294728 /home/kacperks/projects/XtreemNodes/include/TextureHandler.h
|
|
||||||
"stb_image.h"
|
|
||||||
"Base.h"
|
|
||||||
|
|
||||||
1667088826 /home/kacperks/projects/XtreemNodes/include/stb_image.h
|
|
||||||
"stb_image.h"
|
|
||||||
<stdio.h>
|
|
||||||
<stdlib.h>
|
|
||||||
<stdarg.h>
|
|
||||||
<stddef.h>
|
|
||||||
<stdlib.h>
|
|
||||||
<string.h>
|
|
||||||
<limits.h>
|
|
||||||
<math.h>
|
|
||||||
<stdio.h>
|
|
||||||
<assert.h>
|
|
||||||
<stdint.h>
|
|
||||||
<emmintrin.h>
|
|
||||||
<intrin.h>
|
|
||||||
<arm_neon.h>
|
|
||||||
|
|
||||||
1667294728 /home/kacperks/projects/XtreemNodes/include/FastNoiseLite.h
|
|
||||||
<cmath>
|
|
||||||
|
|
||||||
1667347897 source:c:\development\xtreemminer\gui.cpp
|
|
||||||
"GUI.h"
|
|
||||||
|
|
||||||
1667333037 c:\development\xtreemminer\include\gui.h
|
|
||||||
"Base.h"
|
|
||||||
<SFML/Main.hpp>
|
|
||||||
<SFML/Graphics.hpp>
|
|
||||||
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
||||||
<CodeBlocks_layout_file>
|
|
||||||
<FileVersion major="1" minor="0" />
|
|
||||||
<ActiveTarget name="Debug" />
|
|
||||||
<File name="include\NodeRenderer.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="2409" topLine="24" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="MapBlock.cpp" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="29" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="include\Nodes.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="264" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="include\LevelGenerator.h" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="174" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="GUI.cpp" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="1286" topLine="3" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="include\stb_image.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="8925" topLine="160" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="LevelGenerator.cpp" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="87" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="include\FastNoiseLite.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="100664" topLine="2262" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="include\Base.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="28" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="include\MapBlock.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="438" topLine="3" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="include\Logger.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="97" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="include\GUI.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="331" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="main.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="201" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="include\TextureHandler.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="2192" topLine="17" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
</CodeBlocks_layout_file>
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
||||||
<CodeBlocks_project_file>
|
|
||||||
<FileVersion major="1" minor="6" />
|
|
||||||
<Project>
|
|
||||||
<Option title="XtreemNodes" />
|
|
||||||
<Option pch_mode="2" />
|
|
||||||
<Option compiler="gcc" />
|
|
||||||
<Build>
|
|
||||||
<Target title="Debug">
|
|
||||||
<Option output="bin/Debug/XtreemNodes" prefix_auto="1" extension_auto="1" />
|
|
||||||
<Option object_output="obj/Debug/" />
|
|
||||||
<Option type="1" />
|
|
||||||
<Option compiler="gcc" />
|
|
||||||
<Compiler>
|
|
||||||
<Add option="-g" />
|
|
||||||
<Add directory="include" />
|
|
||||||
</Compiler>
|
|
||||||
</Target>
|
|
||||||
<Target title="Release">
|
|
||||||
<Option output="bin/Release/XtreemNodes" prefix_auto="1" extension_auto="1" />
|
|
||||||
<Option object_output="obj/Release/" />
|
|
||||||
<Option type="1" />
|
|
||||||
<Option compiler="gcc" />
|
|
||||||
<Compiler>
|
|
||||||
<Add option="-O2" />
|
|
||||||
<Add directory="include" />
|
|
||||||
</Compiler>
|
|
||||||
<Linker>
|
|
||||||
<Add option="-s" />
|
|
||||||
</Linker>
|
|
||||||
</Target>
|
|
||||||
</Build>
|
|
||||||
<Compiler>
|
|
||||||
<Add option="-Wall" />
|
|
||||||
<Add option="-fexceptions" />
|
|
||||||
</Compiler>
|
|
||||||
<Linker>
|
|
||||||
<Add option="-lGLEW" />
|
|
||||||
<Add option="-lGL" />
|
|
||||||
<Add option="-lsfml" />
|
|
||||||
</Linker>
|
|
||||||
<Unit filename="GUI.cpp" />
|
|
||||||
<Unit filename="MapBlock.cpp" />
|
|
||||||
<Unit filename="include/Base.h" />
|
|
||||||
<Unit filename="include/FastNoiseLite.h" />
|
|
||||||
<Unit filename="include/GUI.h" />
|
|
||||||
<Unit filename="include/Logger.h" />
|
|
||||||
<Unit filename="include/MapBlock.h" />
|
|
||||||
<Unit filename="include/NodeRenderer.h" />
|
|
||||||
<Unit filename="include/Nodes.h" />
|
|
||||||
<Unit filename="include/TextureHandler.h" />
|
|
||||||
<Unit filename="include/Utilities.h" />
|
|
||||||
<Unit filename="include/stb_image.h" />
|
|
||||||
<Unit filename="main.cpp" />
|
|
||||||
<Extensions>
|
|
||||||
<lib_finder disable_auto="1" />
|
|
||||||
</Extensions>
|
|
||||||
</Project>
|
|
||||||
</CodeBlocks_project_file>
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
||||||
<CodeBlocks_project_file>
|
|
||||||
<FileVersion major="1" minor="6" />
|
|
||||||
<Project>
|
|
||||||
<Option title="XtreemNodes" />
|
|
||||||
<Option pch_mode="2" />
|
|
||||||
<Option compiler="gcc" />
|
|
||||||
<Build>
|
|
||||||
<Target title="Debug">
|
|
||||||
<Option output="bin/Debug/XtreemNodes" prefix_auto="1" extension_auto="1" />
|
|
||||||
<Option object_output="obj/Debug/" />
|
|
||||||
<Option type="1" />
|
|
||||||
<Option compiler="gcc" />
|
|
||||||
<Compiler>
|
|
||||||
<Add option="-g" />
|
|
||||||
<Add directory="include" />
|
|
||||||
</Compiler>
|
|
||||||
</Target>
|
|
||||||
<Target title="Release">
|
|
||||||
<Option output="bin/Release/XtreemNodes" prefix_auto="1" extension_auto="1" />
|
|
||||||
<Option object_output="obj/Release/" />
|
|
||||||
<Option type="1" />
|
|
||||||
<Option compiler="gcc" />
|
|
||||||
<Compiler>
|
|
||||||
<Add option="-O2" />
|
|
||||||
<Add directory="include" />
|
|
||||||
</Compiler>
|
|
||||||
<Linker>
|
|
||||||
<Add option="-s" />
|
|
||||||
</Linker>
|
|
||||||
</Target>
|
|
||||||
</Build>
|
|
||||||
<Compiler>
|
|
||||||
<Add option="-Wall" />
|
|
||||||
<Add option="-fexceptions" />
|
|
||||||
</Compiler>
|
|
||||||
<Linker>
|
|
||||||
<Add option="-lfreeglut" />
|
|
||||||
<Add option="-lglew32" />
|
|
||||||
<Add option="-lglu32" />
|
|
||||||
<Add option="-lopengl32" />
|
|
||||||
<Add option="-lsfml-window" />
|
|
||||||
<Add option="-lsfml-graphics" />
|
|
||||||
</Linker>
|
|
||||||
<Unit filename="GUI.cpp" />
|
|
||||||
<Unit filename="LevelGenerator.cpp" />
|
|
||||||
<Unit filename="MapBlock.cpp" />
|
|
||||||
<Unit filename="include/Base.h" />
|
|
||||||
<Unit filename="include/FastNoiseLite.h" />
|
|
||||||
<Unit filename="include/GUI.h" />
|
|
||||||
<Unit filename="include/LevelGenerator.h" />
|
|
||||||
<Unit filename="include/Logger.h" />
|
|
||||||
<Unit filename="include/MapBlock.h" />
|
|
||||||
<Unit filename="include/NodeRenderer.h" />
|
|
||||||
<Unit filename="include/Nodes.h" />
|
|
||||||
<Unit filename="include/TextureHandler.h" />
|
|
||||||
<Unit filename="include/Utilities.h" />
|
|
||||||
<Unit filename="include/stb_image.h" />
|
|
||||||
<Unit filename="main.cpp" />
|
|
||||||
<Extensions>
|
|
||||||
<lib_finder disable_auto="1" />
|
|
||||||
</Extensions>
|
|
||||||
</Project>
|
|
||||||
</CodeBlocks_project_file>
|
|
||||||
BIN
data/img/bro.png
Normal file
BIN
data/img/bro.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
BIN
data/img/grass.png
Normal file
BIN
data/img/grass.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 778 B |
Binary file not shown.
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 19 KiB |
@@ -1,19 +1,19 @@
|
|||||||
#ifndef BASE
|
#ifndef BASE
|
||||||
#define BASE
|
#define BASE
|
||||||
|
|
||||||
//#include "NodeRenderer.h"
|
#include "MapBlock.h"
|
||||||
//#include "MapBlock.h"
|
|
||||||
|
class NodeManager;
|
||||||
class NodeManager;
|
class BlockManager;
|
||||||
class BlockManager;
|
|
||||||
|
extern NodeManager nodeManager;
|
||||||
extern NodeManager nodeManager;
|
extern BlockManager blockManager;
|
||||||
extern BlockManager blockManager;
|
|
||||||
|
extern float light;
|
||||||
|
|
||||||
struct Position2D
|
/*struct Position2D
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
int z;
|
int z;
|
||||||
};
|
};*/
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
19
include/Camera.h
Normal file
19
include/Camera.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include <glm/glm.hpp>
|
||||||
|
#include <glm/ext/matrix_transform.hpp>
|
||||||
|
|
||||||
|
class Camera
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Camera() = default;
|
||||||
|
virtual ~Camera()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const glm::mat4& get_view();
|
||||||
|
const glm::mat4& get_projection();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const glm::mat4& matrix;
|
||||||
|
glm::mat4 m_view, m_projection;
|
||||||
|
};
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,26 +1,26 @@
|
|||||||
#ifndef GUI
|
#ifndef GUI
|
||||||
#define GUI
|
#define GUI
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
#include <SFML/Main.hpp>
|
#include <SFML/Main.hpp>
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
class Button
|
class Button
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Button(sf::Image* normal, sf::Image* clicked, std::string text, Position2D location);
|
Button(sf::Image* normal, sf::Image* clicked, std::string text, Position2D location);
|
||||||
void checkClick(Position2D);
|
void checkClick(Position2D);
|
||||||
void setState(bool state);
|
void setState(bool state);
|
||||||
void setText(std::string);
|
void setText(std::string);
|
||||||
bool getVar();
|
bool getVar();
|
||||||
sf::Sprite* getSprite();
|
sf::Sprite* getSprite();
|
||||||
sf::String* getText();
|
sf::String* getText();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sf::Sprite normal;
|
sf::Sprite normal;
|
||||||
sf::Sprite clicked;
|
sf::Sprite clicked;
|
||||||
sf::Sprite* currentSpr;
|
sf::Sprite* currentSpr;
|
||||||
sf::String String;
|
sf::String String;
|
||||||
bool current;
|
bool current;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
#ifndef LEVELGENERATOR
|
#ifndef LEVELGENERATOR
|
||||||
#define LEVELGENERATOR
|
#define LEVELGENERATOR
|
||||||
#include "FastNoiseLite.h"
|
#include "FastNoiseLite.h"
|
||||||
|
|
||||||
class LevelGenerator
|
class LevelGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LevelGenerator();
|
LevelGenerator();
|
||||||
void generateBlock();
|
void setSeed();
|
||||||
|
void generateBlock();
|
||||||
protected:
|
void terraformBlock();
|
||||||
|
void populate();
|
||||||
private:
|
|
||||||
FastNoiseLite perlin, os, cellular;
|
protected:
|
||||||
int seed = 138;
|
|
||||||
};
|
private:
|
||||||
|
FastNoiseLite perlin, os, cellular;
|
||||||
#endif
|
int seed = 138; // 1338, 1337. 138 are good ones
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
|
||||||
class Logger
|
class Logger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void log(char* comp, char* message);
|
void log(char* comp, char* message);
|
||||||
{
|
{
|
||||||
printf("Message: %c", message);
|
printf("Message: %c", message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,33 +1,38 @@
|
|||||||
#ifndef MAPBLOCK
|
#ifndef MAPBLOCK
|
||||||
#define MAPBLOCK
|
#define MAPBLOCK
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
class MapBlock
|
class MapBlock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int mapBlock[65536];
|
int mapBlock[65536];
|
||||||
MapBlock();
|
MapBlock();
|
||||||
// TODO; Make this function work with global coordinates and move it to BlockManager
|
};
|
||||||
void addNode(int id, int meta, int x, int y, int z);
|
|
||||||
|
class BlockManager
|
||||||
};
|
{
|
||||||
|
public:
|
||||||
class BlockManager
|
MapBlock mapBlocks[16][16];
|
||||||
{
|
BlockManager();
|
||||||
public:
|
int getNodeAt(int x, int y, int z);
|
||||||
MapBlock mapBlocks[16][16];
|
void addNode(int id, int meta, int x, int y, int z);
|
||||||
BlockManager();
|
bool isAir(int x, int y, int z);
|
||||||
int getNodeAt(int x, int y, int z);
|
bool isNodeClear(int x, int y, int z);
|
||||||
bool isAir(int x, int y, int z);
|
};
|
||||||
};
|
|
||||||
|
struct Position2D
|
||||||
class BlockUtilities
|
{
|
||||||
{
|
int x;
|
||||||
public:
|
int z;
|
||||||
BlockUtilities();
|
};
|
||||||
static Position2D getBlockFromNodeCoordinates(int x, int z);
|
|
||||||
};
|
class BlockUtilities
|
||||||
|
{
|
||||||
#endif
|
public:
|
||||||
|
BlockUtilities();
|
||||||
|
static Position2D getBlockFromNodeCoordinates(int x, int z);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -1,144 +1,285 @@
|
|||||||
#ifndef NODERENDERER_H
|
#ifndef NODERENDERER_H
|
||||||
#define NODERENDERER_H
|
#define NODERENDERER_H
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
#include "MapBlock.h"
|
#include "MapBlock.h"
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
|
|
||||||
class NodeRenderer
|
class NodeRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NodeRenderer()
|
NodeRenderer()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~NodeRenderer()
|
virtual ~NodeRenderer()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int renderNode(int x, int y, int z)
|
int renderNode(int x, int y, int z, int tex)
|
||||||
{
|
{
|
||||||
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z); // The block the node at (x, y, z) is in
|
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z); // The block the node at (x, y, z) is in
|
||||||
|
Position2D textureCoordinate;
|
||||||
glColor3f(1.0F, 1.0F, 1.0F);
|
textureCoordinate.x = tex - (16 * floor(tex / 16));
|
||||||
|
textureCoordinate.z = floor(tex / 16) + 1;
|
||||||
glBegin(GL_QUADS);
|
|
||||||
// Front
|
|
||||||
if(blockManager.isAir(x, y, z - 1))
|
//glColor3f(light, light, light);
|
||||||
{
|
|
||||||
glTexCoord2f(.0F, .0F);
|
glBegin(GL_TRIANGLES);
|
||||||
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
// Front
|
||||||
|
if(blockManager.isAir(x, y, z - 1))
|
||||||
glTexCoord2f(1.0F, .0F);
|
{
|
||||||
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
/*glTexCoord2f(.0F, .0F);
|
||||||
|
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
||||||
glColor3f(.6F, .6F, .6F); // Bottom vertices
|
|
||||||
glTexCoord2f(1.0F, 1.0F);
|
glTexCoord2f(.0625F * textureCoordinate, .0F);
|
||||||
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
||||||
|
|
||||||
glTexCoord2f(.0F, 1.0F);
|
//glColor3f(.6F, .6F, .6F); // Bottom vertices
|
||||||
glVertex3f(x + .0F, y + .0F, z + .0F);
|
glTexCoord2f(.0625F * textureCoordinate, .0625F * textureCoordinate);
|
||||||
glColor3f(1.0F, 1.0F, 1.0F);
|
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
||||||
}
|
|
||||||
|
//glColor3f(1.0F, 1.0F, 1.0F);
|
||||||
// Back
|
glTexCoord2f(.0F, .0625F * textureCoordinate);
|
||||||
if(blockManager.isAir(x, y, z + 1))
|
glVertex3f(x + .0F, y + .0F, z + .0F);*/
|
||||||
{
|
|
||||||
|
|
||||||
glTexCoord2f(.0F, .0F);
|
glTexCoord2f(.0625F * (textureCoordinate.x - 1), .0625F * (textureCoordinate.z - 1));
|
||||||
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
||||||
|
|
||||||
glTexCoord2f(1.0F, .0F);
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * (textureCoordinate.z - 1));
|
||||||
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);
|
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
||||||
|
|
||||||
glColor3f(.6F, .6F, .6F);
|
//glColor3f(.6F, .6F, .6F); // Bottom vertices
|
||||||
glTexCoord2f(1.0F, 1.0F);
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * textureCoordinate.z);
|
||||||
glVertex3f(x + 1.0F, y + .0F, z + 1.0F);
|
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
||||||
|
|
||||||
glTexCoord2f(.0F, 1.0F);
|
|
||||||
glVertex3f(x + .0F, y + .0F, z + 1.0F);
|
//glColor3f(1.0F, 1.0F, 1.0F);
|
||||||
glColor3f(1.0F, 1.0F, 1.0F);
|
glTexCoord2f(.0625F * (textureCoordinate.x - 1), .0625F * textureCoordinate.z);
|
||||||
}
|
glVertex3f(x + .0F, y + .0F, z + .0F);
|
||||||
|
|
||||||
// Right
|
glTexCoord2f(.0625F * (textureCoordinate.x - 1), .0625F * (textureCoordinate.z - 1));
|
||||||
if(blockManager.isAir(x + 1, y, z))
|
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
||||||
{
|
|
||||||
glTexCoord2f(1.0F, .0F);
|
//glColor3f(.6F, .6F, .6F); // Bottom vertices
|
||||||
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * textureCoordinate.z);
|
||||||
|
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
||||||
glColor3f(.6F, .6F, .6F);
|
}
|
||||||
glTexCoord2f(1.0F, 1.0F);
|
|
||||||
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
// Back
|
||||||
|
if(blockManager.isAir(x, y, z + 1))
|
||||||
glTexCoord2f(.0F, 1.0F);
|
{
|
||||||
glVertex3f(x + 1.0F, y + .0F, z + 1.0F);
|
/*glTexCoord2f(.0F, .0F);
|
||||||
glColor3f(1.0F, 1.0F, 1.0F);
|
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
||||||
|
|
||||||
glTexCoord2f(.0F, .0F);
|
glTexCoord2f(.0625F * textureCoordinate, .0F);
|
||||||
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);
|
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);
|
||||||
}
|
|
||||||
|
//glColor3f(.6F, .6F, .6F);
|
||||||
// Left
|
glTexCoord2f(.0625F * textureCoordinate, .0625F * textureCoordinate);
|
||||||
if(blockManager.isAir(x - 1, y, z))
|
glVertex3f(x + 1.0F, y + .0F, z + 1.0F);
|
||||||
{
|
|
||||||
glTexCoord2f(1.0F, .0F);
|
//glColor3f(1.0F, 1.0F, 1.0F);
|
||||||
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
glTexCoord2f(.0F, .0625F * textureCoordinate);
|
||||||
|
glVertex3f(x + .0F, y + .0F, z + 1.0F);*/
|
||||||
glColor3f(.6F, .6F, .6F);
|
|
||||||
glTexCoord2f(1.0F, 1.0F);
|
|
||||||
glVertex3f(x + .0F, y + .0F, z + .0F);
|
glTexCoord2f(.0625F * (textureCoordinate.x - 1), .0625F * (textureCoordinate.z - 1));
|
||||||
|
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
||||||
glTexCoord2f(.0F, 1.0F);
|
|
||||||
glVertex3f(x + .0F, y + .0F, z + 1.0F);
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * (textureCoordinate.z - 1));
|
||||||
glColor3f(1.0F, 1.0F, 1.0F);
|
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);
|
||||||
|
|
||||||
glTexCoord2f(.0F, .0F);
|
//glColor3f(.6F, .6F, .6F);
|
||||||
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * textureCoordinate.z);
|
||||||
}
|
glVertex3f(x + 1.0F, y + .0F, z + 1.0F);
|
||||||
|
|
||||||
// Bottom
|
|
||||||
//printf("\n\nx: %i, y: %i, z: %i, VALUE: %s", x, y, z, blockManager.isAir(x, y - 1, z) ? "true" : "false");
|
|
||||||
if(blockManager.isAir(x, y - 1, z))
|
|
||||||
{
|
|
||||||
//printf("\nWUT? x: %i, y: %i, z: %i, VALUE: %s", x, y, z, blockManager.isAir(x, y - 1, z) ? "true" : "false");
|
|
||||||
glTexCoord2f(.0F, .0F);
|
glTexCoord2f(.0625F * (textureCoordinate.x - 1), .0625F * (textureCoordinate.z - 1));
|
||||||
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
||||||
|
|
||||||
glTexCoord2f(1.0F, .0F);
|
//glColor3f(1.0F, 1.0F, 1.0F);
|
||||||
glVertex3f(x + .0F, y + .0F, z + .0F);
|
glTexCoord2f(.0625F * (textureCoordinate.x - 1), .0625F * textureCoordinate.z);
|
||||||
|
glVertex3f(x + .0F, y + .0F, z + 1.0F);
|
||||||
glTexCoord2f(1.0F, 1.0F);
|
|
||||||
glVertex3f(x + .0F, y + .0F, z + 1.0F);
|
//glColor3f(.6F, .6F, .6F);
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * textureCoordinate.z);
|
||||||
glTexCoord2f(.0F, 1.0F);
|
glVertex3f(x + 1.0F, y + .0F, z + 1.0F);
|
||||||
glVertex3f(x + 1.0F, y + .0F, z + 1.0F);
|
}
|
||||||
}
|
|
||||||
|
// Right
|
||||||
// Top
|
if(blockManager.isAir(x + 1, y, z))
|
||||||
if(blockManager.isAir(x, y + 1, z))
|
{
|
||||||
{
|
/*glTexCoord2f(.0625F * textureCoordinate, .0F);
|
||||||
glTexCoord2f(.0F, .0F);
|
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
||||||
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
|
||||||
|
//glColor3f(.6F, .6F, .6F);
|
||||||
glTexCoord2f(1.0F, .0F);
|
glTexCoord2f(.0625F * textureCoordinate, 1.0F);
|
||||||
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
||||||
|
|
||||||
glTexCoord2f(1.0F, 1.0F);
|
//glColor3f(1.0F, 1.0F, 1.0F);
|
||||||
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
glTexCoord2f(.0F, .0625F * textureCoordinate);
|
||||||
|
glVertex3f(x + 1.0F, y + .0F, z + 1.0F);
|
||||||
glTexCoord2f(.0F, 1.0F);
|
|
||||||
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);
|
glTexCoord2f(.0F, .0F);
|
||||||
}
|
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);*/
|
||||||
|
|
||||||
glEnd();
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * (textureCoordinate.z - 1));
|
||||||
return 1;
|
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
||||||
}
|
|
||||||
|
//glColor3f(.6F, .6F, .6F);
|
||||||
protected:
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * textureCoordinate.z);
|
||||||
|
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
||||||
private:
|
|
||||||
|
//glColor3f(1.0F, 1.0F, 1.0F);
|
||||||
};
|
glTexCoord2f(.0625F * (textureCoordinate.x - 1), .0625F * textureCoordinate.z);
|
||||||
|
glVertex3f(x + 1.0F, y + .0F, z + 1.0F);
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * (textureCoordinate.x - 1), .0625F * (textureCoordinate.z - 1));
|
||||||
|
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * (textureCoordinate.z - 1));
|
||||||
|
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
||||||
|
|
||||||
|
//glColor3f(1.0F, 1.0F, 1.0F);
|
||||||
|
glTexCoord2f(.0625F * (textureCoordinate.x - 1), .0625F * textureCoordinate.z);
|
||||||
|
glVertex3f(x + 1.0F, y + .0F, z + 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Left
|
||||||
|
if(blockManager.isAir(x - 1, y, z))
|
||||||
|
{
|
||||||
|
/*glTexCoord2f(.0625F * textureCoordinate, .0F);
|
||||||
|
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
||||||
|
|
||||||
|
//glColor3f(.6F, .6F, .6F);
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate, .0625F * textureCoordinate);
|
||||||
|
glVertex3f(x + .0F, y + .0F, z + .0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0F, .0625F * textureCoordinate);
|
||||||
|
glVertex3f(x + .0F, y + .0F, z + 1.0F);
|
||||||
|
//glColor3f(1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0F, .0F);
|
||||||
|
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);*/
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * (textureCoordinate.z - 1));
|
||||||
|
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
||||||
|
|
||||||
|
//glColor3i(100, 100, 100);
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * textureCoordinate.z);
|
||||||
|
glVertex3f(x + .0F, y + .0F, z + .0F);
|
||||||
|
|
||||||
|
//glColor3i(255, 255, 255);
|
||||||
|
glTexCoord2f(.0625F * (textureCoordinate.x - 1), .0625F * textureCoordinate.z);
|
||||||
|
glVertex3f(x + .0F, y + .0F, z + 1.0F);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * (textureCoordinate.x - 1), .0625F * (textureCoordinate.z - 1));
|
||||||
|
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * (textureCoordinate.z - 1));
|
||||||
|
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
||||||
|
|
||||||
|
//glColor3f(1.0F, 1.0F, 1.0F);
|
||||||
|
glTexCoord2f(.0625F * (textureCoordinate.x - 1), .0625F * textureCoordinate.z);
|
||||||
|
glVertex3f(x + .0F, y + .0F, z + 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bottom
|
||||||
|
//printf("\n\nx: %i, y: %i, z: %i, VALUE: %s", x, y, z, blockManager.isAir(x, y - 1, z) ? "true" : "false");
|
||||||
|
if(y > 0 && blockManager.isAir(x, y - 1, z))
|
||||||
|
{
|
||||||
|
//printf("\nWUT? x: %i, y: %i, z: %i, VALUE: %s", x, y, z, blockManager.isAir(x, y - 1, z) ? "true" : "false");
|
||||||
|
/*glTexCoord2f(.0F, .0F);
|
||||||
|
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate, .0F);
|
||||||
|
glVertex3f(x + .0F, y + .0F, z + .0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate, .0625F * textureCoordinate);
|
||||||
|
glVertex3f(x + .0F, y + .0F, z + 1.0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0F, .0625F * textureCoordinate);
|
||||||
|
glVertex3f(x + 1.0F, y + .0F, z + 1.0F);*/
|
||||||
|
|
||||||
|
glTexCoord2f(.0F, .0F);
|
||||||
|
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate.x, .0F);
|
||||||
|
glVertex3f(x + .0F, y + .0F, z + .0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * textureCoordinate.z);
|
||||||
|
glVertex3f(x + .0F, y + .0F, z + 1.0F);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
glTexCoord2f(.0F, .0625F * textureCoordinate.x);
|
||||||
|
glVertex3f(x + 1.0F, y + .0F, z + 1.0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0F, .0F);
|
||||||
|
glVertex3f(x + 1.0F, y + .0F, z + .0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * textureCoordinate.z);
|
||||||
|
glVertex3f(x + .0F, y + .0F, z + 1.0F);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Top
|
||||||
|
if(blockManager.isNodeClear(x, y + 1, z))
|
||||||
|
{
|
||||||
|
/*glTexCoord2f(.0F, .0F);
|
||||||
|
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate, .0F);
|
||||||
|
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate, .0625F * textureCoordinate);
|
||||||
|
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0F, .0625F * textureCoordinate);
|
||||||
|
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);*/
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * (textureCoordinate.x - 1), .0625F * (textureCoordinate.z - 1));
|
||||||
|
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * (textureCoordinate.z - 1));
|
||||||
|
glVertex3f(x + .0F, y + 1.0F, z + .0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * textureCoordinate.z);
|
||||||
|
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * (textureCoordinate.x - 1), .0625F * textureCoordinate.z);
|
||||||
|
glVertex3f(x + 1.0F, y + 1.0F, z + 1.0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * textureCoordinate.x, .0625F * textureCoordinate.z);
|
||||||
|
glVertex3f(x + .0F, y + 1.0F, z + 1.0F);
|
||||||
|
|
||||||
|
glTexCoord2f(.0625F * (textureCoordinate.x - 1), .0625F * (textureCoordinate.z - 1));
|
||||||
|
glVertex3f(x + 1.0F, y + 1.0F, z + .0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
glEnd();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
class Node
|
class Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Node(int i, int j)
|
Node(int i, int j)
|
||||||
{
|
{
|
||||||
id = i;
|
id = i;
|
||||||
textureIndex = j;
|
textureIndex = j;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getTextureIndexFromSide(int side)
|
int getTextureIndexFromSide(int side)
|
||||||
{
|
{
|
||||||
return textureIndex;
|
return textureIndex;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
int id;
|
int id;
|
||||||
int textureIndex;
|
int textureIndex;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,70 +1,77 @@
|
|||||||
#define STBI_FAILURE_USERMSG
|
#define STBI_FAILURE_USERMSG
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include "stb_image.h"
|
#include "stb_image.h"
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
|
|
||||||
|
|
||||||
//#ifndef TEXTURE_HANDLER
|
#ifndef TEXTURE_HANDLER
|
||||||
//#define TEXTURE_HANDLER
|
#define TEXTURE_HANDLER
|
||||||
class TextureHandler
|
class TextureHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int width = -1;
|
int width = -1;
|
||||||
int height = -1;
|
int height = -1;
|
||||||
int comp = -1;
|
int comp = -1;
|
||||||
unsigned char* imageData;
|
unsigned char* imageData;
|
||||||
unsigned char* imageData1;
|
unsigned char* imageData1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GLuint textures;
|
GLuint texture;
|
||||||
GLuint textures1;
|
unsigned char* loadTexture(char* filename)
|
||||||
unsigned char* loadTexture(char* filename)
|
{
|
||||||
{
|
return stbi_load(filename, &width, &height, &comp, 0);
|
||||||
return stbi_load(filename, &width, &height, &comp, 0);
|
}
|
||||||
}
|
|
||||||
|
void loadAllTextures()
|
||||||
void loadAllTextures()
|
{
|
||||||
{
|
int textureIndex = 0;
|
||||||
int textureIndex = 0;
|
|
||||||
imageData = loadTexture("data/img/texturemap.png");
|
imageData = loadTexture("data/img/texturemap.png");
|
||||||
|
glGenTextures(1, &texture);
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
|
|
||||||
glGenTextures(1, &textures);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
glBindTexture(GL_TEXTURE_2D, textures);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
}
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, imageData);
|
int getTextureForNode(int x, int y, int z)
|
||||||
|
{
|
||||||
imageData1 = loadTexture("data/img/oak.png");
|
//Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
|
||||||
glGenTextures(1, &textures1);
|
if(blockManager.getNodeAt(x, y, z) == 1)
|
||||||
glBindTexture(GL_TEXTURE_2D, textures1);
|
{
|
||||||
|
return 1;
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
}
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
else if(blockManager.getNodeAt(x, y, z) == 2)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
{
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, imageData1);
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void getTextureForNode(int x, int y, int z)
|
else if(blockManager.getNodeAt(x, y, z) == 3)
|
||||||
{
|
{
|
||||||
//Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
|
return 4;
|
||||||
if(blockManager.getNodeAt(x, y, z) == 1)
|
}
|
||||||
{
|
|
||||||
glBindTexture(GL_TEXTURE_2D, textures);
|
else if(blockManager.getNodeAt(x, y, z) == 12)
|
||||||
}
|
{
|
||||||
|
return 81;
|
||||||
else if(blockManager.getNodeAt(x, y, z) == 2)
|
}
|
||||||
{
|
|
||||||
glBindTexture(GL_TEXTURE_2D, textures1);
|
else if(blockManager.getNodeAt(x, y, z) == 13)
|
||||||
}
|
{
|
||||||
|
return 113;
|
||||||
|
}
|
||||||
}
|
|
||||||
};
|
else if(blockManager.getNodeAt(x, y, z) == 20)
|
||||||
|
{
|
||||||
//#endif
|
return 17;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
15
include/TitleMenu.h
Normal file
15
include/TitleMenu.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef TITLEMENU
|
||||||
|
#define TITLEMENU
|
||||||
|
|
||||||
|
class TitleMenu
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TitleMenu()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void renderGUI();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,24 +1,24 @@
|
|||||||
#ifndef UTILITIES
|
#ifndef UTILITIES
|
||||||
#define UTILITIES
|
#define UTILITIES
|
||||||
|
|
||||||
|
|
||||||
class Utilities
|
class Utilities
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Utilities()
|
Utilities()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static float degToRad(int degrees)
|
static float degToRad(int degrees)
|
||||||
{
|
{
|
||||||
return 3.14 / 180 * degrees; // Only the first three digits of pi
|
return 3.14 / 180 * degrees; // Only the first three digits of pi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
15796
include/stb_image.h
15796
include/stb_image.h
File diff suppressed because it is too large
Load Diff
434
main.cpp
434
main.cpp
@@ -1,196 +1,238 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
#include "MapBlock.h"
|
#include "LevelGenerator.h"
|
||||||
#include "Base.h"
|
//#include "MapBlock.h"
|
||||||
#include "NodeRenderer.h"
|
//#include "Base.h"
|
||||||
#include "TextureHandler.h"
|
#include "NodeRenderer.h"
|
||||||
#include <math.h>
|
#include "TextureHandler.h"
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
#include <random>
|
#include <cstdio>
|
||||||
#include <SFML/Window.hpp>
|
#include "include/Camera.h"
|
||||||
|
#include <random>
|
||||||
NodeRenderer renderer;
|
#include <glm/ext/matrix_transform.hpp>
|
||||||
|
#include <SFML/Window.hpp>
|
||||||
BlockManager blockManager;
|
#include "include/TitleMenu.h"
|
||||||
TextureHandler textureHandler;
|
|
||||||
|
NodeRenderer renderer;
|
||||||
GLfloat playerX = 0;
|
BlockManager blockManager;
|
||||||
GLfloat playerY = -30;
|
LevelGenerator levelGen;
|
||||||
GLfloat playerZ = -100;
|
TextureHandler textureHandler;
|
||||||
GLfloat playerRotX = 0;
|
|
||||||
GLfloat playerRotY = 0;
|
GLfloat playerX = 2.5F;
|
||||||
|
GLfloat playerY = 20.0F;
|
||||||
|
GLfloat playerZ = 1.5F;
|
||||||
|
GLfloat playerRotX = 0;
|
||||||
void display()
|
GLfloat playerRotY = 0;
|
||||||
{
|
float light = 1.0F;
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
sf::Vector2i oldMousePos;
|
||||||
glLoadIdentity();
|
|
||||||
|
TitleMenu title;
|
||||||
|
|
||||||
glRotatef(playerRotX, 1.0F, .0F, .0F);
|
void display()
|
||||||
glRotatef(playerRotY, .0F, 1.0F, .0F);
|
{
|
||||||
glTranslatef(playerX, playerY, playerZ);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
glLoadIdentity();
|
||||||
|
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
||||||
|
//glRotatef(playerRotX, 1.0F, .0F, .0F);
|
||||||
|
//glRotatef(playerRotY, .0F, 1.0F, .0F);
|
||||||
glBegin(GL_QUADS);
|
Camera* camera;
|
||||||
|
|
||||||
|
const glm::mat4& matrix = glm::lookAt(glm::vec3(playerX, playerY, playerZ), glm::vec3(playerX - cos(glm::radians(playerRotY)), playerY - playerRotX, playerZ + sin(glm::radians(playerRotY))), glm::vec3(0, 1, 0));
|
||||||
for(int x = 0; x < 100; x++)
|
|
||||||
{
|
//https://glm.g-truc.net/0.9.9/api/a00668.html#gaa64aa951a0e99136bba9008d2b59c78e
|
||||||
for(int y = 0; y < 64; y++)
|
glMatrixMode(GL_MODELVIEW);
|
||||||
{
|
//TODO transform
|
||||||
for(int z = 0; z < 100; z++)
|
//glMatrixMode(GL_PROJECTION);
|
||||||
{
|
glLoadMatrixf(&matrix[0][0]);
|
||||||
if(blockManager.getNodeAt(x, y, z) > 0)
|
//glTranslatef(playerX, playerY, playerZ);
|
||||||
{
|
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
textureHandler.getTextureForNode(x, y, z);
|
|
||||||
renderer.renderNode(x, y, z);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
for(int x = 0; x < 256; x++)
|
||||||
glEnd();
|
{
|
||||||
|
for(int y = 0; y < 80; y++)
|
||||||
glFlush();
|
{
|
||||||
glutSwapBuffers();
|
for(int z = 0; z < 256; z++)
|
||||||
/*
|
{
|
||||||
sf::Vector2i lastMousePos = sf::Vector2i(0, 0);
|
if(blockManager.getNodeAt(x, y, z) > 0)
|
||||||
const sf::Window& window = nullptr;
|
{
|
||||||
sf::Vector2i mouseDelta = sf::Mouse::getPosition(window) - lastMousePos;
|
renderer.renderNode(x, y, z, textureHandler.getTextureForNode(x, y, z));
|
||||||
lastMousePos = sf::Mouse::getPosition(window);*/
|
}
|
||||||
//glutPostRedisplay();
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//title.renderGUI();
|
||||||
void reshape(int width, int height)
|
|
||||||
{
|
glFlush();
|
||||||
glMatrixMode(GL_PROJECTION);
|
glutSwapBuffers();
|
||||||
|
}
|
||||||
glLoadIdentity();
|
|
||||||
gluPerspective(30, width / (float) height, 5, 512.0F);
|
|
||||||
glViewport(0, 0, width, height);
|
void reshape(int width, int height)
|
||||||
|
{
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glutPostRedisplay();
|
|
||||||
}
|
glLoadIdentity();
|
||||||
|
gluPerspective(50, width / (float) height, .1F, 512.0F);
|
||||||
void updateTimer(int time)
|
glViewport(0, 0, width, height);
|
||||||
{
|
|
||||||
// Movement
|
glMatrixMode(GL_MODELVIEW);
|
||||||
if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
|
glutPostRedisplay();
|
||||||
{
|
}
|
||||||
playerZ += .8;
|
|
||||||
}
|
int movementAngle = 0;
|
||||||
|
int angularVel = 1;
|
||||||
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
|
|
||||||
{
|
void updateTimer(int time)
|
||||||
playerZ -= .8;
|
{
|
||||||
}
|
// Movement
|
||||||
|
if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
|
||||||
if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
|
{
|
||||||
{
|
movementAngle = 0;
|
||||||
playerX += .8;
|
}
|
||||||
}
|
|
||||||
|
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
|
||||||
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
|
{
|
||||||
{
|
movementAngle = 180; // 200 grads
|
||||||
playerX -= .8;
|
}
|
||||||
}
|
|
||||||
|
if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
|
||||||
if(sf::Keyboard::isKeyPressed(sf::Keyboard::LShift))
|
{
|
||||||
{
|
movementAngle = 90;
|
||||||
playerY += .8;
|
}
|
||||||
}
|
|
||||||
|
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
|
||||||
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space))
|
{
|
||||||
{
|
movementAngle = 270;
|
||||||
playerY -= .8;
|
}
|
||||||
}
|
|
||||||
|
if(sf::Keyboard::isKeyPressed(sf::Keyboard::W) || sf::Keyboard::isKeyPressed(sf::Keyboard::S))
|
||||||
// Rotation
|
{
|
||||||
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
|
int oldX = playerX;
|
||||||
{
|
int oldZ = playerZ;
|
||||||
playerRotY -= 1.8;
|
playerX = playerX - cos(glm::radians(playerRotY + movementAngle)) * angularVel;
|
||||||
}
|
playerZ = playerZ + sin(glm::radians(playerRotY + movementAngle)) * angularVel;
|
||||||
|
if(blockManager.getNodeAt(playerX, playerY, playerZ) != 0)
|
||||||
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
|
{
|
||||||
{
|
playerX = oldX;
|
||||||
playerRotY += 1.8;
|
playerZ = oldZ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
|
|
||||||
{
|
if(sf::Keyboard::isKeyPressed(sf::Keyboard::LShift))
|
||||||
playerRotX -= 1.8;
|
{
|
||||||
}
|
if(blockManager.getNodeAt(playerX, playerY - 4, playerZ) == 0)
|
||||||
|
{
|
||||||
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
|
playerY -= .8;
|
||||||
{
|
}
|
||||||
playerRotX += 1.8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
|
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space))
|
||||||
{
|
{
|
||||||
exit(0);
|
playerY += .8;
|
||||||
}
|
}
|
||||||
|
|
||||||
glutPostRedisplay();
|
// Rotation
|
||||||
glutTimerFunc(30, &updateTimer, 0);
|
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
|
||||||
}
|
{
|
||||||
|
playerRotY -= 1.8;
|
||||||
int main(int argc, char **argv)
|
}
|
||||||
{
|
|
||||||
glutInit(&argc, argv);
|
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
{
|
||||||
glutInitWindowSize(800, 600);
|
playerRotY += 1.8;
|
||||||
glutCreateWindow("XtreemNodes Engine - By MCL Software and Cube Software");
|
}
|
||||||
|
|
||||||
glClearColor(.4, .7, .8 , 255);
|
if(sf::Keyboard::isKeyPressed(sf::Keyboard::F1))
|
||||||
glEnable(GL_DEPTH_TEST);
|
{
|
||||||
glEnable(GL_TEXTURE_2D);
|
levelGen.setSeed();
|
||||||
//glEnable(GL_CULL_FACE);
|
levelGen.generateBlock();
|
||||||
//glCullFace(GL_FRONT);
|
}
|
||||||
//glFrontFace(GL_CCW);
|
|
||||||
|
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
|
||||||
// Load textures
|
{
|
||||||
textureHandler.loadAllTextures();
|
playerRotX += 1.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
|
||||||
|
{
|
||||||
|
playerRotX = 1.8;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
// Mouse-based movement
|
||||||
for(int y = 0; y < 16; y++)
|
sf::Vector2i mousePos = sf::Mouse::getPosition();
|
||||||
{
|
sf::Vector2i mousePosDiff = oldMousePos - mousePos;
|
||||||
for(int x = 0; x < 16; x++)
|
playerRotX -= mousePosDiff.y;
|
||||||
{
|
playerRotY -= mousePosDiff.x;
|
||||||
for(int z = 0; z < 16; z++)
|
oldMousePos = sf::Vector2i(1920 / 2, 1080 / 2);
|
||||||
{
|
sf::Mouse::setPosition(sf::Vector2i(1920 / 2, 1080 / 2));
|
||||||
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
|
|
||||||
printf("\n|x: %i |y: %i | z: %i | id: %i", x, y, z, blockManager.getNodeAt(x, y, z));
|
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
|
||||||
|
{
|
||||||
}
|
printf("PlayerX: %f, PlayerZ: %f", playerX, playerZ);
|
||||||
}
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
glutPostRedisplay();
|
||||||
|
glutTimerFunc(30, &updateTimer, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
updateTimer(0);
|
{
|
||||||
glutDisplayFunc(&display);
|
glutInit(&argc, argv);
|
||||||
glutReshapeFunc(&reshape);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
|
glutInitWindowSize(1920, 1080);
|
||||||
glutMainLoop();
|
glutCreateWindow("XtreemNodes Engine - by MCL Software");
|
||||||
|
|
||||||
return 0;
|
glClearColor(.4, .7, .8 , 255);
|
||||||
}
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
//glEnable(GL_CULL_FACE);
|
||||||
|
//glCullFace(GL_FRONT);
|
||||||
|
//glFrontFace(GL_CCW);
|
||||||
|
|
||||||
|
// Load textures
|
||||||
|
textureHandler.loadAllTextures();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
for(int y = 0; y < 16; y++)
|
||||||
|
{
|
||||||
|
for(int x = 0; x < 16; x++)
|
||||||
|
{
|
||||||
|
for(int z = 0; z < 16; z++)
|
||||||
|
{
|
||||||
|
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
|
||||||
|
printf("\n|x: %i |y: %i | z: %i | id: %i", x, y, z, blockManager.getNodeAt(x, y, z));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
levelGen.generateBlock();
|
||||||
|
|
||||||
|
updateTimer(0);
|
||||||
|
glutDisplayFunc(&display);
|
||||||
|
glutReshapeFunc(&reshape);
|
||||||
|
|
||||||
|
glutMainLoop();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user