Commit 63e1d174 by Kai Westerkamp

Zwischenstand

parent 10e12c16
...@@ -24,18 +24,24 @@ void main(void) ...@@ -24,18 +24,24 @@ void main(void)
debugout = Weights; debugout = Weights;
//debugout = vec4(1); //debugout = vec4(1);
mat4x4 BoneTransform = Bones[BoneIDs[0]] * Weights[0]; mat4x4 BoneTransform= mat4x4(0.0);
BoneTransform += Bones[BoneIDs[1]] * Weights[1];
BoneTransform += Bones[BoneIDs[2]] * Weights[2]; for(int i =0; i <4; i++){
BoneTransform += Bones[BoneIDs[3]] * Weights[3]; BoneTransform += Bones[BoneIDs[i]] * Weights[i];
}
if(Weights[0] == 0.0){
BoneTransform = mat4x4(1.0);
}
vec4 Pos = BoneTransform*vec4(Position,1.0); vec4 Pos = BoneTransform*vec4(Position,1.0);
vec4 Nor = BoneTransform*vec4(Normal,0.0);
//Pos = vec4(Position,1.0); //Pos = vec4(Position,1.0);
vCamPosition = vec4(MV*Pos).xyz; vCamPosition = vec4(MV*Pos).xyz;
vCamNormal = N*Normal; vCamNormal = N*(Nor.xyz);
vUV = UV; vUV = UV;
......
...@@ -44,7 +44,7 @@ void MainWidget::initializeGL(){ ...@@ -44,7 +44,7 @@ void MainWidget::initializeGL(){
// Shader // Shader
animationShader = initShader(QLatin1String(":/animate.frag"),QLatin1String(":/animate.vert")); animationShader = initShader(QLatin1String(":/animate.frag"),QLatin1String(":/animate.vert"));
camDistance = 30.0; camDistance = 100.0;
m_view = QMatrix4x4(); m_view = QMatrix4x4();
m_view.lookAt(QVector3D(0.0,camDistance,camDistance),QVector3D(0.0,0.0,0.0),QVector3D(0.0,1.0,0.0)); m_view.lookAt(QVector3D(0.0,camDistance,camDistance),QVector3D(0.0,0.0,0.0),QVector3D(0.0,1.0,0.0));
...@@ -54,7 +54,7 @@ void MainWidget::initializeGL(){ ...@@ -54,7 +54,7 @@ void MainWidget::initializeGL(){
void MainWidget::loadNewMesh(){ void MainWidget::loadNewMesh(){
QString fn = QFileDialog::getOpenFileName(NULL, tr("Open Mesh..."), QString fn = QFileDialog::getOpenFileName(NULL, tr("Open Mesh..."),
QString("D:\\Projekte\\GraPa\\A5\\Models"), QString("D:\\Projekte\\GraPa\\A5\\Models"),
tr("*.md5mesh *.3ds *.md2 *.obj" )); tr("*.md5mesh *.3ds *.md2 *.obj *.dae *.dxf" ));
if(fn.isEmpty()) if(fn.isEmpty())
return; return;
...@@ -98,15 +98,16 @@ void MainWidget::paintGL(){ ...@@ -98,15 +98,16 @@ void MainWidget::paintGL(){
QMatrix4x4 rot; QMatrix4x4 rot;
int time = QTime::currentTime().second()*1000+QTime::currentTime().msec(); int time = QTime::currentTime().second()*1000+QTime::currentTime().msec();
rot.rotate(time/100.0*36/5,QVector3D(0,1,0)); //rot.rotate(time/100.0*36/5,QVector3D(0,1,0));
animationShader->bind(); animationShader->bind();
animationShader->setUniformValue("colorTexture",0); animationShader->setUniformValue("colorTexture",0);
animationShader->setUniformValue("LightPos",QVector3D(0,100,100)); animationShader->setUniformValue("LightPos",QVector3D(0,100,100));
time = startTime.msecsTo(QTime::currentTime()) /1000.0; float ftime = startTime.msecsTo(QTime::currentTime()) /1000.0;
mesh->render(animationShader,m_view*rot, m_projection,(float) time);
mesh->render(animationShader,m_view*rot, m_projection,(float) ftime);
animationShader->release(); animationShader->release();
update(); update();
......
...@@ -133,6 +133,7 @@ private: ...@@ -133,6 +133,7 @@ private:
QVector3D calcInterpolatedScaling(float AnimTime,const aiNodeAnim *nodeAnimation); QVector3D calcInterpolatedScaling(float AnimTime,const aiNodeAnim *nodeAnimation);
QQuaternion calcInterpolatedRotation(float AnimTime,const aiNodeAnim *nodeAnimation); QQuaternion calcInterpolatedRotation(float AnimTime,const aiNodeAnim *nodeAnimation);
QVector3D calcInterpolatedTranslation(float AnimTime, const aiNodeAnim *nodeAnimation); QVector3D calcInterpolatedTranslation(float AnimTime, const aiNodeAnim *nodeAnimation);
QVector3D calcInterpolatedVectorKey(float AnimTime,const aiNodeAnim *nodeAnimation, const aiVectorKey* keys, const int numberOfKeys);
void renderNode(QOpenGLShaderProgram *shader, Node &node, QMatrix4x4 V,QMatrix4x4 P,QMatrix4x4 M); void renderNode(QOpenGLShaderProgram *shader, Node &node, QMatrix4x4 V,QMatrix4x4 P,QMatrix4x4 M);
...@@ -140,8 +141,10 @@ private: ...@@ -140,8 +141,10 @@ private:
QVector3D convert(aiVector3D in){ return QVector3D(in.x,in.y,in.z);} QVector3D convert(aiVector3D in){ return QVector3D(in.x,in.y,in.z);}
QQuaternion convert(aiQuaternion quat){ return QQuaternion(quat.w,quat.x,quat.y,quat.z);} QQuaternion convert(aiQuaternion quat){ return QQuaternion(quat.w,quat.x,quat.y,quat.z);}
QVector3D linInterpolate(QVector3D start, QVector3D end, float Factor){ return (1.0-Factor)*start + Factor*end;}
QVector3D linInterpolate(QVector3D start, QVector3D end, float Factor){ return (1.0-Factor)*start + Factor*end;}
QVector3D Catmul(QVector3D before, QVector3D start, QVector3D end, QVector3D after,float Factor);
float timeCatmul(QVector3D p1, QVector3D p2, float t_1);
}; };
......
...@@ -17,6 +17,7 @@ void Texture::Load(GLenum textureTarget, QString fileName) ...@@ -17,6 +17,7 @@ void Texture::Load(GLenum textureTarget, QString fileName)
qDebug()<<"No Image to load"; qDebug()<<"No Image to load";
return; return;
} }
qDebug()<<"Loading Texture:"<<fileName; qDebug()<<"Loading Texture:"<<fileName;
QString suffix = QFileInfo(fileName).completeSuffix(); QString suffix = QFileInfo(fileName).completeSuffix();
......
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