Re: [Plib-users] passing more than one value to psl scripts
Brought to you by:
sjbaker
From: Jonathan W. <jtw...@in...> - 2004-11-25 22:13:36
|
On Thu, 2004-11-25 at 11:31 +0100, Gerald Franz wrote: > For our purposes it is necessary to pass each frame a > larger number of variable values (e.g., 6 float values containing > an object's position or orientation or 16 values of a transformation > matrix) to the scripts. I succeeded in accessing these data > individually by writing access functions that return just one specific > ordinate, but I could not find a mechanism to pass a complete array. > It seems pretty cumbersome and like a lot of overhead to need 6 or > even 16 function calls for such an initialization. I've been pondering the same question, and the best idea I have been able to come up with is to use an int value as a handle with each unique value representing an sgVec or sgMat, then writing wrapper functions for all the lowlevel sg functions. so for example if I wanted to add two vectors I could use: in c++ sgVec3 position; sgVec3 offset; sgVec3 result; sgAddVec3(&result, &position, &offset); or in psl int position_handle = pslGetVec3Handle("position"); int offset_handle = pslGetVec3Handle("offset"); int result_handle = pslNewVec3("result"); pslSgAddVec3(result_handle,position_handle, offset_handle); There would be some added overhead in matching hashes, but hopefully most of it could be simplified to only happen once per script. I haven't tried this out yet, so I have no idea if it would work. Any suggestions? -Jonathan |