Fog settings and Region

If you feel like you're up to the challenge of building your own Ages in Blender or 3ds Max, this is the place for you!

Re: Fog settings and Region

Postby tachzusamm » Fri Apr 23, 2010 2:23 am

Aha!
Now the whole stuff begins to make sense to me.

D'Lanor wrote: The parameters of your pythonfilemod are picked up in order of appearance in the Python file by those PtAttrib... classes. I remember when I figured that out it was a big eye opener.

Hehe, yes I can imagine. Thanks for figuring that out. :)

Now let's see if I can get this to work.
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Fog settings and Region

Postby tachzusamm » Fri Apr 23, 2010 5:46 am

Hey - it worked like a charm. 8-)

The final code, just for reference (although I guess I should write a WIKI when I find time):

AlcScript:
Code: Select all
Region_FogChange:
    logic:
        modifiers:
          - name: logicMod_Enter
            cursor: up
            flags:
              - multitrigger
            conditions:
              - type: volumesensor
                satisfied: true
                direction: enter
                trignum: -1
            activators:
              - type: objectinvolume
                remote: Region_FogChange
            actions:
              - type: pythonfile
                ref: :FogChangePythonFileMod
          - name: logicMod_Exit
            cursor: up
            flags:
              - multitrigger
            conditions:
              - type: volumesensor
                satisfied: true
                direction: exit
                trignum: -1
            activators:
              - type: objectinvolume
                remote: Region_FogChange
            actions:
              - type: pythonfile
                ref: :FogChangePythonFileMod
        actions:
          - type: pythonfile
            name: FogChangePythonFileMod
            pythonfile:
                file: <NameOfPythonFile>    # without '.py' extension
                parameters:
                  - type: activator
                    ref: logicmod:logicMod_Enter
                  - type: activator
                    ref: logicmod:logicMod_Exit


Python file with name <NameOfPythonFile>.py:
Code: Select all
from Plasma import *
from PlasmaTypes import *
actEnter = ptAttribActivator(1, 'Enter region activator')
actExit = ptAttribActivator(2, 'Exit region activator')

class <NameOfPythonFile>(ptModifier):
    def __init__(self):
        ptModifier.__init__(self)
        # self.id = 16001    #(is this needed?)
        self.version = 1
        print ('__init__%s v.%s' % (self.__class__.__name__, self.version))


    def OnFirstUpdate(self):
        pass


    def OnServerInitComplete(self):
        pass


    def OnNotify(self, state, id, events):
        if (not PtWasLocallyNotified(self.key)):
            return
        if ((id == actEnter.id) and state):
            print '<NameOfPythonFile>.OnNotify: Region entered'
            self.MySetFogDensity_onEnter()
        elif ((id == actExit.id) and state):
            print '<NameOfPythonFile>.OnNotify: Region left'
            self.MySetFogDensity_onExit()


    def OnSDLNotify(self, VARname, SDLname, playerID, tag):
        pass


    def MySetFogDensity_onEnter(self):
        PtFogSetDefLinear(-20, 100, 1)


    def MySetFogDensity_onExit(self):
        PtFogSetDefLinear(1, 1000, 0.2)



Really funny and cool to see the avatar entering a fog region suddenly. May need some improvements now, e.g. blending in the fog more softly, but I think I can manage this with a timer. Assumed just calling PtFogSetDefLinear() multiple times does not cause server overload in a multiplayer environment.
Do I guess right that PtFogSetDefLinear() only affects the user's client?


But now an additional question:
How can I make the Python function accept parameters from AlcScript?

I'm asking this to make the function reuseable in case more than one fog region is needed.
At least ONE parameter would be okay, to get an index passed to the Python function telling *which* region is currently meant, in order to determine different fog parameters.

Thanks again.
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Fog settings and Region

Postby diafero » Fri Apr 23, 2010 7:29 am

Do I guess right that PtFogSetDefLinear() only affects the user's client?
Yes, you do. So no matter how often you call it, there is no effect on multiplayer gameplay. A step of 0.1 to 0.05 seconds should be enough to get a smooth transition without putting too much load on the engine.
SoftVolumes would actually also be a great tool in this case, making the transition depend on the avatar's position. Can Python read a soft volume's current strength?

How can I make the Python function accept parameters from AlcScript?
You can add more parameters to these ptAttrib* things at the top.
However, if you want more regions, the Cyan way to do it would be to just have more PythonFileMods. That Python file you wrote will be kind of "instantiated" for each PythonFileMod, filled with different values depending on the PythonFileMod's parameters. For some reason Cyan decided that it is a good idea to instantiate the whole module instead of just the class (which it is not), but if you just imagine the module global variables to be class properties, and the PythonFileMods calling the "constructor" (i.e. filling these ptAttrib* values), it works exactly like OOP does.
If you want different colours/fog settings for different regions, just make them PythonFileMod options, too.
Which reminds me, couldn't you even directly use Cyan's xFogSet? I don't have the source code on this machine, so I can't tell how flexible it is. This would however make your age depend on the Offline KI, so that xFogSet is present.
I prefer e-mails to "diafero arcor de" (after adding the at and the dot) over PMs.

"Many people's horizon is a circle with a radius of zero. They call it their point of view."

Deep Island Shard | Offline KI
diafero
Deep Island Admin
 
Posts: 2972
Joined: Mon May 05, 2008 5:50 am
Location: Germany

Re: Fog settings and Region

Postby tachzusamm » Fri Apr 23, 2010 8:49 am

EDIT:
diafero wrote:SoftVolumes would actually also be a great tool in this case, making the transition depend on the avatar's position. Can Python read a soft volume's current strength?

If using SoftVolumes is possible as well, would be a valuable information too. This way it could be more flexible.
But - I thought SoftVolumes depend on the Camera position, and regions already track the avatar's position.
/EDIT


Well, I can add a Python file for each fog area then - no problem. I don't want to create more than a few foggy regions. :D

I never heard about that xFogSet; but now as I understood how this currently used way works, I think I will keep this.


Oh, by the way - if you're wondering why I needed all that - here's a (very) short preview of what I have done with it:
http://www.youtube.com/watch?v=j6re0KmuFb8

(better quality video coming soon - seems it needs a long time to process or activate)
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Fog settings and Region

Postby Aloys » Fri Apr 23, 2010 9:16 am

tachzusamm wrote:Oh, by the way - if you're wondering why I needed all that - here's a (very) short preview of what I have done with it:
http://www.youtube.com/watch?v=j6re0KmuFb8

Nice! :) It really add to the underwater feeling.
How did you do the underwater swimming? An invisible colider or is the swim surface going down?
User avatar
Aloys
 
Posts: 1968
Joined: Sun Oct 21, 2007 7:57 pm
Location: France (GMT +1)

Re: Fog settings and Region

Postby tachzusamm » Fri Apr 23, 2010 9:31 am

Aloys wrote:How did you do the underwater swimming? An invisible colider or is the swim surface going down?

Yes, it's simply the swim surface. 8-)
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Fog settings and Region

Postby ametist » Fri Apr 23, 2010 11:23 pm

How very cool to be able to swim under water!! :) Thanks a lot for sharing, now I get ideas in my head... :D
User avatar
ametist
 
Posts: 360
Joined: Fri Dec 28, 2007 6:55 am

Re: Fog settings and Region

Postby kaelisebonrai » Sun Apr 25, 2010 9:33 am

Wow, that is truly impressive.

I never really expected such an effect in an age. =) Its a nice solution to the issue of underwater effects in uru. =)

I guess I wouldn't've put two and two together. =) Thanks for the inspiration =D
User avatar
kaelisebonrai
 
Posts: 849
Joined: Sun Feb 03, 2008 3:27 am
Location: Perth, Western Australia

Re: Fog settings and Region

Postby ddb174 » Wed May 05, 2010 10:26 am

Wow, that looks beautiful and smooth! Great work!
ddb174
 
Posts: 928
Joined: Thu Apr 10, 2008 7:28 pm

Re: Fog settings and Region

Postby tachzusamm » Tue May 11, 2010 2:26 am

Well, I'm still trying to figure out how to pass parameters to Python scripts via AlcScript - and I don't get it.
The goal is to have the scripts more flexible, and replace those constant fog settings with variables.

diafero wrote:
How can I make the Python function accept parameters from AlcScript?
You can add more parameters to these ptAttrib* things at the top.


So far it seems logical. But what do those ptAttrib* functions do? I mean, what do they return? A dictionary?

I assume I have to do it this way in the Python part:

Code: Select all
from Plasma import *
from PlasmaTypes import *
actEnter = ptAttribActivator(1, 'Enter region activator')
actExit = ptAttribActivator(2, 'Exit region activator')
fogStartEnter = ptAttribInt(3, 'Enter region fog start', -20)  # 3rd param. is default
fogEndEnter = ptAttribInt(4, 'Enter region fog end', 100)
fogDensEnter = ptAttribFloat(5, 'Enter region fog density', 1.0)
[..]


now, where do the values go? Just into 'fogStartEnter' directly, or into something like 'fogStartEnter.value' ?

I guess it would look like this:

Code: Select all
[..]
    def MySetFogDensity_onEnter(self):
        PtFogSetDefLinear(fogStartEnter.value, fogEndEnter.value, fogDensEnter.value)

[..]


Yes?


And now the AlcScript part; I get no idea where to pass the parameters.
I assume it should be placed somewhere in the actions.pythonfile.parameters block:

Code: Select all
Region_FogChange:
[..]
        actions:
          - type: pythonfile
            name: FogChangePythonFileMod
            pythonfile:
                file: <NameOfPythonFile>    # without '.py' extension
                parameters:
                  - type: activator
                    ref: logicmod:logicMod_Enter
                    # Enter parameters here?
                  - type: activator
                    ref: logicmod:logicMod_Exit
                    # Exit parameters here?


but... how? What is the syntax here for parameters?
Or is this the wrong place to put them...
:?:
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

PreviousNext

Return to Building

Who is online

Users browsing this forum: No registered users and 2 guests

cron