diff --git a/Globals.cpp b/Globals.cpp index 13d4520..914660c 100644 --- a/Globals.cpp +++ b/Globals.cpp @@ -5,8 +5,10 @@ int const Globals::gen = 0; int const Globals::major = 0; int const Globals::minor = 4; int const Globals::patch = 2; +int Globals::surfaceId = 2; bool Globals::showMouse = true; bool Globals::useMousePoint = false; +G3D::TextureRef Globals::surface; POINT Globals::mousepoint; Globals::Globals(void){} diff --git a/Globals.h b/Globals.h index db0e4b5..f0052d2 100644 --- a/Globals.h +++ b/Globals.h @@ -1,5 +1,6 @@ #pragma once #include "DataModelInstance.h" +#include class Globals { @@ -14,4 +15,6 @@ public: static const int major; static const int minor; static const int patch; + static G3D::TextureRef surface; + static int surfaceId; }; \ No newline at end of file diff --git a/PhysicalInstance.cpp b/PhysicalInstance.cpp index bbb607a..7c97dce 100644 --- a/PhysicalInstance.cpp +++ b/PhysicalInstance.cpp @@ -1,4 +1,5 @@ #include "PhysicalInstance.h" +#include "Globals.h" bool canCollide = true; bool anchored = false; Vector3 size; @@ -130,36 +131,77 @@ void PhysicalInstance::render(RenderDevice* rd) { if(changed) Box box = getBox(); + glColor(color); - glBegin(GL_QUADS); + /*glEnable( GL_TEXTURE_2D ); + glEnable(GL_BLEND);// you enable blending function + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture( GL_TEXTURE_2D, Globals::surfaceId); + glBegin(GL_QUADS);*/ for(int i = 0; i < 96; i+=16) { + double add = 0.8; + Surface face; if(i == 0)//Back { + face = back; } - if(i == 16)//Right + else if(i == 16)//Right { + face = right; } - if(i == 32)//Front + else if(i == 32)//Front { + face = front; } else if(i == 48)//Top { + face = top; } else if(i == 64)//Left { + face = left; } else if(i == 80)//Bottom { + face = bottom; } + + if(face == Snaps) + add = 0.0; + else if(face == Inlets) + add = 0.2; + Vector3 v0 = Vector3(vertecies[i], vertecies[i+1], vertecies[i+2]), v1 = Vector3(vertecies[i+3], vertecies[i+4], vertecies[i+5]), v3 = Vector3(vertecies[i+9], vertecies[i+10], vertecies[i+11]); - glNormal3fv((v1 - v0).cross(v3 - v0).direction()); + /*glNormal3fv((v1 - v0).cross(v3 - v0).direction()); + glTexCoord2f(0.0F,0.0F); glVertex3fv(v0); + glTexCoord2f(1.0F,0.0F); glVertex3fv(v1); + glTexCoord2f(1.0F,0.25F); glVertex3f(vertecies[i+6], vertecies[i+7], vertecies[i+8]); + glTexCoord2f(0.0F,0.25F); + glVertex3fv(v3);*/ + + glEnable( GL_TEXTURE_2D ); + glEnable(GL_BLEND);// you enable blending function + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture( GL_TEXTURE_2D, Globals::surfaceId); + glBegin( GL_QUADS ); + glNormal3fv((v1 - v0).cross(v3 - v0).direction()); + glTexCoord2d(0.0,0.0+add); + glVertex3fv(v0); + glTexCoord2d( 1.0,0.0+add); + glVertex3fv(v1); + glTexCoord2d(1.0,0.2+add); + glVertex3f(vertecies[i+6], vertecies[i+7], vertecies[i+8]); + glTexCoord2d( 0.0,0.2+add); glVertex3fv(v3); + glEnd(); + glDisable( GL_TEXTURE_2D ); } - glEnd(); + /*glEnd(); + glDisable(GL_TEXTURE_2D);*/ glColor(Color3::white()); if(!children.empty()) { diff --git a/content/images/surface.png b/content/images/surface.png new file mode 100644 index 0000000..1be30dc Binary files /dev/null and b/content/images/surface.png differ diff --git a/content/images/surfacebr.png b/content/images/surfacebr.png new file mode 100644 index 0000000..6c41c96 Binary files /dev/null and b/content/images/surfacebr.png differ diff --git a/main.cpp b/main.cpp index 21aacc9..dabb245 100644 --- a/main.cpp +++ b/main.cpp @@ -1428,6 +1428,8 @@ void Demo::run() { // Load objects here= cursor = Texture::fromFile(GetFileInPath("/content/cursor2.png")); + Globals::surface = Texture::fromFile(GetFileInPath("/content/images/surfacebr.png")); + Globals::surfaceId = Globals::surface->getOpenGLID(); fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt")); fntlighttrek = GFont::fromFile(GetFileInPath("/content/font/lighttrek.fnt")); cameraSound = GetFileInPath("/content/sounds/SWITCH3.wav");