This is the structure I'm using to hold the model info:
Code: Select all
struct OBJECT
{
scene::IAnimatedMeshSceneNode* Model;
wchar_t model_name[1024];
core::vector3df scale;
s32 listID;
};
OBJECT object[10];
After loading a model, I have this part:
Code: Select all
object[model_count].listID = lbox->addItem(object[model_count].model_name);
model_count++;
Here's part of the event reciever:
Code: Select all
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
IGUIEnvironment* env = Device->getGUIEnvironment();
switch(event.GUIEvent.EventType)
{
case EGET_MENU_ITEM_SELECTED:
{
// a menu item was clicked
IGUIContextMenu* menu = (IGUIContextMenu*)event.GUIEvent.Caller;
s32 id = menu->getItemCommandId(menu->getSelectedItem());
switch(id)
{
case 100: // File -> Open Model
env->addFileOpenDialog(L"Please select a model file to open");
break;
case 200: // File -> Quit
Device->closeDevice();
break;
case 300: // View -> Skybox
SkyBox->setVisible(!SkyBox->isVisible());
break;
case 400: // View -> Debug Information
if (object[model_number].Model)
object[model_number].Model->setDebugDataVisible(!object[model_number].Model->isDebugDataVisible());
break;
case 500: // Help->About
showAboutText();
break;
case 610: // View -> Material -> Solid
if (object[model_number].Model)
object[model_number].Model->setMaterialType(video::EMT_SOLID);
break;
case 620: // View -> Material -> Transparent
if (object[model_number].Model)
object[model_number].Model->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
break;
case 630: // View -> Material -> Reflection
if (object[model_number].Model)
object[model_number].Model->setMaterialType(video::EMT_SPHERE_MAP);
break;
}
break;
}
case EGET_LISTBOX_CHANGED:
if(id == 150)
{
s32 id = lbox->getSelected();
int item_count = 0;
while(item_count < lbox->getItemCount())
{
if(object[item_count].listID == id)
{
model_number = item_count;
}
item_count++;
}
}
break;