Page 1 of 1

[Solved]x,y,z properties of Ogre.Vector3 is missing

Posted: Wed Jan 23, 2019 2:39 am
by niubaty
Ogre Version: master
Operating System: win10
Render System: GL3+

Code: Select all

>>> dir(Ogre.Vector3(1,1,1))
['__add__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__init_subclass__', '__int__', '__isub__', '__itruediv__', '__le__', '__lt__', '__mul__', '__ne__', '__neg__', '__new__', '__pos__', '__radd__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__rsub__', '__rtruediv__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', 'acquire', 'angleBetween', 'append', 'disown', 'distance', 'dotProduct', 'isNaN', 'isZeroLength', 'length', 'makeCeil', 'makeFloor', 'next', 'normalise', 'normalisedCopy', 'own', 'positionEquals', 'reflect', 'squaredDistance', 'squaredLength', 'this', 'thisown', 'xy']
The x,y,z static const Vector3 UNIT_X and other properties of Ogre.Vector3 is missing, the OgreVector3.h is very different from the version of 1.10. I don't know how to make it work.

Re: x,y,z properties of Ogre.Vector3 is missing

Posted: Wed Jan 23, 2019 11:48 am
by paroj

Code: Select all

>>> Ogre.Vector3(2)[1]
2.0

Re: x,y,z properties of Ogre.Vector3 is missing

Posted: Wed Jan 23, 2019 1:33 pm
by niubaty
paroj wrote:
Wed Jan 23, 2019 11:48 am

Code: Select all

>>> Ogre.Vector3(2)[1]
2.0

Code: Select all

>>> import Ogre
>>> v=Ogre.Vector3(1,2,3)
>>> v[1]
2.0
>>> v[1]=3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'Ogre.Ogre.Vector3' object does not support item assignment

Re: x,y,z properties of Ogre.Vector3 is missing

Posted: Wed Jan 23, 2019 2:10 pm
by paroj
the main purpose of the math types in the bindings is to allow calling functions taking the respective type. While you can use it for math computations they will slow due to the python>C++>python roundtrips.

If you want to make it work nevertheless start here:
https://github.com/OGRECave/ogre/blob/m ... gre.i#L175

probably you will need to change the bindings like that:
https://github.com/swig/swig/blob/maste ... oad.i#L210

Re: x,y,z properties of Ogre.Vector3 is missing

Posted: Thu Jan 24, 2019 6:58 am
by niubaty
1.What's the correct python way if I want to increase a vector3 in every frame?

In older version(1.10):

Code: Select all

v.x+=1
Is there any more efficient way than below:

Code: Select all

v+=Ogre.Vector3(1,0,0)

2.some function of vector3 is missing too (getRotationTo)

Code: Select all

Traceback (most recent call last):
  File "character_sample.py", line 682, in <module>
    app.getRoot().startRendering()
  File "character_sample.py", line 385, in frameRenderingQueued
    self.char.addTime(fe.timeSinceLastFrame)
  File "character_sample.py", line 134, in addTime
    self.updateBody(dt)
  File "character_sample.py", line 146, in updateBody
    togoal=self.bodynode.getOrientation().zAxis().getRotationTo(self.goaldirection)
AttributeError: 'Ogre.Ogre.Vector3' object has no attribute 'getRotationTo'

Re: x,y,z properties of Ogre.Vector3 is missing

Posted: Wed Jan 30, 2019 6:58 pm
by paroj

Re: x,y,z properties of Ogre.Vector3 is missing

Posted: Sun Feb 17, 2019 11:43 am
by niubaty
paroj wrote:
Wed Jan 30, 2019 6:58 pm
fixed in https://github.com/OGRECave/ogre/pull/1074
Thank you