mirror of
https://github.com/ConjureETS/LOG750-LAB2.git
synced 2026-03-24 03:21:19 +00:00
Sphere rotat
This commit is contained in:
parent
0663336b94
commit
0d23827d81
@ -5,6 +5,7 @@ uniform bool isPhong;
|
||||
uniform sampler2D tex;
|
||||
uniform float skyMult;
|
||||
uniform bool drawTextures;
|
||||
uniform bool isLightSource;
|
||||
|
||||
in vec3 fNormal;
|
||||
in vec3 fPosition;
|
||||
@ -22,7 +23,9 @@ main()
|
||||
} else {
|
||||
texColor = ifColor;
|
||||
}
|
||||
if(isSky) {
|
||||
if(isLightSource) {
|
||||
fColor = texColor;
|
||||
} else if(isSky) {
|
||||
fColor = skyMult * normalize(texColor*texColor*texColor*2/1.41)*2;
|
||||
} else if(isPhong) {
|
||||
// Get lighting vectors
|
||||
|
||||
@ -3,6 +3,7 @@ uniform mat4 mvMatrix;
|
||||
uniform mat4 projMatrix;
|
||||
uniform mat3 normalMatrix;
|
||||
uniform vec3 lDirection;
|
||||
uniform bool isLightSource;
|
||||
|
||||
uniform vec4 color;
|
||||
|
||||
@ -30,7 +31,7 @@ main()
|
||||
|
||||
ifColor = color;
|
||||
|
||||
if(!isPhong && !isSky) {
|
||||
if(!isPhong && !isSky && !isLightSource) {
|
||||
// Get lighting vectors
|
||||
vec3 LightDirection = normalize(lDirection);
|
||||
vec3 nfNormal = normalize(fNormal);
|
||||
|
||||
@ -69,7 +69,7 @@ class SkyboxCamera : public qglviewer::Camera
|
||||
|
||||
Viewer::Viewer()
|
||||
{
|
||||
activeColor = new QColor(255, 255, 255, 255);
|
||||
activeColor = new QColor(255, 255, 255, 255);
|
||||
activeCell = nullptr;
|
||||
activeShape = 0;
|
||||
angle_mult = 0.1;
|
||||
@ -117,6 +117,7 @@ void Viewer::drawSkybox()
|
||||
m_program->setUniformValue(m_mvMatrixLocation, modelViewMatrix);
|
||||
m_program->setUniformValue(m_isSkyLoc, true);
|
||||
m_program->setUniformValue(m_drawTextLoc, true);
|
||||
m_program->setUniformValue(m_isLightLoc, false);
|
||||
|
||||
int faces = floor(numVerticesCube/6);
|
||||
for(int i = 0; i < faces; i++){ // 6 vertexes par face
|
||||
@ -162,6 +163,8 @@ void Viewer::draw()
|
||||
sunRotate.rotate(rotAngle, 1, 0, 0);
|
||||
|
||||
m_program->setUniformValue(m_lDirLoc, (sun * sunRotate));
|
||||
selection->transform.setToIdentity();
|
||||
selection->transform.rotate(rotAngle, 0, 1, 0);
|
||||
|
||||
// Traverse the Scene in order to draw its components
|
||||
|
||||
@ -333,6 +336,9 @@ void Viewer::initShaders()
|
||||
if ((m_drawTextLoc = m_program->uniformLocation("drawTextures")) < 0)
|
||||
qDebug() << "Unable to find m_shader location for" << "drawTextures";
|
||||
|
||||
if ((m_isLightLoc = m_program->uniformLocation("isLightSource")) < 0)
|
||||
qDebug() << "Unable to find m_shader location for" << "isLightSource";
|
||||
|
||||
|
||||
m_program->setUniformValue(m_isPhongLoc, true);
|
||||
m_program->setUniformValue(m_drawTextLoc, true);
|
||||
@ -619,6 +625,7 @@ void Viewer::visit(Cube &s)
|
||||
m_program->setUniformValue(m_normalMatrixLoc, modelViewMatrix.normalMatrix());
|
||||
m_program->setUniformValue(m_colorLocation, s.getColor());
|
||||
m_program->setUniformValue(m_drawTextLoc, true);
|
||||
m_program->setUniformValue(m_isLightLoc, false);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, i*6, 6);
|
||||
}
|
||||
@ -634,8 +641,9 @@ void Viewer::visit(Sphere &s)
|
||||
m_program->setUniformValue(m_isSkyLoc, false);
|
||||
m_program->setUniformValue(m_mvMatrixLocation, modelViewMatrix);
|
||||
m_program->setUniformValue(m_normalMatrixLoc, modelViewMatrix.normalMatrix());
|
||||
m_program->setUniformValue(m_colorLocation, QColor(255, 255, 255, 255));
|
||||
m_program->setUniformValue(m_colorLocation, QColor(255, 255, 255, 200));
|
||||
m_program->setUniformValue(m_drawTextLoc, false);
|
||||
m_program->setUniformValue(m_isLightLoc, true);
|
||||
|
||||
glDrawElements(GL_TRIANGLES, numTriSphere * 3, GL_UNSIGNED_INT, 0);
|
||||
}
|
||||
|
||||
@ -100,6 +100,7 @@ private:
|
||||
int m_lDirLoc;
|
||||
int m_skyMultLoc;
|
||||
int m_drawTextLoc;
|
||||
int m_isLightLoc;
|
||||
|
||||
float angle_mult;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user