git-svn-id: svn://db.shs.com.ru/libs@540 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2019-05-27 16:36:51 +00:00
parent 09e7268779
commit bb75525a3b
37 changed files with 926 additions and 683 deletions

View File

@@ -37,11 +37,11 @@ void Loader3DS::init3DSMesh(GLObjectBase * o, const QVector<uint> & smooth) {
v2 = points[cf.p2];
fnormals[i] = ((v1 - v0) * (v2 - v0)).normalized();
}
uint fcnt = faces.size() * 3;
int fcnt = faces.size() * 3;
vertices.resize(fcnt * 3);
normals.resize(vertices.size());
if (has_uv) uvs.resize(fcnt * 2);
uint ind = 0, induv = 0, ncnt0, ncnt1, ncnt2, csg;
int ind = 0, induv = 0, ncnt0, ncnt1, ncnt2, csg;
//qDebug() << faces.size();
if (smooth.isEmpty()) {
for (int i = 0; i < faces.size(); ++i) {
@@ -129,18 +129,18 @@ Material Loader3DS::materialByName(const QVector<Material> & materials, const QS
}
GLObjectBase * loadFrom3DSFile(const QString & filepath, double scale) {
GLObjectBase * loadFrom3DSFile(const QString & filepath, float scale) {
QFile f(filepath);
if (!f.exists()) {
qDebug() << "[Loader 3DS] Error: can`t open \"" + filepath + "\"";
return 0;
return nullptr;
}
f.open(QIODevice::ReadOnly);
QDataStream stream(&f);
QVector<Material> materials;
QVector<uint> smooth;
QVector<ushort> face_mats;
GLObjectBase * root = new GLObjectBase(), * co = 0;
GLObjectBase * root = new GLObjectBase(), * co = nullptr;
Material mat;
Loader3DS::Chunk cc;
Loader3DS::Face face;
@@ -159,7 +159,7 @@ GLObjectBase * loadFrom3DSFile(const QString & filepath, double scale) {
case LOADER_3DS_CHUNK_MAIN: /*qDebug() << "main" << cc.size;*/ break;
case LOADER_3DS_CHUNK_OBJECTS: /*qDebug() << " objects" << cc.size;*/ break;
case LOADER_3DS_CHUNK_OBJECT:
if (co != 0) {
if (co != nullptr) {
Loader3DS::init3DSMesh(co, smooth);
root->addChild(co);
}
@@ -257,7 +257,7 @@ GLObjectBase * loadFrom3DSFile(const QString & filepath, double scale) {
stream.skipRawData(cc.size - 6);
fl = globject_cast<Light * >(co)->decay_end;
//fl1 = globject_cast<Light * >(co)->decay_start;
globject_cast<Light * >(co)->decay_quadratic = 4. / fl;
globject_cast<Light * >(co)->decay_quadratic = 4.f / fl;
//qDebug() << "decay" << globject_cast<Light * >(co)->decay_quadratic;
break;
case LOADER_3DS_CHUNK_COLOR_F:
@@ -337,7 +337,7 @@ GLObjectBase * loadFrom3DSFile(const QString & filepath, double scale) {
materials << mat;
foreach (const Material & m, materials)
qDebug() << m.name;
if (co != 0) {
if (co != nullptr) {
Loader3DS::init3DSMesh(co, smooth);
root->addChild(co);
}