Loading Videos
Blitz3D Forums/Blitz3D Programming/Loading Videos
| ||
Is there any way to load videos into the game and play it through the game? I am not sure if there is a way, but if there is that would be really helpful with something else i am doing. |
| ||
Yes, you can play AVI files directly onto a texture surface. Check out: http://www.blitzbasic.com/b3ddocs/command.php?name=OpenMovie&ref=2d_cat in the manual. |
| ||
Ok ill try that. Thank you! |
| ||
it works great. I had a metal gear solid trailer playing on a terrain, each polygon of the terrain showed the video, so it was like flying over a giant mosaic of video screens. I'm not sure if the sound is 3D though, you'll need to experiment with that. |
| ||
Apologise my roughness, where the heck is the example of using openmovie to draw to a texture?? I opened your link, but it seems that is just the 2D openmovie ddraw command. I could do 3D video textures only with BlitzMovie.dll, are you sure you can draw a video texture with native blitz3D commands ? Ok, I found this and seems ok to me: ;--- VIDEO --------------------- movies_millis=MilliSecs()-movies_millis movies_storemillis=movies_storemillis+movies_millis movies_millis=MilliSecs() If movies_storemillis>32 movies_storemillis=0 DrawMovie( ? ) ;draw movie here CopyRect ? ;copyrect to texture here EndIf ;---------------------------------- |
| ||
Yeah... I think it's something like SetBuffer TextureBuffer(movietex) DrawMovie(hmovie,0,0,MovieWidth(hmovie),MovieHeight(hmovie)) SetBuffer BackBuffer() There should be an example in the archives. |
| ||
As far as I recall you can't drawmovie directly to a texturebuffer. Or probably it works only on some cards, and not on some others. Altering Pixels of a texture is slow anyway, so using Copyrect to copy eg. from backbuffer to texturebuffer is pretty fast. But you definitely NEED to set the texture flag 256 to get at least half-decent speed. |
| ||
i will try and find the code but i had an example of a avi playing on a spining cube. i think it was really simple |
| ||
rob had an example in the code archives, misc 3d, it was a link to a "movie3d.zip", but the link is broken now. ok here's a quick sample that should work on most machines: ; playing a movie in a texture Graphics3D 640,480,32,2 SetBuffer BackBuffer() camera=CreateCamera() TranslateEntity camera,0,0,-4 light=CreateLight() RotateEntity light, 45,45,0 cube=CreateCube() tex=CreateTexture(256,256,256) EntityTexture cube,tex movie_file$="test.avi" movie=OpenMovie(movie_file$) While KeyDown(1)=0 dummy=DrawMovie(movie,0,0,256,256) ; here you can scale the movie to the texture size most efficiently CopyRect 0,0,256,256,0,0,BackBuffer(),TextureBuffer(tex) If MoviePlaying(movie)=0 Then CloseMovie movie movie=OpenMovie(movie_file$) ; reload when finished = loop EndIf TurnEntity cube,.2,.4,.6 RenderWorld() Flip Wend CloseMovie movie End |
| ||
; Simple movie on 3D Object example (rob@...) ; sample avi was a simple quicktime trailer preview converted. ; for best results and efficient memory usage please use power of two sizes. ; ie. 256x256 Graphics3D 640,480,16,2 camera=CreateCamera() light=CreateLight() ;create texture for the movie & 3d entity movietex = CreateTexture(256,256,256+48) cube = CreateCube() EntityTexture cube,movietex MoveEntity cube,0,0,6 EntityFX cube,16 EntityBlend cube,3 For i=0 To 3 temp=CopyEntity(cube,cube) PositionEntity temp,Rnd(-10,10),Rnd(-10,10),Rnd(-10,10) Next ;load movie movie = OpenMovie("sample.avi") While Not KeyHit(1) ; this is just a delay before updating movie If t>2 t=0 If MoviePlaying(movie)=0 Then movie = OpenMovie("sample.avi") DrawMovie(movie) CopyRect 0,0,256,128,0,0,BackBuffer(),TextureBuffer(movietex) EndIf t=t+1 TurnEntity cube,-.4,.4,0 RenderWorld Flip Wend End |
| ||
Works great thanks, it was bugging me i couldnt find the old example but i know i have it some where |