Commit 8d755aaa authored by Thomas Jund's avatar Thomas Jund
Browse files

avec les obj et textures pour la ville

parent 002ed37a
......@@ -606,15 +606,16 @@ void generatePlanet(EnvMap& envMap)
{
unsigned int nx = envMap.geometry.size(0) / envMap.maxCellSize ;
unsigned int ny = envMap.geometry.size(1) / envMap.maxCellSize ;
if (nx < 1) nx = 1 ;
if (ny < 1) ny = 1 ;
if (nx < 1)
nx = 1 ;
if (ny < 1)
ny = 1 ;
Algo::Surface::Modelisation::Polyhedron<PFP> prim(envMap.map, envMap.position) ;
prim.cylinder_topo(nx, ny, true, true) ;
double pi = 3.14159265358979323846f ;
double xRadius = envMap.geometry.size(0) / 2 * pi ;
double yRadius = envMap.geometry.size(1) / 2 * pi ;
double xRadius = envMap.geometry.size(0) / 2 * M_PI;
double yRadius = envMap.geometry.size(1) / 2 * M_PI ;
prim.embedSphere((xRadius+yRadius)/2.0f) ;
}
......@@ -624,6 +625,7 @@ typename PFP::VEC3 parametrization(typename PFP::VEC3 p, float r,const Geom::Bou
{
p[0] = 2.0f*M_PI*(p[0]-bb.min()[0])/bb.size(0);
p[1] = ((2.0f*M_PI*(p[1]-bb.min()[1])/bb.size(1))-M_PI)/2.0f;
r += p[2];
return typename PFP::VEC3(2.0f*r*cos(p[0])*cos(p[1]),
2.0f*r*sin(p[0])*cos(p[1]),
......
......@@ -32,7 +32,7 @@ class ArticulatedObstacle;
#include "pfp.h"
//#define EXPORTING3
#define EXPORTING3
#ifdef EXPORTING3
#include "Utils/Shaders/shaderPhongTexture.h"
......@@ -108,6 +108,8 @@ public:
PFP::TVEC3 position ;
PFP::TVEC3 normal ;
Geom::BoundingBox<PFP::VEC3> bb;
PFP::MAP mapScenary ;
PFP::TVEC3 positionScenary ;
PFP::TVEC3 normalScenary ;
......
......@@ -58,8 +58,8 @@ public:
Utils::VBO* m_texcoordVBO;
// Utils::ShaderPhongTexture* m_shaderTex;
Utils::ShaderSimpleTexture* m_shaderTex;
Utils::ShaderPhongTexture* m_shaderTex;
// Utils::ShaderSimpleTexture* m_shaderTex;
Algo::Surface::Import::OBJModel<PFP2> m_obj;
unsigned int m_nbIndices;
#else
......
// ShaderCustomTex::fragmentShaderText
PRECISON;
uniform sampler2D textureUnit;
in vec3 N;
in vec2 fragTexCoord;
FRAG_OUT_DEF;
void main()
{
gl_FragData[0] = texture2D(textureUnit,fragTexCoord);
gl_FragData[1] = vec4( 0.5*normalize(N)+vec3(0.5), 1.0 );
}
\ No newline at end of file
// ShaderCustomTex::geometryShaderText
VARYING_IN vec2 texCoord[];
VARYING_OUT vec2 fragTexCoord;
VARYING_OUT vec3 N;
void main(void)
{
vec3 v1 = POSITION_IN(1).xyz - POSITION_IN(0).xyz;
vec3 v2 = POSITION_IN(2).xyz - POSITION_IN(0).xyz;
N = cross(v1,v2);
N = normalize(N);
int i;
for(i=0; i< NBVERTS_IN; i++)
{
gl_Position = POSITION_IN(i);
fragTexCoord = texCoord[i];
EmitVertex();
}
EndPrimitive();
}
#ifndef __SHADER_CUSTOMTEX__
#define __SHADER_CUSTOMTEX__
#include "Utils/GLSLShader.h"
#include "Geometry/vector_gen.h"
#include "Utils/clippingShader.h"
#include "Utils/textures.h"
#include "Utils/gl_def.h"
using namespace CGoGN;
class ShaderCustomTex : public Utils::ClippingShader
{
protected:
// shader sources
static std::string vertexShaderText;
static std::string fragmentShaderText;
static std::string geometryShaderText;
CGoGNGLuint m_unif_unit;
int m_unit;
Utils::GTexture* m_tex_ptr;
Utils::VBO* m_vboPos;
Utils::VBO* m_vboTexCoord;
void restoreUniformsAttribs();
public:
ShaderCustomTex();
/**
* choose the texture unit engine to use for this texture
*/
void setTextureUnit(GLenum texture_unit);
/**
* set the texture to use
*/
void setTexture(Utils::GTexture* tex);
/**
* activation of texture unit with set texture
*/
void activeTexture();
/**
* activation of texture unit with texture id
*/
void activeTexture(CGoGNGLuint texId);
unsigned int setAttributePosition(Utils::VBO* vbo);
unsigned int setAttributeTexCoord(Utils::VBO* vbo);
};
#endif
// ShaderCustomTex::vertexShaderText
ATTRIBUTE vec3 VertexPosition;
ATTRIBUTE vec2 VertexTexCoord;
uniform mat4 ModelViewProjectionMatrix;
VARYING_VERT vec2 texCoord;
INVARIANT_POS;
void main ()
{
gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);
texCoord = VertexTexCoord;
}
......@@ -53,7 +53,7 @@
#include "shaderCustom.h"
#define EXPORTING
//#define EXPORTING
using namespace CGoGN ;
......
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
This image diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment