def setup_scene(self) : h3dres = self._h3dres # Add terrain self.terrain = h3d.addNodes(h3d.RootNode, h3dres.terrain) # Set sun direction for ambient pass h3d.setMaterialUniform(h3dres.matRes, "sunDir", 1, -1, 0, 0 ); self.add_camera("MainCamera", h3dres.forwardPipe) h3d.setNodeTransform(self.camera, 512.0, 120.0, 512.0, 0, 2250.0, 0, 1, 1, 1)
def graphic_update(self, cur_fps, ani_time, weight): forward = h3d.getNodeParamI( self.camera, h3d.Camera.PipeResI ) == self._h3dres.forwardPipe if (PIWIO.key_clicked() and PIWIO.clicked_key() == Qt.Key_F5) :self.__mode += 1 if self.__mode > 0 : if forward: h3d.utils.showText( "Pipeline: forward", 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(): if PIWIO.clicked_key() == Qt.Key_F3 : if forward : h3d.setNodeParamI( self.camera, h3d.Camera.PipeResI, self._h3dres.deferredPipe ) else : h3d.setNodeParamI( self.camera, h3d.Camera.PipeResI, self._h3dres.forwardPipe ) SetCamera(self.camera) elif PIWIO.clicked_key() == Qt.Key_1 : self.change_skybox(self._h3dres.skyBox) elif PIWIO.clicked_key() == Qt.Key_2 : self.change_skybox(self._h3dres.skyBox2) elif PIWIO.clicked_key() == Qt.Key_3 : mtl = h3d.getNodeParamI(self._vol, 20001) h3d.setMaterialUniform(mtl, "FluidColor", 0.59, 0.69, 0.99, 1.0) h3d.setMaterialUniform(mtl, "absorptionIdx", 2.0, 1.1, 0.45, 0.0) elif PIWIO.clicked_key() == Qt.Key_4 : mtl = h3d.getNodeParamI(self._vol, 20001) h3d.setMaterialUniform(mtl, "FluidColor", 0.0, 0.0, 0.0, 0.0) h3d.setMaterialUniform(mtl, "absorptionIdx", 0.0, 0.0, 0.0, 0.0) if self.animation : self.__rotate += 30.0/cur_fps anchor = h3d.getNodeParent(self.camera) t,r,s = h3d.getNodeTransform(anchor) h3d.setNodeTransform(anchor, t[0], t[1], t[2], r[0], self.__rotate, r[2], s[0], s[1], s[2]) if len(self.__data_list) > 0: self.__file_ptr += self.__skip self.__file_ptr %= len(self.__data_list) fn = self.__data_list[self.__file_ptr] if not SPH.UpdateSphData(self._sphdata, fn) : print "can not load file {}".format(fn) else : SPH.AdvanceSph(self._vol) if not forward and self.create_cmap : self.update_shader_fov(self.light_fov) h3d.render(self._light_camera) # restore self.update_shader_fov(45.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)
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)
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)
def graphic_update(self, cur_fps, ani_time, weight): forward = h3d.getNodeParamI( self.camera, h3d.Camera.PipeResI) == self._h3dres.forwardPipe if (PIWIO.key_clicked() and PIWIO.clicked_key() == Qt.Key_F5): self.__mode += 1 if self.__mode > 0: if forward: h3d.utils.showText("Pipeline: forward", 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(): if PIWIO.clicked_key() == Qt.Key_F3: if forward: h3d.setNodeParamI(self.camera, h3d.Camera.PipeResI, self._h3dres.deferredPipe) else: h3d.setNodeParamI(self.camera, h3d.Camera.PipeResI, self._h3dres.forwardPipe) SetCamera(self.camera) elif PIWIO.clicked_key() == Qt.Key_1: self.change_skybox(self._h3dres.skyBox) elif PIWIO.clicked_key() == Qt.Key_2: self.change_skybox(self._h3dres.skyBox2) elif PIWIO.clicked_key() == Qt.Key_3: mtl = h3d.getNodeParamI(self._vol, 20001) h3d.setMaterialUniform(mtl, "FluidColor", 0.59, 0.69, 0.99, 1.0) h3d.setMaterialUniform(mtl, "absorptionIdx", 2.0, 1.1, 0.45, 0.0) elif PIWIO.clicked_key() == Qt.Key_4: mtl = h3d.getNodeParamI(self._vol, 20001) h3d.setMaterialUniform(mtl, "FluidColor", 0.0, 0.0, 0.0, 0.0) h3d.setMaterialUniform(mtl, "absorptionIdx", 2.0, 1.1, 0.45, 0.0) if self.animation: self.__rotate += 30.0 / cur_fps anchor = h3d.getNodeParent(self.camera) t, r, s = h3d.getNodeTransform(anchor) h3d.setNodeTransform(anchor, t[0], t[1], t[2], r[0], self.__rotate, r[2], s[0], s[1], s[2]) if len(self.__data_list) > 0: self.__file_ptr += self.__skip self.__file_ptr %= len(self.__data_list) fn = self.__data_list[self.__file_ptr] if not SPH.UpdateSphData(self._sphdata, fn): print "can not load file {}".format(fn) else: SPH.AdvanceSph(self._vol) if self.__shot_dir != '' and self.__file_ptr > 0: fn = self.__data_list[self.__file_ptr - 1] fn = os.path.join(self.__shot_dir, '{}.tga'.format(os.path.split(fn)[-1])) utils.screenshot(fn) if not forward and self.create_cmap: self.update_shader_fov(self.light_fov) h3d.render(self._light_camera) # restore self.update_shader_fov(45.0)
def _h3dSetupScene(self): h3dres = self._h3dres # Add terrain self.terrain = h3d.addNodes(h3d.RootNode, h3dres.terrain) # Set sun direction for ambient pass h3d.setMaterialUniform(h3dres.matRes, "sunDir", 1, -1, 0, 0 );