BGE Development: mouse look actuator 3

Today’s update is focused about getting radians to display in the user interface.

Now when looking at setting the mouse look rotation caps you can see the little degree symbol and if you hoover the mouse over the value you will see how many radians that is:

Within the source code the file rna_actuator.c controls the interface to the actuators struct. Here things like the minimum and maximum values can be defined, along with the text that appears in the user interface and other details like the step size when dragging the cursor to change a value. For every variable defined as part of an actuators struct an interface is needed to use it. For example, for the X cap:

prop = RNA_def_property(srna, "xcap", PROP_FLOAT, PROP_EULER);
RNA_def_property_float_sdna(prop, NULL, "xcap");
RNA_def_property_range(prop, 0.0, 3.141594);
RNA_def_property_ui_text(prop, "X Cap", "Cap rotation on the mouse X axis, 0=disabled");
RNA_def_property_update(prop, NC_LOGIC, NULL);

It had me stumped for a while how to get the degrees symbol to appear and to show the radian value, initially I though all you need is to pass the PROP_EULER subtype when defining the property. The cap variables where still shorts – who really needs to cap rotation at 59.14 degree? But no dice. To get it working I needed to change the caps to floats, which I guess makes sense when dealing with Euler values.

The other advantage is that the conversion from degrees to radians is all handled as part of the interface, so I don’t need to do it as part of the actuators code.

And while I was messing around in rna_actuator.c I made a few other improvements to the struct’s interface, such as step sizes and what not.

Advertisements

~ by Jay on May 2, 2012.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: