Esempio n. 1
0
    def get_cmap_res(self) :
        res = self._h3dres.lightMat
        cnt = h3d.getResElemCount(res, h3d.MatRes.SamplerElem)
        for i in range(cnt) :
            uni_name = h3d.getResParamStr(res, h3d.MatRes.SamplerElem, i, h3d.MatRes.SampNameStr)
            if uni_name == 'causticMap' :
                h3d.setResParamI(res, h3d.MatRes.SamplerElem, i, h3d.MatRes.SampTexResI, self._h3dres.cmap)
                break

        res = h3d.findResource(h3d.ResTypes.Shader, 'shaders/sph_lighting.shader')
        if res != 0 :
            cnt = h3d.getResElemCount(res, h3d.ShaderRes.UniformElem)
            for i in range(cnt) :
                uni_name = h3d.getResParamStr(res, h3d.ShaderRes.UniformElem, i, h3d.ShaderRes.UnifNameStr)
                if uni_name in self.cmap_mat :
                    self.cmap_mat[uni_name] = i
            self.ligth_shader_res = res

        res = h3d.findResource(h3d.ResTypes.Shader, 'shaders/sph1.shader')
        if res != 0 :
            cnt = h3d.getResElemCount(res, h3d.ShaderRes.UniformElem)
            for i in range(cnt) :
                uni_name = h3d.getResParamStr(res, h3d.ShaderRes.UniformElem, i, h3d.ShaderRes.UnifNameStr)
                if uni_name == 'cameraFov' :
                    self.fov_slot = i
                    break
            self.sph1_shader_res = res
Esempio n. 2
0
    def get_cmap_res(self):
        res = self._h3dres.lightMat
        cnt = h3d.getResElemCount(res, h3d.MatRes.SamplerElem)
        for i in range(cnt):
            uni_name = h3d.getResParamStr(res, h3d.MatRes.SamplerElem, i,
                                          h3d.MatRes.SampNameStr)
            if uni_name == 'causticMap':
                h3d.setResParamI(res, h3d.MatRes.SamplerElem, i,
                                 h3d.MatRes.SampTexResI, self._h3dres.cmap)
                break

        res = h3d.findResource(h3d.ResTypes.Shader,
                               'shaders/sph_lighting.shader')
        if res != 0:
            cnt = h3d.getResElemCount(res, h3d.ShaderRes.UniformElem)
            for i in range(cnt):
                uni_name = h3d.getResParamStr(res, h3d.ShaderRes.UniformElem,
                                              i, h3d.ShaderRes.UnifNameStr)
                if uni_name in self.cmap_mat:
                    self.cmap_mat[uni_name] = i
            self.ligth_shader_res = res

        res = h3d.findResource(h3d.ResTypes.Shader, 'shaders/sph_fluid.shader')
        if res != 0:
            cnt = h3d.getResElemCount(res, h3d.ShaderRes.UniformElem)
            for i in range(cnt):
                uni_name = h3d.getResParamStr(res, h3d.ShaderRes.UniformElem,
                                              i, h3d.ShaderRes.UnifNameStr)
                if uni_name == 'cameraFov':
                    self.fov_slot = i
                    break
            self.sph1_shader_res = res
Esempio n. 3
0
    def get_cmap_res(self) :
        # print self.light_material_name
        res = h3d.findResource(h3d.ResTypes.Material, self.light_material_name)
        idx = get_smapler_by_name(res, 'causticMap')
        if idx >= 0 : h3d.setResParamI(res, h3d.MatRes.SamplerElem, idx, h3d.MatRes.SampTexResI, self.cmap)
        else : print "Get error caustic map id"
        self.light_mat_res = res
        
        # get light matrix uniform id
        res = h3d.findResource(h3d.ResTypes.Shader, self.light_shader_name)
        if res != 0 :
            cnt = h3d.getResElemCount(res, h3d.ShaderRes.UniformElem)
            for i in range(cnt) :
                uni_name = h3d.getResParamStr(res, h3d.ShaderRes.UniformElem, i, h3d.ShaderRes.UnifNameStr)
                if uni_name in self.cmap_mat : self.cmap_mat[uni_name] = i
            self.light_shader_res = res
        else: print "Get error light shader id"

        res = h3d.findResource(h3d.ResTypes.Shader, 'shaders/sph_fluid.shader')
        if res != 0 :
            cnt = h3d.getResElemCount(res, h3d.ShaderRes.UniformElem)
            for i in range(cnt) :
                uni_name = h3d.getResParamStr(res, h3d.ShaderRes.UniformElem, i, h3d.ShaderRes.UnifNameStr)
                if uni_name == 'cameraFov' :
                    self.fov_slot = i
                    break
            self.sph1_shader_res = res
        else : print "Get error fluid shader id"
Esempio n. 4
0
 def load_res(self) :
     
     class H3DRes: pass
         
     h3dres = H3DRes()
     self._h3dres = h3dres
     # Pipelines
     h3dres.forwardPipe = h3d.addResource(h3d.ResTypes.Pipeline, "pipelines/forward.pipeline.xml", 0)
     h3dres.deferredPipe = h3d.addResource(h3d.ResTypes.Pipeline, "pipelines/sphvol.pipeline.xml", 0)
     # Overlays
     h3dres.fontMat = h3d.addResource(h3d.ResTypes.Material, "overlays/font.material.xml", 0)
     h3dres.panelMat = h3d.addResource(h3d.ResTypes.Material, "overlays/panel.material.xml", 0)
     h3dres.logoMat = h3d.addResource(h3d.ResTypes.Material, "overlays/logo.material.xml", 0)
     # Shader for deferred shading
     h3dres.lightMat = h3d.addResource(h3d.ResTypes.Material, "materials/sphLight.material.xml", 0)
     # Environment
     h3dres.env = h3d.addResource(h3d.ResTypes.SceneGraph, "models/platform/platform.scene.xml", 0)
     # Skybox
     h3dres.skyBox = h3d.addResource(h3d.ResTypes.SceneGraph, "models/skybox/skybox_desert.scene.xml", 0)
     # Volume box
     h3dres.volBox = h3d.addResource(h3d.ResTypes.SceneGraph, "models/sphvolbox/box.scene.xml", 0)
     if not h3d.utils.loadResourcesFromDisk(DataDir):
         print 'loading of some resources failed: See Horde3D_Log.html'
     # Load sph volume
     h3dres.sphVol = SPH.LoadVolumeData('./frame_273.fr')
     if h3dres.sphVol != 0:
         material =  h3d.findResource( h3d.ResTypes.Material, "models/sphvolbox/box.material.xml" )
         h3d.setResParamI(material, h3d.MatRes.SamplerElem, 0, h3d.MatRes.SampTexResI, h3dres.sphVol)
     else :
         print 'can not laod sph raw volume data'
Esempio n. 5
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)
Esempio n. 6
0
 def start(self):
     # save hordeid
     obj3d = self.gocBehavior('Object3D')
     self._sky = obj3d.horde_id
     self.light_mat_res = h3d.findResource(h3d.ResTypes.Material, "materials/sphLight.material.xml")
     
     # set up skybox
     mesh = h3d.getNodeChild(self._sky, 0)
     res = h3d.getNodeParamI(mesh, h3d.Mesh.MatResI)
     idx = get_smapler_by_name(res, "albedoMap")
     if idx != -1 :
         evn_map = h3d.getResParamI(res, h3d.MatRes.SamplerElem, idx, h3d.MatRes.SampTexResI)
         idx = get_smapler_by_name(self.light_mat_res, "envMap")
         if idx != -1:
             h3d.setResParamI(self.light_mat_res, h3d.MatRes.SamplerElem, idx, h3d.MatRes.SampTexResI, evn_map)
Esempio n. 7
0
    def _h3dAddResources(self):
        class H3DRes:
            pass

        h3dres = H3DRes()
        self._h3dres = h3dres

        # Pipelines
        h3dres.forwardPipe = h3d.addResource(h3d.ResTypes.Pipeline, "pipelines/forward.pipeline.xml", 0)
        # Overlays
        h3dres.fontMat = h3d.addResource(h3d.ResTypes.Material, "overlays/font.material.xml", 0)
        h3dres.panelMat = h3d.addResource(h3d.ResTypes.Material, "overlays/panel.material.xml", 0)
        h3dres.logoMat = h3d.addResource(h3d.ResTypes.Material, "overlays/logo.material.xml", 0)
        # Terrain
        h3dres.terrain = h3d.addResource(h3d.ResTypes.SceneGraph, "terrains/terrain1/terrain1.scene.xml", 0)
        h3dres.matRes = h3d.findResource(h3d.ResTypes.Material, "terrains/terrain1/terrain1.material.xml" );
Esempio n. 8
0
    def start(self):
        # get horde id
        obj3d = self.gocBehavior('Object3D')
        self.h3did = obj3d.horde_id
        self._enable = h3d.getNodeType(
            self.h3did) == h3d.sph.H3DEXT_NodeType_Sph
        # print self.fr_dir, self.play, dir(self._piw_prop_fr_dir)
        # init
        self.__data_list = []
        self.__file_ptr = 0
        self.__skip = 1
        self.__solids = {}
        # print self.cm
        if self._enable:
            if self.fr_dir != "":
                self.change_fr_dir(self.fr_dir, self.__skip)
            self._sphdata = h3d.getNodeParamI(self.h3did,
                                              h3d.sph.H3DEXTSph.VolumeResI)
            # parse template
            if self.template:
                solids = [x.split(':') for x in self.template.split()]
                for kind, params in solids:
                    scngraph, cx, cy, cz, sx, sy, sz, bx, by, bz = params.split(
                        ';')
                    scnres = h3d.findResource(h3d.ResTypes.SceneGraph,
                                              scngraph)
                    if not scnres:
                        print "Can not find template's scene graph"
                        return
                    # print scngraph, scnres, cx, cy, cz, sx, sy, sz
                    self.__solids[int(kind)] = dict(
                        scnres=scnres,
                        com=np.array([float(cx),
                                      float(cy),
                                      float(cz)]),
                        scale=np.array([float(sx),
                                        float(sy),
                                        float(sz)]),
                        bscale=np.array([float(bx),
                                         float(by),
                                         float(bz)]),
                        nodes=[])

        else:
            print "PlayFrFiles attached to a wrong type of node, please specify a SPH node instead!"
Esempio n. 9
0
    def start(self):
        # save hordeid
        obj3d = self.gocBehavior('Object3D')
        self._sky = obj3d.horde_id
        self.light_mat_res = h3d.findResource(
            h3d.ResTypes.Material, "materials/sphLight.material.xml")

        # set up skybox
        mesh = h3d.getNodeChild(self._sky, 0)
        res = h3d.getNodeParamI(mesh, h3d.Mesh.MatResI)
        idx = get_smapler_by_name(res, "albedoMap")
        if idx != -1:
            evn_map = h3d.getResParamI(res, h3d.MatRes.SamplerElem, idx,
                                       h3d.MatRes.SampTexResI)
            idx = get_smapler_by_name(self.light_mat_res, "envMap")
            if idx != -1:
                h3d.setResParamI(self.light_mat_res, h3d.MatRes.SamplerElem,
                                 idx, h3d.MatRes.SampTexResI, evn_map)
Esempio n. 10
0
 def load_res(self) :
     
     class H3DRes: pass
         
     h3dres = H3DRes()
     self._h3dres = h3dres
     # Pipelines
    # Pipelines
     h3dres.forwardPipe = h3d.addResource(h3d.ResTypes.Pipeline, "pipelines/forward.pipeline.xml", 0)
     # Overlays
     h3dres.fontMat = h3d.addResource(h3d.ResTypes.Material, "overlays/font.material.xml", 0)
     h3dres.panelMat = h3d.addResource(h3d.ResTypes.Material, "overlays/panel.material.xml", 0)
     h3dres.logoMat = h3d.addResource(h3d.ResTypes.Material, "overlays/logo.material.xml", 0)
     # Terrain
     h3dres.terrain = h3d.addResource(h3d.ResTypes.SceneGraph, "terrains/terrain1/terrain1.scene.xml", 0)
     h3dres.matRes = h3d.findResource(h3d.ResTypes.Material, "terrains/terrain1/terrain1.material.xml" );
     if not h3d.utils.loadResourcesFromDisk(DataDir + "|../../Data/Terrain"):
         print 'loading of some resources failed: See Horde3D_Log.html'
Esempio n. 11
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)
Esempio n. 12
0
    def setup_scene(self):
        h3dres = self._h3dres

        self._env = h3d.addNodes(h3d.RootNode, h3dres.env)
        #h3d.setNodeTransform(self._env, 0, 0, 0, 0, 0, 0, 0.23, 0.23, 0.23)
        h3d.setNodeTransform(self._env, 0, -20, 0, 0, 0, 0, 20, 20, 20)
        # Add skybox
        self._sky = h3d.addNodes(h3d.RootNode, h3dres.skyBox)
        h3d.setNodeTransform(self._sky, 0, 0, 0, 90, 0, 0, 50, 50, 50)

        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)

        self._light = h3d.addLightNode(h3d.RootNode, 'Light1', h3dres.lightMat,
                                       '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)

        # Attach particle system to hand joint
        self.set_particlesys(h3dres.particleSys2)
        self.add_camera("MainCamera", self.__rmode_dict[3][1])
        h3d.setNodeTransform(self.camera, -25, 14, 9, -30, -60, 5, 1, 1, 1)