If you created a property with dimension 16 and type TYPE_FLOAT_64, then it's totally normal that the property is interpreted as a m44d.
About the strings: IOHelpers::edit_particles_property uses strings as input type to set the property values.
Under the hood, it converts the string values to the actual type of the property, in this case, doubles.
The strings are never stored in the property, it's just a convenient way to have a single entry function to set values, regardless of the underlying property type.
If understood correctly, what you want to do is this: for each point on the point cloud, store an array of 16 doubles (ie. its matrix).
The simplified steps to do this is:
- create the property, with type TYPE_FLOAT_64, and with dimension 16 (ie. the value of the property on each point will have 16 values, therefore there will be 16 x N values in the property)
- get the matrix array for each point, convert it to string
- iterate over the number of points in your point cloud: for each point set the stringified matrix value for the corresponding point index
Here is an extract of an example (see the attached zip file for the whole project):
python code
# get the particle container and its point count
container = ix.get_item("project://scene/context/container")
point_count = int(container.get_module().get_point_count())
# create the point property values: as many matrices as points in the particle container, and put the values in a string array
values = []
for i in range(point_count):
m44d = create_dummy_m44d(True)
values.append(m44d_to_string(m44d))
# create the point indices: [0, 1, 2, ...]
indices = range(point_count)
# create the m44d property (dim 16, float64)
prop_name = 'm44_float64'
create_point_property(container, prop_name, ix.api.ResourceProperty.TYPE_FLOAT_64, 16)
# set the values on the associated point indices
set_point_property_indexed_values(container, prop_name, values, indices)
print ''
# print them for debug
print_point_property_indices(container, prop_name)
print ''
print_property_values(container, prop_name, ix.api.ResourceProperty.TYPE_CHAR)
print ''
I've also changed the way it converts the matrix to a string, to get more decimals (by default Python keeps few decimals when converting a floating number to string)
python code
def m44_to_string(m44, separator = ' '):
"""
Get the GMathMatrix4x4d flattened values as a string separated with the separator.
"""
s = ''
for i in range(4):
for j in range(4):
s += '{:.16f}'.format(m44d.get_item(i, j)) # 16 decimals
if j < 3: s += separator
if i < 3: s += separator
return s
Does this help?
I'm working on seeing what improvements should be done to make the APIs more simpler and friendlier