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

Problems building or running the engine, queries about how to use features etc.
Post Reply
niubaty
Kobold
Posts: 27
Joined: Thu Jan 10, 2019 2:19 pm
x 2

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

Post 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.
Last edited by niubaty on Sun Feb 17, 2019 11:44 am, edited 1 time in total.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

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

Post by paroj »

Code: Select all

>>> Ogre.Vector3(2)[1]
2.0
niubaty
Kobold
Posts: 27
Joined: Thu Jan 10, 2019 2:19 pm
x 2

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

Post 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
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

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

Post 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
niubaty
Kobold
Posts: 27
Joined: Thu Jan 10, 2019 2:19 pm
x 2

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

Post 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'
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

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

Post by paroj »

niubaty
Kobold
Posts: 27
Joined: Thu Jan 10, 2019 2:19 pm
x 2

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

Post by niubaty »

paroj wrote: Wed Jan 30, 2019 6:58 pm fixed in https://github.com/OGRECave/ogre/pull/1074
Thank you
Post Reply