git-svn-id: svn://db.shs.com.ru/libs@688 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -132,6 +132,8 @@ Material * assimpMaterial(const aiMaterial * m) {
|
||||
|
||||
Light * assimpLight(const aiLight * l) {
|
||||
if (!l) return 0;
|
||||
if (l->mType != aiLightSource_POINT && l->mType != aiLightSource_SPOT)
|
||||
return 0;
|
||||
Light * ret = new Light();
|
||||
ret->setName(fromAiString(l->mName));
|
||||
ret->setPos(fromAiVector3D(l->mPosition));
|
||||
@@ -221,28 +223,32 @@ Scene * loadScene(const QString & filepath) {
|
||||
lights << assimpLight(ais->mLights[i]);
|
||||
QMap<QString, Light * > light_by_name;
|
||||
foreach (Light * l, lights)
|
||||
light_by_name[l->name()] = l;
|
||||
if (l)
|
||||
light_by_name[l->name()] = l;
|
||||
|
||||
QVector<Light*> out_lights;
|
||||
ObjectBaseList rootl = assimpObject(ais->mRootNode, meshes, ais->mMeshes, materials, light_by_name, out_lights);
|
||||
if (rootl.isEmpty()) return 0;
|
||||
ObjectBase * root = rootl[0];
|
||||
root->transferTransformToChildren(true);
|
||||
|
||||
ObjectBaseList rcl = root->children(true);
|
||||
foreach (ObjectBase * c, rcl) {
|
||||
foreach (Light * l, out_lights) {
|
||||
if (c->name() == (l->name() + ".Target")) {
|
||||
l->setAim((l->worldTransform().inverted() * QVector4D(c->worldPos(), 1)).toVector3D());
|
||||
l->setDistance((l->worldPos() - c->worldPos()).length());
|
||||
delete c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
root->cleanTree();
|
||||
|
||||
Scene * scene = new Scene();
|
||||
scene->setName(root->name());
|
||||
foreach (ObjectBase * o, root->children())
|
||||
scene->addObject(o);
|
||||
lights.removeAll(0);
|
||||
qDeleteAll(lights);
|
||||
|
||||
return scene;
|
||||
|
||||
Reference in New Issue
Block a user