bool ElAvatar::creat(unsigned int width, unsigned int height) { using namespace ELGUI; // setup texture D3DXCreateTexture(ElDeviceManager::getDevice(), width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &mTexture); mTexture->GetSurfaceLevel(0, &mSurface); // setup imageset ElGUITexture* gui_texture = (ElGUITexture*)System::getSingleton().getRenderer()->createTexture(); gui_texture->setTexture(mTexture); Imageset* imageset = ImagesetManager::getSingleton().createImageset(ElAvatarImageset, gui_texture); Rect rect = Rect(Point(0.0f, 0.0f), Size(width, height)); imageset->defineImage(ElAvatarImage, rect, Point(0.0f, 0.0f)); // setup scene if (!_createScene()) return false; // setup scene camera ElCamera* sceneCamera = ElNew ElCamera; float aspect = (float)width / (float)height; //sceneCamera->setPosition(D3DXVECTOR3(0.0f, 1.0f, -5.0f)); sceneCamera->setPosition(D3DXVECTOR3(0.0f, 2.175f, -0.5f)); sceneCamera->setProjectionParameters(ElCamera::PT_PERSPECTIVE, D3DX_PI / 4, aspect, 0.1f, 500.0f); mScene->setCamera(sceneCamera); return true; }
//----------------------------------------------------------------------- CEGUI::Imageset* EditorDocument::generateRealImageset(const wxString& pathName) { const String imagesetName ( CEGUIHelper::ToCEGUIString( m_imagesetName ) ); const String imageFilename ( CEGUIHelper::ToCEGUIString( pathName + m_imageFilename ) ); ImagesetManager& isMgr = ImagesetManager::getSingleton(); if ( isMgr.isImagesetPresent( imagesetName ) ) // TODO: Maybe ask user whether to continue here? isMgr.destroyImageset( imagesetName ); // create the imageset Imageset* imageset = isMgr.createImagesetFromImageFile( imagesetName, imageFilename ); // auto-scale options imageset->setAutoScalingEnabled( m_autoScaled ); imageset->setNativeResolution( CEGUI::Size( m_nativeResolution.x, m_nativeResolution.y ) ); // iterate over all the elements in the class mapNamedRegion::iterator it; for( it = m_mapSetRectangles.begin(); it != m_mapSetRectangles.end(); ++it ) { const String imageName = CEGUIHelper::ToCEGUIString( wxString( it->first ) ); if ( !imageset->isImageDefined( imageName ) ) { const wxRect r( it->second ); const CEGUI::Rect newDim( ( ( r.GetLeft() > 0 ) ? r.GetLeft() : 0 ), ( ( r.GetTop() > 0 ) ? r.GetTop() : 0 ), ( ( r.GetRight() + 1 > 0 ) ? r.GetRight() + 1 : 0 ), ( ( r.GetBottom() + 1 > 0 ) ? r.GetBottom() + 1 : 0 ) ); const CEGUI::Point p ( 0.0f, 0.0f ); imageset->defineImage( imageName, newDim, p ); } } if ( imageset->isImageDefined ( "full_image" ) ) imageset->undefineImage( "full_image" ); return imageset; }