Пример #1
0
def construct_tree(root):
    # get a plain list of current scene
    cnt = h3d.findNodes(h3d.RootNode, "", h3d.NodeTypes.Undefined)
    if cnt == 0: return

    local_dict = {}
    for i in range(cnt):
        node_id = h3d.getNodeFindResult(i)
        if node_id == h3d.RootNode:
            continue
        node_name = h3d.getNodeParamStr(node_id, h3d.NodeParams.NameStr)
        # sikp the editor's interal nodes
        if node_name.startswith('__') and node_name.endswith('__'):
            continue
        local_dict[node_id] = gModel.createItem(node_name, node_id)

    # add children recursively
    for nid, item in local_dict.iteritems():
        pid = h3d.getNodeParent(nid)
        try:
            parent = gModel.getItem(local_dict[pid])
            parent.appendRow(gModel.getItem(item))
        except KeyError:
            # it's top level node, or its parent is a editor node
            root.appendRow(gModel.getItem(item))
Пример #2
0
    def _h3dSetupScene(self):
        h3dres = self._h3dres

        self._env = h3d.addNodes(h3d.RootNode, h3dres.env)
        h3d.setNodeTransform(self._env, 0, -20, 0, 0, 0, 0, 20, 20, 20)

        self._knight = h3d.addNodes(h3d.RootNode, h3dres.knight)
        h3d.setNodeTransform(self._knight, 0, 0, 0, 0, 180, 0, 0.1, 0.1, 0.1)
        h3d.setupModelAnimStage(self._knight, 0, h3dres.knightAnim1, 0, '', False)
        h3d.setupModelAnimStage(self._knight, 1, h3dres.knightAnim2, 0, '', False)

        # Attach particle system to hand joint
        h3d.findNodes(self._knight, 'Bip01_R_Hand', h3d.NodeTypes.Joint)
        hand = h3d.getNodeFindResult(0)
        self._particleSystem = h3d.addNodes(hand, h3dres.particleSys)
        h3d.setNodeTransform(self._particleSystem, 0, 40, 0, 90, 0, 0, 1, 1, 1)

        self._light = h3d.addLightNode(h3d.RootNode, 'Light1', 0, 'LIGHTING', 'SHADOWMAP')
        h3d.setNodeTransform(self._light, 0, 15, 10, -60, 0, 0, 1, 1, 1)
        h3d.setNodeParamF(self._light, h3d.Light.RadiusF, 0, 30)
        h3d.setNodeParamF(self._light, h3d.Light.FovF, 0, 90)
        h3d.setNodeParamI(self._light, h3d.Light.ShadowMapCountI, 1)
        h3d.setNodeParamF(self._light, h3d.Light.ShadowMapBiasF, 0, 0.01)
        h3d.setNodeParamF(self._light, h3d.Light.ColorF3, 0, 1.0)
        h3d.setNodeParamF(self._light, h3d.Light.ColorF3, 1, 0.8)
        h3d.setNodeParamF(self._light, h3d.Light.ColorF3, 2, 0.7)

        # Customize post processing effects
        mat = h3d.findResource(h3d.ResTypes.Material, 'pipelines/postHDR.material.xml')
        # hdrParams: exposure, brightpass threshold, brightpass offset (see shader for description)
        h3d.setMaterialUniform(mat, 'hdrExposure', 2.5, 0.0, 0.0, 0.0)
        h3d.setMaterialUniform(mat, 'hdrBrightThres', 0.5, 0.0, 0.0, 0.0)
        h3d.setMaterialUniform(mat, 'hdrBrightOffset', 0.08, 0.0, 0.0, 0.0)
Пример #3
0
def construct_tree(root) :
    # get a plain list of current scene
    cnt = h3d.findNodes(h3d.RootNode, "", h3d.NodeTypes.Undefined)
    if cnt == 0 : return
    
    local_dict = {}
    for i in range(cnt) :
        node_id = h3d.getNodeFindResult(i)
        if node_id == h3d.RootNode : 
            continue
        node_name = h3d.getNodeParamStr(node_id, h3d.NodeParams.NameStr)
        # sikp the editor's interal nodes
        if node_name.startswith('__') and node_name.endswith('__') : 
            continue
        local_dict[node_id] = gModel.createItem(node_name, node_id)

    # add children recursively
    for nid, item in local_dict.iteritems() :
        pid = h3d.getNodeParent(nid)
        try :
            parent = gModel.getItem(local_dict[pid])
            parent.appendRow(gModel.getItem(item))
        except KeyError :
            # it's top level node, or its parent is a editor node
            root.appendRow(gModel.getItem(item))
Пример #4
0
 def set_particlesys(self, psys):
     # Attach particle system to hand joint
     h3d.findNodes(self._knight, 'Bip01_R_Hand', h3d.NodeTypes.Joint)
     hand = h3d.getNodeFindResult(0)
     if self._particleSystem is not None:
         h3d.removeNode(self._particleSystem)
     self._particleSystem = h3d.addNodes(hand, psys)
     h3d.setNodeTransform(self._particleSystem, 0, 40, 0, 90, 0, 0, 1, 1, 1)
Пример #5
0
    def _mainloopUpdate(self, dt):
        app.App._mainloopUpdate(self, dt)

        for w in self._windows:
            h3d.setNodeTransform(w.camera, self._x, self._y, self._z, self._rx, self._ry, 0, 1, 1, 1)

            if self._debugViewMode:
                h3d.setOption(h3d.Options.DebugViewMode, 1.0)
            else:
                h3d.setOption(h3d.Options.DebugViewMode, 0.0)

            if self._wireframeMode:
                h3d.setOption(h3d.Options.WireframeMode, 1.0)
            else:
                h3d.setOption(h3d.Options.WireframeMode, 0.0)

            key = pyglet.window.key
            curVel = self._velocity * dt
            if w.keyboard[key.LSHIFT]:
                curVel *= 5
            if w.keyboard[key.W]:
                self._x -= sin(radians(self._ry)) * cos(-radians(self._rx)) * curVel
                self._y -= sin(-radians(self._rx)) * curVel
                self._z -= cos(radians(self._ry)) * cos(-radians(self._rx)) * curVel
            if w.keyboard[key.S]:
                self._x += sin(radians(self._ry)) * cos(-radians(self._rx)) * curVel
                self._y += sin(-radians(self._rx)) * curVel
                self._z += cos(radians(self._ry)) * cos(-radians(self._rx)) * curVel
            if w.keyboard[key.A]:
                self._x += sin(radians(self._ry - 90)) * curVel
                self._z += cos(radians(self._ry - 90)) * curVel
            if w.keyboard[key.D]:
                self._x += sin(radians(self._ry + 90)) * curVel
                self._z += cos(radians(self._ry + 90)) * curVel
            if w.keyboard[key._1]:
                self._weight += 2 * dt
                if self._weight > 1.0:
                    self._weight = 1.0
            if w.keyboard[key._2]:
                self._weight -= 2 * dt
                if self._weight < 0.0:
                    self._weight = 0.0

            break # we use only exactly ONE window

        if not self._freeze:
            self._animTime += dt

            h3d.setModelAnimParams(self._knight, 0, self._animTime * 24.0, self._weight)
            h3d.setModelAnimParams(self._knight, 1, self._animTime * 24.0, 1.0 - self._weight)

            count = h3d.findNodes(self._particleSystem, '', h3d.NodeTypes.Emitter)
            for i in range(count):
                h3d.advanceEmitterTime(h3d.getNodeFindResult(i), dt)
Пример #6
0
    def setup_scene(self) :
        h3dres = self._h3dres

        # Add skybox
        self._sky = h3d.addNodes(h3d.RootNode, h3dres.skyBox)
        h3d.setNodeTransform(self._sky, 0, 0, 0, 0, 0, 0, 500, 500, 500)
        # Add light source
        self._light = h3d.addLightNode(h3d.RootNode, 'Light1', h3dres.lightMat, 'LIGHTING', 'SHADOWMAP')
        h3d.setNodeTransform(self._light, 0, 20, 50, -30, 0, 0, 1, 1, 1)
        h3d.setNodeParamF(self._light, h3d.Light.RadiusF, 0, 200)
        h3d.setNodeParamF(self._light, h3d.Light.FovF, 0, 90)
        h3d.setNodeParamI(self._light, h3d.Light.ShadowMapCountI, 3)
        h3d.setNodeParamF(self._light, h3d.Light.ShadowSplitLambdaF, 0, 0.9)
        h3d.setNodeParamF(self._light, h3d.Light.ShadowMapBiasF, 0, 0.001)
        h3d.setNodeParamF(self._light, h3d.Light.ColorF3, 0, 0.9)
        h3d.setNodeParamF(self._light, h3d.Light.ColorF3, 1, 0.7)
        h3d.setNodeParamF(self._light, h3d.Light.ColorF3, 2, 0.75)
        # Add domino scene
        self._domino = h3d.addNodes(h3d.RootNode, h3dres.dominoRes )
        # Add particle effects
        h3d.findNodes(self._domino, 'sphere', h3d.NodeTypes.Mesh)
        sphere = h3d.getNodeFindResult(0)
        self._particleSystem = h3d.addNodes(sphere, h3dres.particleSys)
        # Set particle parameter
        count = h3d.findNodes(self._particleSystem, '', h3d.NodeTypes.Emitter)
        for i in range(count):
            node = h3d.getNodeFindResult(i)
            h3d.setNodeParamF(node, h3d.Emitter.ForceF3, 1, 1.5)
            h3d.setNodeParamF(node, h3d.Emitter.EmissionRateF, 0, 200)
            h3d.setNodeParamF(node, h3d.Emitter.SpreadAngleF, 0, 45)

        # Customize post processing effects
        mat = h3d.findResource(h3d.ResTypes.Material, 'pipelines/postHDR.material.xml')
        # hdrParams: exposure, brightpass threshold, brightpass offset (see shader for description)
        h3d.setMaterialUniform(mat, 'hdrExposure', 2.5, 0.0, 0.0, 0.0)
        h3d.setMaterialUniform(mat, 'hdrBrightThres', 0.5, 0.0, 0.0, 0.0)
        h3d.setMaterialUniform(mat, 'hdrBrightOffset', 0.08, 0.0, 0.0, 0.0)

        self.add_camera("MainCamera", h3dres.hdrPipe)
        h3d.setNodeTransform(self.camera, -14.0, 40.0, 24.0, -50.0, -20, 1.3, 1, 1, 1)
Пример #7
0
    def graphic_update(self, cur_fps, ani_time, weight):
        hdr = h3d.getNodeParamI( self.camera, h3d.Camera.PipeResI ) == self._h3dres.hdrPipe 
        
        if (PIWIO.key_clicked() and PIWIO.clicked_key() == Qt.Key_F5) :self.__mode += 1
        
        if self.__mode > 0 :
            if hdr:
                h3d.utils.showText( "Pipeline: hdr", 0.03, 0.24, 0.026, 1, 1, 1, self._h3dres.fontMat )
            else:
                h3d.utils.showText( "Pipeline: deferred", 0.03, 0.24, 0.026, 1, 1, 1, self._h3dres.fontMat )
        
        if self.__mode == 3 : self.__mode = 0

        if PIWIO.key_clicked() and PIWIO.clicked_key() == Qt.Key_F3 :
            if hdr :
                h3d.setNodeParamI( self.camera, h3d.Camera.PipeResI, self._h3dres.deferredPipe )
            else :
                h3d.setNodeParamI( self.camera, h3d.Camera.PipeResI, self._h3dres.hdrPipe )
            SetCamera(self.camera)

        count = h3d.findNodes(self._particleSystem, '', h3d.NodeTypes.Emitter)
        for i in range(count):
            h3d.updateEmitter(h3d.getNodeFindResult(i), 1.0/cur_fps)
Пример #8
0
    def graphic_update(self, cur_fps, ani_time, weight):

        if (PIWIO.key_clicked() and PIWIO.clicked_key() == Qt.Key_F5):
            self.__mode += 1

        if PIWIO.key_clicked() and PIWIO.clicked_key() == Qt.Key_F3:
            self.change_render_mode(self.__render_mode + 1)

        if self.__mode > 0:
            name, _ = self.__rmode_dict[self.__render_mode]
            h3d.utils.showText("Pipeline: {}".format(name), 0.03, 0.24, 0.026,
                               1, 1, 1, self._h3dres.fontMat)

        if self.__mode == 3: self.__mode = 0

        h3d.setModelAnimParams(self._knight, 0, ani_time, weight)
        h3d.setModelAnimParams(self._knight, 1, ani_time, 1.0 - weight)
        h3d.updateModel(
            self._knight,
            h3d.ModelUpdateFlags.Animation | h3d.ModelUpdateFlags.Geometry)

        count = h3d.findNodes(self._particleSystem, '', h3d.NodeTypes.Emitter)
        for i in range(count):
            h3d.updateEmitter(h3d.getNodeFindResult(i), 1.0 / cur_fps)