OK, I've got more fun for you guys. I added these functions into
PythonScriptModule/TundraWrapper class:
in the header:
//getters for float3 x, y and z coordinates
float x(float3* self);
float y(float3* self);
float z(float3* self);
in the source:
float TundraDecorator::x(float3* self)
{
return self->x;
}
float TundraDecorator::y(float3* self)
{
return self->y;
}
float TundraDecorator::z(float3* self)
{
return self->z;
}
and ran it in py like this:
import tundra as tundra
class CameraTest:
def __init__(self):
tundra.LogInfo("***** Python CameraTest starting *****")
tundra.Frame().connect("Updated(float)", self.update)
def update(self, frametime):
print
tundra._pythonscriptmodule.GetActiveCamera().GetComponentRaw("EC_Placeable").Position().x()
print
tundra._pythonscriptmodule.GetActiveCamera().GetComponentRaw("EC_Placeable").Position().y()
print
tundra._pythonscriptmodule.GetActiveCamera().GetComponentRaw("EC_Placeable").Position().z()
= = = = =
It works, hooray. But my efforts to do the same with the rotation
haven't so far. Tried something like this:
float3 TundraDecorator::rotation(Quat* self)
{
return self->ToEulerZYX;
}
Which compiles, but crashes at runtime, if I try this:
print
tundra._pythonscriptmodule.GetActiveCamera().GetComponentRaw("EC_Placeable").Orientation().rotation().z()
same thing with this:
float3 TundraDecorator::rot(Transform* self)
{
return self->rot;
}
and in py
print
tundra._pythonscriptmodule.GetActiveCamera().GetComponentRaw("EC_Placeable").transform.rot().z()
Crashes.
Ahh, one more stupid question: should probably add a graceful exit
function of some kind, because the line at init
tundra.Frame().connect("Updated(float)", self.update)
causes a crashdump at Tundra exit. A hint on disconnecting gracefully?
--
http://groups.google.com/group/realxtend
http://www.realxtend.org