How to get the position of a piece of an egg model?

I have a simple model from maya, in the sence there is a sphere.
what I want is to get the possition of the sphere, and then do other action,for example:excute a command when I click it, setPos(), setTexture(),and so on.
But I try again and again, it is invalid.Could some one give me a hand?
a Piece code of the egg file is:
pSphere1 {
{ net }
{ Polyset keep descend }
pSphereShape1.verts {
0 {
-6.08872 0.948746 4.56128
{ 0.148756 -0.987692 -0.0483333 }
{ 0.5 0.5 0.5 1 }
}
1 {
-6.10846 0.948746 4.52252
{ 0.126539 -0.987692 -0.0919361 }
{ 0.5 0.5 0.5 1 }
}
2 {
-5.99876 0.981301 4.44282
{ 0.249965 -0.951071 -0.18161 }
{ 0.5 0.5 0.5 1 }
}

Can you be more specific? What code are you trying to run? What sort of error message do you get?

Some code likes this:
self.environ = loader.loadModel(“models/c3”)
self.environ.reparentTo(render)
self.environ.setPos(0,0,0)

    self.x = self.environ.find("**/pSphere1")
    print self.x,self.x.getPos()
    self.x.setTag('myObjectTag', '2')
    self.x.setTexture("models/rock03.jpg")

I want to get the position of pSphere1 in above egg file, but what it print is “render/c3.egg/-PandaNode/-PandaNode/pSphere1 LPoint3f(0, 0, 0)”. Then I want to setTexture, but it is invalid.
Thanks.

getPos() returns LPoint3f(0, 0, 0) because it has no position relative to its parent. If you want to get the position relative to the root, use self.x.getPos(self.environ).

You get the setTexture error because you’re not using setTexture correctly:

tex = loader.loadTexture("models/rock03.jpg")
self.x.setTexture("models/rock03.jpg")

I try the code above:
self.x = self.environ.find("**/pSphere1")
print self.x,self.x.getPos(self.environ)
#self.initCollisionSphere(self.x,True)
self.x.setTag(‘myObjectTag’, ‘2’)
self.x.setTexture(loader.loadTexture(“models/rock03.jpg”))

but, the output is still “render/c3.egg/-PandaNode/-PandaNode/pSphere1 LPoint3f(0, 0, 0)”, and self.x.setTexture(loader.loadTexture(“models/rock03.jpg”)) is not in use.

I’ve already explained why the position is probably 0. As for replacing the texture, if you have an existing texture on there, you’ll need to specify the override flag, like setTexture(x, 1).

This is also explained in the manual:
panda3d.org/manual/index.ph … eplacement

Thanks very much,dear sir. With your help, I try to design another simple model in maya, and I could change the position of the sphere now. But with the two models, I connot get the proper position , and I cannot set texture with setTexture(x, 1) too. I will try again later.
Thanks very much.

Are you sure you didn’t mean to set the tag to “1” or “local” instead of “net”?

The setTexture function wroks, because I notice that there are words “In order for this to work, the model you apply it to must already have texture coordinates defined” in the manual. So I predifined simple texture in maya, then the object in my exported egg file could be changed.

But I meet problems in setH function, when I use setH, the object doesnot rotate around itself, but a point I donot konw.

It rotates around the (0, 0, 0) point of the model. If you want to rotate it around a different point, move it around in your modeling program so that the origin is the point it will rotate around.

Still problem about getPos.
I have a polySurface in egg file,such like

<Group> polySurface96 {
        <DCS> { 1 }
        <VertexPool> polySurfaceShape96.verts 

Now I could get the node and change its texture, but when I try to get position, the result is not what I want.

self.environ = loader.loadModel("models/JFM_HOME/scenes/JFM_home")
        self.environ.reparentTo(render)
        self.environ.setPos(10,0,0)
        self.x = self.environ.find("**/polySurface96")
        #self.dummyN = self.environ.attachNewNode("dummyNode")
        #self.x.reparentTo(self.dummyN)
        #self.dummyN.setPos(-10,0,0)
        #self.x.setPos(10,0,0)
        print self.x,ralphStartPos,self.x.getPos(),self.x.getPos(render),self.x.getPos(self.environ)
        

The msg is “render/JFM_home.egg/-PandaNode/JFM_home_BG/fnagjian/pPlane17_gro/polySurface96 LPoint3f(-10.3016, 0, 7.33341) LPoint3f(0, 0, 0) LPoint3f(10, 0, 0) LPoint3f(0, 0, 0)”. That the self.x.getPos(render) gives is the position of self.environ, and none of the printed pos is the actual pos I want.

I compare the “start_pos” code from roaming ralph’s world.egg, and thinking it has something to do with the <Matrix (X)>, but how could I get a <Matrix (X)> tag for polySurface or polyset?

Thx rdb.
I found there was a option “-trans” with maya2egg.
-trans type Specifies which transforms in the Maya file should be converted to transforms in the egg file. The option may be one of all, model, dcs, or none. The default is model, which means only transforms on nodes that have the model flag or the dcs flag are preserved.
So I used “-trans all”, it worked.
But how to make nodes that have the model flag or the dcs flag in maya?
Thanks a lot.

lsyer

There is a mel file, eggObjectFlags.mel, in the Panda source tree. You can use it to assign Panda object flags to nodes in Maya.

David