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

@@ -27,7 +27,7 @@ void LoaderASE::initASEMesh(GLObjectBase * o) {
bool has_uv = !puvws.isEmpty(), has_norms = !fnormals.isEmpty();
Vector3i cf;
Vector3d v0, v1, v2, cn0, cn1, cn2;
uint ni = 0;
int ni = 0;
for (int i = 0; i < points.size(); ++i)
points[i] -= pos;
if (!has_norms) {
@@ -43,11 +43,11 @@ void LoaderASE::initASEMesh(GLObjectBase * o) {
fnormals[ni] = cn0; ++ni;
}
}
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;
int ind = 0, induv = 0;
qDebug() << "init ase" << faces.size() << "faces";
ni = 0;
for (int i = 0; i < faces.size(); ++i) {
@@ -79,15 +79,15 @@ void LoaderASE::initASEMesh(GLObjectBase * o) {
}
GLObjectBase * loadFromASEFile(const QString & filepath, double scale) {
GLObjectBase * loadFromASEFile(const QString & filepath, float scale) {
QFile f(filepath);
if (!f.exists()) {
qDebug() << "[Loader ASE] Error: can`t open" << filepath;
return 0;
return nullptr;
}
f.open(QIODevice::ReadOnly);
//QVector<Material> materials;
GLObjectBase * root = new GLObjectBase(), * co = 0;
GLObjectBase * root = new GLObjectBase(), * co = nullptr;
root->setName(QFileInfo(f).baseName());
QTextStream stream(&f);
QVector<Material> materials;
@@ -95,7 +95,8 @@ GLObjectBase * loadFromASEFile(const QString & filepath, double scale) {
QVector<Vector3i> faces, uvws;
QVector<Vector3d> normals;
Vector3d cv;
int mst = -1, pst;//, mat_ind;
int mst = -1;//, mat_ind;
qint64 pst;
QString line, cname;
@@ -121,7 +122,7 @@ GLObjectBase * loadFromASEFile(const QString & filepath, double scale) {
if (line.left(17) == "*MATERIAL_DIFFUSE") {materials[i].color_diffuse = colorFromString(line.right(line.length() - 18)); continue;} //qDebug() << "diffuse " << i << " = " << colorFromString(line.right(line.length() - 18));
if (line.left(18) == "*MATERIAL_SPECULAR") {materials[i].color_specular = colorFromString(line.right(line.length() - 19)); continue;} //qDebug() << "specular " << i << " = " << colorFromString(line.right(line.length() - 19));
if (line.left(23) == "*MATERIAL_SHINESTRENGTH") {materials[i].map_specular.color_amount = line.right(line.length() - 24).toFloat(); continue;}
if (line.left(15) == "*MATERIAL_SHINE") {materials[i].map_specularity.color_amount = 2. / exp(line.right(line.length() - 16).toFloat()); continue;}
if (line.left(15) == "*MATERIAL_SHINE") {materials[i].map_specularity.color_amount = 2.f / expf(line.right(line.length() - 16).toFloat()); continue;}
if (line.left(22) == "*MATERIAL_TRANSPARENCY") {materials[i].transparency = line.right(line.length() - 23).toFloat(); continue;}
if (line.left(12) == "*MAP_DIFFUSE") {
line = stream.readLine().trimmed();
@@ -167,7 +168,7 @@ GLObjectBase * loadFromASEFile(const QString & filepath, double scale) {
if (line.indexOf("GEOMOBJECT {") >= 0) cotype = 0;
if (line.indexOf("LIGHTOBJECT {") >= 0) cotype = 1;
mst = -1;
if (co != 0) {
if (co != nullptr) {
co->points = points;
co->faces = faces;
co->normals = normals;
@@ -367,7 +368,7 @@ GLObjectBase * loadFromASEFile(const QString & filepath, double scale) {
mst = -1;
}
f.close();
if (co != 0) {
if (co != nullptr) {
co->points = points;
co->faces = faces;
co->normals = normals;