aerys / minko

3D framework for web, desktop and mobile devices.
http://minko.io
Other
904 stars 210 forks source link

Loading a 3D file. #241

Closed unco182 closed 8 years ago

unco182 commented 8 years ago

Hi,

I'm trying to load a 3d file (.ifc), and I'm trying to find my way with the tutorial 6 (which must be outdated I guess). After some change on tutorial's code, I still got some errors that I don't know how to fix.

Maybe someone can help :)

My issue is on the callback of the "auto complete = ..."

auto complete = sceneManager->assets()->loader()->complete()->connect([&](file::AssetLibrary::Ptr assets){
        auto root = scene::Node::create("root")->addComponent(sceneManager);

        auto camera = scene::Node::create("camera")
        ->addComponent(Renderer::create(0x7f7f7fff))
        ->addComponent(Transform::create(Matrix4x4::create()->lookAt(Vector3::create(0.f, 0.f, 0.f), Vector3::create(0.f, 0.f, 5.f))))
        ->addComponent(PerspectiveCamera::create((float) WINDOW_WIDTH / (float) WINDOW_HEIGHT, (float) PI * 0.25f, .1f, 1000.f));

        root->addChild(camera);

        auto objModel = assets->symbol(OBJ_MODEL_FILENAME);
        auto daeModel = assets->symbol(DAE_MODEL_FILENAME);
        auto ifcModel = assets->symbol(IFC_MODEL_FILENAME);

        // change scale for the obj file
        objModel->component<Transform>()->matrix()->appendScale(0.01f);

        // change position
        objModel->component<Transform>()->matrix()->translation(-1.f, -1.f, 0.f);
        daeModel->component<Transform>()->matrix()->translation(1.f, -1.f, 0.f);

        // add to the scene
        root->addChild(objModel);
        root->addChild(daeModel);
        root->addChild(ifcModel);

        auto enterFrame = canvas->enterFrame()->connect([&](Canvas::Ptr canvas, float t, float dt)
        {
            sceneManager->nextFrame(t, dt);
        });

        canvas->run();
    });

Here is the full code

#include "minko/Minko.hpp"
#include "minko/MinkoSDL.hpp"
#include "minko/MinkoASSIMP.hpp"
#include "minko/MinkoJPEG.hpp"

using namespace minko;
using namespace minko::component;
using namespace minko::math;

const uint WINDOW_WIDTH = 800;
const uint WINDOW_HEIGHT = 600;

const std::string OBJ_MODEL_FILENAME = "model/pirate.obj";
const std::string DAE_MODEL_FILENAME = "model/pirate.dae";
const std::string IFC_MODEL_FILENAME = "model/pirate.ifc";

int main(int argc, char** argv)
{
    auto canvas = Canvas::create("Minko Tutorial - Load 3D files", WINDOW_WIDTH, WINDOW_HEIGHT);
    auto sceneManager = SceneManager::create(canvas);

    std::shared_ptr<file::AssetLibrary> tmp = sceneManager->assets();

    // setup assets
    sceneManager->assets()->loader()->options()->registerParser<file::ASSIMPParser>("dae")->registerParser<file::ASSIMPParser>("ifc")->registerParser<file::JPEGParser>("jpg");

    sceneManager->assets()->effect("effect/Basic.effect");

    sceneManager->assets()->loader()->queue(OBJ_MODEL_FILENAME);
    sceneManager->assets()->loader()->queue(DAE_MODEL_FILENAME);
    sceneManager->assets()->loader()->queue(IFC_MODEL_FILENAME);

    sceneManager->assets()->loader()->options()->generateMipmaps(true);
    sceneManager->assets()->loader()->options()->effect(sceneManager->assets()->effect("effect/Basic.effect"));

    auto complete = sceneManager->assets()->loader()->complete()->connect([&](file::AssetLibrary::Ptr assets){
        auto root = scene::Node::create("root")->addComponent(sceneManager);

        auto camera = scene::Node::create("camera")
        ->addComponent(Renderer::create(0x7f7f7fff))
        ->addComponent(Transform::create(Matrix4x4::create()->lookAt(Vector3::create(0.f, 0.f, 0.f), Vector3::create(0.f, 0.f, 5.f))))
        ->addComponent(PerspectiveCamera::create((float) WINDOW_WIDTH / (float) WINDOW_HEIGHT, (float) PI * 0.25f, .1f, 1000.f));

        root->addChild(camera);

        auto objModel = assets->symbol(OBJ_MODEL_FILENAME);
        auto daeModel = assets->symbol(DAE_MODEL_FILENAME);
        auto ifcModel = assets->symbol(IFC_MODEL_FILENAME);

        // change scale for the obj file
        objModel->component<Transform>()->matrix()->appendScale(0.01f);

        // change position
        objModel->component<Transform>()->matrix()->translation(-1.f, -1.f, 0.f);
        daeModel->component<Transform>()->matrix()->translation(1.f, -1.f, 0.f);

        // add to the scene
        root->addChild(objModel);
        root->addChild(daeModel);
        root->addChild(ifcModel);

        auto enterFrame = canvas->enterFrame()->connect([&](Canvas::Ptr canvas, float t, float dt)
        {
            sceneManager->nextFrame(t, dt);
        });

        canvas->run();
    });

    sceneManager->assets()->loader()->load();

    return 0;

Thanks in advance

Noxalus commented 8 years ago

Do you have any error message? Did you try without loading only your IFC? (don't queue the DAE and OBJ files)

unco182 commented 8 years ago

For now, I'm just trying to build this tutorial with no error. But it seems that some class are not existing anymore

auto complete = sceneManager->assets()->loader()->complete()->connect([&](file::AssetLibrary::Ptr assets){

Do you know how to make this compile, I got an No viable conversion from '(lambda at /Users/albanpellegrini/Developer/openIFC/src/main.cpp:61:75)' to 'Callback' (aka 'function<void (std::__1::shared_ptr)>')

Thx in advance

Noxalus commented 8 years ago

The signature of the complete signal is not the same anymore, you get a pointer of the Loader instead of a pointer of the AssetLibrary.

auto complete = sceneManager->assets()->loader()->complete()->connect([&](file::Loader::Ptr loader)
{
    // Your code
})

All tutorials are really old and outdated, I suggest you to look at the examples instead. (cube example is a good start)

unco182 commented 8 years ago

Thx for this!

Do you know if I can find somewhere a list of the main change that happened on Minko ? (such as change of type name...)

Noxalus commented 8 years ago

Someone is currently working on the update of tutorials (code + documentation), and it should come soon.

For the main change, we had something like that for the migration of Minko beta 2 to Minko beta 3. I hope it can help.

Minko to GLM math expressions equivalent

Transform common usage

Beta 2 Beta3
transform->x() math::vec3(transform->modelToWorldMatrix() * math::vec4(math::vec3(), 1)).x
transform->y() math::vec3(transform->modelToWorldMatrix() * math::vec4(math::vec3(), 1)).y
transform->z() math::vec3(transform->modelToWorldMatrix() * math::vec4(math::vec3(), 1)).z
transform->matrix()->prependTranslation(x, y, z) transform->matrix(transform->matrix() * math::translate(math::vec3(x, y, z)))
transform->matrix()->appendTranslation(x, y, z) transform->matrix(math::translate(math::vec3(x, y, z)) * transform->matrix())
transform->matrix()->prependRotationX(angle) transform->matrix(transform->matrix() * math::rotate(angle, math::vec3(1.f, 0.f, 0.f)))
transform->matrix()->appendRotationX(angle) transform->matrix(math::rotate(angle, math::vec3(1.f, 0.f, 0.f)) * transform->matrix())
transform->matrix()->prependRotationY(angle) transform->matrix(transform->matrix() * math::rotate(angle, math::vec3(0.f, 1.f, 0.f)))
transform->matrix()->appendRotationY(angle) transform->matrix(math::rotate(angle, math::vec3(0.f, 1.f, 0.f)) * transform->matrix())
transform->matrix()->prependRotationZ(angle) transform->matrix(transform->matrix() * math::rotate(angle, math::vec3(0.f, 0.f, 1.f)))
transform->matrix()->appendRotationZ(angle) transform->matrix(math::rotate(angle, math::vec3(0.f, 0.f, 1.f)) * transform->matrix())
transform->matrix()->prependScale(x, y, z) transform->matrix(transform->matrix() * math::scale(math::vec3(x, y, z)))
transform->matrix()->appendScale(x, y, z) transform->matrix(math::scale(math::vec3(x, y, z)) * transform->matrix())
transform->deltaModelToWorld(v) math::normalize(math::mat3(transform->modelToWorldMatrix()) * v).xyz
transform->matrix()->lookAt(lookAt, position, up) transform->matrix(math::inverse(math::lookAt(position, lookAt, up)))
transform->deltaWorldToModel(v) math::normalize(math::mat3(math::inverse(transform->modelToWorldMatrix())) * v).xyz

Matrices

Beta 2 Beta3
Matrix4x4::create() math::mat4()
matrix->determinant() math::determinant(matrix)
matrix->rotationQuaternion() math::quat(matrix)
matrix->translation() matrix[3]
matrix->invert() math::inverse(matrix)

Vectors

Beta 2 Beta3
Vector3::create() math::vec3()
vector3->x() vector3.x
vector3->y() vector3.y
vector3->z() vector3.z
vector3->length() math::length(vector3)
Vector3::zero() math::vec3(0)

Data

Container class is now called Store instead.

unco182 commented 8 years ago

Thanks again !

Now I got an error while loading my .ifc

info: Logger.hpp:45 write(): Info,  T0: Load $$$___magic___$$$.ifc

info: Logger.hpp:45 write(): Debug, T0: Assimp 3.1.3918756528 amd64 gcc debug noboost singlethreaded

info: Logger.hpp:45 write(): Info,  T0: File extension not known, trying signature-based detection

info: Logger.hpp:45 write(): Error, T0: No suitable reader found for the file format of file "$$$___magic___$$$.ifc".

error: Loader.cpp:329   errorThrown(): : No suitable reader found for the file format of file "$$$___magic___$$$.ifc".
libc++abi.dylib: terminating with uncaught exception of type minko::file::Error: No suitable reader found for the file format of file "$$$___magic___$$$.ifc".

Here is my full code

#include "minko/Minko.hpp"
#include "minko/MinkoSDL.hpp"
#include "minko/MinkoASSIMP.hpp"
#include "minko/MinkoJPEG.hpp"

using namespace minko;
using namespace minko::component;
using namespace minko::math;

const uint WINDOW_WIDTH = 800;
const uint WINDOW_HEIGHT = 600;

//const std::string OBJ_MODEL_FILENAME = "model/pirate.obj";
//const std::string DAE_MODEL_FILENAME = "model/pirate.dae";
const std::string IFC_MODEL_FILENAME = "pirate.ifc";

int main(int argc, char** argv)
{

    auto canvas = Canvas::create("Minko Tutorial - Load 3D files", WINDOW_WIDTH, WINDOW_HEIGHT);
    auto sceneManager = SceneManager::create(canvas);

    std::shared_ptr<file::AssetLibrary> tmp = sceneManager->assets();

    // setup assets
    sceneManager->assets()->loader()->options()->registerParser<file::ASSIMPParser>("dae")->registerParser<file::ASSIMPParser>("ifc")->registerParser<file::JPEGParser>("jpg");

    sceneManager->assets()->effect("effect/Basic.effect");

    sceneManager->assets()->loader()->queue(IFC_MODEL_FILENAME);

    sceneManager->assets()->loader()->options()->generateMipmaps(true);
    sceneManager->assets()->loader()->options()->effect(sceneManager->assets()->effect("effect/Basic.effect"));

    auto complete = sceneManager->assets()->loader()->complete()->connect([&](file::Loader::Ptr loader)
    {
        auto root = scene::Node::create("root")->addComponent(sceneManager);

        auto camera = scene::Node::create("camera")
        ->addComponent(Renderer::create(0x7f7f7fff))
        ->addComponent(Transform::create(math::inverse(math::lookAt(math::vec3(0.25f, 0.75f, 2.5f),
                                                                    math::vec3(0.f, 0.75f, 0.f),
                                                                    math::vec3(0, 1, 0)))))
        ->addComponent(PerspectiveCamera::create(canvas->aspectRatio()));

        root->addChild(camera);

        auto ifcModel = sceneManager->assets()->symbol(IFC_MODEL_FILENAME);

        // add to the scene
        root->addChild(ifcModel);

        auto enterFrame = canvas->enterFrame()->connect([&](Canvas::Ptr canvas, float t, float dt)
        {
            sceneManager->nextFrame(t, dt);
        });

        canvas->run();
    });

    sceneManager->assets()->loader()->load();

    return 0;

}

I'm obviously missing or not understanding something important...

Thanks in advance

Noxalus commented 8 years ago

Please use three blackquotes (```) to surround a block of code instead a single one (that is used for inline code).

This code is still wrong on many points. Here is what you should have instead:

#include "minko/Minko.hpp"
#include "minko/MinkoSDL.hpp"
#include "minko/MinkoASSIMP.hpp"

using namespace minko;
using namespace minko::component;

const math::uint WINDOW_WIDTH = 800;
const math::uint WINDOW_HEIGHT = 600;

const std::string IFC_MODEL_FILENAME = "model/myfile.ifc";

int
main(int argc, char** argv)
{
    auto canvas = Canvas::create("Minko Tutorial - Loading 3D files", WINDOW_WIDTH, WINDOW_HEIGHT);
    auto sceneManager = component::SceneManager::create(canvas);

    sceneManager->assets()->loader()->options()
        ->registerParser<file::IFCParser>("ifc") // We need to register the IFC parser to load ".ifc" files
    ;

    sceneManager->assets()->loader()
        ->queue("effect/Basic.effect")
        ->queue("effect/Phong.effect")
        ->queue(IFC_MODEL_FILENAME)
    ;

    auto root = scene::Node::create("root")
        ->addComponent(sceneManager);

    auto camera = scene::Node::create("camera")
        ->addComponent(Renderer::create(0x7f7f7fff))
        ->addComponent(Transform::create(math::inverse(math::lookAt(math::vec3(0.f, 0.f, 5.f), math::vec3(), math::vec3(0.f, 1.f, 0.f)))))
        ->addComponent(PerspectiveCamera::create((float) WINDOW_WIDTH / (float) WINDOW_HEIGHT, (float) M_PI * 0.25f, .1f, 1000.f));

    root->addChild(camera);

    auto complete = sceneManager->assets()->loader()->complete()->connect([&](file::Loader::Ptr loader)
    {
        // Retrieve our IFC model
        auto symbol = sceneManager->assets()->symbol(IFC_MODEL_FILENAME);

        // Add the symbol to the scene
        root->addChild(symbol);
    });

    auto enterFrame = canvas->enterFrame()->connect([&](Canvas::Ptr c, float t, float dt)
    {
        sceneManager->nextFrame(t, dt);
    });

    sceneManager->assets()->loader()->load();
    canvas->run();

    return 0;
}
unco182 commented 8 years ago

Thx !

My project is compiling and running now, but nothing is displayed on the iOS Simulator Here is log

2016-02-03 14:48:23.436 openIFC[28907:887397] Final URL: file:///Users/albanpellegrini/Library/Developer/CoreSimulator/Devices/E8E90619-CE43-4802-B1C6-641B3529938D/data/Containers/Data/Application/D21DE237-FFD6-4FE2-B964-07A7472EAFC5/Library/
2016-02-03 14:48:23.462 openIFC[28907:887397] Final URL: file:///Users/albanpellegrini/Library/Developer/CoreSimulator/Devices/E8E90619-CE43-4802-B1C6-641B3529938D/data/Containers/Data/Application/D21DE237-FFD6-4FE2-B964-07A7472EAFC5/Documents/
debug: Loader.cpp:200   protocolCompleteHandler(): file 'effect/Basic.effect' loaded, 0 file(s) still loading, 2 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'BaseStreamingTemplate.effect' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'BaseTemplate.effect' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Basic.vertex.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Skinning.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Pop.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Basic.fragment.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'TextureLod.extension.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Fog.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Math.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'TextureLod.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'LightMapping.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'effect/Phong.effect' loaded, 0 file(s) still loading, 1 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Phong.vertex.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Pack.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Phong.fragment.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Envmap.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Phong.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'ShadowMapping.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'pirate.ifc' loaded, 0 file(s) still loading, 0 file(s) in the queue
info: Logger.hpp:45 write(): Info,  T0: Registering custom importer for these file extensions: ifcifczip

info: Logger.hpp:45 write(): Info,  T0: Load $$$___magic___$$$.ifc

info: Logger.hpp:45 write(): Debug, T0: Assimp 3.1.3918756528 amd64 gcc debug noboost singlethreaded

info: Logger.hpp:45 write(): Info,  T0: Found a matching importer for this file format

info: Logger.hpp:45 write(): Info,  T0: Import root directory is './'

info: Logger.hpp:45 write(): Debug, T0: IFC: File schema is 'IFC2X3'

info: Logger.hpp:45 write(): Debug, T0: STEP: got 1250 object records with 1245 inverse index entries

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Debug, T0: IFC: got units used for lengths

info: Logger.hpp:45 write(): Debug, T0: IFC: got units used for angles

info: Logger.hpp:45 write(): Error, T0: IFC: skipping unknown IfcUnit entry - expected entity

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: got world coordinate system

info: Logger.hpp:45 write(): Warn,  T0: too many aggregate elements

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: looking at spatial structure `Default` which is of type 

info: Logger.hpp:45 write(): Debug, T0: IFC: selecting this spatial structure as root structure

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: skipping IfcAnnotation entity due to importer settings

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: generate mesh procedurally by extrusion (IfcExtrudedAreaSolid)

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: generate mesh procedurally by extrusion (IfcExtrudedAreaSolid)

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: generate mesh procedurally by extrusion (IfcExtrudedAreaSolid)

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: skipping IfcAnnotation entity due to importer settings

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: skipping IfcAnnotation entity due to importer settings

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: skipping IfcAnnotation entity due to importer settings

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: STEP: evaluated 857 object records

info: Logger.hpp:45 write(): Info,  T0: Entering post processing pipeline

info: Logger.hpp:45 write(): Debug, T0: ValidateDataStructureProcess begin

info: Logger.hpp:45 write(): Debug, T0: ValidateDataStructureProcess end

info: Logger.hpp:45 write(): Debug, T0: FlipUVsProcess begin

info: Logger.hpp:45 write(): Debug, T0: FlipUVsProcess finished

info: Logger.hpp:45 write(): Debug, T0: RemoveVCProcess begin

info: Logger.hpp:45 write(): Debug, T0: RemoveVCProcess finished. Nothing to be done ...

info: Logger.hpp:45 write(): Debug, T0: GenUVCoordsProcess begin

info: Logger.hpp:45 write(): Debug, T0: GenUVCoordsProcess finished

info: Logger.hpp:45 write(): Debug, T0: TriangulateProcess begin

info: Logger.hpp:45 write(): Info,  T0: TriangulateProcess finished. All polygons have been triangulated.

info: Logger.hpp:45 write(): Debug, T0: SortByPTypeProcess begin

info: Logger.hpp:45 write(): Info,  T0: Points: 0, Lines: 0, Triangles: 12, Polygons: 0 (Meshes, X = removed)

info: Logger.hpp:45 write(): Debug, T0: SortByPTypeProcess finished

info: Logger.hpp:45 write(): Debug, T0: FindInvalidDataProcess begin

info: Logger.hpp:45 write(): Debug, T0: FindInvalidDataProcess finished. Everything seems to be OK.

info: Logger.hpp:45 write(): Debug, T0: SplitLargeMeshesProcess_Triangle begin

info: Logger.hpp:45 write(): Debug, T0: SplitLargeMeshesProcess_Triangle finished. There was nothing to do

info: Logger.hpp:45 write(): Debug, T0: Generate spatially-sorted vertex cache

info: Logger.hpp:45 write(): Debug, T0: GenVertexNormalsProcess begin

info: Logger.hpp:45 write(): Info,  T0: GenVertexNormalsProcess finished. Vertex normals have been calculated

info: Logger.hpp:45 write(): Debug, T0: JoinVerticesProcess begin

info: Logger.hpp:45 write(): Debug, T0: Mesh 0 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 1 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 2 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 3 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 4 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 5 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 6 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 7 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 8 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 9 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 10 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 11 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Info,  T0: JoinVerticesProcess finished | Verts in: 288 out: 96 | ~66.7%

info: Logger.hpp:45 write(): Debug, T0: SplitLargeMeshesProcess_Vertex begin

info: Logger.hpp:45 write(): Debug, T0: SplitLargeMeshesProcess_Vertex finished. There was nothing to do

info: Logger.hpp:45 write(): Debug, T0: LimitBoneWeightsProcess begin

info: Logger.hpp:45 write(): Debug, T0: LimitBoneWeightsProcess end

info: Logger.hpp:45 write(): Debug, T0: ImproveCacheLocalityProcess begin

info: Logger.hpp:45 write(): Info,  T0: Cache relevant are 0 meshes (0 faces). Average output ACMR is nan

info: Logger.hpp:45 write(): Debug, T0: ImproveCacheLocalityProcess finished. 

info: Logger.hpp:45 write(): Info,  T0: Leaving post processing pipeline

debug: AbstractASSIMPParser.cpp:338 convertScene(): 0 dependencies loaded!

Also I saw this info: Logger.hpp:45 write(): Debug, T0: IFC: skipping IfcAnnotation entity due to importer settings and I would like to be able to get these annotation if I succeed in displaying my file. Where should I look to change this importer settings ?

Thanks in advance

warrenseine commented 8 years ago

You should look at the Assimp plugin IFC parser (here).

unco182 commented 8 years ago

Thanks warrenseine,

While loading my file I got this error happening in Renderer.cpp:

capture d ecran 2016-02-03 a 15 46 53

Any idea why this error happen ? I'm going to try with an other ifc but I'm not sure it gonna change anything

EDIT : With an other .ifc I have the same behavior (see the log in my previous post)

Noxalus commented 8 years ago

Yes, it seems that some surfaces of your IFC files don't have effect associated. You can set a default effect on each surfaces in the loader options.

sceneManager->assets()->loader()->options()->effect(sceneManager->assets()->effect("effect/Basic.effect"));

Obviously, to do that, you need to load the Basic effect before to load your IFC file.

unco182 commented 8 years ago

Thanks, but I think its not working (Or I'm doing sthg wrong again !).

I put sceneManager->assets()->loader()->options()->effect(sceneManager->assets()->effect("effect/Basic.effect")); at the beginning of my code and I got the same error

Full code :

#include "minko/Minko.hpp"
#include "minko/MinkoSDL.hpp"
#include "minko/MinkoASSIMP.hpp"

using namespace minko;
using namespace minko::component;

const math::uint WINDOW_WIDTH = 800;
const math::uint WINDOW_HEIGHT = 600;

const std::string IFC_MODEL_FILENAME = "pirate.ifc";
//const std::string IFC_MODEL_FILENAME = "4333_EGI_ARC_0000_ECP_GSY_A-Niveau_1.ifc";

int main(int argc, char** argv)
{
    auto canvas = Canvas::create("Minko Tutorial - Loading 3D files", WINDOW_WIDTH, WINDOW_HEIGHT);
    auto sceneManager = component::SceneManager::create(canvas);

    sceneManager->assets()->loader()->options()->effect(sceneManager->assets()->effect("effect/Basic.effect"));

    sceneManager->assets()->loader()->options()
    ->registerParser<file::IFCParser>("ifc") // We need to register the IFC parser to load ".ifc" files
    ;

    sceneManager->assets()->loader()
    ->queue("effect/Basic.effect")
    ->queue("effect/Phong.effect")
    ->queue(IFC_MODEL_FILENAME)
    ;

    auto root = scene::Node::create("root")
    ->addComponent(sceneManager);

    auto camera = scene::Node::create("camera")
    ->addComponent(Renderer::create(0x7f7f7fff))
    ->addComponent(Transform::create(math::inverse(math::lookAt(math::vec3(0.f, 0.f, 5.f), math::vec3(), math::vec3(0.f, 1.f, 0.f)))))
    ->addComponent(PerspectiveCamera::create((float) WINDOW_WIDTH / (float) WINDOW_HEIGHT, (float) M_PI * 0.25f, .1f, 1000.f));

    root->addChild(camera);

    auto complete = sceneManager->assets()->loader()->complete()->connect([&](file::Loader::Ptr loader)
    {
        // Retrieve our IFC model
        auto symbol = sceneManager->assets()->symbol(IFC_MODEL_FILENAME);

        // Add the symbol to the scene
        root->addChild(symbol);
    });

    auto enterFrame = canvas->enterFrame()->connect([&](Canvas::Ptr c, float t, float dt)
    {
        sceneManager->nextFrame(t, dt);
    });

    sceneManager->assets()->loader()->load();
    canvas->run();

    return 0;
}
warrenseine commented 8 years ago

You should put that line in your complete handler. The effect is not yet loaded when you try to use it.

unco182 commented 8 years ago

Thx, but It's still not working wherever I put the line of code in the complete handler

Noxalus commented 8 years ago

You need to load the Basic effect with another loader to do what you want. Thus, you can load your file only when the other loader has loaded the Basic effect. This should looks like that:

#include "minko/Minko.hpp"
#include "minko/MinkoSDL.hpp"
#include "minko/MinkoASSIMP.hpp"

using namespace minko;
using namespace minko::component;

const math::uint WINDOW_WIDTH = 800;
const math::uint WINDOW_HEIGHT = 600;

const std::string IFC_MODEL_FILENAME = "model/myfile.ifc";

int
main(int argc, char** argv)
{
    auto canvas = Canvas::create("Minko Tutorial - Loading 3D files", WINDOW_WIDTH, WINDOW_HEIGHT);
    auto sceneManager = component::SceneManager::create(canvas);

    // Create a loader to load effect files
    auto effectLoader = file::Loader::create(sceneManager->assets()->loader());
    effectLoader->options(effectLoader->options()->clone());

    // Add effect files to load
    effectLoader
        ->queue("effect/Basic.effect")
        ->queue("effect/Phong.effect");

    // Set options for the default loader (the one use to load our file)
    sceneManager->assets()->loader()->options()
        ->registerParser<file::IFCParser>("ifc");

    sceneManager->assets()->loader()
        ->queue(IFC_MODEL_FILENAME);

    auto root = scene::Node::create("root")
        ->addComponent(sceneManager);

    auto camera = scene::Node::create("camera")
        ->addComponent(Renderer::create(0x7f7f7fff))
        ->addComponent(Transform::create(math::inverse(math::lookAt(math::vec3(0.f, 0.f, 5.f), math::vec3(), math::vec3(0.f, 1.f, 0.f)))))
        ->addComponent(PerspectiveCamera::create((float) WINDOW_WIDTH / (float) WINDOW_HEIGHT, (float) M_PI * 0.25f, .1f, 1000.f));

    root->addChild(camera);

    auto effectLoaderComplete = effectLoader->complete()->connect([&](file::Loader::Ptr loader)
    {
        // Retrieve the Basic effect from loaded assets library
        auto basicEffect = sceneManager->assets()->effect("effect/Basic.effect");
        // Set the default effect to apply on each surface
        sceneManager->assets()->loader()->options()->effect(basicEffect);

        // Start the file loading
        sceneManager->assets()->loader()->load();
    });

    auto fileLoaderComplete = sceneManager->assets()->loader()->complete()->connect([&](file::Loader::Ptr loader)
    {
        // Retrieve our IFC model
        auto symbol = sceneManager->assets()->symbol(IFC_MODEL_FILENAME);

        // Add the symbol to the scene
        root->addChild(symbol);
    });

    auto enterFrame = canvas->enterFrame()->connect([&](Canvas::Ptr c, float t, float dt)
    {
        sceneManager->nextFrame(t, dt);
    });

    // Start the effects loading
    effectLoader->load();

    canvas->run();

    return 0;
}
unco182 commented 8 years ago

Yaaay ! It kinda works ! Thanks !

I now can load my file, but it display nothing but a grey screen (see screenshot).

capture d ecran 2016-02-04 a 10 39 21

Here is my log :

2016-02-04 10:37:22.620 openIFC[33451:1026176] Final URL: file:///Users/albanpellegrini/Library/Developer/CoreSimulator/Devices/E8E90619-CE43-4802-B1C6-641B3529938D/data/Containers/Data/Application/38649F81-9107-475C-B801-5680EFDD4985/Library/
2016-02-04 10:37:22.635 openIFC[33451:1026176] Final URL: file:///Users/albanpellegrini/Library/Developer/CoreSimulator/Devices/E8E90619-CE43-4802-B1C6-641B3529938D/data/Containers/Data/Application/38649F81-9107-475C-B801-5680EFDD4985/Documents/
debug: Loader.cpp:200   protocolCompleteHandler(): file 'effect/Basic.effect' loaded, 0 file(s) still loading, 1 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'BaseStreamingTemplate.effect' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'BaseTemplate.effect' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Basic.vertex.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Skinning.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Pop.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Basic.fragment.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'TextureLod.extension.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Fog.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Math.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'TextureLod.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'LightMapping.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'effect/Phong.effect' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Phong.vertex.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Pack.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Phong.fragment.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Envmap.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Phong.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'ShadowMapping.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'pirate.ifc' loaded, 0 file(s) still loading, 0 file(s) in the queue
info: Logger.hpp:45 write(): Info,  T0: Registering custom importer for these file extensions: ifcifczip

info: Logger.hpp:45 write(): Info,  T0: Load $$$___magic___$$$.ifc

info: Logger.hpp:45 write(): Debug, T0: Assimp 3.1.3918756528 amd64 gcc debug noboost singlethreaded

info: Logger.hpp:45 write(): Info,  T0: Found a matching importer for this file format

info: Logger.hpp:45 write(): Info,  T0: Import root directory is './'

info: Logger.hpp:45 write(): Debug, T0: IFC: File schema is 'IFC2X3'

info: Logger.hpp:45 write(): Debug, T0: STEP: got 1250 object records with 1245 inverse index entries

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Debug, T0: IFC: got units used for lengths

info: Logger.hpp:45 write(): Debug, T0: IFC: got units used for angles

info: Logger.hpp:45 write(): Error, T0: IFC: skipping unknown IfcUnit entry - expected entity

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: got world coordinate system

info: Logger.hpp:45 write(): Warn,  T0: too many aggregate elements

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: looking at spatial structure `Default` which is of type 

info: Logger.hpp:45 write(): Debug, T0: IFC: selecting this spatial structure as root structure

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcAnnotationFillArea

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: generate mesh procedurally by extrusion (IfcExtrudedAreaSolid)

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: generate mesh procedurally by extrusion (IfcExtrudedAreaSolid)

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: generate mesh procedurally by extrusion (IfcExtrudedAreaSolid)

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcAnnotationFillArea

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Error, T0: an error occurred reading escape sequences in ASCII text

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcTextLiteralWithExtent

info: Logger.hpp:45 write(): Warn,  T0: IFC: skipping unknown IfcGeometricRepresentationItem entity, type is IfcAnnotationFillArea

info: Logger.hpp:45 write(): Skipping one or more lines with the same contents

info: Logger.hpp:45 write(): Debug, T0: IFC: STEP: evaluated 1074 object records

info: Logger.hpp:45 write(): Info,  T0: Entering post processing pipeline

info: Logger.hpp:45 write(): Debug, T0: ValidateDataStructureProcess begin

info: Logger.hpp:45 write(): Debug, T0: ValidateDataStructureProcess end

info: Logger.hpp:45 write(): Debug, T0: FlipUVsProcess begin

info: Logger.hpp:45 write(): Debug, T0: FlipUVsProcess finished

info: Logger.hpp:45 write(): Debug, T0: RemoveVCProcess begin

info: Logger.hpp:45 write(): Debug, T0: RemoveVCProcess finished. Nothing to be done ...

info: Logger.hpp:45 write(): Debug, T0: GenUVCoordsProcess begin

info: Logger.hpp:45 write(): Debug, T0: GenUVCoordsProcess finished

info: Logger.hpp:45 write(): Debug, T0: TriangulateProcess begin

info: Logger.hpp:45 write(): Info,  T0: TriangulateProcess finished. All polygons have been triangulated.

info: Logger.hpp:45 write(): Debug, T0: SortByPTypeProcess begin

info: Logger.hpp:45 write(): Info,  T0: Points: 0, Lines: 0, Triangles: 12, Polygons: 0 (Meshes, X = removed)

info: Logger.hpp:45 write(): Debug, T0: SortByPTypeProcess finished

info: Logger.hpp:45 write(): Debug, T0: FindInvalidDataProcess begin

info: Logger.hpp:45 write(): Debug, T0: FindInvalidDataProcess finished. Everything seems to be OK.

info: Logger.hpp:45 write(): Debug, T0: SplitLargeMeshesProcess_Triangle begin

info: Logger.hpp:45 write(): Debug, T0: SplitLargeMeshesProcess_Triangle finished. There was nothing to do

info: Logger.hpp:45 write(): Debug, T0: Generate spatially-sorted vertex cache

info: Logger.hpp:45 write(): Debug, T0: GenVertexNormalsProcess begin

info: Logger.hpp:45 write(): Info,  T0: GenVertexNormalsProcess finished. Vertex normals have been calculated

info: Logger.hpp:45 write(): Debug, T0: JoinVerticesProcess begin

info: Logger.hpp:45 write(): Debug, T0: Mesh 0 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 1 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 2 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 3 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 4 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 5 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 6 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 7 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 8 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 9 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 10 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Debug, T0: Mesh 11 (unnamed) | Verts in: 24 out: 8 | ~66.6667%

info: Logger.hpp:45 write(): Info,  T0: JoinVerticesProcess finished | Verts in: 288 out: 96 | ~66.7%

info: Logger.hpp:45 write(): Debug, T0: SplitLargeMeshesProcess_Vertex begin

info: Logger.hpp:45 write(): Debug, T0: SplitLargeMeshesProcess_Vertex finished. There was nothing to do

info: Logger.hpp:45 write(): Debug, T0: LimitBoneWeightsProcess begin

info: Logger.hpp:45 write(): Debug, T0: LimitBoneWeightsProcess end

info: Logger.hpp:45 write(): Debug, T0: ImproveCacheLocalityProcess begin

info: Logger.hpp:45 write(): Info,  T0: Cache relevant are 0 meshes (0 faces). Average output ACMR is nan

info: Logger.hpp:45 write(): Debug, T0: ImproveCacheLocalityProcess finished. 

info: Logger.hpp:45 write(): Info,  T0: Leaving post processing pipeline

debug: AbstractASSIMPParser.cpp:338 convertScene(): 0 dependencies loaded!
WARNING: Output of vertex shader 'vVertexScreenPosition' not read by fragment shader
Noxalus commented 8 years ago

Your model might be too small/large, try to scale it:

symbol->component<Transform>()->matrix(symbol->component<Transform>()->matrix() * math::scale(math::vec3(0.01f)));
unco182 commented 8 years ago

Thanks it helped !

atonamy commented 8 years ago

But in my case it doesn't work at all :(

I use latest release v3.0-b2

Here is my code:

#include "minko/Minko.hpp"
#include "minko/MinkoSDL.hpp"
#include "minko/MinkoASSIMP.hpp"

using namespace minko;
using namespace minko::component;
using namespace minko::math;

const uint WINDOW_WIDTH = 800;
const uint WINDOW_HEIGHT = 600;

const std::string OBJ_MODEL_FILENAME = "model/pirate.obj";

int
main(int argc, char** argv)
{
    auto canvas = Canvas::create("Minko Tutorial - Loading 3D files", WINDOW_WIDTH, WINDOW_HEIGHT);
    auto sceneManager = component::SceneManager::create(canvas);

    // Create a loader to load effect files
    auto effectLoader = file::Loader::create(sceneManager->assets()->loader());
    effectLoader->options(effectLoader->options()->clone());

    // Add effect files to load
    effectLoader
    ->queue("effect/Basic.effect")
    ->queue("effect/Phong.effect");

    // Set options for the default loader (the one use to load our file)
    sceneManager->assets()->loader()->options()
    ->registerParser<file::OBJParser>("obj");

    sceneManager->assets()->loader()
    ->queue(OBJ_MODEL_FILENAME);

    auto root = scene::Node::create("root")
    ->addComponent(sceneManager);

    auto camera = scene::Node::create("camera")
    ->addComponent(Renderer::create(0x7f7f7fff))
    ->addComponent(Transform::create(
                                     Matrix4x4::create()->lookAt(Vector3::create(0.f, 0.f, 0.f), Vector3::create(0.f, 0.f, 5.f))
                                     ))
    ->addComponent(PerspectiveCamera::create((float) WINDOW_WIDTH / (float) WINDOW_HEIGHT, (float) M_PI * 0.25f, .1f, 1000.f));

    root->addChild(camera);

    auto effectLoaderComplete = effectLoader->complete()->connect([&](file::Loader::Ptr loader)
                                                                  {
                                                                      // Retrieve the Basic effect from loaded assets library
                                                                      auto basicEffect = sceneManager->assets()->effect("effect/Basic.effect");
                                                                      // Set the default effect to apply on each surface
                                                                      sceneManager->assets()->loader()->options()->effect(basicEffect);

                                                                      // Start the file loading
                                                                      sceneManager->assets()->loader()->load();
                                                                  });

    auto fileLoaderComplete = sceneManager->assets()->loader()->complete()->connect([&](file::Loader::Ptr loader)
                                                                                    {
                                                                                        // Retrieve our IFC model
                                                                                        auto symbol = sceneManager->assets()->symbol(OBJ_MODEL_FILENAME);

                                                                                        // Add the symbol to the scene
                                                                                        root->addChild(symbol);
                                                                                    });

    auto enterFrame = canvas->enterFrame()->connect([&](Canvas::Ptr c, float t, float dt)
                                                    {
                                                        sceneManager->nextFrame(t, dt);
                                                    });

    // Start the effects loading
    effectLoader->load();

    canvas->run();

    return 0;
}

Exception at runtime what i get:

2016-03-08 14:49:12.204 minko-tutorial-06-load-3d-files[1916:72748] Final URL: file:///Users/arsenius/Library/Developer/CoreSimulator/Devices/8FE9D2D4-E9F3-480E-849E-5C5C8976B4E2/data/Containers/Data/Application/BAC86EB0-290F-4620-827C-1592B7D0EFE7/Library/ 2016-03-08 14:49:12.275 minko-tutorial-06-load-3d-files[1916:72748] Final URL: file:///Users/arsenius/Library/Developer/CoreSimulator/Devices/8FE9D2D4-E9F3-480E-849E-5C5C8976B4E2/data/Containers/Data/Application/BAC86EB0-290F-4620-827C-1592B7D0EFE7/Documents/ debug: Loader.cpp:182 protocolCompleteHandler(): file 'effect/Basic.effect' loaded, 0 file(s) still loading, 1 file(s) in the queue debug: Loader.cpp:182 protocolCompleteHandler(): file 'Basic.vertex.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue debug: Loader.cpp:182 protocolCompleteHandler(): file 'Skinning.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue debug: Loader.cpp:182 protocolCompleteHandler(): file 'Basic.fragment.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue debug: Loader.cpp:182 protocolCompleteHandler(): file 'Fog.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue debug: Loader.cpp:182 protocolCompleteHandler(): file 'effect/Phong.effect' loaded, 0 file(s) still loading, 0 file(s) in the queue debug: Loader.cpp:182 protocolCompleteHandler(): file 'Phong.vertex.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue debug: Loader.cpp:182 protocolCompleteHandler(): file 'Phong.fragment.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue debug: Loader.cpp:182 protocolCompleteHandler(): file 'Phong.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue debug: Loader.cpp:182 protocolCompleteHandler(): file 'Envmap.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue debug: Loader.cpp:182 protocolCompleteHandler(): file 'Phong.struct.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue debug: Loader.cpp:182 protocolCompleteHandler(): file 'model/pirate.obj' loaded, 0 file(s) still loading, 0 file(s) in the queue AbstractASSIMPParser::parse() AbstractASSIMPParser: preparing to parse debug: Loader.cpp:277 errorThrown(): : Invalid parameters passed to ReadFileFromMemory() libc++abi.dylib: terminating with uncaught exception of type minko::file::Error: Invalid parameters passed to ReadFileFromMemory()

What I'm doing wrong?

warrenseine commented 8 years ago

Please use the latest version of minko on master or dev branches if you're building new projects.

atonamy commented 8 years ago

Ok I use master, but now have another issue.

Just use load 3d files tutorial.

#include "minko/Minko.hpp"
#include "minko/MinkoSDL.hpp"
#include "minko/MinkoASSIMP.hpp"
#include "minko/MinkoJPEG.hpp"

using namespace minko;
using namespace minko::math;
using namespace minko::component;

const math::uint WINDOW_WIDTH = 800;
const math::uint WINDOW_HEIGHT = 600;

//const std::string OBJ_MODEL_FILENAME = "/asset/model/pirate.obj";
const std::string DAE_MODEL_FILENAME = "model/pirate.dae";

int main(int argc, char** argv)
{
    auto canvas = Canvas::create("Minko Tutorial - Loading 3D files", WINDOW_WIDTH, WINDOW_HEIGHT);
    auto sceneManager = component::SceneManager::create(canvas);

    canvas->context()->errorsEnabled(true);

    sceneManager->assets()->loader()->options()
        //->registerParser<file::OBJParser>("obj")
        ->registerParser<file::ColladaParser>("dae")
        ->registerParser<file::JPEGParser>("jpg");

    sceneManager->assets()->loader()
        ->queue("effect/Basic.effect")
        ->queue("effect/Phong.effect")
        ->queue(DAE_MODEL_FILENAME)
//      ->queue(OBJ_MODEL_FILENAME)
        ;

    sceneManager->assets()->loader()->options()
        ->generateMipmaps(true);

    auto root = scene::Node::create("root")
        ->addComponent(sceneManager);

    auto camera = scene::Node::create("camera")
        ->addComponent(Renderer::create(0x7f7f7fff))
        ->addComponent(Transform::create(inverse(lookAt(vec3(0.f, 0.f, 5.f), vec3(), vec3(0.f, 1.f, 0.f)))))
        ->addComponent(PerspectiveCamera::create((float)WINDOW_WIDTH / (float)WINDOW_HEIGHT, (float)M_PI * 0.25f, .1f, 1000.f));

    root->addChild(camera);
        sceneManager->assets()->loader()->options()
            ->effect(sceneManager->assets()->effect("effect/Basic.effect"));

    auto complete = sceneManager->assets()->loader()->complete()->connect([&](file::Loader::Ptr loader)
    {
        // DAE model
        auto daeModel = sceneManager->assets()->symbol(DAE_MODEL_FILENAME);

        auto daeMove = daeModel->component<Transform>();
        daeMove->matrix(translate(vec3(1.f, -1.f, 0.f)) * daeMove->matrix());

        // add the scene
        root->addChild(daeModel);

        /*// OBJ Model
        auto objModel = sceneManager->assets()->symbol(OBJ_MODEL_FILENAME);

        // change scale for the object file
        auto objScale = objModel->component<Transform>();
        objScale->matrix(scale(vec3(.01f)) * objScale->matrix());

        // change position for the object file
        auto objMove = objModel->component<Transform>();
        objMove->matrix(translate(vec3(-1.f, -1.f, 0.f)) * objMove->matrix());

        // add the scene
        root->addChild(objModel);*/

    });

    sceneManager->assets()->loader()->load();

    auto enterFrame = canvas->enterFrame()->connect([&](Canvas::Ptr canvas, float t, float dt)
    {
        sceneManager->nextFrame(t, dt);
    });

    canvas->run();

    return 0;
}

The exception is

2016-03-08 18:11:54.679 minko-tutorial-06-load-3d-files[7513:139821] Final URL: file:///Users/arsenius/Library/Developer/CoreSimulator/Devices/8FE9D2D4-E9F3-480E-849E-5C5C8976B4E2/data/Containers/Data/Application/04CC7CAE-5F27-4D55-854F-2B77727E54AB/Library/
2016-03-08 18:11:54.821 minko-tutorial-06-load-3d-files[7513:139821] Final URL: file:///Users/arsenius/Library/Developer/CoreSimulator/Devices/8FE9D2D4-E9F3-480E-849E-5C5C8976B4E2/data/Containers/Data/Application/04CC7CAE-5F27-4D55-854F-2B77727E54AB/Documents/
debug: Loader.cpp:200   protocolCompleteHandler(): file 'effect/Basic.effect' loaded, 0 file(s) still loading, 2 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'BaseStreamingTemplate.effect' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'BaseTemplate.effect' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Basic.vertex.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Skinning.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Pop.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Basic.fragment.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'TextureLod.extension.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Fog.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Math.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'TextureLod.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'LightMapping.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'effect/Phong.effect' loaded, 0 file(s) still loading, 1 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Phong.vertex.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Pack.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Phong.fragment.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Envmap.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'Phong.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
debug: Loader.cpp:200   protocolCompleteHandler(): file 'ShadowMapping.function.glsl' loaded, 0 file(s) still loading, 0 file(s) in the queue
error: Loader.cpp:329   errorThrown(): ProtocolError: File does not exist: model/pirate.dae, include paths: /Users/arsenius/Library/Developer/CoreSimulator/Devices/8FE9D2D4-E9F3-480E-849E-5C5C8976B4E2/data/Containers/Bundle/Application/E2763720-3997-4D35-9888-BFF10B6FEE55/minko-tutorial-06-load-3d-files.app/asset,/Users/arsenius/Library/Developer/CoreSimulator/Devices/8FE9D2D4-E9F3-480E-849E-5C5C8976B4E2/data/Containers/Bundle/Application/E2763720-3997-4D35-9888-BFF10B6FEE55/minko-tutorial-06-load-3d-files.app/../../../asset
libc++abi.dylib: terminating with uncaught exception of type minko::file::Error: File does not exist: model/pirate.dae, include paths: /Users/arsenius/Library/Developer/CoreSimulator/Devices/8FE9D2D4-E9F3-480E-849E-5C5C8976B4E2/data/Containers/Bundle/Application/E2763720-3997-4D35-9888-BFF10B6FEE55/minko-tutorial-06-load-3d-files.app/asset,/Users/arsenius/Library/Developer/CoreSimulator/Devices/8FE9D2D4-E9F3-480E-849E-5C5C8976B4E2/data/Containers/Bundle/Application/E2763720-3997-4D35-9888-BFF10B6FEE55/minko-tutorial-06-load-3d-files.app/../../../asset
(lldb) 

File does not exist But all files in asset folder. I checked.

Noxalus commented 8 years ago

This is due to the fact that some assets copy instructions are missing to the premake5.lua file. Try adding this at the end of the file:

minko.package.assets {
    ['**'] = { 'copy' }
}
atonamy commented 8 years ago

I just edited shell script like on screenshot below and it works now. Thanks a lot. screen shot 2016-03-08 at 7 24 10 pm

Need to fix it. Otherwise for beginners like me it's taking a lot of time to get started. I spent whole day just to fix this issue.