Fixed wall UV mappings

linux_template
sigonasr2 2 years ago
parent afeadd3e6c
commit b0e348658c
  1. 1
      Faceball2030/Faceball2030.vcxproj
  2. BIN
      Faceball2030/assets/yazawa.png
  3. 63
      Faceball2030/main.cpp
  4. 3
      Faceball2030/main.h

@ -119,6 +119,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

Binary file not shown.

After

Width:  |  Height:  |  Size: 659 KiB

@ -36,8 +36,8 @@ void FaceBall::LoadLevel(int level)
std::vector<MapSquare>row;
for (int x = 0; x < MAP_SIZE.x; x++) {
row.push_back({});
mapMesh.tris.push_back({ {{(float)x,0,(float)y},{(float)x,0,(float)y + 1},{(float)x + 1,0,(float)y}},{{0,0},{1,0},{0,1}},BLUE });
mapMesh.tris.push_back({ {{(float)x + 1,0,(float)y},{(float)x,0,(float)y + 1},{(float)x + 1,0,(float)y + 1}},{{0,0},{1,0},{0,1}},BLUE });
mapMesh.tris.push_back({ {{(float)x,0,(float)y},{(float)x,0,(float)y + 1},{(float)x + 1,0,(float)y}},{{0,0},{0,1},{1,0}},BLUE });
mapMesh.tris.push_back({ {{(float)x + 1,0,(float)y},{(float)x,0,(float)y + 1},{(float)x + 1,0,(float)y + 1}},{{1,0},{0,1},{1,1}},BLUE });
}
map.push_back(row);
}
@ -58,20 +58,20 @@ void FaceBall::LoadLevel(int level)
}
AddWall(wallData, { x,y });
if (map[y][x].wallN != NULL) {
mapMesh.tris.push_back({ {{(float)x,1,(float)y},{(float)x,0,(float)y},{(float)x + 1,1,(float)y}},{{0,0},{1,0},{0,1}},YELLOW });
mapMesh.tris.push_back({ {{(float)x,0,(float)y},{(float)x + 1,0,(float)y},{(float)x + 1,1,(float)y}},{{0,0},{1,0},{0,1}},YELLOW });
mapMesh.tris.push_back({ {{(float)x,1,(float)y},{(float)x,0,(float)y},{(float)x + 1,1,(float)y}},{{0,0},{0,1},{1,0}},YELLOW });
mapMesh.tris.push_back({ {{(float)x,0,(float)y},{(float)x + 1,0,(float)y},{(float)x + 1,1,(float)y}},{{0,1},{1,1},{1,0}},YELLOW });
}
if (map[y][x].wallS != NULL) {
mapMesh.tris.push_back({ {{(float)x + 1,1,(float)y + 1},{(float)x,0,(float)y + 1},{(float)x,1,(float)y + 1}},{{0,0},{1,0},{0,1}},DARK_RED });
mapMesh.tris.push_back({ {{(float)x + 1,1,(float)y + 1},{(float)x + 1,0,(float)y + 1},{(float)x,0,(float)y + 1}},{{0,0},{1,0},{0,1}},DARK_RED });
mapMesh.tris.push_back({ {{(float)x + 1,1,(float)y + 1},{(float)x,0,(float)y + 1},{(float)x,1,(float)y + 1}},{{0,0},{1,1},{1,0}},DARK_RED });
mapMesh.tris.push_back({ {{(float)x + 1,1,(float)y + 1},{(float)x + 1,0,(float)y + 1},{(float)x,0,(float)y + 1}},{{0,0},{0,1},{1,1}},DARK_RED });
}
if (map[y][x].wallW != NULL) {
mapMesh.tris.push_back({ {{(float)x,1,(float)y},{(float)x,1,(float)y + 1}, {(float)x,0,(float)y + 1}},{{0,0},{1,0},{0,1}},MAGENTA });
mapMesh.tris.push_back({ {{(float)x,0,(float)y},{(float)x,1,(float)y}, {(float)x,0,(float)y + 1}}, {{0,0},{1,0},{0,1}},MAGENTA });
mapMesh.tris.push_back({ {{(float)x,1,(float)y},{(float)x,1,(float)y + 1}, {(float)x,0,(float)y + 1}},{{1,0},{0,0},{0,1}},MAGENTA });
mapMesh.tris.push_back({ {{(float)x,0,(float)y},{(float)x,1,(float)y}, {(float)x,0,(float)y + 1}}, {{1,1},{1,0},{0,1}},MAGENTA });
}
if (map[y][x].wallE != NULL) {
mapMesh.tris.push_back({ {{(float)x + 1,0,(float)y + 1},{(float)x + 1,1,(float)y + 1},{(float)x + 1,1,(float)y}},{{0,0},{1,0},{0,1}},CYAN });
mapMesh.tris.push_back({ {{(float)x + 1,0,(float)y + 1} ,{(float)x + 1,1,(float)y},{(float)x + 1,0,(float)y}},{{0,0},{1,0},{0,1}},CYAN });
mapMesh.tris.push_back({ {{(float)x + 1,0,(float)y + 1},{(float)x + 1,1,(float)y + 1},{(float)x + 1,1,(float)y}},{{1,1},{1,0},{0,0}},CYAN });
mapMesh.tris.push_back({ {{(float)x + 1,0,(float)y + 1} ,{(float)x + 1,1,(float)y},{(float)x + 1,0,(float)y}},{{1,1},{0,0},{0,1}},CYAN });
}
}
}
@ -472,8 +472,8 @@ void FaceBall::RenderWorld() {
vec3d vTarget = { 0,sinf(pitch),cosf(pitch) };
mat4x4 matCameraRot = Matrix_MakeRotationY(fYaw);
vLookDir = Matrix_MultiplyVector(matCameraRot, vTarget);
vTarget = Vector_Add(player.GetPos(), vLookDir);
mat4x4 matCamera = Matrix_PointAt(player.GetPos(), vTarget, vUp);
vTarget = Vector_Add(freeRoam?freeRoamCamera:player.GetPos(), vLookDir);
mat4x4 matCamera = Matrix_PointAt(freeRoam?freeRoamCamera:player.GetPos(), vTarget, vUp);
mat4x4 matView = Matrix_QuickInverse(matCamera);
std::vector<Triangle>vecTrianglesToRaster;
@ -505,7 +505,7 @@ void FaceBall::RenderWorld() {
normal = Vector_CrossProduct(line1, line2);
normal = Vector_Normalise(normal);
vec3d vCameraRay = Vector_Sub(triTransformed.p[0], player.GetPos());
vec3d vCameraRay = Vector_Sub(triTransformed.p[0], freeRoam?freeRoamCamera:player.GetPos());
if (Vector_DotProduct(normal, vCameraRay) < 0) {
vec3d light_dir = Vector_Mul(vLookDir, -1);
@ -666,24 +666,34 @@ void FaceBall::HandleKeys(float fElapsedTime) {
pitch = 0;
}
if (GetKey(W).bHeld) {
if (!CheckCollision({ vForward.x,0,0 })) {
vec3d xMovement{ vForward.x,0,0 };
player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
if (freeRoam) {
freeRoamCamera = Vector_Add(freeRoamCamera, vForward);
}
if (!CheckCollision({0,0,vForward.z})) {
vec3d zMovement{ 0,0,vForward.z };
player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
else {
if (!CheckCollision({ vForward.x,0,0 })) {
vec3d xMovement{ vForward.x,0,0 };
player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
}
if (!CheckCollision({ 0,0,vForward.z })) {
vec3d zMovement{ 0,0,vForward.z };
player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
}
}
}
if (GetKey(S).bHeld) {
vec3d vReverse = { -vForward.x,-vForward.y,-vForward.z };
if (!CheckCollision({ vReverse.x,0,0 })) {
vec3d xMovement{ vReverse.x,0,0 };
player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
if (freeRoam) {
freeRoamCamera = Vector_Add(freeRoamCamera, vReverse);
}
if (!CheckCollision({ 0,0,vReverse.z })) {
vec3d zMovement{ 0,0,vReverse.z };
player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
else {
if (!CheckCollision({ vReverse.x,0,0 })) {
vec3d xMovement{ vReverse.x,0,0 };
player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
}
if (!CheckCollision({ 0,0,vReverse.z })) {
vec3d zMovement{ 0,0,vReverse.z };
player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
}
}
}
if (GetKey(olc::A).bHeld) {
@ -733,11 +743,12 @@ bool FaceBall::OnUserCreate()
circle = new Decal(new Sprite("assets/circle.png"));
arrow = new Decal(new Sprite("assets/arrow.png"));
enemy_ShootMe_tex = new Decal(new Sprite("assets/enemies/ShootMe.png"));
YAZAWA = new Decal(new Sprite("assets/yazawa.png"));
InitializeEnemyData();
Mesh testEnemy("assets/enemies/ShootMe.obj", enemy_ShootMe_tex);
mapMesh.texture = dot;
mapMesh.texture = YAZAWA;
LoadLevel(1);

@ -169,7 +169,7 @@ class FaceBall : public PixelGameEngine
}
EnemyData GetData(EnemyID id);
Decal* circle,*arrow;
Decal* circle,*arrow,*YAZAWA;
private:
Mesh mapMesh;
@ -193,6 +193,7 @@ class FaceBall : public PixelGameEngine
float pitch = -PI / 6;
Player player = { {3.7,0.3,0.7}, {{0.5,0.5},0.2} };
vec3d freeRoamCamera = { 1,0.5,1 };
vec3d Matrix_MultiplyVector(mat4x4& m, vec3d& i);
mat4x4 Matrix_MakeIdentity();

Loading…
Cancel
Save