Basic Driver suggestion

Basic Driver

This is a suggestion for a basic driver system.

A Driver uses input variables to set an output variable.
This basic driver would do the same but be more straight forward to use.

scene_control: controlling one mesh.x position with another mesh.z position.
face_rigging: controlling a mesh_shapekey with a mesh.y position
body_rigging: controlling a mesh_shapekey with a armature.bone.rot.z rotation.
scene: using a mesh.x to control lights.

Interface

Whats required is a basic input output interface.

in: controller object property
in: min/start user variable
in: max/end user variable
out: control modified object property
in: min/start user variable
in: max/end user variable




I think the Driver Panel would be best added to the properties.scene panel.
Drivers are not part of a mesh or armature, they control multiple objects: mesh, armature, bone, light, camera.

Code

code

a_size=a_max-a_min; // a min max size
b_size=b_max-b_min; // b min max size
a_pos=controller-a_min; // controller position
a_fac=a_pos/a_size; // 0.0-1.0 factor
control=b_min+(b_size*a_fac); // set

example

controller // Mesh.red.location.x: 3.00
min // 2.50
max // 5.00
control // Mesh.blue.location.x
min // 8.00
max // 1.50

a_size=a_max-a_min; // 2.50
b_size=b_max-b_min; // -6.50
a_pos=controller-a_min; // 0.50
a_fac=a_pos/a_size; // 0.2
control=b_min+(b_size*a_fac); // 6.7=8.00+(-1.3)

example

controller // Mesh.red.location.x: 4.50
min // 2.50
max // 5.00
control // Mesh.blue.location.x
min // 8.00
max // 1.50

a_size=a_max-a_min; // 2.50
b_size=b_max-b_min; // -6.50
a_pos=controller-a_min; // 2
a_fac=a_pos/a_size; // 0.8
control=b_min+(b_size*a_fac); // 2.8=8.00+(-5.2)

Driver Memory

Drivers are part of the AnimData memory stack.
Each struct required for animation, mesh, armature, bone, light, has a pointer to the AnimData:


struct Mesh{
Animdata *adt;
}
struct Armature{
Animdata *adt;
}
struct Bone{
Animdata *adt;
}

From what I gather, at the momemt Drivers are part of the FCurve stack.

AnimData
NLA
FCurve
FCurve type Driver

When they are created and modified, they are created and modified as FCurves as a Driver_type.
I dont propose to get rid of this system because it will cause many compatability issues.
what i think should be done is to create a new data block for basic drivers and keep the FCurve_Driver.
then see how it goes from there.


AnimData
NLA
FCurve
FCurve.Driver
xDriver


struct xDriver{
pointer a_var;
float a_min;
float a_max;
pointer b_var;
float b_min;
float b_min;
} xDriver;

These new basic drivers wouldnt be part of the graph editor (not till later if wanted).
They would just be basic linier range control to start.

EX

This is just a suggestion.
I dont know allot, how the AnimData system works, and how object properties are read and set.

Be good to hear from some dudes who know the code better.
What functions would be required for the AnimData for a xDriver memory stack:
Whats the best way to setup the structs:
Whats are the main problems that need to be solved:
Whats the best way to input controller and control properties from the GUI, python string, or some sort of generic property tree: