fixed flat / sphere scaling and mouse move input scaling
This commit is contained in:
parent
fc113617c9
commit
6aa2c5686f
@ -24,6 +24,7 @@ vec3 phongLighting(in vec3 kd, in vec3 ks, in float ns, in vec3 color, in vec3 n
|
|||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
// looping the world in the shape of a toreiller (infinite flat surface)
|
// looping the world in the shape of a toreiller (infinite flat surface)
|
||||||
|
//float zoomRatio = mix(1, 1/camera.z, flatSphere);
|
||||||
vec2 worldCoord = texCoord*worldSize + camera.xy*worldSize.y + (texCoord-vec2(0.25, 0.5))*surfaceRatio*worldSize;
|
vec2 worldCoord = texCoord*worldSize + camera.xy*worldSize.y + (texCoord-vec2(0.25, 0.5))*surfaceRatio*worldSize;
|
||||||
ivec2 nbRevolutions = ivec2(floor(worldCoord / worldSize));
|
ivec2 nbRevolutions = ivec2(floor(worldCoord / worldSize));
|
||||||
if(abs(mod(nbRevolutions.y, 2)) > 0.5)
|
if(abs(mod(nbRevolutions.y, 2)) > 0.5)
|
||||||
|
@ -18,7 +18,7 @@ void main(void)
|
|||||||
vec2 flatTexCoord = texCoord;
|
vec2 flatTexCoord = texCoord;
|
||||||
texCoord = mix(texCoord, flatTexCoord, vec2(flatSphere));
|
texCoord = mix(texCoord, flatTexCoord, vec2(flatSphere));
|
||||||
normal = inNormal.xyz;
|
normal = inNormal.xyz;
|
||||||
vec4 flatPos = vec4(inTexCoord.x*2 -1, inTexCoord.y*2 -1, 0.0, 1.0);
|
vec4 flatPos = vec4((inTexCoord.x*2 -1)*camera.z, (inTexCoord.y*2 -1)*camera.z, 0.0, 1.0);
|
||||||
vec3 position = vec3(inPosition.xy, inPosition.z - 1);
|
vec3 position = vec3(inPosition.xy, inPosition.z - 1);
|
||||||
vec4 projPos = mvp * vec4(position*camera.z, 1.0);
|
vec4 projPos = mvp * vec4(position*camera.z, 1.0);
|
||||||
gl_Position = mix(projPos, flatPos, vec4(flatSphere));
|
gl_Position = mix(projPos, flatPos, vec4(flatSphere));
|
||||||
|
@ -30,6 +30,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
connect(ui->actionPlayPause, SIGNAL(toggled(bool)), this, SLOT(pauseSimu(bool)));
|
connect(ui->actionPlayPause, SIGNAL(toggled(bool)), this, SLOT(pauseSimu(bool)));
|
||||||
connect(ui->actionAction_step, SIGNAL(triggered(bool)), this, SLOT(stepSimu()));
|
connect(ui->actionAction_step, SIGNAL(triggered(bool)), this, SLOT(stepSimu()));
|
||||||
connect(ui->actionStop, SIGNAL(triggered(bool)), this, SLOT(stopSimu()));
|
connect(ui->actionStop, SIGNAL(triggered(bool)), this, SLOT(stopSimu()));
|
||||||
|
connect(ui->resetToDefaultAdvanced, SIGNAL(pressed()), this, SLOT(resetAdvancedToDefault()));
|
||||||
changeSimSpeed(ui->simSpeedSlider->value());
|
changeSimSpeed(ui->simSpeedSlider->value());
|
||||||
ui->advancedGroupBox->hide();
|
ui->advancedGroupBox->hide();
|
||||||
}
|
}
|
||||||
@ -100,6 +101,12 @@ void MainWindow::stopSimu()
|
|||||||
delete p_simu;
|
delete p_simu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::resetAdvancedToDefault()
|
||||||
|
{
|
||||||
|
ui->flatSphereSlider->setValue(0);
|
||||||
|
ui->surfaceRatioSlider->setValue(50);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::pauseSimu(bool pause)
|
void MainWindow::pauseSimu(bool pause)
|
||||||
{
|
{
|
||||||
m_paused = pause;
|
m_paused = pause;
|
||||||
|
@ -32,6 +32,7 @@ private slots:
|
|||||||
void updateSimu();
|
void updateSimu();
|
||||||
void stepSimu();
|
void stepSimu();
|
||||||
void stopSimu();
|
void stopSimu();
|
||||||
|
void resetAdvancedToDefault();
|
||||||
void pauseSimu(bool);
|
void pauseSimu(bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>744</width>
|
<width>683</width>
|
||||||
<height>490</height>
|
<height>499</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -190,14 +190,14 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Spherical / Flat</string>
|
<string>Spherical / Flat</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QSlider" name="flatSphereSlider">
|
<widget class="QSlider" name="flatSphereSlider">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -225,14 +225,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>surface ratio</string>
|
<string>surface ratio</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QSlider" name="surfaceRatioSlider">
|
<widget class="QSlider" name="surfaceRatioSlider">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -263,6 +263,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QPushButton" name="resetToDefaultAdvanced">
|
||||||
|
<property name="text">
|
||||||
|
<string>Reset to default</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include "mapscene.h"
|
#include "mapscene.h"
|
||||||
#include <parametricmesh.h>
|
#include <parametricmesh.h>
|
||||||
#include <glm/ext.hpp>
|
#include <glm/ext.hpp>
|
||||||
|
|
||||||
#define SCROLL_SPEED 0.998f
|
#define SCROLL_SPEED 0.998f
|
||||||
|
|
||||||
class ToreillerGenerator : public MeshGenerator
|
class ToreillerGenerator : public MeshGenerator
|
||||||
@ -150,6 +149,12 @@ void PixelPipeline::resizeGL(int w, int h)
|
|||||||
m_view = glm::translate(glm::mat4(), glm::vec3(0, 0, -3));
|
m_view = glm::translate(glm::mat4(), glm::vec3(0, 0, -3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PixelPipeline::cameraMove(int x, int y)
|
||||||
|
{
|
||||||
|
m_camera.x -= 2*x/(m_camera.z*m_width);
|
||||||
|
m_camera.y += 2*y/(m_camera.z*m_height);
|
||||||
|
}
|
||||||
|
|
||||||
void PixelPipeline::cameraZoom(int nbScrolls)
|
void PixelPipeline::cameraZoom(int nbScrolls)
|
||||||
{
|
{
|
||||||
while(nbScrolls != 0)
|
while(nbScrolls != 0)
|
||||||
@ -167,6 +172,11 @@ void PixelPipeline::cameraZoom(int nbScrolls)
|
|||||||
}
|
}
|
||||||
if(m_camera.z > m_mapHeight/4)
|
if(m_camera.z > m_mapHeight/4)
|
||||||
m_camera.z = m_mapHeight/4;
|
m_camera.z = m_mapHeight/4;
|
||||||
else if(m_camera.z < 0.4f)
|
else if(m_camera.z < 1)
|
||||||
m_camera.z = 0.4f;
|
m_camera.z = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Coord PixelPipeline::getToreillerPos(int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ class Shader;
|
|||||||
class PixelMesh;
|
class PixelMesh;
|
||||||
class MapScene;
|
class MapScene;
|
||||||
class Mesh;
|
class Mesh;
|
||||||
|
class Coord;
|
||||||
|
|
||||||
class PixelPipeline : public Pipeline
|
class PixelPipeline : public Pipeline
|
||||||
{
|
{
|
||||||
@ -46,12 +47,14 @@ public:
|
|||||||
virtual void renderGL(Scene *scene);
|
virtual void renderGL(Scene *scene);
|
||||||
virtual void resizeGL(int w, int h);
|
virtual void resizeGL(int w, int h);
|
||||||
|
|
||||||
void cameraMove(int x, int y) { m_camera.x -= x/(m_camera.z*m_width); m_camera.y += y/(m_camera.z*m_width); }
|
void cameraMove(int x, int y);
|
||||||
void cameraZoom(int nbScrolls);
|
void cameraZoom(int nbScrolls);
|
||||||
|
|
||||||
void setSurfaceRatio(float surfaceRatio) { m_surfaceRatio = surfaceRatio; }
|
void setSurfaceRatio(float surfaceRatio) { m_surfaceRatio = surfaceRatio; }
|
||||||
void setFlatSphere(float flatSphere) { m_flatSphere = flatSphere; }
|
void setFlatSphere(float flatSphere) { m_flatSphere = flatSphere; }
|
||||||
void setShowToreiller(bool showToreiller) { m_showToreiller = showToreiller; }
|
void setShowToreiller(bool showToreiller) { m_showToreiller = showToreiller; }
|
||||||
|
|
||||||
|
Coord getToreillerPos(int mouseX, int mouseY);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PIXELPIPELINE_H
|
#endif // PIXELPIPELINE_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user