LQuaternionf - how do i create one?

Hi everyone - got a couple of questions.

  1. how do i load LQuaternionf without importing all of pandac.PandaModules?

  2. how do i create an LQuaternionf?

I tried to import LQuaternionf last night using the following python code:

     from pandac.PandaModules import LQuaternionf, LVector3f

and it doesn’t work. ppython can’t find LQuaternionf in the PandaModules namespace.

but when I do

     from pandac.PandaModules import *

it’s loaded

so that’s question 1

question 2

i’m trying to get a quaternion for obj and do some rotational work obj’s positioning (offset is the quaternion i’m using to figure out the rotation).

     objqua = self.obj.getQuat()
     
     #offset = LQuaternionf() -> ppython complained about this *a lot*
     offset = LRotationf() #ppython does not complain
     
     offset.setFromAxisAngle(2*elapsed,LVector3f.unitY())

in any case, ppython complains when it gets to LRotationf() (which i guess is a wrapper for LQuaternionf? ppython complained about LQuaternionf so I changed over to LRotationf and that seemed to work ok).

So the second question is really a 2 part-er.

the first part being why can’t i import LQuaternionf but I can use LRotationf?

the second part being ok cool i can make an LQuaternionf or a LRotationf - how to do create an object with that type?

thanks!

ct

You can do it this way :

from pandac.PandaModules import LRotationf, Vec3

objqua = LRotationf(self.obj.getQuat())
objqua.setFromAxisAngle(2*elapsed,Vec3(0,1,0))

Check out the CollisionDetection sample.

Thanks again for the tip!

I also discovered that 90% of the underlying structures I need to use are in fact in this API - they’re just called something different

Vec3, Quat, etc

ct