static GLint Gen3DObjectList() { int i; int j; GLint lid=glGenLists(1); int mcount=0; int mindex=0; glNewList(lid, GL_COMPILE); glBegin (GL_TRIANGLES); for(i=0;i<sizeof(face_indicies)/sizeof(face_indicies[0]);i++) { if(!mcount) { SelectMaterial(material_ref[mindex][0]); mcount=material_ref[mindex][1]; mindex++; } mcount--; for(j=0;j<3;j++) { int vi=face_indicies[i][j]; int ni=face_indicies[i][j+3];//Normal index int ti=face_indicies[i][j+6];//Texture index glNormal3f (normals[ni][0],normals[ni][1],normals[ni][2]); glTexCoord2f(textures[ti][0],textures[ti][1]); glVertex3f (vertices[vi][0],vertices[vi][1],vertices[vi][2]); } } glEnd (); glEndList(); return lid; };
void MaterialEditor::OnCellSelected(UIList *, UIListCell *selectedCell) { if (selectedCell->GetIndex() != selectedMaterial) { if (lastSelection && lastSelection->GetIndex() == selectedMaterial) { lastSelection->SetSelected(false, false); } selectedCell->SetSelected(true, false); lastSelection = selectedCell; SelectMaterial(selectedCell->GetIndex()); } }
void MaterialEditor::OnAllPressed(BaseObject * , void * , void * ) { displayMode = EDM_ALL; btnAll->SetSelected(true, false); btnSelected->SetSelected(false, false); if (lastSelection) { lastSelection->SetSelected(false, false); lastSelection = NULL; } SelectMaterial(0); RefreshList(); }
void MaterialEditor::WillDisappear() { for_each(materials.begin(), materials.end(), SafeRelease<Material>); materials.clear(); for_each(workingNodeMaterials.begin(), workingNodeMaterials.end(), SafeRelease<Material>); workingNodeMaterials.clear(); SelectMaterial(-1); if (lastSelection) { lastSelection->SetSelected(false, false); lastSelection = NULL; } }
void MaterialEditor::SetWorkingScene(Scene *newWorkingScene, SceneNode *newWorkingSceneNode) { if ((newWorkingScene == workingScene) && (workingSceneNode == newWorkingSceneNode)) { return; } SafeRelease(workingMaterial); SafeRelease(workingSceneNode); SafeRelease(workingScene); workingScene = SafeRetain(newWorkingScene); materialProps->SetWorkingScene(workingScene); workingSceneNode = SafeRetain(newWorkingSceneNode); UdpateButtons(NULL != workingSceneNode); SelectMaterial(0); RefreshList(); }
void MaterialEditor::SetSize(const Vector2 &newSize) { DraggableDialog::SetSize(newSize); btnSetupFog->SetPosition(Vector2(newSize.x - ControlsFactory::BUTTON_WIDTH, ControlsFactory::BUTTON_HEIGHT)); btnSetupColor->SetPosition(Vector2(newSize.x - ControlsFactory::BUTTON_WIDTH*2, ControlsFactory::BUTTON_HEIGHT)); line->SetPosition(Vector2(newSize.x - ControlsFactory::BUTTON_WIDTH*3, ControlsFactory::BUTTON_HEIGHT * 3)); Rect setupFogRect(newSize.x - ControlsFactory::BUTTON_WIDTH, ControlsFactory::BUTTON_HEIGHT, ControlsFactory::BUTTON_WIDTH, ControlsFactory::BUTTON_HEIGHT); Rect fogRect(setupFogRect.x - ControlsFactory::BUTTON_WIDTH, setupFogRect.dy + setupFogRect.y, ControlsFactory::BUTTON_WIDTH * 2, ControlsFactory::BUTTON_HEIGHT * 5); fogControl->SetRect(fogRect); Rect setupColorRect(setupFogRect); setupColorRect.x -= ControlsFactory::BUTTON_WIDTH; Rect colorRect(setupColorRect.x - ControlsFactory::BUTTON_WIDTH, setupColorRect.dy + setupColorRect.y, ControlsFactory::BUTTON_WIDTH * 3, ControlsFactory::BUTTON_HEIGHT * 5); colorControl->SetRect(colorRect); float32 materialListWidth = materialsList->GetSize().x; Rect noMaterialsRect = noMaterials->GetRect(); noMaterials->SetRect(Rect(materialListWidth, noMaterialsRect.y, newSize.x - materialListWidth, noMaterialsRect.dy)); Rect propsRect = materialProps->GetRect(); RemoveControl(materialProps); SafeRelease(materialProps); materialProps = new MaterialPropertyControl(Rect(materialListWidth, propsRect.y, newSize.x - materialListWidth, propsRect.dy), false); materialProps->SetDelegate(this); AddControl(materialProps); SelectMaterial(selectedMaterial); }