Hi All,
I'm building a ruby plugin for SketchUp. I created a havok dll (havok is
a physic engine) and I need to share/pass data between ruby and the dll.
So far I had no problem to send data from ruby to the dll, but I can't
figure out the other way.
SketchUp 8 uses ruby 1.8.6, so I use the same Win32API version.
Here is my ruby code:
def get_matrix(index)
matrix = Array.new(16,0.1)
matrix2 = @getKaplaMatrix.call(index,matrix.pack("f*"))
matrix3 = matrix2.unpack("f*")
# puts "HELLO HELLO HELLO"
# puts matrix3
if (matrix3.size() != 16)
puts "WRONG ARRAY"
else
puts "ARRAY OK"
end
return matrix3
end
Here is my dll code:
DECLDIR float* getKaplaMatrix (int indice, float* matrix)
{
float* kaplaMatrix = havokUtilities->getKaplaMatrix(indice);
for(int i=0 ; i < 16; i++)
{
matrix[i] = kaplaMatrix[i];
}
matrix[14]/= 2;
matrix[13]/= 2;
matrix[12]/= 2;
return(matrix);
}
I'm trying to send a 4x4 matrix (stored in a [16] array) from the dll to
ruby, but I always get errors because some returned arrays are too
short. I did some tests and found that then there is an "integer"
(declared as "1.0") in the array, the value after the "integer" are
lost...
The result is that among all the arrays I send to ruby, some of then are
of the wrong dimension (because some matrix have some zeros values for
example). I have not the slightest idea of why this is
happening...
Thx
···
--
Posted via http://www.ruby-forum.com/.
