[Bf-committers] extending Blender (Re: What documents should I read in order to embedblender?)
antont at kyperjokki.fi
Thu Apr 23 14:44:18 CEST 2009
>> Blender is an application, not a set of libraries for other applications
> I do not agree with you, in my opinion, free software is to make code
> reusable to other application, even commercial software exports APIs
This is not an opinion, am just describing the current state of affairs
in the source.
I agree with you that reusable components are nice. In fact when I first
started with Blender myself, it was when I was searching for a nice
simple realtime engine that supported 3d character animations, which I
could control from Python code. I was wishing Blender was a library that
I could use normally to make my own app, and even tried making it so,
but quickly withdrew from that and resorted to running my own code
inside Blender itself. It is just what is easier with how the code is now.
And Blender has an API for others to use, the Blender Python API. Like
said, you can use it to run your C or C++ written stuff within Blender
too. You don't in fact need to make any special py bindings to your C
code even, as py now comes with the ctypes module that can be use to
load any dll/so and call normal c functions in there etc.,
You can even call .net code via the python.net bridge (and there's a
similar bridge to Java). Sure, a C API might be nice for people who are
allergic to py (sometimes without a reason), but there is no such in
Blender now and no one is working now to make one either. Like said am
just telling what is easy now.
Of course anyone is free to make Blender a set of libraries and/or a C
API to it, but that is not in anyone's roadmap (yet) AFAIK.
>> to use -- the embedding you originally thought about would probably be
>> possible to hack somehow, but much easier would indeed be to make your
>> application to be added functionality within Blender itself. The
>> existing things in Blender, like the 3d modelling or the sequencer
>> (video) editor, are in a way already independent applications on top of
>> the common base (which gives them the database, UI tools etc).
>> A way to add functionality to Blender is using the Python API. That has
>> been limited with regard to e.g. UI, but as a part of the 2.5 work that
>> has been made better so that tools that register to Blender via py
>> should be able to integrate to the normal UI in the same way as the
>> default c written tools are. I don't personally know the status nor the
>> details of that there yet, but am looking forward to benefitting from
>> that myself for own custom tools.
>> You mention wanting to use the C language. If it is for performance, one
>> thing you can do is to implement the processing things in C, and add a
>> py api to that so your library can be called from the Python running on
>> the Blender side. It's pretty straightforward. If the reason for wanting
>> to use C is because that's what you know well from before, it doesn't
>> hurt to give Python a chance too 'cause it wont take you many hours to
>> test something with it.
>> Another way is to write your own code in C similarily to how the builtin
>> 'applications' in Blender are, define your own spacetype etc if that's
>> how you wish to do the UI. There is no separate C API for that though,
>> AFAIK not in 2.5 either, so I'm afraid that would mean having to
>> maintain your own fork of Blender if you wan't to distribute it to
>> others too. Via the py API your own code could be used with the
>> unmodified Blender.
>> Feasibility of these approaches depend on the exact functionality that
>> you need (e.g. the UI, data storage etc), but many things are certainly
>> Bf-committers mailing list
>> Bf-committers at blender.org
> Bf-committers mailing list
> Bf-committers at blender.org
More information about the Bf-committers