Moving a object in the sence/singal map

Not sure how to ask this… I need to move a object’s Hpr with in a singal “world” model. I broken down the world model into their own GeomNode so I could see what objects needed to do what… (like water- grass- so on), but I need to somehow change their… matrixs to around that object. I tried ReparentTo(render), but I still get the old matrix pos of 0,0,0. Is there anyway around this?

You want to change the pivot point of a node? The pivot point of each node is always (0, 0, 0) of that node, but since (0, 0, 0) is the same position as whatever the parent’s node is set to, it means that every node rotates about its parent’s position.

So, if you want node A to rotate about (10, 20, 30), for instance, you could do:

dummy = NodePath('dummy')
dummy.setPos(10, 20, 30)


I’ve tried that ^^; … for some reason, the Node still keep the pivot point from the “Town model” even after changing its’ parent to a dummy node.

O = Any point that you may pick for the dummy node

O(point (1,1,1)----(model) (The model still keeps its distant from the point that it was when it was parent to its org. model.

If you want the model to rotate about a different point within itself, you have to translate the model. Use:

d1 = NodePath('d1')
d2 = NodePath('d2')
model.setPos(-x, -y, -z)
d2.setPos(x, y, z)
d2.setHpr(h, p, r)

Whatever angle you rotate d2 will rotate the model around its point (x, y, z).


Thanks drwr, but no luck on that code for say. I talk to ThomasEgi he pointed me to some code that works, but inreturn… I ran into another problem. With this code I would have to hard incode all the center points for the object to spin around to.

Is there no way to get a objects poistion base on render? getPos(render) wont work right out of the boxs… Still will print 0,0,0

object.getPos(render) returns the (0, 0, 0) point of your object relative to render.

If (0, 0, 0) is not the point you want, what point do you want?


Yes and no… As you can see in the two pics in the middle… point 0,0,0 area is in a totally different spot than the object… off by more than 260 give or take. I need the objects poisition center…

I don’t understand what your pictures are trying to show me.

The point (0, 0, 0) is a specific point of your model, according to the way the model was created. You can’t directly change that point, but you can use nested nodes to achieve the effect you want, as I’ve been trying to describe above.

If you’re not having luck understanding the nested nodes idea, it is possible to move the point (0, 0, 0) on your model. To do this, use flattenLight(). For instance:

model.setPos(10, 10, 0)

This will move the point (0, 0, 0) to (-10, -10, 0).

Or, you can go into the modeling package where you created the model, and move the origin there. You might have to “freeze transforms” or whatever the equivalent is in your modeling package.


I know drwr. I been trying to do nested nodes from the start to no luck cus of the 260+ offset the object has…

Here my code so far… the WarpGate is the code for the object… This code works, but lacks a way to do many of em unless I do a hard code point for each warpgate… This is why I need a way to change that 0,0,0 point to its true position.

Either way, Thanks for the help drwr… I’m sorry I’m confusing you as such. I had a feeling I would sadly.

        geomNodeCollection = self.environ.findAllMatches('**/+GeomNode')
        x = 0
        x2 = 0
        x3 = 0
        y = 0
        geomNode = {}
        self.dummygeomNode = {}
        self.TargetgeomNodeLimit = 50
        NumberOfgeomNode = len(geomNodeCollection)
        self.WaterGeomNode = render.attachNewNode("WaterNode")
        self.GateGeomNode = render.attachNewNode("GateNode")
        for nodePath in geomNodeCollection:
          #Scan the nodePath for spical objects such as grass, water, the WarpGates.
          if nodePath.getName() == "A1River":
            self.river = nodePath
            self.water = loader.loadTexture("Misc/a1/Water.png")
            self.textureStage0 = TextureStage("stage0")
            self.RiverSound = self.audio3d.loadSfx("Music/Enviroment/stream.ogg")
            self.audio3d.attachSoundToObject(self.RiverSound, self.river)
          elif nodePath.getName() == "WarpGate":
            x3 = x3 + 1
            self.Gates[x3] = self.GateGeomNode
            print self.Gates[x3].getPos()
            geomNode[x] = nodePath
            x = x + 1
            x2 = x2 + 1
            #Normal-- used for even number. Combindes all the NodePath into one.
            if x2 == (self.TargetgeomNodeLimit):
              self.dummygeomNode[y] = render.attachNewNode("DummyNode"+str(y))
              for i in range((x-self.TargetgeomNodeLimit),x):
              y = y + 1
              x2 = 0
            #If the number is odd do this.
            elif x2 == NumberOfgeomNode:
              self.dummygeomNode[y] = render.attachNewNode("DummyNode"+str(y))
              for i in range((NumberOfgeomNode-x2),x):


Have you tried using flattenLight(), as I suggest? Or can you just move the model in your modeling package, as I also suggest?


Yes I have, Light-Strong doesn’t seem to do a thing. My modeling package can’t either. I can load them up on their own, but then again I would need to do the hard code points.