 |
Irrlicht Engine Official forum of the Irrlicht Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Emil_halim
Joined: 29 Mar 2005 Posts: 518 Location: Alex,Egypt
|
Posted: Tue Apr 12, 2005 8:06 pm Post subject: Playing movie in texture |
|
|
Hi ALL
here is a TMovie class that will allow you to play any movie format in a texture
| Code: |
#include <dshow.h>
#include <mmstream.h>
#include <amstream.h>
#include <ddstream.h>
static GUID MY_CLSID_AMMultiMediaStream={0x49C47CE5,0x9BA4,0x11D0,0x82,0x12,0x00,0xC0,0x4F,0xC3,0x2C,0x45};
static GUID MY_IID_IAMMultiMediaStream={0xBEBE595C,0x9A6F,0x11D0,0x8F,0xDE,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
static GUID MY_MSPID_PrimaryVideo={0xA35FF56A,0x9FDA,0x11D0,0x8F,0xDF,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
static GUID MY_IID_IDirectDrawMediaStream={0xF4104FCE,0x9A70,0x11D0,0x8F,0xDE,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
static GUID MY_MSPID_PrimaryAudio={0xA35FF56B,0x9FDA,0x11D0,0x8F,0xDF,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
class TMovie
{
IAMMultiMediaStream* pAMStream;
IMediaStream* pPrimaryVidStream;
IDirectDrawMediaStream* pDDStream;
IDirectDrawStreamSample* pSample;
IDirectDrawSurface* pSurface;
RECT Movie_rect;
LONG MoviePitch;
void* MovieBuffer;
DWORD time;
DWORD oldtick;
public:
TMovie()
{
CoInitialize(0);
pAMStream = 0;
pPrimaryVidStream = 0;
pDDStream = 0;
pSample = 0;
pSurface = 0;
time = 0;
}
~TMovie()
{
pPrimaryVidStream->Release();
pDDStream->Release();
pSample->Release();
pSurface->Release();
pAMStream->Release();
CoUninitialize();
}
void LoadMovie(char* filename)
{
WCHAR buf[512];
MultiByteToWideChar(CP_ACP,0,filename,-1,buf,512);
CoCreateInstance(MY_CLSID_AMMultiMediaStream,0,1,MY_IID_IAMMultiMediaStream,(void**)&pAMStream);
pAMStream->Initialize((STREAM_TYPE) 0, 0, NULL);
pAMStream->AddMediaStream( 0, &MY_MSPID_PrimaryVideo, 0, NULL);
pAMStream->OpenFile(buf,4);
pAMStream->GetMediaStream( MY_MSPID_PrimaryVideo, &pPrimaryVidStream);
pPrimaryVidStream->QueryInterface(MY_IID_IDirectDrawMediaStream,(void**)&pDDStream);
pDDStream->CreateSample(0,0,0,&pSample);
pSample->GetSurface(&pSurface,&Movie_rect);
pAMStream->SetState((STREAM_STATE)1);
}
void NextMovieFrame()
{
if(GetTickCount()-oldtick < time)return ;
oldtick = GetTickCount();
pSample->Update( 0, NULL, NULL, 0);
}
int MovieWidth() { return (Movie_rect.right - Movie_rect.left);}
int MovieHeight() { return (Movie_rect.bottom - Movie_rect.top);}
void DrawMovie(int x,int y,ITexture* Buf)
{
void* pBits = Buf->lock();
LONG Pitch = Buf->getPitch();
DDSURFACEDESC ddsd;
ddsd.dwSize=sizeof(DDSURFACEDESC);
pSurface->Lock( NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT , NULL);
int wmin=(Pitch<ddsd.lPitch)?Pitch:ddsd.lPitch;
for(int h=0; h<ddsd.dwHeight; h++)
memcpy((BYTE*)pBits+((y+h)*Pitch)+x*4,(BYTE*)ddsd.lpSurface+h*ddsd.lPitch,wmin);
pSurface->Unlock(NULL);
Buf->unlock();
}
void SetMovieFPS(int fps)
{
time = fps;
}
} ;
|
you can use it as the following
| Code: |
TMovie* movie = new TMovie;
movie->LoadMovie("mymovie.mpg");
movie->SetMovieFPS(25);
ITexture* movTxtr;
irrVideo->setTextureCreationFlag(ETCF_ALWAYS_32_BIT , TRUE);
irrVideo->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, FALSE);
movTxtr = irrVideo->addTexture(dimension2d<s32>(512,256),"imovie");
while(irrDevice->run())
{
irrVideo->beginScene(true, true, SColor(0,200,200,200))
movie->NextMovieFrame()
movie->DrawMovie(0,0,movTxtr)
irrSceneMgr->drawAll()
irrVideo->endScene()
}
|
now you see how it is so easy to play any movie in your texture.
next time i will add some effect functions that allow you to play movie in grayscale, negative. _________________ Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/ |
|
| Back to top |
|
 |
keless
Joined: 15 Dec 2003 Posts: 802 Location: Los Angeles, California, USA
|
Posted: Tue Apr 12, 2005 9:03 pm Post subject: |
|
|
can anyone add some openGL code behind this interface so its not DX-dependant? I think I saw a tutorial on AVI texture rendering at gametutorials.com _________________ a screen cap is worth 0x100000 DWORDS |
|
| Back to top |
|
 |
Emil_halim
Joined: 29 Mar 2005 Posts: 518 Location: Alex,Egypt
|
Posted: Wed Apr 13, 2005 4:47 am Post subject: |
|
|
| keless wrote: | | can anyone add some openGL code behind this interface so its not DX-dependant? I think I saw a tutorial on AVI texture rendering at gametutorials.com |
i have tested it with OpenGL ,DX9, DX8, and it works very well.
so what kind of movie this class will play ?
it will play any movie format that you install it's codec in your system, i mean
AVI , MPEG, ASF , ......
also you can control the Speed of Playing by SetMovieFPS function,so try
defferent value and see the speed. _________________ Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/ |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Apr 13, 2005 5:08 am Post subject: |
|
|
Ahh but it won't work with linux as is, No DShow  |
|
| Back to top |
|
 |
Emil_halim
Joined: 29 Mar 2005 Posts: 518 Location: Alex,Egypt
|
Posted: Wed Apr 13, 2005 5:56 am Post subject: |
|
|
i have added some functions that allow you to make pixel processing on your movie
so you can play your movie in grayscale,nigative,also you can apply those effects to the entire
movie or a specific rectangle part of movie.
here is the new class
| Code: |
#include <dshow.h>
#include <mmstream.h>
#include <amstream.h>
#include <ddstream.h>
static GUID MY_CLSID_AMMultiMediaStream={0x49C47CE5,0x9BA4,0x11D0,0x82,0x12,0x00,0xC0,0x4F,0xC3,0x2C,0x45};
static GUID MY_IID_IAMMultiMediaStream={0xBEBE595C,0x9A6F,0x11D0,0x8F,0xDE,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
static GUID MY_MSPID_PrimaryVideo={0xA35FF56A,0x9FDA,0x11D0,0x8F,0xDF,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
static GUID MY_IID_IDirectDrawMediaStream={0xF4104FCE,0x9A70,0x11D0,0x8F,0xDE,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
static GUID MY_MSPID_PrimaryAudio={0xA35FF56B,0x9FDA,0x11D0,0x8F,0xDF,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
class TMovie
{
IAMMultiMediaStream* pAMStream;
IMediaStream* pPrimaryVidStream;
IDirectDrawMediaStream* pDDStream;
IDirectDrawStreamSample* pSample;
IDirectDrawSurface* pSurface;
RECT Movie_rect;
LONG MoviePitch;
void* MovieBuffer;
DWORD time;
DWORD oldtick;
BOOL flg;
public:
TMovie()
{
CoInitialize(0);
pAMStream = 0;
pPrimaryVidStream = 0;
pDDStream = 0;
pSample = 0;
pSurface = 0;
time = 0;
}
~TMovie()
{
pPrimaryVidStream->Release();
pDDStream->Release();
pSample->Release();
pSurface->Release();
pAMStream->Release();
CoUninitialize();
}
void LoadMovie(char* filename)
{
WCHAR buf[512];
MultiByteToWideChar(CP_ACP,0,filename,-1,buf,512);
CoCreateInstance(MY_CLSID_AMMultiMediaStream,0,1,MY_IID_IAMMultiMediaStream,(void**)&pAMStream);
pAMStream->Initialize((STREAM_TYPE) 0, 0, NULL);
pAMStream->AddMediaStream( 0, &MY_MSPID_PrimaryVideo, 0, NULL);
pAMStream->OpenFile(buf,4);
pAMStream->GetMediaStream( MY_MSPID_PrimaryVideo, &pPrimaryVidStream);
pPrimaryVidStream->QueryInterface(MY_IID_IDirectDrawMediaStream,(void**)&pDDStream);
pDDStream->CreateSample(0,0,0,&pSample);
pSample->GetSurface(&pSurface,&Movie_rect);
pAMStream->SetState((STREAM_STATE)1);
}
void NextMovieFrame()
{
if(GetTickCount()-oldtick < time){flg = false ;return;}
oldtick = GetTickCount();
flg = true;
pSample->Update( 0, NULL, NULL, 0);
}
int MovieWidth() { return (Movie_rect.right - Movie_rect.left);}
int MovieHeight() { return (Movie_rect.bottom - Movie_rect.top);}
void DrawMovie(int x,int y,ITexture* Buf)
{
void* pBits = Buf->lock();
LONG Pitch = Buf->getPitch();
DDSURFACEDESC ddsd;
ddsd.dwSize=sizeof(DDSURFACEDESC);
pSurface->Lock( NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT , NULL);
int wmin=(Pitch<ddsd.lPitch)?Pitch:ddsd.lPitch;
for(int h=0; h<ddsd.dwHeight; h++)
memcpy((BYTE*)pBits+((y+h)*Pitch)+x*4,(BYTE*)ddsd.lpSurface+h*ddsd.lPitch,wmin);
pSurface->Unlock(NULL);
Buf->unlock();
}
void SetMovieFPS(int fps)
{
time = fps;
}
void MovieLock()
{
DDSURFACEDESC ddsd;
ddsd.dwSize=sizeof(DDSURFACEDESC);
pSurface->Lock( NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
MoviePitch = ddsd.lPitch;
MovieBuffer = ddsd.lpSurface;
}
void MovieUnlock()
{
pSurface->Unlock( NULL);
}
void Gray(int x1,int y1,int x2,int y2)
{
if(!flg) return;
DWORD clr;
LPBYTE buff;
for (int h=y1; h<y2; h++)
for (int w=x1; w<x2; w++)
{
buff = (LPBYTE)MovieBuffer + w*4 + h*MoviePitch;
clr = (buff[0] + buff[1] + buff[2]) /3;
*(DWORD*)buff = RGB((BYTE)clr,(BYTE)clr,(BYTE)clr);
}
}
void Negative(int x1,int y1,int x2,int y2)
{
if(!flg) return;
DWORD clr;
LPBYTE buff;
for (int h=y1; h<y2; h++)
for (int w=x1; w<x2; w++)
{
buff = (LPBYTE)MovieBuffer + w*4 + h*MoviePitch;
*(DWORD*)buff = RGB((BYTE)255-buff[0],(BYTE)255-buff[1],(BYTE)255-buff[2]);
}
}
void Intensity(float intnsty,int x1,int y1,int x2,int y2)
{
if(!flg) return;
DWORD clr;
LPBYTE buff;
for (int h=y1; h<y2; h++)
for (int w=x1; w<x2; w++)
{
buff = (LPBYTE)MovieBuffer + w*4 + h*MoviePitch;
*(DWORD*)buff = RGB((BYTE)buff[0]/intnsty,(BYTE)buff[1]/intnsty,(BYTE)buff[2]/intnsty);
}
}
};
|
and here is how you can use it and apply the effects
| Code: |
while(irrDevice->run())
{
irrVideo->beginScene(true, true, SColor(0,200,200,200));
movie->NextMovieFrame() ;
movie->MovieLock();
movie->Gray(0,0,320,240) ;
// movie->Negative(0,0,320,240);
// movie->Intensity(2.5,0,0,320,100);
movie->MovieUnlock();
movie->DrawMovie(0,0,movTxtr);
irrSceneMgr->drawAll()
irrVideo->endScene()
}
|
_________________ Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/ |
|
| Back to top |
|
 |
Emil_halim
Joined: 29 Mar 2005 Posts: 518 Location: Alex,Egypt
|
|
| Back to top |
|
 |
hybrid Guest
|
Posted: Wed Apr 13, 2005 7:48 am Post subject: |
|
|
| Emil_halim wrote: | | keless wrote: | | can anyone add some openGL code behind this interface so its not DX-dependant? I think I saw a tutorial on AVI texture rendering at gametutorials.com |
i have tested it with OpenGL ,DX9, DX8, and it works very well.
|
But I guess you did not test it on a system with no DirectX installed?! Although I do not know these MS d-foo features I would guess that dshow is part of DX. that's why it is not working with OpenGL. It just renders to the OpenGL capable window with DirectX functions. If it would use OpenGL it would be possible to use it with Linux as well.
I think that OpenGL processing as well as any Linux support would need another library to do the video file format parsing so plenty of work and another bunch of dependencies. But if there is an interface defined--maybe based on the code posted in this thread--it could be possible to create a portable add-on. |
|
| Back to top |
|
 |
Emil_halim
Joined: 29 Mar 2005 Posts: 518 Location: Alex,Egypt
|
Posted: Wed Apr 13, 2005 4:38 pm Post subject: |
|
|
| hybrid wrote: | | Emil_halim wrote: | | keless wrote: | | can anyone add some openGL code behind this interface so its not DX-dependant? I think I saw a tutorial on AVI texture rendering at gametutorials.com |
i have tested it with OpenGL ,DX9, DX8, and it works very well.
|
But I guess you did not test it on a system with no DirectX installed?! Although I do not know these MS d-foo features I would guess that dshow is part of DX. that's why it is not working with OpenGL. It just renders to the OpenGL capable window with DirectX functions. If it would use OpenGL it would be possible to use it with Linux as well.
|
yes , i have tested it with windows XP and directx9 installed.
really i do not know how to do that in linux. _________________ Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/ |
|
| Back to top |
|
 |
DexTer Guest
|
Posted: Thu Apr 14, 2005 1:12 pm Post subject: |
|
|
Just a thought,
------------------
I think there should be a compiler directives or something,
like USE_GL_FEATURES when using OpenGL or USE_D3X_FEATURES.
when using DirectX drivers.
To add or use some D3X or OGL extra features
that cannot be implemented on both or a features
that only one of then has. I beleived both the drivers
has thier own special features.
I thinks its kewl to have these, to not limit the engine
for using only features that can implement on both drivers.
coz i believe both of them has thier own strength & weakneses.
------------------
Nywayz, I gonna try this one, I think it is COOL to test 'your D3X DxShow
Player' on my project.
Hiyaa... |
|
| Back to top |
|
 |
Emil_halim
Joined: 29 Mar 2005 Posts: 518 Location: Alex,Egypt
|
Posted: Thu Apr 14, 2005 6:38 pm Post subject: |
|
|
Here is a working example that showing you how to play your movie in
a rotating surface in the screen.
| Code: |
#include <dshow.h>
#include <mmstream.h>
#include <amstream.h>
#include <ddstream.h>
#include "irrlicht.h"
// Irrlicht Namespaces
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
static GUID MY_CLSID_AMMultiMediaStream={0x49C47CE5,0x9BA4,0x11D0,0x82,0x12,0x00,0xC0,0x4F,0xC3,0x2C,0x45};
static GUID MY_IID_IAMMultiMediaStream={0xBEBE595C,0x9A6F,0x11D0,0x8F,0xDE,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
static GUID MY_MSPID_PrimaryVideo={0xA35FF56A,0x9FDA,0x11D0,0x8F,0xDF,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
static GUID MY_IID_IDirectDrawMediaStream={0xF4104FCE,0x9A70,0x11D0,0x8F,0xDE,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
static GUID MY_MSPID_PrimaryAudio={0xA35FF56B,0x9FDA,0x11D0,0x8F,0xDF,0x00,0xC0,0x4F,0xD9,0x18,0x9D};
class TMovie
{
IAMMultiMediaStream* pAMStream;
IMediaStream* pPrimaryVidStream;
IDirectDrawMediaStream* pDDStream;
IDirectDrawStreamSample* pSample;
IDirectDrawSurface* pSurface;
RECT Movie_rect;
LONG MoviePitch;
void* MovieBuffer;
DWORD time;
DWORD oldtick;
BOOL flg;
public:
TMovie()
{
CoInitialize(0);
pAMStream = 0;
pPrimaryVidStream = 0;
pDDStream = 0;
pSample = 0;
pSurface = 0;
time = 0;
}
~TMovie()
{
pPrimaryVidStream->Release();
pDDStream->Release();
pSample->Release();
pSurface->Release();
pAMStream->Release();
CoUninitialize();
}
void LoadMovie(char* filename)
{
WCHAR buf[512];
MultiByteToWideChar(CP_ACP,0,filename,-1,buf,512);
CoCreateInstance(MY_CLSID_AMMultiMediaStream,0,1,MY_IID_IAMMultiMediaStream,(void**)&pAMStream);
pAMStream->Initialize((STREAM_TYPE) 0, 0, NULL);
pAMStream->AddMediaStream( 0, &MY_MSPID_PrimaryVideo, 0, NULL);
pAMStream->OpenFile(buf,4);
pAMStream->GetMediaStream( MY_MSPID_PrimaryVideo, &pPrimaryVidStream);
pPrimaryVidStream->QueryInterface(MY_IID_IDirectDrawMediaStream,(void**)&pDDStream);
pDDStream->CreateSample(0,0,0,&pSample);
pSample->GetSurface(&pSurface,&Movie_rect);
pAMStream->SetState((STREAM_STATE)1);
}
void NextMovieFrame()
{
if(GetTickCount()-oldtick < time){flg = false ;return;}
oldtick = GetTickCount();
flg = true;
pSample->Update( 0, NULL, NULL, 0);
}
int MovieWidth() { return (Movie_rect.right - Movie_rect.left);}
int MovieHeight() { return (Movie_rect.bottom - Movie_rect.top);}
void DrawMovie(int x,int y,ITexture* Buf)
{
void* pBits = Buf->lock();
LONG Pitch = Buf->getPitch();
DDSURFACEDESC ddsd;
ddsd.dwSize=sizeof(DDSURFACEDESC);
pSurface->Lock( NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT , NULL);
int wmin=(Pitch<ddsd.lPitch)?Pitch:ddsd.lPitch;
for(int h=0; h<ddsd.dwHeight; h++)
memcpy((BYTE*)pBits+((y+h)*Pitch)+x*4,(BYTE*)ddsd.lpSurface+h*ddsd.lPitch,wmin);
pSurface->Unlock(NULL);
Buf->unlock();
}
void SetMovieFPS(int fps)
{
time = fps;
}
void Stop()
{
pAMStream->SetState(STREAMSTATE_STOP);
}
void Run()
{
pAMStream->SetState(STREAMSTATE_RUN);
}
void MovieLock()
{
DDSURFACEDESC ddsd;
ddsd.dwSize=sizeof(DDSURFACEDESC);
pSurface->Lock( NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
MoviePitch = ddsd.lPitch;
MovieBuffer = ddsd.lpSurface;
}
void MovieUnlock()
{
pSurface->Unlock( NULL);
}
void Gray(int x1,int y1,int x2,int y2)
{
if(!flg) return;
DWORD clr;
LPBYTE buff;
for (int h=y1; h<y2; h++)
for (int w=x1; w<x2; w++)
{
buff = (LPBYTE)MovieBuffer + w*4 + h*MoviePitch;
clr = (buff[0] + buff[1] + buff[2]) /3;
*(DWORD*)buff = RGB((BYTE)clr,(BYTE)clr,(BYTE)clr);
}
}
void Negative(int x1,int y1,int x2,int y2)
{
if(!flg) return;
DWORD clr;
LPBYTE buff;
for (int h=y1; h<y2; h++)
for (int w=x1; w<x2; w++)
{
buff = (LPBYTE)MovieBuffer + w*4 + h*MoviePitch;
*(DWORD*)buff = RGB((BYTE)255-buff[0],(BYTE)255-buff[1],(BYTE)255-buff[2]);
}
}
void Intensity(float intnsty,int x1,int y1,int x2,int y2)
{
if(!flg) return;
DWORD clr;
LPBYTE buff;
for (int h=y1; h<y2; h++)
for (int w=x1; w<x2; w++)
{
buff = (LPBYTE)MovieBuffer + w*4 + h*MoviePitch;
*(DWORD*)buff = RGB((BYTE)buff[0]/intnsty,(BYTE)buff[1]/intnsty,(BYTE)buff[2]/intnsty);
}
}
};
class CSampleSceneNode : public ISceneNode
{
aabbox3d<f32> Box;
S3DVertex Vertices[4];
SMaterial Material;
public:
CSampleSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id): ISceneNode(parent, mgr, id)
{
float u = 320.0/512.0;
float v = 240.0/256.0;
Material.Wireframe = false;
Material.Lighting = false;
Vertices[0] = S3DVertex(-10,-10,0, 0,0,0,SColor(255,255,255,255),0,v);
Vertices[1] = S3DVertex( 10,-10,0, 0,0,0,SColor(255,255,255,255),u,v);
Vertices[2] = S3DVertex( 10, 10,0, 0,0,0,SColor(255,255,255,255),u,0);
Vertices[3] = S3DVertex(-10, 10,0, 0,0,0,SColor(255,255,255,255),0,0);
Box.reset(Vertices[0].Pos);
for (s32 i=1; i<4; ++i) Box.addInternalPoint(Vertices[i].Pos);
}
virtual void OnPreRender()
{
if (IsVisible) SceneManager->registerNodeForRendering(this);
ISceneNode::OnPreRender();
}
virtual void render()
{
u16 indices[] = { 0,1,3, 3,1,2, 1,0,2, 2,0,3 };
IVideoDriver* driver = SceneManager->getVideoDriver();
driver->setMaterial(Material);
driver->setTransform(ETS_WORLD, AbsoluteTransformation);
driver->drawIndexedTriangleList(&Vertices[0], 4, &indices[0], 4);
}
virtual const aabbox3d<f32>& getBoundingBox() const
{
return Box;
}
virtual s32 getMaterialCount()
{
return 1;
}
virtual SMaterial& getMaterial(s32 i)
{
return Material;
}
};
int main()
{
IrrlichtDevice* irrDevice = createDevice(EDT_OPENGL,dimension2d<s32>(640,480),32,false,false,false,0);
IVideoDriver* irrVideo = irrDevice->getVideoDriver();
ISceneManager* irrSceneMgr = irrDevice->getSceneManager();
TMovie* movie = new TMovie;
movie->LoadMovie("Mymovie.asf");
movie->SetMovieFPS(25);
irrVideo->setTextureCreationFlag(ETCF_ALWAYS_32_BIT , TRUE);
irrVideo->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, FALSE);
ITexture* movTxtr = irrVideo->addTexture(dimension2d<s32>(512,256),"imovie");
irrSceneMgr->addCameraSceneNode(0, vector3df(0,0,-20), vector3df(0,0,0));
CSampleSceneNode* myNode = new CSampleSceneNode(irrSceneMgr->getRootSceneNode(), irrSceneMgr, 666);
myNode->setMaterialTexture( 0, movTxtr);
myNode->drop();
ISceneNodeAnimator* anim = irrSceneMgr->createRotationAnimator(vector3df(0,0.1f,0));
myNode->addAnimator(anim);
anim->drop();
while(device->run())
{
irrVideo->beginScene(true, true, SColor(0,200,200,200));
movie->NextMovieFrame();
movie->DrawMovie(0,0,movTxtr);
irrSceneMgr->drawAll();
irrVideo->endScene();
}
device->drop();
return 0;
}
|
i hope you like it. _________________ Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/ |
|
| Back to top |
|
 |
Guest
|
Posted: Fri Apr 15, 2005 9:54 am Post subject: |
|
|
OK, so it won't run on Linux, or the Mac, or most other platforms.
That doesn't mean it isn't useful to a lot of people though.
At the very least it's a working suggestion for how someone would interface with a moving video texture.
I suppose an OpenGL equivalent could be based on OpenML. |
|
| Back to top |
|
 |
hybrid Guest
|
Posted: Fri Apr 15, 2005 12:58 pm Post subject: |
|
|
| Anonymous wrote: |
At the very least it's a working suggestion for how someone would interface with a moving video texture.
I suppose an OpenGL equivalent could be based on OpenML. |
What is OpenML ?
But a more important point is that an automatically updating texture will definitely be of some interest. So why not starting from the proposal in this thread and abstract from the implementation? If someone creates an interface (or interface extension) to allow dynamic updating of video textures anyone could use it. The different, probably hardware or platfrom dependent, implementations would not hurt that much anymore. It would be much easier for someone to add new implementations for Linux and others as well.
If I read the code well enough there is no direct relation to any directX method except for the data preparations. Thus, everything comes down to an interface allowing scheduled texture updates and some helper functions to provide the new texture on time.
NB: Even in my Linux directed point of view it is a nice piece of code provided by Emil and at least my postings were not meant to offend anyone. It was just a correction since the original announcement was not complete with respect to OpenGL support. |
|
| Back to top |
|
 |
Emil_halim
Joined: 29 Mar 2005 Posts: 518 Location: Alex,Egypt
|
Posted: Fri Apr 15, 2005 2:48 pm Post subject: |
|
|
if someone here consider himself a Linux guru, and know how the movie in linux can be played as a stream , so he could implement the movie player easly.
i will explain it setp by step
Dshow gives us a control on playing movie as stream, and allow us to update that stream in frame
after frame. and gives us a frame in a DirectDraw surface.
so i update textuer by lock the DirectDraw surface and the texture it self, then copy from
the surface to a texture ,so you have to create a texture bigger than the surface in size,
then i unlocked the surface and the texture.
that is all, so it will be very easy if we could get a frame by frame in linux. is there a library
could make that in linux ? _________________ Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/ |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Apr 21, 2005 8:09 pm Post subject: |
|
|
| How can i add sound too? |
|
| Back to top |
|
 |
Emil_halim
Joined: 29 Mar 2005 Posts: 518 Location: Alex,Egypt
|
Posted: Fri Apr 22, 2005 5:39 am Post subject: |
|
|
actually,adding sound is very easy,but it has some bugs that i do not fix untill now.
any way replace the LoadMovie function with this
| Code: |
void LoadMovie(char* filename)
{
WCHAR buf[512];
MultiByteToWideChar(CP_ACP,0,filename,-1,buf,512);
CoCreateInstance(MY_CLSID_AMMultiMediaStream,0,1,MY_IID_IAMMultiMediaStream,(void**)&pAMStream);
pAMStream->Initialize((STREAM_TYPE) 0, 0, NULL);
pAMStream->AddMediaStream( 0, &MY_MSPID_PrimaryVideo, 0, NULL);
pAMStream->AddMediaStream( 0, &MY_MSPID_PrimaryAudio, AMMSF_ADDDEFAULTRENDERER, NULL);
pAMStream->OpenFile(buf,AMMSF_RENDERTOEXISTING); // 4);
pAMStream->GetMediaStream( MY_MSPID_PrimaryVideo, &pPrimaryVidStream);
pPrimaryVidStream->QueryInterface(MY_IID_IDirectDrawMediaStream,(void**)&pDDStream);
pDDStream->CreateSample(0,0,0,&pSample);
pSample->GetSurface(&pSurface,&Movie_rect);
pAMStream->SetState((STREAM_STATE)1);
}
|
have fun. _________________ Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/ |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|