I’ve created a small piece of environment in MAYA, and I also made a point to mark the place where I want my car to be loaded in Panda3D. In my code I read the position of that point from .egg file, and assign my car model at the right place.
self.box = loader.loadModel("Models/Environ.egg")
self.startPoint = self.box.find("**/StartPonit")
self.SPforCar = self.startPoint.getPos()
# Load the car and its collision sphere
self.car = loader.loadModel("Models/Car")
self.car.reparentTo(render)
self.car.setScale(1.5)
self.car.setPos(self.SPforCar )
But when I run the application, the car is not at the place I defined. I think there maybe some difference between MAYA’s coordinates and Panda3D’s.
How can I set one model in a position predefined in another model in Panda?
Thanks!
enn0x, thank you. But it still doesn’t work. My car is still at where it was.
I moved it to the place where I’d like it to be at the beginning by arrow keys, and tried to get the position by self.car.getPos. I wrote down that point(Point3(-172, 82, 3)), then I changed my code to set the car at that point when loaded. The result is when I ran the code, the car is not at the place I want it be.
I thought maybe I kept down the wrong data. So I ran the code again, move the car to the point I want it to be at the beginning. However, this time, the point is not the same as the previus one. Then I ran a third time, same position, totally different number.
I’m so confused! Any suggestion will be greatly appreciated!
Hmm… I believe Panda3D to be deterministic. So same state => same numbers. Is the orientation of your car different when you get different numbers for position? Either this, or the sequence of actions you have done to move the car to the start position. But I have to admit I that don’t have a clue so far. Sorry.
Try using a Maya locator to define your point, instead of an ordinary node. Or, alternatively, use eggObjectFlags.mel to flag your ordinary point node with a “DCS” flag.
Either of these two will ensure that gets written into the egg file, which tells Panda that the transform on that particular node is meaningful. Otherwise Panda will optimize it away on loading.
However, Panda is pretty deterministic. If you’re seeing random behavior on different runs, I suspect you may be getting confused.
With this code you’re reading a position relative to the coordinates of your environment model.
Of course this position is meaningless if you’re applying them to the world coordinates of another model.
So try to reparent your car to your environment model, or recalculate the position into world coordinates.