Should I write up what I’ve learned of Blender-modding, when I’m done with this add-on I’m making?
I’d gladly share what I’ve learned, if anyone’s interested.
I’d gladly share what I’ve learned, if anyone’s interested.
Computers v. Developers
#ifdef __cplusplus
#include <map>
#include <vector>
struct BL_FramePropertyPair {
CValue* property;
} BL_FramePropertyPair;
class BL_ActionGameLogic {
public:
BL_ActionGameLogic();
void wilma(int);
void apply_properties(int frame, KX_GameObject* go);
private:
std::map<int, std::vector<BL_FramePropertyPair>> frame;
};
#else
typedef
struct BL_ActionGameLogic
Fred;
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__STDC__) || defined(__cplusplus)
extern void c_function(BL_ActionGameLogic*); /* ANSI C prototypes */
extern Fred* cplusplus_callback_function(BL_ActionGameLogic*);
extern void add_property(BL_ActionGameLogic* agl);
extern void remove_property(BL_ActionGameLogic* agl);
#else
extern void c_function(); /* K&R style */
extern Fred* cplusplus_callback_function();
#endif
#ifdef __cplusplus
}
#endif
I’m looking at bAction, and it appears to be the object I want:
/* Action - reusable F-Curve 'bag' (act)
*
* This contains F-Curves that may affect settings from more than one ID blocktype and/or
* datablock (i.e. sub-data linked/used directly to the ID block that the animation data is linked to),
* but with the restriction that the other unrelated data (i.e. data that is not directly used or linked to
* by the source ID block).
*
* It serves as a 'unit' of reusable animation information (i.e. keyframes/motion data), that
* affects a group of related settings (as defined by the user).
*/
typedef struct bAction {
ID id; /* ID-serialisation for relinking */
ListBase curves; /* function-curves (FCurve) */
ListBase chanbase; /* legacy data - Action Channels (bActionChannel) in pre-2.5 animation system */
ListBase groups; /* groups of function-curves (bActionGroup) */
ListBase markers; /* markers local to the Action (used to provide Pose-Libraries) */
int flag; /* settings for this action */
int active_marker; /* index of the active marker */
int idroot; /* type of ID-blocks that action can be assigned to (if 0, will be set to whatever ID first evaluates it) */
int pad;
} bAction;
Unlike every other animation-object I’ve found, it doesn’t reference anything complex. ListBase is just an abstraction for vectors and such, since bAction is just C, as far as I can tell.
What’s intriguing is that Action Actuators hold a pointer to a bAction object, and that referenced object is used as a defining component of the actuator’s update-method. Now look at the following snippet of the Action Actuator’s method, Update():
// Handle a frame property if it's defined
if ((m_flag & ACT_FLAG_ACTIVE) && m_framepropname[0] != 0)
{
CValue* oldprop = obj->GetProperty(m_framepropname);
CValue* newval = new CFloatValue(obj->GetActionFrame(m_layer));
if (oldprop)
oldprop->SetValue(newval);
else
obj->SetProperty(m_framepropname, newval);
newval->Release();
}
What this shows is that the actuator can pretty easily modify a property in the object to which it is attached. Combining everything so far, there’s a very simple I shouldn’t watch videos while typing articles. Data stored within an action meant solely for game logic can reasonably be accessed and applied as a keyframe is reached without causing any interference to the established system of animation.
That’s what I was getting at.
There are still a few questions, however:
It’s not a mountain of inquiries by any stretch, but hey. Anyway, I’m gonna lie down for a while. I think I caught another cold.
Attached is a little comic outlining what I’m trying to do with my Blender-project.
I’ve got a lead in the form of a header-file: BKE_animsys. Locating it now.
BL_Action seems to have the code I’m looking for, but there’s some polymorphism or something goin on, so I can’t say with certainty what objects are being manipulated.
Okay, I found a header/source-file called “BL_Action”. I am very hopeful.
I personally stick to higher-level languages, as, after 10 years of it, I’m pretty sick of programming and computers in general. At this point, all I’m really trying to do is save the next generation some time.

….
In this new project, however, I’m using C++; if not C outright. It’s just a matter of using the same tools Blender is built upon. ☺
The following code is integral to my next major coding-project (aside from #OneGameAMonth), which is to add a new layer of functionality to Blender’s animation-system: this new ability will to alter the value of game properties, making fighting-games an incredible lot easier than they are currently.
bool SCA_PropertyActuator::Update()
{
bool result = false;
bool bNegativeEvent = IsNegativeEvent();
RemoveAllEvents();
if (bNegativeEvent)
return false; // do nothing on negative events
CValue* propowner = GetParent();
CParser parser;
parser.SetContext( propowner->AddRef());
CExpression* userexpr= NULL;
if (m_type==KX_ACT_PROP_TOGGLE)
{
/* don't use */
CValue* newval;
CValue* oldprop = propowner->GetProperty(m_propname);
if (oldprop)
{
newval = new CBoolValue((oldprop->GetNumber()==0.0) ? true:false);
oldprop->SetValue(newval);
} else
{ /* as not been assigned, evaluate as false, so assign true */
newval = new CBoolValue(true);
propowner->SetProperty(m_propname,newval);
}
newval->Release();
}
else if ((userexpr = parser.ProcessText(m_exprtxt))) {
switch (m_type)
{
case KX_ACT_PROP_ASSIGN:
{
CValue* newval = userexpr->Calculate();
CValue* oldprop = propowner->GetProperty(m_propname);
if (oldprop)
{
oldprop->SetValue(newval);
} else
{
propowner->SetProperty(m_propname,newval);
}
newval->Release();
break;
}
case KX_ACT_PROP_ADD:
{
CValue* oldprop = propowner->GetProperty(m_propname);
if (oldprop)
{
// int waarde = (int)oldprop->GetNumber(); /*unused*/
CExpression* expr = new COperator2Expr(VALUE_ADD_OPERATOR,new CConstExpr(oldprop->AddRef()),
userexpr->AddRef());
CValue* newprop = expr->Calculate();
oldprop->SetValue(newprop);
newprop->Release();
expr->Release();
}
break;
}
case KX_ACT_PROP_COPY:
{
if (m_sourceObj)
{
CValue* copyprop = m_sourceObj->GetProperty(m_exprtxt);
if (copyprop)
{
CValue *val = copyprop->GetReplica();
GetParent()->SetProperty(
m_propname,
val);
val->Release();
}
}
break;
}
/* case KX_ACT_PROP_TOGGLE: */ /* accounted for above, no need for userexpr */
default:
{
}
}
userexpr->Release();
}
return result;
}
Need help making games? websites? mafia hits? I'll help you do it more simply. There's a lot of nonsense out there in development, and I've got as little patience for it as you. My focus is, right now:
On this site, you'll find a mix of detailed tutorials and quick tips to keep from losing nights to stupid hiccups. Along the way, I will spam fanart and digressions regarding modern survivalism, personal projects, and tales of my antagonizing the animal kingdom.
WARNING: the author of this blog has an unhealthy interest in women, and it is periodically reflected in the content shared. Most of the sick displays will be safe for work.
loading tweets…