Commit 42afb638 by Kai Westerkamp

Model update

parent 063c2e60
...@@ -115,7 +115,7 @@ void MainWidget::initializeGL(){ ...@@ -115,7 +115,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 *.dae *.dxf *.mesh.xml" )); tr("*.md5mesh *.3ds *.md2 *.obj *.dae *.dxf *.mesh.xml *.blend *.b3d" ));
if(fn.isEmpty()) if(fn.isEmpty())
return; return;
......
...@@ -93,8 +93,9 @@ Mesh::Mesh(QOpenGLFunctions_4_3_Core *f,QString fileName) ...@@ -93,8 +93,9 @@ Mesh::Mesh(QOpenGLFunctions_4_3_Core *f,QString fileName)
const aiMaterial* material = scene->mMaterials[i]; const aiMaterial* material = scene->mMaterials[i];
aiString mname; aiString mname;
material->Get(AI_MATKEY_NAME, mname); material->Get(AI_MATKEY_NAME, mname);
qDebug()<<"Loading Material"<<(i+1)<<"/"<<scene->mNumMaterials<<":"<<mname.C_Str();
initMaterial(dir, i, material); initMaterial(dir, i, material);
qDebug()<<"Loaded Material"<<(i+1)<<"/"<<scene->mNumMaterials<<":"<<mname.C_Str()<<"Shininess"<<materials[i].Shininess;
} }
} }
qDebug()<<"Materials Read"; qDebug()<<"Materials Read";
...@@ -248,8 +249,10 @@ void Mesh::initMaterial(QString dir, unsigned int i, const aiMaterial* material) ...@@ -248,8 +249,10 @@ void Mesh::initMaterial(QString dir, unsigned int i, const aiMaterial* material)
materials[i].Specular = QVector3D(spec.r, spec.g, spec.b); materials[i].Specular = QVector3D(spec.r, spec.g, spec.b);
materials[i].Shininess = shine; materials[i].Shininess = shine;
if (materials[i].Shininess == 0.0) if (materials[i].Shininess == 0.0){
materials[i].Shininess = 30; materials[i].Shininess = 2;
}
if (material->GetTextureCount(aiTextureType_DIFFUSE) > 0) { if (material->GetTextureCount(aiTextureType_DIFFUSE) > 0) {
...@@ -257,7 +260,8 @@ void Mesh::initMaterial(QString dir, unsigned int i, const aiMaterial* material) ...@@ -257,7 +260,8 @@ void Mesh::initMaterial(QString dir, unsigned int i, const aiMaterial* material)
if (material->GetTexture(aiTextureType_DIFFUSE, 0, &Path, NULL, NULL, NULL, NULL, NULL) == AI_SUCCESS) { if (material->GetTexture(aiTextureType_DIFFUSE, 0, &Path, NULL, NULL, NULL, NULL, NULL) == AI_SUCCESS) {
QString temp = QString(Path.data); QString temp = QString(Path.data);
//temp = temp.split("\\").last(); temp = temp.split("\\").last();
temp = temp.split("/").last();
std::string FullPath = dir.toStdString() + "/" + temp.toStdString(); std::string FullPath = dir.toStdString() + "/" + temp.toStdString();
materials[i].texture.Load(GL_TEXTURE_2D, QString(FullPath.c_str())); materials[i].texture.Load(GL_TEXTURE_2D, QString(FullPath.c_str()));
materials[i].hasTexture = true; materials[i].hasTexture = true;
...@@ -546,7 +550,9 @@ QVector3D Mesh::calcInterpolatedVectorKey(float AnimTime,const aiNodeAnim *nodeA ...@@ -546,7 +550,9 @@ QVector3D Mesh::calcInterpolatedVectorKey(float AnimTime,const aiNodeAnim *nodeA
QVector3D start = convert(keys[index].mValue); QVector3D start = convert(keys[index].mValue);
QVector3D end = convert(keys[index+1].mValue); QVector3D end = convert(keys[index+1].mValue);
if(start.distanceToPoint(end) < 0.00001){ // same keyframe
if(start.distanceToPoint(end) < EPSILON){ // same keyframe
return start; return start;
} }
...@@ -561,9 +567,9 @@ QVector3D Mesh::calcInterpolatedVectorKey(float AnimTime,const aiNodeAnim *nodeA ...@@ -561,9 +567,9 @@ QVector3D Mesh::calcInterpolatedVectorKey(float AnimTime,const aiNodeAnim *nodeA
break; break;
case aiAnimBehaviour_REPEAT:// use start or end case aiAnimBehaviour_REPEAT:// use start or end
{ {
// QVector3D before = convert(keys[index-1].mValue); QVector3D before = convert(keys[index-1].mValue);
// QVector3D after = convert(keys[numberOfKeys - 1].mValue); QVector3D after = convert(keys[numberOfKeys - 1].mValue);
// return Catmul(before,start,end,after,Factor); return Catmul(before,start,end,after,Factor);
} }
case aiAnimBehaviour_LINEAR: // linear interpolate case aiAnimBehaviour_LINEAR: // linear interpolate
return linInterpolate(start,end,Factor); return linInterpolate(start,end,Factor);
...@@ -579,9 +585,9 @@ QVector3D Mesh::calcInterpolatedVectorKey(float AnimTime,const aiNodeAnim *nodeA ...@@ -579,9 +585,9 @@ QVector3D Mesh::calcInterpolatedVectorKey(float AnimTime,const aiNodeAnim *nodeA
break; break;
case aiAnimBehaviour_REPEAT: // use start or end case aiAnimBehaviour_REPEAT: // use start or end
{ {
// QVector3D before = convert(keys[index-1].mValue); QVector3D before = convert(keys[index-1].mValue);
// QVector3D after = convert(keys[0].mValue); QVector3D after = convert(keys[0].mValue);
// return Catmul(before,start,end,after,Factor); return Catmul(before,start,end,after,Factor);
} }
case aiAnimBehaviour_LINEAR: // linear interpolate case aiAnimBehaviour_LINEAR: // linear interpolate
return linInterpolate(start,end,Factor); return linInterpolate(start,end,Factor);
...@@ -593,6 +599,16 @@ QVector3D Mesh::calcInterpolatedVectorKey(float AnimTime,const aiNodeAnim *nodeA ...@@ -593,6 +599,16 @@ QVector3D Mesh::calcInterpolatedVectorKey(float AnimTime,const aiNodeAnim *nodeA
} else{ } else{
QVector3D before = convert(keys[index-1].mValue); QVector3D before = convert(keys[index-1].mValue);
QVector3D after = convert(keys[index+2].mValue); QVector3D after = convert(keys[index+2].mValue);
if(before.distanceToPoint(start) < EPSILON
||end.distanceToPoint(after)<EPSILON){ // keyframes before or after are the same. No Nomal computation
//TODO
return linInterpolate(start,end,Factor);
}
return Catmul(before,start,end,after,Factor); return Catmul(before,start,end,after,Factor);
} }
...@@ -616,8 +632,14 @@ QVector3D Mesh::Catmul(QVector3D P0, QVector3D P1, QVector3D P2, QVector3D P3,fl ...@@ -616,8 +632,14 @@ QVector3D Mesh::Catmul(QVector3D P0, QVector3D P1, QVector3D P2, QVector3D P3,fl
QVector3D B2 = (t3-t)/(t3-t1)*A2 + (t-t1)/(t3-t1)*A3; QVector3D B2 = (t3-t)/(t3-t1)*A2 + (t-t1)/(t3-t1)*A3;
QVector3D C = (t2-t)/(t2-t1)*B1 + (t-t1)/(t2-t1)*B2; QVector3D C = (t2-t)/(t2-t1)*B1 + (t-t1)/(t2-t1)*B2;
if(C.isNull() || qIsNaN(C.x())){
qCritical()<<"Catmul bad:"<<C<<"from"<<P0<<P1<<P2<<P3;
}
return C; return C;
} }
double Mesh::timeCatmul(QVector3D p1, QVector3D p2, double t_1){ double Mesh::timeCatmul(QVector3D p1, QVector3D p2, double t_1){
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#define boneIndex 3 #define boneIndex 3
#define boneweightIndex 4 #define boneweightIndex 4
#define EPSILON 0.00001
struct Vertex struct Vertex
{ {
......
Upload Feito por Dark Angel The 3d Free Models.
\ No newline at end of file
# Max2Mtl Version 4.0 Mar 10th, 2001
#
# Multi/Sub SMDImport (1) to come
#
newmtl Material__10
Ka 0.6 0.6 0.6
Kd 0.6 0.6 0.6
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
map_Kd metrocop_sheet.tga
#
# Multi/Sub SMDImport done
#
# EOF
This source diff could not be displayed because it is too large. You can view the blob instead.
Upload By Dark Angle The 3d Free Models.
\ No newline at end of file
hey guys heres all the ranges for the ninja model, 20 ranges and 300 frames....Phew!!
you may need to scale or rotate the model and change animation speeds for various 3D game engines...
Please check the numbers carefully cus they dont follow any order and in between ranges often skip a few frames, this as how I achieved certain moves in Character FX its not a mistake :)
1-14 Walk (normal)
15-30 Stealth Walk
32-44 Punch and swipe sword
45-59 Swipe and spin sword
60-68 Overhead twohanded downswipe
69-72 Up to block position (play backwards to lower sword if you want)
73-83 Forward kick
84-93 Pick up from floor (or down to crouch at frame 87)
94-102 Jump
103-111 Jump without height (for programmer controlled jumps)
112-125 High jump to Sword Kill (Finish em off move??)
126-133 Side Kick
134-145 Spinning Sword attack (might wanna speed this up in game)
146-158 Backflip
159-165 Climb wall
166-173 Death 1 - Fall back onto ground
174-182 Death 2 - Fall forward onto ground
184-205 Idle 1 - Breathe heavily
206-250 Idle 2
251-300 Idle 3
Ok there it is, have fun and maybe drop by my forums hang out, ask questions, post your own work etc
Feel free to use however you like, commercial etc, credits are Appreciated as a LOT of work went into this! ;-)
This source 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