having an issue following a horribly structured API

so I’ve looked at the API, which I have to say is quite bland… I can’t seem to find anything past:
bge.logic.getCurrentController()

I did a search for “cont.owner” which came up with no results…

IK most people tend to use ‘cont’ for this, so what are the class methods and variables??
same goes for cont.mesh.[?] and cont.owner.[?] which I see alot on google, mainly for shader usage.

I also need to know the stuff for I think cont.owner.parent, as for me, this would be a rig object…

thanks

also, if I may please ask mods/admins not to close this thread. :slight_smile:
I’d love feedback on this for as long as possible. :wink:

Here’s the python apy of the getCurrentController() if you see, there’s a button that says “Return type”(you can click it), the getCurrentController() return the class bge.types.SCA_PythonController(SCA_IController), which have the “owner” attribute.

The getCurrentController() return the controller that execute the script, the owner variable is the object owner of the controller.

cont.mesh? it not exist…

oh woops, that was a mental mis-direct… I meant “mesh = own.meshes[0]; mesh.[?]” sry :stuck_out_tongue:

is there any way to get:

for bone in cont.owner.parent.bones:

for this game I’m making, I’m using a global armature get the envelopes of the bones dynamically connected to a bone on (this) object.

find the bone labeled “%s_connect”%(cont.owner.meshes[0].name)
get the envelopes from the children (if any) connected to this bone to morph (this) mesh by

I don’t get what you mean but object.bones doesn’t exist. Instead you can use

for bone in armature.channels

And to check if it’s connected

 if bone.parent: 

Check BL_Armature in the doc for more info.

Sent from my Nexus 5 using Tapatalk.

so I’m guessing:


cont = bge.logic.getCurrentController()
own = cont.owner
mesh = own.meshes[0]
armature = own.parent

collections = [] # get envelopes from here
for bone in armature.channels:
    if bone.parent.name == "%s_connect"%(mesh.name):
        collections.append(bone) # we'll want the children of this bone for their envelopes

for bone in collections:
    # deform this mesh's vertices with these bones

right?? :confused:

nope… how do I get the armature so I can get the channels??

The armature is the object. Any armature object is a type bl_armatureobject
So if the parent of the object running the script is an armature, controller.owner.parent is the armature

wait… I’m a derp… my issue was python3, since I’m used to using 2.7

so yes, it was right to begin with :stuck_out_tongue:

admin-note: don’t close this thread, I’m sure to run into more issues.

There should be one thread per issue.

The thread should have a descriptive name, relative to the issue at hand.

You should only ask for help after your independent research efforts fail to produce an answer.

yea… the issue I’m having is trying to build a script following a poorly structured API…

I’m taking my answer I’m looking for in steps… since what I want to do hasn’t been done before, and is too complex to simply ‘ask’.

so I’ve gotten that step done…
now on to the next:


deforms = []
for bone in [ C.bone for C in armature.channels if C.bone.parent and C.bone.parent.name == "%s_connect"%(mesh.name)]:
    # how do I get the envelopes here??

EDIT:
also, I learn by following examples and seeing how they work, not by people explaining things to me…
though yes, a small amount of explaination does go a long way… even for me…

EDIT2:
if I must mention, I’ve tried asking about this before here…
those threads still have no response yet… >_>

Your loop is strange, “bone” is not a valid attribute. It can simply be like this


for bone in armature.channels:
    if bone.name.. [The rest of your code here]

Sent from my Nexus 5 using Tapatalk

probably because I didn’t know what attributes did what, and was a REAL noob when I wrote that code…
and the fact that code was only written as a guess and was expected not to work. :stuck_out_tongue:

but still… wrong code man :slight_smile:
look at my later posts for a working code :wink:

here it is again:


deforms = []
for bone in [ C.bone for C in armature.channels if C.bone.parent and C.bone.parent.name == "%s_connect"%(mesh.name)]:
    print(bone.name)

@experienced users:
go ahead and test it, I already have it working… :stuck_out_tongue:
but now I need to get the envelopes from the bones to send to the vertex shader.

EDIT:
I’m sorry… I re-read the post…
I only need specific bones which are the children of “%s_connect”%(mesh.name)

so I’m guessing I get the bone envelopes using the head, tail, and length??

someone help me out here plz :confused:

if so, what’s the algorithm behind it??

this is what the shader will use to process the new vertex positions >_>

The engine, and it’s api is object oriented. So you need to figure out what object you have, then look in the api under bge.types to find what methods it has…
In this case, you have a bone, so:
http://www.blender.org/documentation/blender_python_api_2_71_release/bge.types.BL_ArmatureBone.html

According to your above statements you are not familiar in reading API docs. I really advice you do some Python training and check the Python docs.

The BGE API is similar structured as the Python API. It describes each available object type with its attributes, sometimes with examples.

In difference to the Python API the BGE API does not contain a tutorial section, especially not a Python one. This is not the Purpose of the BGE API. The BGE API is a reference.

Avoid to rely on samples you found somewhere. Obviously this is not covered by any API doc. In a lot of cases it contains irritating names and questionable structures. E.g. you will never find a description of a “cont” or “main”. You need to train yourself to distinguish API related code from custom code.

It is not likely that you can find chained attributes in an API documentation. You can search for the attribute name. The results will tell you what object types have such an attribute. You can search for the object type. The results will show you where it is referred to.

You see you need to know how you read the book.

@monster: thanks for the advice :slight_smile:

but referring to the python API…
the python API is (to put it simply) a nightmare and nothing more than a hassle to try to follow. (it should be burned)
(I’ve already puked (multiple times) at the fact the blender API follows it’s structure…)

2.49’s downloadable (<3) API helped me out ALOT better than the current API
(especially the function/class tree browser (<3 <3) )

I am experienced with python2.7 (I can’t call myself an expert though), especially in the PyOpenGL area. :wink:
(PyOpenGL runs slower on Python3 (no intent to fix, as nothing needs to be “fixed”), so I stick with 2.7)

@API devs:
perhapse you guys should take some tips from my project’s functions:
http://tcll5850.proboards.com/thread/182/layout (note: highly unfinished)
my project makes model importing more like OpenGL’s automated state engine (no ‘.’ operator), so it’s ALOT easier to follow and script for.
(scripting for blender has become even more of a nightmare since 24x, so I’ve developed this to take it’s place)
^ only applies to model I/O

anyways, my point is the structure-tree…
this is basically my project’s docs which contains references and simple explainations as to how the function works.
(it’s meant mainly to help noobs but to also help pros to keep them from misunderstanding things)

now doesn’t this seem alot better than Blender’s API?
(no “search” needed, just click the function you want and get it with anything it needs on the fly.)

something for me alone, if you guys want to copy:
I’ve made my docs on my forum specifically for user feedback on my functions.
I believe a convenient way of user feedback is an added benefit to aid development.
so why not start with the functions everyone will be using :stuck_out_tongue:

I absolutely agree with you that the old API structure was much better then the current one. Unfortunately it is as it is.

The differences beween Python 2.7 and 3.x are in most cases very small.
The differences between bge 2.49 and 2.5+ are mostly additions. So you still can use the old API.

Typical with the bge you do not program in OpenGL as the bge does that for you. You are supposed to describe behavior on an higher level. Nevertheless you can do. But I’m not sure if that is better placed at the BGE sources directly.

but referring to the python API…
the python API is (to put it simply) a nightmare and nothing more than a hassle to try to follow. (it should be burned)
(I’ve already puked (multiple times) at the fact the blender API follows it’s structure…)

To each their own I guess, but I’ve lost count the amount of times the Python API helped me code a complex function. A lot of the Python2 stuff works perfectly fine (or easily enough adapted) to work in Python3. I would appreciate it if you spoke about the hard work put into Python (and Blender) with a little more respect.

I followed your link but it took me to a page with just a list of functions. Was that intended? I couldn’t see any descriptions or list of inputs. A fair amount of those functions looked like they could easily be replaced by publicly accessible variables.

I’m interested to ask why you feel like this, As I really enjoy the API references.