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.reparentTo(render)
A.reparentTo(dummy)
dummy.setPos(10, 20, 30)``````

David

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.
|
|
|
|
(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')
d1.reparentTo(render)
d2.reparentTo(d1)
model.reparentTo(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).

David

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?

David

Yes and no… img11.imageshack.us/gal.php?g=61450529.png 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)
model.flattenLight()``````

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.

David

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.river.setTexture(self.water)
self.textureStage0 = TextureStage("stage0")
self.river.setTexture(self.textureStage0,self.water,0)
self.audio3d.attachSoundToObject(self.RiverSound, self.river)
self.audio3d.setSoundVelocityAuto(self.RiverSound)
self.RiverSound.setLoop(True)
nodePath.setScale(0.015,0.015,0.015)
nodePath.reparentTo(self.WaterGeomNode)

elif nodePath.getName() == "WarpGate":
x3 = x3 + 1
self.GateGeomNode.setPos(nodePath,0,-260,6)
self.GateGeomNode.setHpr(nodePath,0,.8,0)
nodePath.setScale(0.015,0.015,0.015)
nodePath.wrtReparentTo(self.GateGeomNode)
self.Gates[x3] = self.GateGeomNode
print self.Gates[x3].getPos()

else:
geomNode[x] = nodePath
geomNode[x].setScale(0.015,0.015,0.015)
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):
geomNode[i].reparentTo(self.dummygeomNode[y])
self.dummygeomNode[y].flattenStrong()
self.dummygeomNode[y].reparentTo(render)
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):
geomNode[i].reparentTo(self.dummygeomNode[y])
self.dummygeomNode[y].flattenStrong()
self.dummygeomNode[y].reparentTo(render)

self.WaterGeomNode.reparentTo(render)``````

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

David

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.