Thoughts and tutorials on programming

Friday, December 15, 2006

off-center? appears that if your object is "off center" from its center, then its physics are messed up--meaning that edges of your objects might poke right through other objects, etc.--things you wouldn't anticipate. Courious, but overcome-able thankfully--center your objects [edit mode, "object" menu, :) transform, obData to center].

errors off by one

If you get an error message in blender, it says six, but error's on five, so subtract one. Thanks!

Tuesday, December 12, 2006

ipo's and parenting

I believe the best way to get the "dynamic 3d avatar" is to have a "fake person" that is attached to a real (invisible) parent, which parent has dynamics associated with it.

Also, it appears that you CAN set object arbitrarily in Blender (see the addObject2.blend example) by using "instantaddobject" and that instantreplacemesh also exists, BTW. Then you can change it more easily on the fly. (call "getlastcreated object" [?] immediately after calling that).

Thursday, December 07, 2006

ipo's versus frames

It appears that sometimes frames are "dropped" for whatever reason (the "framedout" message, perhaps?) and when it does not show the frame IPO's don't advance. So this throws off timing a little if you rely on IPO's finishing on time, but hey :-) Now we know.

Wednesday, December 06, 2006

how to flip normals/invert them

go to edit mode (intuitively enough) and then w, invert

Tuesday, December 05, 2006

how to do buttons in blender, and also how to set object property names

So--the mouse left guy fires TWICE--once when you click down, once wuen you click up. To check for this in the script run "sensor.isPositive()" or something like that.

You CAN add things to objects on the fly "getOwner().abc = 3" BUT these are reset if the scene is reset (or hard changed, I presume). With scene freezes I'm not sure what happens (!)

So life is good.

how to get blender to not choke when you check for a variable that doesn't exist

print == ""
except AttributeError:
print "bad!"
print "done"

Monday, December 04, 2006

text boxes

It would seem that "text" objects don't appear in the blender game engine. It would appear that you can create a "more intense" one, however.

Saturday, December 02, 2006

empty's bounce

So...make an empty, turn it into an actor, and make it dynamic and...voila! Empty's bounce!

Friday, December 01, 2006

How to edit this blog

apparently you have to go to, then click on "blogger homepage" then click on "go to something beta" and THEN you can add a post. Intense :8

how to unparent in blender

Thanks to jdpf for this tip!

Friday, November 17, 2006

Replace Mesh

So replacing the mesh for an empty makes Blender crash.


Merging converging

Well, this is officially my first blog post ever. I feel like Captain Picard discovering a new galaxy...

So file merging in Blender isn't everything we want it to be. I went ahead and separated our two main scenes into two separate files, then created a new file with the two scenes merged using File->Append.
Good News: When a scene is deleted, its library goes with it. This means that the merge didn't cause any library/object conflicts (we may see some if the same objects are used in multiple scenes).
Bad News: Actuators that move between scenes break when you separate the scenes. If a given scene doesn't exist, the variable is clobbered in the actor pane (i.e., SCE: Navigation goes blank because it can't see the scene Navigation).
Possible workarounds:
-Fix it every time we merge, or
-instead of deleting the scene we aren't touching, have a total of three copies of the same file. Two are the working copies of the two scenes we will be working on, the third is a manually merged version. To do this merge, we'd create a new blender file and append the two scenes from the other two files. But no, this would still lack the second scene at some point, so that doesn't work. hmmm.....

Wednesday, November 15, 2006

can't rotate

Can't rotate anything in blender? It stands still? one of those little buttons is the culprit. The triple dot with the arrow underneath. Uncheck it and you are set :-)

Monday, November 13, 2006

blank panels

so say you click on the 'pac man' logic button, or the texture button, and nothing ever appears at the bottom of your screen. Do not fear: go to "Panels" menu and choose "View all" (or hit home). They will magically reappear.

all white objects in blender game hit the p button and the objects come up all white? Check 1) every object has a light in its same layer. 2) are you in 'textured' draw type--the little spikey ball at the bottom of the 3D view, before hitting p? These may help :-)

Wednesday, November 08, 2006

disappearing textures Blender if you create a nicely UV-mapped object, run the game engine, then it just appears as 'dots' -- you may need to change the 'material' on that object to 'texface' -- then you will see your UV-mapped images!

Thursday, November 02, 2006

apparent blender game engine bugs

Seems that messages never make it.

python is always one line off

"SystemError: errror return without exception set" in one instance meant naming conflict among actuators. Also can mean you called "addActiveActuator" on an edit object actuator without the values filled in, or it has the wrong values filled in.

MouseOverAny apparently does not LIKE clicking on "square" planes. Very weird. Weird. It also dislikes accepting clicks over circles.

seems also that if the starting mesh is a circle then if you change the mesh later it won't help it with 'mouse over' sensors. Hmm. It appears that 'mouse over' only uses the 'original' mesh for size, for the mouse over sensor. Curious.

Bug with Blender must be that it does not ask you to save, at all, when you exit. A little frustrating! I think it might save

what I wish blender had

An 'add object to this object' actuator--let's just add something :-) Ok maybe that is infeasible, but I could have used it.

I wish "controller" and "owner" and "import GameLogic" were pre-instantiated, for every script so we don't have to have them at the top of every file. This would also make some intuitive sense. It might not be as efficient, tho. But, then again--we're using python so in reality efficiency is not priority number one, so perhaps it's okay.

Message Actuator "getMessage" "getsubject"

"getfiringactuator that fired this script" (either that or divorce the combination logic from the middle column...)

Rasterizer could use 'getmouseposition'

flexible IPO's

from mouse actuators "get actual x, y given some fixed z" (like translate into blender coords this x, y)

on creating an object, being able to give it a position

kx_networkmessageactuator has no ".name" ugh

I wish there were a way to get to *every* actuator. It makes sense that it should be possible. That would make things so much nicer! Like object.getActuator. That would be so nice. Bypass that gui stuff!

A function "does such and such a mesh exist?"

IPO should have a bool "am I still firing?" "am I live?" also each object should have a bool "am I under the influence of some IPO right now?" (since it can only have one at a time), and perhaps a method "stop whatever other ipo you have! " so that it can be replaced with others.

Also a "get current frame number" call would be nice, of the IPO playing.

The property panel should use an "x" to be consistent with the rest of the world :-)

copy and paste with the operating system?

actuators don't have getname? that is ... interesting... they are accessed by name, so I guess it makes sense for them not to have names, but what ever :-)

when you create objects, you can't seem to tell it "create it right HERE" with this velocity -- well maybe you could but I don't know how. Oh well.

if youhave two actuators with the same name attached to a python script (from two different objects) then the return value from "get actuator(schizonamed") is undefined.

Wednesday, November 01, 2006

error message

SystemError: error return without exception set

I got this when I tried to grab a mesh that did not exist, or that was associated with an empty, or something! Also it might be caused by having a python script linked to two actuators (under two distinct objects) but such that they have the same name--then it becomes confused.

Also when I compiled blender on linux, it said /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../i686-pc-linux-gnu/bin/ld: cannot find -lalut

it turns out that since my alut and openal were stored in 'non conventional' locations, gcc didn't want to accept LD_LIBRARY_PATH environment variable, which DID have them, so I then had to add, by hand, to the linking line (i.e. run scons BF_DEBUG=0 BF_QUIEt=0 to figure out the command line used to link blender, then add to it)

and then it works.

I have no idea why.
This makes me want to suggest that scons have a global 'include from here' and 'link from here' settings, at least for linux.

It may have something to do with the environment that scons yields to the builds that it creates--it seems to create an 'internal' 'new' environment and pass that along to the child scons processes (like subdirectories).

Tuesday, October 31, 2006

how to import external modules

Say module is in e:\blender\shared\folder\
in blender do (in a script)
then from folder.file import whateverStuffYouWantLikeFunctionNames

Good luck!

more code snippets how to get active_camera, getSensors of an object

import GameLogic
print dir(GameLogic)

print "current scene is "
liveScene = GameLogic.getCurrentScene()
#print dir(liveScene)
print "now from that here is the camera:"
print dir(liveScene.active_camera)

#for o in liveScene.getObjectList():
# print dir(o)

me = GameLogic.getCurrentController()

print "controller"
print dir(me)
print "sensors:"
for obj in me.getSensors():
print dir(obj)

disappearing blender objects

So it appears that right now if a node has an IPO associated with it AT ALL then it will apply frame 1 of that IPO at the initiation of a game. Whether you like it or not. So if your camera 'disappears' every time or your object jumps at the beginning of a game... :-)

Monday, October 30, 2006

Random Blender notes

Blender Game Engine notes:

import GameLogic
GameLogic.myVar = 3

liveScene = GameLogic.getCurrentScene()
obj = liveScene.getObjectList()["OBCube"]

With the game engine, there seems to be no way to have a script that is fired with two actuators -- i.e. if this AND this then fire this script. Doesn't work. One way around this would be to revamp the GUI system to have another "column" that is logic connectors. like "add a logic connector "AND" or what not. Then you could use those with the normals and with these.

constraints are NOT reflected at 'game time' in the GameEngine. Parent/child objects are.

right now if you restart a scene, it reruns all scripts that have the "quotes" both unchecked (which hmakes them 'init' scripts).
Ways to instantiate 'once' in the GameEngine:

with solid variables:

print == ""
except AttributeError: = "init value"
print "done"

# the above way just makes it possible to not have the script crash, as it would typically do if you checked if the variable bbc existed or had been instantiated.

--there may be others.

Note IPO's for the GameEngine are by frame count, not by frame, so if you have a faster or slower out.

Also it would be nice to have more flexible IPO actuators--i.e. they can change IPO (the name) within the one object (the IPO referring to that object), and another would be then that more objects could use more than one IPO.

That's my notes so far!


With blender mouse actuators, say you have a mouse left actuator attached to a python script. The actuator will fire the python script TWICE per click--once when you click down, once when you click up. So this basically requires you to double check actuatorName.isActive() every time- - just having it fire does not mean what you think it might.

Friday, October 20, 2006

Blender GameLogic IPO's seems that IPO's have some interesting actions, if you change them 'on the fly' while they are being applied to an object.

The normal "thing" for IPO actuators to do is to just play through, then stop.
Let me explain. If you set your IPO to be "play" and you start it, if you tell that actuator to start up again, and it has not finished playing, it will NOT restart--it ignores the command to (re) start and just continues playing. Until it stops. Then it will "allow" the actuator command to re-start it.

Also, about IPO's (background)
each object can only play the (single) IPO that was last associated with it (though I think it may be possible to "link" it to others, it only really uses, for the game engine, the last one you assigned to it).

Currently, if an IPO object is "playing" you can't re-start it. And here is what happens if you change the
1) Begin frame (this is like an interruptive change fo the begin frame, or during playback). This will cause the currrent frame to 'jump' to an offset of the amount that you changed it by. Useful? Perhaps. more of an accidental "feature" I think. 2
2) End frame. If you change the end frame while in playback it will do nothing besides perhaps continue farther or shorter to that end frame. if, however, the IPO had already finished playing (stopped), THEN you changed the end frame, it would just 'skip' to that frame. Almost like assigning the IPO to the new end frame (it thought that you were at the end frame--the end frame changed. It changed you to still be at the end frame).
So nothing too bad.

First Blender thoughts

So...variables in the Blender GameEngine
Here are some things I have noticed over the last few days.

1) you can edit 'properties' of an object on the fly, thus (you don't need an actuator :-) )
import GameLogic
owner = GameLogic.getCurrentController().getOwner() # there might be a better way than this.
owner.propertyname = "newValue"

2) These properties 'reset' when you start or re-start a scene.