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!

Fog settings and Region

Postby tachzusamm » Wed Apr 21, 2010 2:29 am

Is it possible to have a different fog density, depending on a region?
Something similar to what Cyan did in Minkata, although I would prefer an abrupt transition.
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Fog settings and Region

Postby Aloys » Wed Apr 21, 2010 2:49 am

Yes, it is definitely possible. Dlanor post an overview of the code a while ago here. It should definitely be possible to trigger it using a region, but I haven't seen anyone describe a precise step-by-step process yet.
User avatar
Aloys
 
Posts: 1968
Joined: Sun Oct 21, 2007 7:57 pm
Location: France (GMT +1)

Re: Fog settings and Region

Postby tachzusamm » Wed Apr 21, 2010 3:08 am

Thank you for this link, sounds promising.

(Seems again there are so many good hints spreaded around in the forums, sort of hidden in threads, and a small chance to find them when you don't have bookmarks already. Do we need a WIKI page, maybe called "valuable ideas and procedures" to just collect them, like a list of bookmarks with a short description?)

Now I have to find out how to attach the functions to a region.
Looking at the AlcScript reference, I have no idea how to link Python code to a region.

Does somebody know if regions can trigger a callback, like "regionEntered" or "regionLeft"?
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Fog settings and Region

Postby diafero » Wed Apr 21, 2010 10:14 am

I know that regions can trigger a Python code, but I don't know how :(

Oh, and regarding the wiki page - if you have some of these links, just go ahead and start one :) (for example, that thread about how to disable the Relto book could also be added)
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 Lontahv » Wed Apr 21, 2010 9:09 pm

I'm pretty sure Minkata's fog/dust was done with particle systems. I haven't looked but I'd assume there's some kind of exclusion region in the kivas.
Currently getting some ink on my hands over at the Guild Of Ink-Makers (PyPRP2).
User avatar
Lontahv
Councilor of Artistic Direction
 
Posts: 1331
Joined: Wed Oct 03, 2007 2:09 pm

Re: Fog settings and Region

Postby GPNMilano » Wed Apr 21, 2010 9:47 pm

Lontahv wrote:I'm pretty sure Minkata's fog/dust was done with particle systems. I haven't looked but I'd assume there's some kind of exclusion region in the kivas.


You'd be correct on one and incorrect on the other. Minkata's fog is both particle systems and the fog settings in the fni file. Region sensors control the actual fog tweening it with a python file called xFogDistTweener. Inside the caves the fog is set with a pythonfile called xFogSet. Finally the dust itself is particle systems. So it's both fog and systems working together, the fog being controlled by regions.

EDITS:

tachzusamm wrote:Now I have to find out how to attach the functions to a region.
Looking at the AlcScript reference, I have no idea how to link Python code to a region.

Does somebody know if regions can trigger a callback, like "regionEntered" or "regionLeft"?


Had to track down some alcscript from Dorehn's imagers but here's the alcscript for triggering a pythonfile with regions.

This is the code that gets attached to a region.
Code: Select all
RegionName:
    logic:
        modifiers:
          - name: NameOfYourLogicModifier_Enter
            cursor: up
            flags:
              - multitrigger
            conditions:
              - type: volumesensor
                satisfied: true
                direction: enter
                trignum: -1
            activators:
              - type: objectinvolume
                remote: RegionName
          - name: NameOfYourLogicModifier_Exit
            cursor: up
            flags:
              - multitrigger
            conditions:
              - type: volumesensor
                satisfied: true
                direction: exit
                trignum: -1
            activators:
              - type: objectinvolume
                remote: RegionName
      


Then whatever you use for your pythonfilemod you'd have it be activated by the Enter section of the logic mod above.
You can't stop the truth. IC Blog
User avatar
GPNMilano
 
Posts: 1155
Joined: Mon Apr 21, 2008 5:50 am

Re: Fog settings and Region

Postby tachzusamm » Thu Apr 22, 2010 5:54 am

Thank you for the reply; I think I understand now (partly) how the AlcScript should look like.

But I still feel a bit helpless. What is a pythonfilemod?
I have browsed the forums to get an answer, and found that such a pythonfilemod does call a python file finally. Is this correct?
And, besides that, "which" function in a python file is called then?

So, how do I "create/use/install/attach" such a pythonfilemod? Is it a Python file as well, or another AlcScript part, or a Blender object? Or something totally different, or part of an existing function in plasma?

Although I've written some Python import/export scripts for Blender in the past, I feel stupid now.

What I currently understand (hopefully) is:
a) The AlcScript defines that when a region is entered, the "NameOfYourLogicModifier_Enter" pythonfilemod is called. (Is saying "called" right?)
b) ...
?)
f) Finally a function in a script I do write by myself is called, which does for example change the fog density:
Code: Select all
    def MySetFogDensity_onEnter(self, ...):
        fogStart = -20
        fogEnd = 100
        fogDens = 0.5
        PtFogSetDefLinear(fogStart, fogEnd, fogDens)


But, umm, what needs to be done between ?

Seems I need an example, or a reference / link where to get further information.
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Fog settings and Region

Postby D'Lanor » Thu Apr 22, 2010 10:11 am

You can add the pythonfilemod to any object but here it is attached the region:

Code: Select all
RegionName:
    logic:
        modifiers:
          - name: NameOfYourLogicModifier_Enter
            cursor: up
            flags:
              - multitrigger
            conditions:
              - type: volumesensor
                satisfied: true
                direction: enter
                trignum: -1
            activators:
              - type: objectinvolume
                remote: RegionName
            actions:
              - type: pythonfile
                ref: :NameOfPythonFileMod
          - name: NameOfYourLogicModifier_Exit
            cursor: up
            flags:
              - multitrigger
            conditions:
              - type: volumesensor
                satisfied: true
                direction: exit
                trignum: -1
            activators:
              - type: objectinvolume
                remote: RegionName
            actions:
              - type: pythonfile
                ref: :NameOfPythonFileMod
        actions:
          - type: pythonfile
            name: NameOfPythonFileMod
            pythonfile:
                file: YourPythonFile
                parameters:
                  - type: activator
                    ref: logicmod:NameOfYourLogicModifier_Enter
                  - type: activator
                    ref: logicmod:NameOfYourLogicModifier_Exit

Your Python code would look like this then.

Code: Select all
from Plasma import *
from PlasmaTypes import *
actEnter = ptAttribActivator(1, 'Enter region activator')
actExit = ptAttribActivator(2, 'Exit region activator')
class YourPythonFile(ptModifier,):

    def __init__(self):
        ptModifier.__init__(self)
        self.version = 1
        print ('__init__%s v.%s' % (self.__class__.__name__,
         self.version))



    def OnNotify(self, state, id, events):
        if (not PtWasLocallyNotified(self.key)):
            return
        if ((id == actEnter.id) and state):
            self.MySetFogDensity_onEnter()
        elif ((id == actExit.id) and state):
            self.MySetFogDensity_onExit()



# your code here


# glue section here
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Fog settings and Region

Postby tachzusamm » Thu Apr 22, 2010 2:35 pm

Thank you for your advice.
So if I get it right, I have to replace "NameOfYourLogicModifier_Enter" with "actEnter" (same with Exit), and "YourPythonFile" just with the name of the Python file.

Like this:

Code: Select all
Region_FogChange:
    logic:
        modifiers:
          - name: actEnter
            cursor: up
            flags:
              - multitrigger
            conditions:
              - type: volumesensor
                satisfied: true
                direction: enter
                trignum: -1
            activators:
              - type: objectinvolume
                remote: Region_FogChange
            actions:
              - type: pythonfile
                ref: :NameOfPythonFileMod
          - name: actExit
            cursor: up
            flags:
              - multitrigger
            conditions:
              - type: volumesensor
                satisfied: true
                direction: exit
                trignum: -1
            activators:
              - type: objectinvolume
                remote: Region_FogChange
            actions:
              - type: pythonfile
                ref: :NameOfPythonFileMod
        actions:
          - type: pythonfile
            name: NameOfPythonFileMod
            pythonfile:
                file: TestAge_FogChange.py
                parameters:
                  - type: activator
                    ref: logicmod:actEnter
                  - type: activator
                    ref: logicmod:actExit


and Python code:

Code: Select all
from Plasma import *
from PlasmaTypes import *
actEnter = ptAttribActivator(1, 'Enter region activator')
actExit = ptAttribActivator(2, 'Exit region activator')
class TestAge_FogChange(ptModifier,):

    def __init__(self):
        ptModifier.__init__(self)
        self.version = 1
        print ('__init__%s v.%s' % (self.__class__.__name__,
         self.version))



    def OnNotify(self, state, id, events):
        if (not PtWasLocallyNotified(self.key)):
            return
        if ((id == actEnter.id) and state):
            self.MySetFogDensity_onEnter()
        elif ((id == actExit.id) and state):
            self.MySetFogDensity_onExit()



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


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


# glue section



Well... call me stupid, but I still don't get it. What about ":NameOfPythonFileMod"?
Because I don't know what a pythonfilemod is, I have no idea what it's name could be...

Is it just a name I can freely choose (or just keep it named "NameOfPythonFileMod") and all references to this name are those directly inside the AlcScript?
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Fog settings and Region

Postby D'Lanor » Thu Apr 22, 2010 3:23 pm

tachzusamm wrote:Thank you for your advice.
So if I get it right, I have to replace "NameOfYourLogicModifier_Enter" with "actEnter" (same with Exit),

Both names would work. The name in the Python file does not need to match the name in the Alcscript.

tachzusamm wrote:and "YourPythonFile" just with the name of the Python file.

Correct.

tachzusamm wrote:Well... call me stupid, but I still don't get it. What about ":NameOfPythonFileMod"?
Because I don't know what a pythonfilemod is, I have no idea what it's name could be...

Basically a pythonfilemod is used to make your Plasma objects "known" to the Python file. 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.

tachzusamm wrote:Is it just a name I can freely choose (or just keep it named "NameOfPythonFileMod") and all references to this name are those directly inside the AlcScript?

You can freely choose the name.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Next

Return to Building

Who is online

Users browsing this forum: No registered users and 2 guests

cron