How to use the panda3d.core.NodePath function in Panda3D

To help you get started, we’ve selected a few Panda3D examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github panda3d / panda3d / tests / collide / collisions.py View on Github external
def make_collision(solid_from, solid_into):
    node_from = CollisionNode("from")
    node_from.add_solid(solid_from)
    node_into = CollisionNode("into")
    node_into.add_solid(solid_into)

    root = NodePath("root")
    trav = CollisionTraverser()
    queue = CollisionHandlerQueue()

    np_from = root.attach_new_node(node_from)
    np_into = root.attach_new_node(node_into)

    trav.add_collider(np_from, queue)
    trav.traverse(root)

    entry = None
    for e in queue.get_entries():
        if e.get_into() == solid_into:
            entry = e

    return (entry, np_from, np_into)
github panda3d / panda3d / tests / text / test_textnode.py View on Github external
def test_textnode_flatten_color():
    text = core.TextNode("test")
    text.text_color = (0, 0, 0, 1)
    path = core.NodePath(text)

    color = core.LColor(1, 0, 0, 1)
    path.set_color(color)
    path.flatten_strong()

    assert text.text_color.almost_equal(color)
    assert text.shadow_color.almost_equal(color)
    assert text.frame_color.almost_equal(color)
    assert text.card_color.almost_equal(color)
github tobspr / RenderPipeline-Samples / 05-Quboid / src / LevelLoader.py View on Github external
def loadLevelData(self,inputData):
        """
        processes the level asloaded from the file. it seperates the input data until the data for each tile is ready.
        each tile data will be passed to loadTile().
        it returns a rigidNode optimized nodepath.
        """
        rigidNode = RigidBodyCombiner("LevelNode")
        levelNode = NodePath(rigidNode)
        #rigidNode.reparentTo(levelNode)
        #this looks heavy but all it does is deleting whitespaces and seperating the content for each tile into a list.
        inputData = inputData.replace("\n","").strip().replace(" ","").lstrip("<").rstrip(">").split("><")
        
        for tileData in inputData:
            tile = self.loadTile(tileData)
            if tile != None:
                tile.reparentTo(levelNode)
                tile.setPos( self.getPosFromTile(tile) )
                tile.setZ(tile,0.00000001) #workaround for rigid body combiner so it does not assume the (0,0) tile as static
            else:
                print("ERROR, could not load tile with data: ",tileData)
        rigidNode.collect()
        inode = rigidNode.getInternalScene().node() #workaround for a boundingvolume issue with rigidbodycombiner
        inode.setBounds(OmniBoundingVolume())  #still workaround
        inode.setFinal(True) #still workaround
github panda3d / panda3d / direct / src / wxwidgets / ViewPort.py View on Github external
v.grid = DirectGrid(parent=render)
    if name == 'left':
      v.grid.setHpr(0, 0, 90)
      collPlane = CollisionNode('LeftGridCol')
      collPlane.addSolid(CollisionPlane(Plane(1, 0, 0, 0)))
      collPlane.setIntoCollideMask(BitMask32.bit(21))
      v.collPlane = NodePath(collPlane)
      v.collPlane.wrtReparentTo(v.grid)
      #v.grid.gridBack.findAllMatches("**/+GeomNode")[0].setName("_leftViewGridBack")
      LE_showInOneCam(v.grid, name)
    elif name == 'front':
      v.grid.setHpr(90, 0, 90)
      collPlane = CollisionNode('FrontGridCol')
      collPlane.addSolid(CollisionPlane(Plane(0, -1, 0, 0)))
      collPlane.setIntoCollideMask(BitMask32.bit(21))
      v.collPlane = NodePath(collPlane)      
      v.collPlane.wrtReparentTo(v.grid)
      #v.grid.gridBack.findAllMatches("**/+GeomNode")[0].setName("_frontViewGridBack")
      LE_showInOneCam(v.grid, name)
    else:
      collPlane = CollisionNode('TopGridCol')
      collPlane.addSolid(CollisionPlane(Plane(0, 0, 1, 0)))
      collPlane.setIntoCollideMask(BitMask32.bit(21))
      v.collPlane = NodePath(collPlane)
      v.collPlane.reparentTo(v.grid)
      #v.grid.gridBack.findAllMatches("**/+GeomNode")[0].setName("_topViewGridBack")
      LE_showInOneCam(v.grid, name)
    return v
github WindyDarian / Sogal / sogasys / sogal_text.py View on Github external
return self.recordedText[0]['text']
        return ''
        
    def getEndPos(self):
        if self.lines:
            return (self.lines[-1].getEndPos()[0],0 , -(self.currentHeight + self.lines[-1].getLineHeight()))
        else: return (0,0,0)
        
    def hasContent(self):
        "get if this text label empty"
        return bool(self.lines)
        
    

            
class TextLine(NodePath):
    '''
    One line of SogalText, contains geom generated by TextNodes
    Text are unable to be changed
    '''
    def __init__(self,parent = None, height = 0):
        self.parent = parent or aspect2d
        
        NodePath.__init__(self,'line')
        self.reparentTo(self.parent)
        
        self.currentPtr = (0,0,0)
        self.lineHeight = height
        self.lineWidth = 0
        
        self.items = [] #each word/character is a NodePath
        self.__lerpIntervals = []
github PiratesOnlineRewritten / Pirates-Online-Rewritten / pirates / battle / DistributedBattleNPC.py View on Github external
def getProp(self, propPath):
        model = propCache.get(propPath)
        if model:
            return model.copyTo(NodePath())
        else:
            prop = loader.loadModel(propPath)
            motion_blur = prop.find('**/motion_blur')
            if not motion_blur.isEmpty():
                motion_blur.stash()
            prop.flattenStrong()
            propCache[propPath] = prop
            return prop.copyTo(NodePath())
github Craig-Macomber / Panda3D-Terrain-System / meshManager / treeFactory.py View on Github external
n.setTexture(self.barkTexture)
            n.setShaderInput('diffTex',self.barkTexture)
            format=GeomVertexFormat.getV3n3t2()
        else:
            format=GeomVertexFormat.getV3n3()
            n.setColor(.4,.3,.3,1)
        
        #n.setShader(customLoader.makeShader(n))
        
        trunkRequirements=meshManager.GeomRequirements(
                geomVertexFormat=format,
                renderState=n.getState()
                )
        
        
        n=NodePath('tmp')
        
        if self.leafTexture is not None:
            #n.setTag("alpha","")
            n.setShaderInput("alpha",0,0,0) # marker we need cutout alpha
            n.setTexture(self.leafTexture)
            n.setShaderInput('diffTex',self.leafTexture)
            format=GeomVertexFormat.getV3n3t2()
        else:
            format=GeomVertexFormat.getV3n3c4()
        
        #n.setShader(customLoader.makeShader(n,debugCodePrefix="tree",debugGraphPrefix="tree"))
        
        leafRequirements=meshManager.GeomRequirements(
                geomVertexFormat=format,
                renderState=n.getState()
                )
github Craig-Macomber / Panda3D-Terrain-System / meshManager / treeFactory.py View on Github external
if self.barkTexture:
                vNum=numVertices+1
            else:
                vNum=numVertices
            
            for i in xrange(vNum):  #doubles the last vertex to fix UV seam
                angle=-2 * i * math.pi / numVertices
                angleData.append((math.cos(angle),math.sin(angle),1.0*i / numVertices))
        
            angleDatas.append(angleData)
        
        bottom=True
        
        if collision:
            cNode=CollisionNode('cnode')
            cnodePath = NodePath(cNode)
            cnodePath.reparentTo(collision)
            cnodePath.setCollideMask(collisionUtil.groundMask)
            #cnodePath.show()
            
        
        while stack: 
            pos, quat, depth, previousRows, sCoord = stack.pop() 
            length = lengthList[depth]
            sCoord += length/4.0
            
            radius=radiusList[depth]
            
            
            
            perp1 = quat.getRight() 
            perp2 = quat.getForward()
github cosmonium / cosmonium / cosmonium / tiles.py View on Github external
def create_holder_instance(self):
        self.holder = NodePath('tile')
        self.holder.set_pos(self.x0, self.y0, 0.0)
        self.holder.set_scale(*self.get_scale())
        if settings.debug_lod_show_bb:
            self.bounds_shape.create_instance()
        self.holder.node().setBounds(OmniBoundingVolume())
        self.holder.node().setFinal(1)
github WindyDarian / Sogal / sogasys / gui / panel.py View on Github external
distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

====================================================================================
Created on Sep 15, 2013

@author: Windy Darian (大地无敌)
'''
from panda3d.core import NodePath
from direct.showbase.DirectObject import DirectObject


#TODO 来战个痛!
class ListPanel(DirectObject, NodePath):
    '''
    classdocs
    '''


    def __init__(selfparams):
        '''
        Constructor
        '''
        pass