Change Mist Settings? (Possible, but...)

Hey all,

I’m making a small game just to see if I could do it. I know how to set up mist in Blender, my question is that what would I have to do to change the mist settings (start, end and color) during the game. For instance, when the character goes under water, I would like the mist to turn a different color and increase in intensity, simulating the environment of water. Then, of course, when the character left the water, the mist would return to the normal world settings.

How would I go about doing this? I’m assuming that logic bricks are probably out of the question.

At any rate, thanks for any help! =)

J

in 2.49 it will be

Time to get one of the testing builds to see. =)

Thanks,

J

Oooooohhhhh… Shiny!

How will this be accessed? Python?

You can access the mist settings through the Rasterizer Module:
http://www.blender.org/documentation/249PythonDoc/GE/Rasterizer-module.html

prease note: those functions were present in blender’s api for years, but they only work as they should in 2.49 xD

Well, a python script is in order!

import Rasterizer

import Rasterizer

set mist color

Rasterizer.setMistColor([ 0.0, 0.2, 0.0])

set mist end

Rasterizer.setMistEnd(50.0)

set mist start

Rasterizer.setMistStart(10.0)

But it still doesn’t work. I’m terribly new at python, unfortunately. What am I missing, besides a brain? :frowning:

Are you getting any errors in the console?

Are you using 2.48 or 2.49RC1?
edit: scratch that, I used that wonderful scroll functionality of the mouse and saw you said you were getting a test build

I’m having trouble getting the console to post error messages for me. I’m using Ubuntu Linux. I execute Blender through a console, but still can’t seem to get any messages through it.

Basically, I’m in rough shape. =(

I added:

get the object this script is attached to

owner = controller.getOwner()

After the import Rasterizer item.

EDIT:

Aha! I can run 2.46 in Konsole! Error:

PYTHON SCRIPT ERROR:
Traceback (most recent call last):
File “ocean.py”, line 6, in <module>
NameError: name ‘controller’ is not defined
PYTHON SCRIPT ERROR:
Traceback (most recent call last):
File “ocean.py”, line 6, in <module>
NameError: name ‘controller’ is not defined

Might as well post this before it becomes a really naughty bump. =)

Here is a sample .blend file with my stab at a script. As this is my first python script, I’d like to know what am I doing wrong, as it’s not working, and it’s driving me bananas. =(

Thanks for any help.

Attachments

dynamist.blend (129 KB)

just add this:

 controller  = GameLogic.getCurrentController()

before this:

 owner = controller.getOwner()

Thanks for the advice, I did it, and got this error message in console, using 2.49 RC1:

Method getOwner() is deprecated, please use the owner property instead.
        ocean.py:5

uh not sure what that means… but if you use

owner = controller.owner

you don’t get any errors but it doesn’t work…

Did some reading up on that error, and it looks like the new Blender has updated python codes to catch up to the standard. Lots of old stuff is deprecated in favor of newer commands.

At any rate, it still doesn’t work, so it’s probably still impossible. =(

Dan

you don’t use any get and set any more…

so Rasterizer.setMistColor would become Rasteriser.MistColor etc… and I’m not sure if you need to do the whole owner thing at all… this is assuming they’ve updated the rasterizer module.

Still nothing working. Not looking very promising. =(

Python script error from controller "cont#CONTR#1":
Traceback (most recent call last):
  File "ocean.py", line 10, in &lt;module&gt;
AttributeError: 'module' object has no attribute 'MistColor'
Python script error from controller "cont#CONTR#1":
Traceback (most recent call last):
  File "ocean.py", line 10, in &lt;module&gt;
AttributeError: 'module' object has no attribute 'MistColor'

Not giving up, mind you, but it’s really bugging me. I really need this to work if I’m to get this going.

Thanks for the tips, though. They help. Keep them coming, if anyone has anymore.

J

did you compile blender from a recent svn checkout?

I can try that. I’m having trouble finding out where to get the svn, however. I’m running on Linux.

EDIT: Nevermind. I’m downloading the svn now. =)

Not all the get/set functions have been deprecated though, there’s still plenty of functions that still require the old way, I’m sure it’ll become less and less as the new system encompasses more of the API.