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/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. 2
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. 3
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. 4
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. 5
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. 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 change_skybox(self, skyres):
        if self._sky != 0:
            # remove the old sky box
            h3d.removeNode(self._sky)

        h3dres = self._h3dres
        # Add skybox
        self._sky = h3d.addNodes(h3d.RootNode, skyres)
        h3d.setNodeTransform(self._sky, 0, 0, 0, 0, 0, 0, 20, 20, 20)
        # Set ligth envmap
        mesh = h3d.getNodeChild(self._sky, 0)
        res = h3d.getNodeParamI(mesh, h3d.Mesh.MatResI)
        idx = self.get_smapler_by_name(res, "albedoMap")
        if idx != -1 :
            evn_map = h3d.getResParamI(res, h3d.MatRes.SamplerElem, idx, h3d.MatRes.SampTexResI)
            idx = self.get_smapler_by_name(h3dres.lightMat, "envMap")
            if idx != -1:
                h3d.setResParamI(h3dres.lightMat, h3d.MatRes.SamplerElem, idx, h3d.MatRes.SampTexResI, evn_map)
Esempio n. 8
0
    def change_skybox(self, skyres):
        if self._sky != 0:
            # remove the old sky box
            h3d.removeNode(self._sky)

        h3dres = self._h3dres
        # Add skybox
        self._sky = h3d.addNodes(h3d.RootNode, skyres)
        h3d.setNodeTransform(self._sky, 0, 0, 0, 0, 0, 0, 20, 20, 20)
        # Set ligth envmap
        mesh = h3d.getNodeChild(self._sky, 0)
        res = h3d.getNodeParamI(mesh, h3d.Mesh.MatResI)
        idx = self.get_smapler_by_name(res, "albedoMap")
        if idx != -1:
            evn_map = h3d.getResParamI(res, h3d.MatRes.SamplerElem, idx,
                                       h3d.MatRes.SampTexResI)
            idx = self.get_smapler_by_name(h3dres.lightMat, "envMap")
            if idx != -1:
                h3d.setResParamI(h3dres.lightMat, h3d.MatRes.SamplerElem, idx,
                                 h3d.MatRes.SampTexResI, evn_map)