i’m adding models to root of the graph and then i would like to access each model within a for loop, but there since to be a problem. when i try to do move it (with setX() method) it doesnt move the models, instead it moves all of the models, so i think i’m movin the node with models and not the model. please help…
here is my code:
quadsHolder = []
def setQuads():
for i in range(100):
tempQuadNode = loader.loadModel("primitives/cube.egg")
tempQuadNode.reparentTo(render)
tempQuadNode.setPos(random.uniform(3,-3), random.uniform(3,-3), random.uniform(2,-2))
tempQuadNode.setHpr(random.randint(0, 360), random.randint(0, 360), random.randint(0, 360))
tempQuadNode.setTwoSided(True)
tempQuadNode.flattenLight()
quadsHolder.append(tempQuadNode)
def moveQuad():
for item in render.getChildren():
if item.getX() < 3:
item.setX(item.getX()+0.1)
else:
item.setX(-3)
def moveTask(task):
moveQuad()
return task.again
taskMgr.doMoving(0.2, moveTask, 'moveTask')
Try passing 1 as the last parameter to tempModelNode.setColor(). The last parameter is the override value, and 0 means not to override any color that is set on a lower node. 1 will override.