Big stupid bug fixed
This commit is contained in:
parent
51abb756a5
commit
035906e1e7
4 changed files with 36 additions and 34 deletions
|
@ -23,4 +23,5 @@ void main(void)
|
||||||
vec3 ripple = (1.0 + cos(In.Pos.x * PI)) * (1.0 + cos(In.Pos.y * PI)) * In.Att1.x *
|
vec3 ripple = (1.0 + cos(In.Pos.x * PI)) * (1.0 + cos(In.Pos.y * PI)) * In.Att1.x *
|
||||||
vec3(0, cos(phase), 0);
|
vec3(0, cos(phase), 0);
|
||||||
Color = vec4(ripple, 1);
|
Color = vec4(ripple, 1);
|
||||||
|
//Color = vec4(0, In.Att1.w, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ uniform mat4 matrProj;
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
layout(location=0) in vec4 Pos;
|
layout(location=0) in vec4 Pos;
|
||||||
layout(location=4) in vec4 Att1;
|
layout(location=1) in vec4 Att1;
|
||||||
layout(location=8) in vec4 Att2;
|
layout(location=2) in vec4 Att2;
|
||||||
|
|
||||||
out Attribs {
|
out Attribs {
|
||||||
vec4 Pos;
|
vec4 Pos;
|
||||||
|
|
|
@ -7,8 +7,8 @@ uniform mat4 matrProj;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
layout(location=0) in vec2 Vertex;
|
in vec2 Vertex;
|
||||||
layout(location=8) in vec2 TexCoord;
|
in vec2 TexCoord;
|
||||||
|
|
||||||
out Attribs {
|
out Attribs {
|
||||||
vec3 pos;
|
vec3 pos;
|
||||||
|
|
61
ripple.cpp
61
ripple.cpp
|
@ -143,7 +143,7 @@ const int terrainH = 1024;
|
||||||
|
|
||||||
// Wave Packets
|
// Wave Packets
|
||||||
Packets *packets;
|
Packets *packets;
|
||||||
int packetBudget = 10000;
|
int packetBudget = 100000;
|
||||||
/* Wave packets:
|
/* Wave packets:
|
||||||
* vec4: xy = position, zw = direction
|
* vec4: xy = position, zw = direction
|
||||||
* vec4: x = amplitude, y = wavelength, z = phase offset, w = enveloppe size
|
* vec4: x = amplitude, y = wavelength, z = phase offset, w = enveloppe size
|
||||||
|
@ -152,6 +152,9 @@ GLfloat packetData[PACKET_GPU_BUFFER_SIZE * 3 * 4];
|
||||||
|
|
||||||
int nIndexDMM = 0;
|
int nIndexDMM = 0;
|
||||||
|
|
||||||
|
bool debug = false;
|
||||||
|
int printonce = 0;
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
// déclaration des variables globales //
|
// déclaration des variables globales //
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
|
@ -247,26 +250,6 @@ void verifierAngles()
|
||||||
|
|
||||||
void calculerPhysique( )
|
void calculerPhysique( )
|
||||||
{
|
{
|
||||||
if ( /* enmouvement */ false)
|
|
||||||
{
|
|
||||||
static int sensTheta = 1;
|
|
||||||
static int sensPhi = 1;
|
|
||||||
thetaCam += 0.3 * sensTheta;
|
|
||||||
phiCam += 0.5 * sensPhi;
|
|
||||||
//if ( thetaCam <= 0. || thetaCam >= 360.0 ) sensTheta = -sensTheta;
|
|
||||||
if ( phiCam < -90.0 || phiCam > 90.0 ) sensPhi = -sensPhi;
|
|
||||||
|
|
||||||
static int sensAngle = 1;
|
|
||||||
LightSource[0].spotAngle += sensAngle * 0.3;
|
|
||||||
if ( LightSource[0].spotAngle < 5.0 ) sensAngle = -sensAngle;
|
|
||||||
if ( LightSource[0].spotAngle > 60.0 ) sensAngle = -sensAngle;
|
|
||||||
|
|
||||||
// De temps à autre, alterner entre le modèle d'illumination: Lambert, Gouraud, Phong
|
|
||||||
static float type = 0;
|
|
||||||
type += 0.005;
|
|
||||||
varsUnif.typeIllumination = fmod(type,3);
|
|
||||||
}
|
|
||||||
|
|
||||||
verifierAngles();
|
verifierAngles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +262,8 @@ void updatePackets()
|
||||||
|
|
||||||
// TODO Setup wide projection for InitiateWaveField (RasterizeWaveMeshPosition)
|
// TODO Setup wide projection for InitiateWaveField (RasterizeWaveMeshPosition)
|
||||||
|
|
||||||
heightFBO->CommencerCapture();
|
if (!debug)
|
||||||
|
heightFBO->CommencerCapture();
|
||||||
int displayedPackets = 0;
|
int displayedPackets = 0;
|
||||||
int packetChunk =0;
|
int packetChunk =0;
|
||||||
/* Standard wave packets */
|
/* Standard wave packets */
|
||||||
|
@ -317,6 +301,7 @@ void updatePackets()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printonce++;
|
||||||
// printf("PacketData[0] = %f , %f\n", packetData[0], packetData[1]);
|
// printf("PacketData[0] = %f , %f\n", packetData[0], packetData[1]);
|
||||||
/* Ghost packets */
|
/* Ghost packets */
|
||||||
for (int i = 0; i < packets->m_usedGhosts; ++i) {
|
for (int i = 0; i < packets->m_usedGhosts; ++i) {
|
||||||
|
@ -354,8 +339,9 @@ void updatePackets()
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
//displayPacketOutlined(packetChunk / 12);
|
//displayPacketOutlined(packetChunk / 12);
|
||||||
/* TODO EvaluatePackets(packetChunk) */
|
/* TODO EvaluatePackets(packetChunk) */
|
||||||
addPacketDisplacement(packetChunk / 12);
|
addPacketDisplacement(displayedPackets);
|
||||||
heightFBO->TerminerCapture();
|
if (!debug)
|
||||||
|
heightFBO->TerminerCapture();
|
||||||
/* TODO DisplayScene */
|
/* TODO DisplayScene */
|
||||||
/* TODO Get camera center */
|
/* TODO Get camera center */
|
||||||
}
|
}
|
||||||
|
@ -490,7 +476,6 @@ void chargerNuanceurs()
|
||||||
locmatrModelAPD = getloc( progAddPacketDisplacement, "matrModel" , LocUniform);
|
locmatrModelAPD = getloc( progAddPacketDisplacement, "matrModel" , LocUniform);
|
||||||
locmatrVisuAPD = getloc( progAddPacketDisplacement, "matrVisu" , LocUniform);
|
locmatrVisuAPD = getloc( progAddPacketDisplacement, "matrVisu" , LocUniform);
|
||||||
locmatrProjAPD = getloc( progAddPacketDisplacement, "matrProj" , LocUniform);
|
locmatrProjAPD = getloc( progAddPacketDisplacement, "matrProj" , LocUniform);
|
||||||
locTexAPD = getloc( progAddPacketDisplacement, "tex" , LocUniform);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load DisplayPacketOutlined shader
|
// Load DisplayPacketOutlined shader
|
||||||
|
@ -596,8 +581,8 @@ void initPacketMesh()
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vboPacket);
|
glBindBuffer(GL_ARRAY_BUFFER, vboPacket);
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(packetData), NULL, GL_DYNAMIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, sizeof(packetData), NULL, GL_DYNAMIC_DRAW);
|
||||||
glVertexAttribPointer(locPosAPD, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 12, (void*)0);
|
glVertexAttribPointer(locPosAPD, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 12, (void*)0);
|
||||||
glVertexAttribPointer(locAtt1APD, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 12, (void*)4);
|
glVertexAttribPointer(locAtt1APD, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 12, (void*)(4*sizeof(GLfloat)));
|
||||||
glVertexAttribPointer(locAtt2APD, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 12, (void*)8);
|
glVertexAttribPointer(locAtt2APD, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 12, (void*)(8*sizeof(GLfloat)));
|
||||||
glEnableVertexAttribArray(locPosAPD);
|
glEnableVertexAttribArray(locPosAPD);
|
||||||
glEnableVertexAttribArray(locAtt1APD);
|
glEnableVertexAttribArray(locAtt1APD);
|
||||||
glEnableVertexAttribArray(locAtt2APD);
|
glEnableVertexAttribArray(locAtt2APD);
|
||||||
|
@ -606,8 +591,8 @@ void initPacketMesh()
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vboPacket);
|
glBindBuffer(GL_ARRAY_BUFFER, vboPacket);
|
||||||
/* No need to initialize the buffer a second time */
|
/* No need to initialize the buffer a second time */
|
||||||
glVertexAttribPointer(locPosDPO, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 12, (void*)0);
|
glVertexAttribPointer(locPosDPO, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 12, (void*)0);
|
||||||
glVertexAttribPointer(locAtt1DPO, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 12, (void*)4);
|
glVertexAttribPointer(locAtt1DPO, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 12, (void*)(4*sizeof(GLfloat)));
|
||||||
glVertexAttribPointer(locAtt2DPO, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 12, (void*)8);
|
glVertexAttribPointer(locAtt2DPO, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 12, (void*)(8*sizeof(GLfloat)));
|
||||||
glEnableVertexAttribArray(locPosDPO);
|
glEnableVertexAttribArray(locPosDPO);
|
||||||
glEnableVertexAttribArray(locAtt1DPO);
|
glEnableVertexAttribArray(locAtt1DPO);
|
||||||
glEnableVertexAttribArray(locAtt2DPO);
|
glEnableVertexAttribArray(locAtt2DPO);
|
||||||
|
@ -807,7 +792,8 @@ void afficherModele()
|
||||||
updatePackets();
|
updatePackets();
|
||||||
glClearColor( 0.5, 0.6, 0.8, 0.0 );
|
glClearColor( 0.5, 0.6, 0.8, 0.0 );
|
||||||
displayTerrain();
|
displayTerrain();
|
||||||
displayMicroMesh();
|
if (!debug)
|
||||||
|
displayMicroMesh();
|
||||||
} matrModel.PopMatrix();
|
} matrModel.PopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -958,6 +944,11 @@ void FenetreTP::clavier( TP_touche touche )
|
||||||
goD = 1;
|
goD = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TP_h:
|
||||||
|
debug = !debug;
|
||||||
|
printf("Debug is %s!\n", (debug ? "active" : "inactive"));
|
||||||
|
break;
|
||||||
|
|
||||||
case TP_x: // Activer/désactiver l'affichage des axes
|
case TP_x: // Activer/désactiver l'affichage des axes
|
||||||
afficheAxes = !afficheAxes;
|
afficheAxes = !afficheAxes;
|
||||||
std::cout << "// Affichage des axes ? " << ( afficheAxes ? "OUI" : "NON" ) << std::endl;
|
std::cout << "// Affichage des axes ? " << ( afficheAxes ? "OUI" : "NON" ) << std::endl;
|
||||||
|
@ -969,20 +960,29 @@ void FenetreTP::clavier( TP_touche touche )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TP_r:
|
case TP_r:
|
||||||
|
packets->Reset();
|
||||||
|
printonce = 0;
|
||||||
|
printf("Reseting...\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TP_e:
|
||||||
// Send one wave front "One ping only."
|
// Send one wave front "One ping only."
|
||||||
packets->CreateCircularWavefront(0.0, 0.0, 2.0, 0.2, 1.0, 10000);
|
packets->CreateCircularWavefront(0.0, 0.0, 2.0, 0.2, 1.0, 10000);
|
||||||
|
printonce = 0;
|
||||||
printf("Sending a circular wavefront...\n");
|
printf("Sending a circular wavefront...\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TP_f:
|
case TP_f:
|
||||||
// Send one wave front "One ping only."
|
// Send one wave front "One ping only."
|
||||||
packets->CreateLinearWavefront(0.0, 0.0, 1.0, 0.0, 2.0, 0.2, 1.0, 10000);
|
packets->CreateLinearWavefront(0.0, 0.0, 1.0, 0.0, 2.0, 0.2, 1.0, 10000);
|
||||||
|
printonce = 0;
|
||||||
printf("Sending a linear wavefront...\n");
|
printf("Sending a linear wavefront...\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TP_a:
|
case TP_a:
|
||||||
// Send one packet
|
// Send one packet
|
||||||
packets->CreateSpreadingPacket(0.0, 0.0, 1.0, 0.0, 1.0, 2.0, 0.2, 1.0, 10000);
|
packets->CreateSpreadingPacket(0.0, 0.0, 1.0, 0.0, 1.0, 2.0, 0.2, 1.0, 10000);
|
||||||
|
printonce = 0;
|
||||||
printf("Sending a spreading packet...\n");
|
printf("Sending a spreading packet...\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -997,6 +997,7 @@ void FenetreTP::clavier( TP_touche touche )
|
||||||
|
|
||||||
case TP_p: // Permuter la rotation automatique du modèle
|
case TP_p: // Permuter la rotation automatique du modèle
|
||||||
enmouvement = !enmouvement;
|
enmouvement = !enmouvement;
|
||||||
|
printf("Simulation %s\n", (enmouvement ? "running" : "stopped"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue