its still not able to set the material of just an object....so i guess this means that its a problem with creating the texture
#include "CEGUI/CEGUI.h"
#include "OgrePrerequisites.h"
#include "OgreCEGUIRenderer.h"
#include "MovieLogic.h"
#include "OgreStringConverter.h"
#include "OgreLogManager.h"
#include "OgreException.h"
#include "OgreTexture.h"
#include "OgreTextureManager.h"
#include "OgreMaterialManager.h"
#include "OgreTechnique.h"
#include "OgreExternalTextureSourceManager.h"
namespace Ogre
{
MovieLogic::MovieLogic( CEGUI::OgreCEGUIRenderer *renderer )
{
mGUIRenderer = renderer;
mSoundSystem = 0;
mVideoControl = 0;
done = false;
maxTime = 0.0f;
mClip = 0;
mText = 0;
mAudio = 0;
mPaused = true;
}
MovieLogic::~MovieLogic()
{
if( mClip )
{
mClip->changePlayMode( TextureEffectPause );
mVideoControl->destroyAdvancedTexture( "Example/TheoraVideoPlayer/Play" );
}
if( mSoundSystem )
{
mSoundSystem->destroyAudio( mAudio );
VideoSoundManager::stopVideoSoundManager( mSoundSystem );
}
//Unloaded any loaded sound modules
VideoSoundManager::unloadSoundModules();
}
void MovieLogic::initialise()
{
mVideoControl = static_cast<TheoraVideoController*>
(ExternalTextureSourceManager::getSingleton().
getExternalTextureSource("ogg_video"));
if( !mVideoControl )
OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
"Error grabbing Plugin_TheoraVideoSystem. Added in plugins.cfg file?",
"MovieLogic::initialise");
std::vector<std::string> list = VideoSoundManager::loadSoundModules();
//Set first in list as default one
mSoundSystem = VideoSoundManager::startUpVideoSoundManager(list[0]);
}
void MovieLogic::changeSoundSystem( const std::string& sndMgr )
{
VideoSoundManager::stopVideoSoundManager( mSoundSystem );
mSoundSystem = VideoSoundManager::startUpVideoSoundManager(sndMgr);
CEGUI::WindowManager::getSingletonPtr()->getWindow("APS")->setText(sndMgr);
}
unsigned int MovieLogic::getWidth()
{
return mClip->getVideoDriver()->getWidth();
}
unsigned int MovieLogic::getHeight()
{
return mClip->getVideoDriver()->getHeight();
}
void MovieLogic::stopMovie()
{
if( mClip )
{
mClip->changePlayMode( TextureEffectPause );
mVideoControl->destroyAdvancedTexture( "Example/TheoraVideoPlayer/Play" );
if( mSoundSystem )
mSoundSystem->destroyAudio( mAudio );
}
maxTime = 0.0f;
mClip = 0;
mText = 0;
mAudio = 0;
mPaused = true;
}
void MovieLogic::pauseMovie( bool bPause )
{
if( mClip )
{
if( mPaused == bPause )
return;
if( mPaused == false )
mClip->changePlayMode( TextureEffectPause );
else
mClip->changePlayMode( TextureEffectPlay_ASAP );
mPaused = bPause;
}
}
void MovieLogic::playMovie( const String& movieName )
{
stopMovie();
mVideoControl->setInputName( movieName );
mVideoControl->setPlayMode( TextureEffectPause );
mVideoControl->setTextureTecPassStateLevel( 0, 0, 0 );
mVideoControl->setSeekEnabled( false );
mVideoControl->setAutoAudioUpdate( true );
MaterialPtr material = MaterialManager::getSingleton().getByName("Example/TheoraVideoPlayer/Play");
if( material.isNull() )
material = MaterialManager::getSingleton().create("Example/TheoraVideoPlayer/Play", "General");
material->getTechnique(0)->getPass(0)->createTextureUnitState();
mVideoControl->createDefinedTexture( "Example/TheoraVideoPlayer/Play", "General" );
mClip = mVideoControl->getMaterialNameClip( "Example/TheoraVideoPlayer/Play" );
if( !mClip )
OGRE_EXCEPT( Exception::ERR_ITEM_NOT_FOUND, "Clip not found", "MovieLogic::playMovie" );
mClip->registerMessageHandler( this );
if( mSoundSystem )
{
mAudio = mSoundSystem->createAudio();
mClip->setAudioDriver( mAudio );
}
mClip->changePlayMode( TextureEffectPlay_ASAP );
mPaused = false;
mCurrentMoviePlaying = mClip->getMovieName();
mText = mGUIRenderer->createTexture( mClip->getVideoDriver()->getTexture() );
done = false;
}
int MovieLogic::messageEvent( PLUGIN_theora_message m )
{
switch( m )
{
case TH_TheoraStreamDone:
done = true;
LogManager::getSingleton().logMessage("Video Packets empty");
break;
case TH_VorbisStreamDone:
LogManager::getSingleton().logMessage("Audio Packets empty");
break;
case TH_OggStreamDone:
LogManager::getSingleton().logMessage("End of file reached");
break;
case TH_EndOfMovie:
LogManager::getSingleton().logMessage("Movie Playback done");
break;
}
return 0;
}
}
this is the movie logic code.....
using namespace CEGUI;
mMovieControl = new MovieLogic(mGUIRenderer);
mMovieControl->initialise();
FrameWindow* fwnd3 = (FrameWindow*)WindowManager::getSingleton().getWindow("PlayWindow");
assert( fwnd3 );
StaticImage* simg = 0;
mMovieControl->playMovie( "LAXMovieTVOD3TVOD.ogg" );
simg = (StaticImage*)WindowManager::getSingleton().createWindow("TaharezLook/StaticImage", "PlayWindow/Image1");
fwnd3->addChildWindow(simg);
simg->setMaximumSize(Size(2.0f, 2.0f));
simg->setPosition(Point(0.0f, 0.05f));
simg->setSize(Size(1.0f, 0.86f));
simg->setFrameEnabled(false);
simg->setBackgroundEnabled(false);
//Now attach Texture to
if( mMovieControl->getTexture() )
{
CEGUI::String temp = "MyImagesNumber";
CEGUI::String tempName = mMovieControl->getTextureName();
Imageset *img = ImagesetManager::getSingleton().createImageset(
temp, mMovieControl->getTexture() );
unsigned int width = mMovieControl->getWidth();
unsigned int height= mMovieControl->getHeight();
img->defineImage( tempName, Point(0.0f,0.0f), Size( width, height ), Point(0.0f,0.0f));
simg = (StaticImage*)WindowManager::getSingleton().getWindow("PlayWindow/Image1");
simg->setImage( temp, tempName);
}
this is wheri create the movielogic and try to play a video...can you see anything that looks wrong....i copied and pasted the code form the demo project into my project...the demoproject works but not the game....
thanks for all the help by the way....i really appreciate it...