mirror of
https://github.com/ApfelTeeSaft/vb01.git
synced 2026-08-26 19:33:45 +00:00
implemented material texture changing
This commit is contained in:
@@ -5,23 +5,13 @@ layout (location=2) in vec2 aTexCoords;
|
||||
|
||||
out vec2 texCoords;
|
||||
|
||||
uniform bool spatialToScreen;
|
||||
uniform vec2 screen;
|
||||
uniform vec3 pos;
|
||||
uniform mat4 proj;
|
||||
uniform mat4 view;
|
||||
uniform mat4 model;
|
||||
|
||||
void main(){
|
||||
if(!spatialToScreen){
|
||||
float x,y;
|
||||
x=(aVert.x+pos.x-screen.x*.5)/(screen.x*.5);
|
||||
y=(screen.y*.5-(aVert.y+pos.y))/(screen.y*.5);
|
||||
gl_Position=vec4(x,y,pos.z+aVert.z,1);
|
||||
}
|
||||
else{
|
||||
vec3 pos=vec3(proj*view*model*vec4(aVert,1));
|
||||
gl_Position=vec4(pos.xy,aVert.z,1);
|
||||
}
|
||||
texCoords=aTexCoords;
|
||||
}
|
||||
|
||||
+11
-6
@@ -14,11 +14,14 @@ namespace vb01{
|
||||
Material(Type=MATERIAL_2D);
|
||||
~Material();
|
||||
void update();
|
||||
void addDiffuseMap(std::string diffuseMap){diffuseMapTextures.push_back(new Texture(diffuseMap));}
|
||||
void addDiffuseMap(std::string diffuseMap[6]){diffuseMapTextures.push_back(new Texture(diffuseMap));}
|
||||
void addDiffuseMap(Texture *texture){diffuseMapTextures.push_back(texture);}
|
||||
void addNormalMap(std::string normalMap){normalMapTextures.push_back(new Texture(normalMap));}
|
||||
void addSpecularMap(std::string specularMap){specularMapTextures.push_back(new Texture(specularMap));}
|
||||
inline void addDiffuseMap(std::string diffuseMap){diffuseMapTextures.push_back(new Texture(diffuseMap));}
|
||||
inline void addDiffuseMap(std::string diffuseMap[6]){diffuseMapTextures.push_back(new Texture(diffuseMap));}
|
||||
inline void addDiffuseMap(Texture *texture){diffuseMapTextures.push_back(texture);}
|
||||
inline void setDiffuseMap(Texture *texture, int i){diffuseMapTextures[i]=texture;}
|
||||
inline void addNormalMap(std::string normalMap){normalMapTextures.push_back(new Texture(normalMap));}
|
||||
inline void setNormalMap(Texture *texture, int i){normalMapTextures[i]=texture;}
|
||||
inline void addSpecularMap(std::string specularMap){specularMapTextures.push_back(new Texture(specularMap));}
|
||||
inline void setSpecularMap(Texture *texture, int i){specularMapTextures[i]=texture;}
|
||||
inline void setDiffuseColor(Vector4 diffuse){this->diffuseColor=diffuse;}
|
||||
inline void setSpecularColor(Vector4 specular){this->specularColor=specular;}
|
||||
inline void setLightingEnabled(bool lighting){this->lightingEnabled=lighting;}
|
||||
@@ -27,8 +30,10 @@ namespace vb01{
|
||||
inline bool isLightingEnabled(){return lightingEnabled;}
|
||||
inline bool isTexturingEnabled(){return texturingEnabled;}
|
||||
inline bool isDiffuseColorEnabled(){return diffuseColorEnabled;}
|
||||
inline Shader* getShader(){return shader;}
|
||||
inline Texture* getDiffuseMap(int i){return diffuseMapTextures[i];}
|
||||
inline Texture* getNormalMap(int i){return normalMapTextures[i];}
|
||||
inline Texture* getSpecularMap(int i){return specularMapTextures[i];}
|
||||
inline Shader* getShader(){return shader;}
|
||||
inline Type getType(){return type;}
|
||||
private:
|
||||
Type type;
|
||||
|
||||
@@ -106,7 +106,6 @@ namespace vb01{
|
||||
shader->setMat4(model,"model");
|
||||
if(material->getType()==Material::MATERIAL_GUI){
|
||||
shader->setVec2(Vector2((float)width,(float)height),"screen");
|
||||
//shader->setBool(spatialToScreen,"spatialToScreen");
|
||||
if(node)
|
||||
shader->setVec3(pos,"pos");
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace vb01{
|
||||
Mesh();
|
||||
void construct();
|
||||
|
||||
bool staticVerts=true,castShadow=false,spatialToScreen=false;
|
||||
bool staticVerts=true,castShadow=false;
|
||||
Vertex *vertices;
|
||||
unsigned int *indices,VAO,VBO,EBO;
|
||||
int numTris;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#include"quad.h"
|
||||
|
||||
namespace vb01{
|
||||
Quad::Quad(Vector3 size,bool spatial,bool spatialToScreen) : Mesh(){
|
||||
Quad::Quad(Vector3 size,bool spatial) : Mesh(){
|
||||
this->spatial=spatial;
|
||||
this->staticVerts=false;
|
||||
this->spatialToScreen=spatialToScreen;
|
||||
|
||||
int numPolyVerts=3;
|
||||
numTris=2;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace vb01{
|
||||
class Quad : public Mesh{
|
||||
public:
|
||||
Quad(Vector3,bool=true,bool=false);
|
||||
Quad(Vector3,bool=true);
|
||||
void setSize(Vector3);
|
||||
private:
|
||||
Vector3 size;
|
||||
|
||||
@@ -17,12 +17,14 @@ namespace vb01{
|
||||
Texture(std::string[6]);
|
||||
void select(int=0);
|
||||
inline unsigned int* getTexture(){return &texture;}
|
||||
inline std::string getPath(){return path;}
|
||||
private:
|
||||
TextureType type=TextureType::TEXTURE_2D;
|
||||
unsigned int texture;
|
||||
int width,height,numChannels;
|
||||
float weight;
|
||||
unsigned char *data;
|
||||
std::string path="",paths[6];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user