Wc3C.net

Wc3C.net (http://www.wc3c.net/forums.php)
-   Systems (http://www.wc3c.net/forumdisplay.php?f=648)
-   -   Cinematic System (http://www.wc3c.net/showthread.php?t=79554)

Anitarf 01-21-2006 05:59 PM

Cinematic System
 
3 Attachment(s)
A Jass system designed for cinematic composing and playback.

It grants the mapmaker more control and precision in manipulating units, special effects and cameras than is possible with regular GUI triggers.

The system was first used in the Blizzard's cinematic contest winner, The Spirit of Vengeance made by me and iNfraNe.

Version History

Version 1.5b
- Made the system compatible with Warcraft patch 1.24

Version 1.5
- Added subtitle display function for movie-like subtitles
- Added unshaded fade filters, see the "other engines" chapter for more detail
- Added a lock-camera-on-unit feature for camera position and camera facing
- Added a function to the script system for changing individual camera properties
- Tweaked the camera movement to be more precise over uneven terrain
- Did some more optimisation on the particle system

Version 1.4
- Added a fog engine for gradual changes of fog distance and colour
- Redid the particle and camera systems so they should run faster
- - the particle system can now only work with units that are actors
- - you mustn't change the unit custom value of actors for the system to work
- Added unit scaling support to the particle and scripting systems
- The camera trigger can now be turned on or off, for use in playable maps
- Did some more optimisation to the script system functions

Version 1.3
- Did some performance optimisation; thanks to Vexorian for pointing some things out.

Version 1.2
- First public release


Elthanor 01-21-2006 06:19 PM

This might come in handy, but i might need to learn some JAss first.

Any BTW, I LOVED your movie, its soo awesome. Great job!

Vexorian 01-21-2006 06:29 PM

GC is a horribly generic name and needs to be more specific to the system but the problem is that you call it everytime
Collapse BAD:

function CameraMainLoop takes nothing returns nothing
    local real array a
    local real array v
    local real array s
    local real array time
    local integer i = 0

    loop
        exitwhen i == 9
        set i = i + 1
        set time[i] = GetStoredReal( GC(), "camera", "time" + I2S(i) ) + CameraPeriod()

        if time[i] > GetStoredReal( GC(), "camera", "endtime" + I2S(i) ) then
            if GetStoredReal( GC(), "camera", "acc2" + I2S(i) ) != 0 then
                call StoreReal( GC(), "camera", "acc" + I2S(i), GetStoredReal( GC(), "camera", "acc2" + I2S(i) ) )
                call StoreReal( GC(), "camera", "startvel" + I2S(i), GetStoredReal( GC(), "camera", "vel" + I2S(i) ) )
                call StoreReal( GC(), "camera", "startdis" + I2S(i), GetStoredReal( GC(), "camera", "dis" + I2S(i) ) )
                call StoreReal( GC(), "camera", "time" + I2S(i), 0.00 )
                call StoreReal( GC(), "camera", "acc2" + I2S(i), 0.00 )
                set time[i] = 0.00
            else
            endif
        endif

        set a[i] = GetStoredReal( GC(), "camera", "acc" + I2S(i) )
        set v[i] = GetStoredReal( GC(), "camera", "startvel" + I2S(i) )
        set s[i] = GetStoredReal( GC(), "camera", "startdis" + I2S(i) )

        call StoreReal( GC(), "camera", "time" + I2S(i), (time[i]) )

        set s[i] = s[i] + ( v[i] * time[i] ) + ( a[i] * time[i] * time[i] / 2 )
        set v[i] = v[i] + ( a[i] * time[i] )
        if i > 3 and i < 7 then
            if s[i] > 360 then
                set s[i] = s[i] - 360
            elseif s[i] < 0 then
                set s[i] = s[i] + 360
            endif
        endif

        call StoreReal( GC(), "camera", "vel" + I2S(i), v[i] )
        call StoreReal( GC(), "camera", "dis" + I2S(i), s[i] )


    endloop

    call PanCameraToTimed( s[1], s[2], 0.00 )
    call SetCameraField( CAMERA_FIELD_ZOFFSET, s[3], 0.00 )
    call SetCameraField( CAMERA_FIELD_ROTATION, s[4], 0.00 )
    call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, s[5], 0.00 )
    call SetCameraField( CAMERA_FIELD_ROLL, s[6], 0.00 )
    call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, s[7], 0.00 )
    call SetCameraField( CAMERA_FIELD_FARZ, s[8], 0.00 )
    call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, s[9], 0.00 ) 
endfunction

Collapse Good:
function CameraMainLoop takes nothing returns nothing
 local real array a
 local real array v
 local real array s
 local real array time
 local integer i = 0
 local gamecache g=g

    loop
        exitwhen i == 9
        set i = i + 1
        set time[i] = GetStoredReal( g, "camera", "time" + I2S(i) ) + CameraPeriod()

        if time[i] > GetStoredReal( g, "camera", "endtime" + I2S(i) ) then
            if GetStoredReal( g, "camera", "acc2" + I2S(i) ) != 0 then
                call StoreReal( g, "camera", "acc" + I2S(i), GetStoredReal( g, "camera", "acc2" + I2S(i) ) )
                call StoreReal( g, "camera", "startvel" + I2S(i), GetStoredReal( g, "camera", "vel" + I2S(i) ) )
                call StoreReal( g, "camera", "startdis" + I2S(i), GetStoredReal( g, "camera", "dis" + I2S(i) ) )
                call StoreReal( g, "camera", "time" + I2S(i), 0.00 )
                call StoreReal( g, "camera", "acc2" + I2S(i), 0.00 )
                set time[i] = 0.00
            else
            endif
        endif

        set a[i] = GetStoredReal( g, "camera", "acc" + I2S(i) )
        set v[i] = GetStoredReal( g, "camera", "startvel" + I2S(i) )
        set s[i] = GetStoredReal( g, "camera", "startdis" + I2S(i) )

        call StoreReal( g, "camera", "time" + I2S(i), (time[i]) )

        set s[i] = s[i] + ( v[i] * time[i] ) + ( a[i] * time[i] * time[i] / 2 )
        set v[i] = v[i] + ( a[i] * time[i] )
        if i > 3 and i < 7 then
            if s[i] > 360 then
                set s[i] = s[i] - 360
            elseif s[i] < 0 then
                set s[i] = s[i] + 360
            endif
        endif

        call StoreReal( g, "camera", "vel" + I2S(i), v[i] )
        call StoreReal( g, "camera", "dis" + I2S(i), s[i] )


    endloop

    call PanCameraToTimed( s[1], s[2], 0.00 )
    call SetCameraField( CAMERA_FIELD_ZOFFSET, s[3], 0.00 )
    call SetCameraField( CAMERA_FIELD_ROTATION, s[4], 0.00 )
    call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, s[5], 0.00 )
    call SetCameraField( CAMERA_FIELD_ROLL, s[6], 0.00 )
    call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, s[7], 0.00 )
    call SetCameraField( CAMERA_FIELD_FARZ, s[8], 0.00 )
    call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, s[9], 0.00 ) 
 set g=null
endfunction

Why? Because the GC function has a comparission and a return and many other things that charge the performance - As bad as using BJ functions. In functions like this one it is getting called way too much times and using a local will make the charge lighter,

Any logical explanation for doing this:

Collapse BAD:

    call StoreReal( GC(), "camera", "startdis" + I2S(1), CameraSetupGetDestPositionX( whichSetup ) )
    call StoreReal( GC(), "camera", "startdis" + I2S(2), CameraSetupGetDestPositionY( whichSetup ) )
    call StoreReal( GC(), "camera", "startdis" + I2S(3), CameraSetupGetField( whichSetup, CAMERA_FIELD_ZOFFSET ) )
    call StoreReal( GC(), "camera", "startdis" + I2S(4), CameraSetupGetField( whichSetup, CAMERA_FIELD_ROTATION ) )
    call StoreReal( GC(), "camera", "startdis" + I2S(5), CameraSetupGetField( whichSetup, CAMERA_FIELD_ANGLE_OF_ATTACK ) )
    call StoreReal( GC(), "camera", "startdis" + I2S(6), CameraSetupGetField( whichSetup, CAMERA_FIELD_ROLL ) )
    call StoreReal( GC(), "camera", "startdis" + I2S(7), CameraSetupGetField( whichSetup, CAMERA_FIELD_FIELD_OF_VIEW ) )
    call StoreReal( GC(), "camera", "startdis" + I2S(8), CameraSetupGetField( whichSetup, CAMERA_FIELD_FARZ ) )
    call StoreReal( GC(), "camera", "startdis" + I2S(9), CameraSetupGetField( whichSetup, CAMERA_FIELD_TARGET_DISTANCE ) )

instead of this?

Collapse Good:
    call StoreReal( GC(), "camera", "startdis1", CameraSetupGetDestPositionX( whichSetup ) )
    call StoreReal( GC(), "camera", "startdis2", CameraSetupGetDestPositionY( whichSetup ) )
    call StoreReal( GC(), "camera", "startdis3", CameraSetupGetField( whichSetup, CAMERA_FIELD_ZOFFSET ) )
    call StoreReal( GC(), "camera", "startdis4", CameraSetupGetField( whichSetup, CAMERA_FIELD_ROTATION ) )
    call StoreReal( GC(), "camera", "startdis5", CameraSetupGetField( whichSetup, CAMERA_FIELD_ANGLE_OF_ATTACK ) )
    call StoreReal( GC(), "camera", "startdis6", CameraSetupGetField( whichSetup, CAMERA_FIELD_ROLL ) )
    call StoreReal( GC(), "camera", "startdis7", CameraSetupGetField( whichSetup, CAMERA_FIELD_FIELD_OF_VIEW ) )
    call StoreReal( GC(), "camera", "startdis8", CameraSetupGetField( whichSetup, CAMERA_FIELD_FARZ ) )
    call StoreReal( GC(), "camera", "startdis9", CameraSetupGetField( whichSetup, CAMERA_FIELD_TARGET_DISTANCE ) )

Edit: you also have an ==true in the B2I function which is btw useless

iNfraNe 01-21-2006 06:30 PM

Well the good thing about this is, you dont REALLY have to know jass, just some common sense, since all the functions are prebuild and you just need to write some lines (almost all functions are showed in the example cinematic it holds, to make it even easier)

Anitarf 01-21-2006 07:00 PM

Quote:

Originally Posted by Vexorian
GC is a horribly generic name and needs to be more specific to the system but the problem is that you call it everytime

Well, the advantage is I can type it quickly, and when using game cache natives instead of handle vars, that's a big factor. :)

Quote:

Why? Because the GC function has a comparission and a return and many other things that charge the performance - As bad as using BJ functions.
It's still one function call less than using handle variables. But I agree, your suggestion means a considerable optimization, I'll implement it in the next version.

Quote:

Any logical explanation for doing this:

*Insert embarrasingly noob-like code here*
No logical explanation, just the result of copy-pasting, and the irrational fear that 1 might not convert exactly to "1". Will fix.

Quote:

Edit: you also have an ==true in the B2I function which is btw useless
Indeed it is. But it was worse before, I was using the return bug before iNfraNe told me this is faster. :)

Vexorian 01-21-2006 07:11 PM

Why have a B2I at all ?

And

Quote:

Well, the advantage is I can type it quickly, and when using game cache natives instead of handle vars, that's a big factor. :)
if you use g it would be even faster

Anitarf 01-21-2006 07:23 PM

Yeah, well... I had a deadline when I was making this! (excuses, excuses :) )

Anyway, I fixed that now, at least in the most critical functions. It was kinda lame not to use the handle vars because of performance reasons, but then do things like this.

Tim. 01-21-2006 10:49 PM

You know I love this. Awesome beyond a doubt.

Hyarion 01-22-2006 08:12 AM

Is it alright if I kiss the very ground you walk on?

Zeal_ 01-22-2006 12:34 PM

Rename it,

Cinematic Jass for Dummies.

Vexorian 01-22-2006 08:26 PM

why would it have such a lame name?

DanL. 01-23-2006 11:51 PM

Good cinematic, and also good concept .:emote_thumbup:

Freakazoid 01-30-2006 12:22 PM

I hate Jass, but guess i have to learn it :/

Capn_Sniffies 02-02-2006 05:44 PM

Does this work on multiplayer maps?

Anitarf 02-02-2006 06:07 PM

Hmm... cinematic maps are usually single player, no?

But anyway, if you mean to use this in a playable map for an introduction cinematic or anything like that, yes, it should work in multiplayer too. I looked through the code again quickly and I found nothing that would limit it to only one player.


All times are GMT. The time now is 10:30 AM.

Powered by vBulletin (Copyright ©2000 - 2020, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services