We have it working in our mod for replace a model's texture with a video. It
is a bit tricky in this respect because you have to pre-design your uv to
work with it, but it would be easy to translate it to just draw a quad in
the world with that as the texture; Referring to IBIK. It isn't that hard.
Here are the important steps:

First in the OnDataChanged I do this to create my BIK material and get it
ready to be used.

if(updateType == DATA_UPDATE_CREATED)
{
        m_hBikMaterial =
bik->CreateMaterial(m_strVideoMaterial,m_strVideoMaterial,"GAME");

        if ( m_hBikMaterial != BIKMATERIAL_INVALID )
        {
                m_pMaterial = bik->GetMaterial(m_hBikMaterial);
                SetNextClientThink(CLIENT_THINK_ALWAYS);
        }

        if(m_pMaterial)
                m_pMaterial->AddRef();
}

Next in the ClientThink of the entity that you are using to allow the mapper
to input the video file you do.

if(m_hBikMaterial != BIKMATERIAL_INVALID)
{
        if(!bik->Update(m_hBikMaterial))
        {
                bik->SetFrame(m_hBikMaterial,0.0f);
        }
}

This basically attempts to update to a new frame if it is the end I think it
will fail and so it just sets the frame back to the start so it always
loops. You'll have to be sure to clean up your references and stuff when the
entity dies as well, but that is simple stuff. And using it on the model is
as simple as in DrawModel:

modelrender->ForceMaterialOverride(m_pMaterial);
int val = BaseClass::DrawModel(flags);
modelrender->ForceMaterialOverride(0);
return val;

I only wish they would expose someway to manipulate the sound stream so you
can have it appear to come from the world itself and not play everywhere no
matter what. I also first had tried to use IAvi to use AVI files instead,
but that interface refused to work.

Chris

-----Original Message-----
From: hlcoders-boun...@list.valvesoftware.com
[mailto:hlcoders-boun...@list.valvesoftware.com] On Behalf Of Jonas 'Sortie'
Termansen
Sent: Thursday, March 18, 2010 3:28 PM
To: Discussion of Half-Life Programming
Subject: Re: [hlcoders] [GoldSrc] AviKit in any mods?

I attempted to work with BINK and Source's implementation of it. Sadly 
there is not enough functions exposed and not enough documentation to 
really use it. Unless you have engine access, there is no real reliable 
way of getting it working in my experience. I recommend using ffmpeg if 
you can get it working; I have a very simple half-done implementation of 
it - but it's not as good as it could be.

Tony "omega" Sergi skrev:
> You actually shouldn't need to even use avikit.. since the engine has
> loading of avi's AND bink videos.
> preferably you would want to use bink anyway as you wouldn't need to worry
> about codecs.
>
> loading a bink video actually returns a material anyway, and there is an
> actual 'bik' shader for drawing on objects.
> i've never used the shader myself though, i just know it exists.
> -Tony
>
>
> On Fri, Mar 19, 2010 at 3:19 AM, Jonas 'Sortie' Termansen
<hlcod...@maxsi.dk
>   
>> wrote:
>>     
>
>   
>> I have success implementing the free software ffmpeg library in Source.
>> There is nothing like watching a 720p HD xvid on an ingame surface. :D
>> It's not very well implemented though and I don't have any sound
>> support. I'd gladly share the source code with you. ffmpeg is very fast
>> and it provides all the codecs itself and supports most formats VLC do
>> (because it is used by VLC).
>>
>> Rodrigo 'r2d2rigo' Diaz skrev:
>>     
>>> AVIkit was used in a demo MOD from the creator of the library, but AFAIK
>>>       
>> he
>>     
>>> didn't release the source code. I tried to add it some time ago, but
>>>       
>> finally
>>     
>>> dropped the idea.
>>>
>>> 2010/3/18 kevin bowen <fragmasterbo...@gmail.com>
>>>
>>>
>>>       
>>>> Just wondering if anyone has implemented AVIkit and is willing to part
>>>>         
>> with
>>     
>>>> the code :) or if AVIkit has been used in any open source mods (rebirth
>>>>         
>> and
>>     
>>>> arrangemod have the lib's included but don't actually call the
>>>>         
>> functions).
>>     
>>>> I'd do it myself but it would literally take years (I'm a moron), it'd
>>>>         
>> be
>>     
>>>> easier just to ask for it here just incase any devs have a dead hl1 mod
>>>> with
>>>> the code already laid out :)
>>>>
>>>> I've scoured the internet and all I could find was this on a russian HL
>>>> coding site which seems to use the code but I'm not sure if it's an
>>>>         
>> entire
>>     
>>>> replacement for avikit.cpp or if it fits in there somehow (again I'm a
>>>> moron
>>>> when it comes to this)
>>>>
>>>>
>>>>
>>>>  ///////////////////////////////////////////////////////////////
>>>> // Only setup the avi if it's actually a video screen
>>>>
>>>> if (isVideoScreen && replacement[0] != '\0') {
>>>>    char *error_msg = NULL;
>>>>    long xres = 0;
>>>>    long yres = 0;
>>>>    float duration = 0.0f;
>>>>
>>>>    movie = new AVIKit( absolute_replacement, false );
>>>>    if (movie->getError( &error_msg ) != AVIKIT_NOERROR) {
>>>>        gEngfuncs.Con_DPrintf( "SetupAvisFromEntities: Error opening %s:
>>>> %s\n", absolute_replacement, error_msg );
>>>>        delete movie;
>>>>        break;
>>>>    }
>>>>    movie->getVideoInfo( &xres, &yres, &duration );
>>>>    gEngfuncs.Con_DPrintf( "SetupAvisFromEntities: Opened %s: %ld x %ld
>>>>         
>> (%f
>>     
>>>> secs)\n", replacement, xres, yres, duration );
>>>>    gEngfuncs.Con_DPrintf( "Video screen at (%d %d %d), with extents (%d
>>>>         
>> %d
>>     
>>>> %d)\n",
>>>>    (int)origin[0], (int)origin[1], (int)origin[2],
>>>>    (int)extents[0], (int)extents[1], (int)extents[2] );
>>>>
>>>>    // Create the OpenGL texture
>>>>    GLuint texnum;
>>>>    glGenTextures( 1, &texnum );
>>>>
>>>>    if (!AddComplexAvi( movie, texnum, origin, angles, extents,
>>>>         
>> &error_msg
>>     
>>>> )) {
>>>>        gEngfuncs.Con_DPrintf( "SetupAvisFromEntities: Error adding
>>>>         
>> movie:
>>     
>>>> %s\n", error_msg );
>>>>        delete movie;
>>>>    }
>>>>    } else if (isVideoScreen) {
>>>>        gEngfuncs.Con_DPrintf( "SetupAvisFromEntities: Video screen
>>>>         
>> didn't
>>     
>>>> have a movie specified!\n" );
>>>>    }
>>>>
>>>>    //Setting up the texture:
>>>>
>>>>    movie->getVideoInfo( &data->width, &data->height,
&data->total_length
>>>>         
>> );
>>     
>>>>    glEnable( GL_TEXTURE_2D );
>>>>    glBindTexture( GL_TEXTURE_2D, data->texture_index );
>>>>    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
>>>>    glTexImage2D( GL_TEXTURE_2D, 0, 3, data->width, data->height, 0,
>>>>         
>> GL_RGB,
>>     
>>>> GL_UNSIGNED_BYTE, tmpbuffer );
>>>>
>>>>    //Updating the texture each frame:
>>>>
>>>>    // Calculate the frame needed
>>>>    int frame = i->movie->getVideoFrameNumber( i->current_time );
>>>>
>>>>    // If the frame has changed, re-upload it
>>>>    if (frame != i->current_frame) {
>>>>        i->current_frame = frame;
>>>>        i->movie->getVideoFrame( (char*)i->buffer, frame );
>>>>
>>>>        // If the video isn't a power of two on all sides, we need to
>>>>         
>> resize
>>     
>>>> it... <img src="images/smilies/frown.gif" border="0" alt="">
>>>>        if (i->resized_buffer) {
>>>>            gluScaleImage( GL_RGB, i->realwidth, i->realheight,
>>>> GL_UNSIGNED_BYTE, i->buffer, i->width, i->height, GL_UNSIGNED_BYTE,
>>>> i->resized_buffer );
>>>>            // ... and update the OpenGL texture ...
>>>>            glEnable(GL_TEXTURE_2D);
>>>>            glBindTexture( GL_TEXTURE_2D, i->texture_index );
>>>>            glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, i->width,
i->height,
>>>> GL_RGB, GL_UNSIGNED_BYTE, i->resized_buffer );
>>>>            } else {
>>>>                // ... and update the OpenGL texture ...
>>>>                glEnable(GL_TEXTURE_2D);
>>>>                glBindTexture( GL_TEXTURE_2D, i->texture_index );
>>>>                glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, i->width,
>>>> i->height, GL_RGB, GL_UNSIGNED_BYTE, i->buffer );
>>>>            }
>>>>        }
>>>>
>>>>        // If this is a complex movie, draw the polygons
>>>>        if (i->texture_type == AVI_TEXTURE_USER) {
>>>>
>>>>            glEnable( GL_TEXTURE_2D );
>>>>            glBindTexture( GL_TEXTURE_2D, i->texture_index );
>>>>            glDisable( GL_BLEND );
>>>>            glBegin( GL_QUADS );
>>>>
>>>>            // Top left
>>>>            glColor3f( 1.0f, 1.0f, 1.0f );
>>>>            glTexCoord2f( 0.0f, 1.0f );
>>>>            glVertex3f( i->vertexes[0].x, i->vertexes[0].y,
>>>>         
>> i->vertexes[0].z
>>     
>>>> );
>>>>
>>>>            // Bottom left
>>>>            glColor3f( 1.0f, 1.0f, 1.0f );
>>>>            glTexCoord2f( 0.0f, 0.0f );
>>>>            glVertex3f( i->vertexes[1].x, i->vertexes[1].y,
>>>>         
>> i->vertexes[1].z
>>     
>>>> );
>>>>
>>>>            // Bottom right
>>>>            glColor3f( 1.0f, 1.0f, 1.0f );
>>>>            glTexCoord2f( 1.0f, 0.0f );
>>>>            glVertex3f( i->vertexes[2].x, i->vertexes[2].y,
>>>>         
>> i->vertexes[2].z
>>     
>>>> );
>>>>
>>>>            // Top right
>>>>            glColor3f( 1.0f, 1.0f, 1.0f );
>>>>            glTexCoord2f( 1.0f, 1.0f );
>>>>            glVertex3f( i->vertexes[3].x, i->vertexes[3].y,
>>>>         
>> i->vertexes[3].z
>>     
>>>> );
>>>>
>>>>            glEnd();
>>>>        }
>>>>  ///////////////////////////////////////////////////////////////
>>>>
>>>>
>>>> Regardless of this, the AVIkit mod also included fmod.dll, which I'm
>>>> guessing is used for sound and I'm not sure how it pulls this from the
>>>>         
>> AVI.
>>     
>>>> Kevin
>>>> _______________________________________________
>>>> To unsubscribe, edit your list preferences, or view the list archives,
>>>> please visit:
>>>> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>>>>
>>>>
>>>>
>>>>         
>>> _______________________________________________
>>> To unsubscribe, edit your list preferences, or view the list archives,
>>>       
>> please visit:
>>     
>>> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>>>
>>>       
>> _______________________________________________
>> To unsubscribe, edit your list preferences, or view the list archives,
>> please visit:
>> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>>
>>
>>     
>
>
>   


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to