Matrix - Vector product

yaio

19-10-2009 09:32:26

Hello, I have to port in Python this code snippet:

http://www.ogre3d.org/wiki/index.php/Projecting_3D_position_and_size_to_2D#Projecting_position

but when I execute this instruction:

eyeSpacePos = camera.getViewMatrix( True ) * pos

(that is the first line of ProjectPos function) I obtain:


File "C:\...\pp.py", line XX, in projectPos
eyeSpacePos = camera.getViewMatrix( True ) * pos
TypeError: unsupported operand type(s) for *: 'Matrix4' and 'Vector2'


How can I solve this? Thanks!

andy

19-10-2009 10:03:51

Suspect you have something wrong with your code as 'pos' is meant to be a Vector3 not a Vector2..

Multiplying a Matrix4 by a Vector3 is supported, however multiplying by Vector2 is not..

Andy

yaio

19-10-2009 10:47:00

You're right! I've fixed! Thank you!! ^_^