laumaya / GLC_lib

GLC_lib is a C++ library for high performance 3D application based on OpenGL and Qt4 GUI
http://www.glc-lib.net
Other
61 stars 31 forks source link

how to load two models #28

Open Kevin-WangXing opened 6 years ago

Kevin-WangXing commented 6 years ago

I want to load two models,where this lib can load two models?Thanks

PaddiM commented 6 years ago

Not sure if I understand your question. You could load each model in its own world and merge these worlds.

Was this the question?

Kevin-WangXing commented 6 years ago

I want load two models,finally in one world can control them do diffent motion

Kevin-WangXing commented 6 years ago

now use the function of mergeWithAnotherWorld,but have a problem ,two models cannot fully dispaly,

PaddiM commented 6 years ago

What do you mean with "fully display"? Have you tested both models if the contents are valid?

Kevin-WangXing commented 6 years ago

two models are valid, because I had serverally load every models. when I load two models, I found those models merger together, But I hope get two unbroken models, don't know how to deal with it. whether when I load models , also need to set coordinate? I neeed to control each model separately move. Thanks

PaddiM commented 6 years ago

Ah ok,

take a look here:

void GLC_World::mergeWithAnotherWorld(GLC_World& anotherWorld) { GLC_StructOccurrence pAnotherRoot= anotherWorld.rootOccurrence(); GLC_StructOccurrence pRoot= rootOccurrence(); if (pAnotherRoot->childCount() > 0) { QList<GLC_StructOccurrence*> childs= pAnotherRoot->children(); const int size= childs.size(); for (int i= 0; i < size; ++i) { pRoot->addChild(childs.at(i)->clone(m_pWorldHandle, false)); } pRoot->updateChildrenAbsoluteMatrix(); } else { pRoot->addChild(anotherWorld.rootOccurrence()->clone(m_pWorldHandle, false)); } }

So if you check for the added occurrences of the second model, you could modify the matrix of these to move them (never tried it, but should work)

Kevin-WangXing commented 6 years ago

yes, if want to control two models,must separate those, may modify matrix can work, however don't konw which function I should change, which function is right, saw most function,also test ,no work, can you give me some advices. thank U

PaddiM commented 6 years ago

You could use the instance (GLC_StructInstance) from an occurrence. It has methods for move, translate and direct matrix assignment.