Beispiel #1
0
 def __init__(self, radius=1.0, scale=None):
     Shape.__init__(self)
     self.radius = radius
     if scale is None:
         self.radius = radius
         self.scale = LVecBase3(self.radius, self.radius, self.radius)
     else:
         self.scale = LVecBase3(*scale) * radius
         self.radius = max(scale) * radius
     self.blend = TransparencyBlend.TB_PremultipliedAlpha
     self.scale_factor = 1.0
Beispiel #2
0
 def __init__(self, radius=1.0, scale=None):
     Shape.__init__(self)
     self.radius = radius
     if scale is None:
         self.radius = radius
         self.scale = LVecBase3(self.radius, self.radius, self.radius)
     else:
         self.scale = LVecBase3(*scale) * radius
         self.radius = max(scale) * radius
     self.nb_points = 1
     self.size = 1.0
     self.yellow_color = LColor(255.0 / 255, 248.0 / 255, 231.0 / 255, 1.0)
     self.blue_color = LColor(102.0 / 255, 153.0 / 255, 255.0 / 255, 1.0)
Beispiel #3
0
 def __init__(self, radius=1.0, scale=None):
     Shape.__init__(self)
     self.radius = radius
     self.seed = random()
     if scale is None:
         self.radius = radius
         self.scale = LVecBase3(self.radius, self.radius, self.radius)
     else:
         self.scale = LVecBase3(*scale) * radius
         self.radius = max(scale) * radius
     self.nb_points = 1
     self.size = 1.0
     self.yellow_color = srgb_to_linear((255.0 / 255, 248.0 / 255, 231.0 / 255, 1.0))
     self.blue_color = srgb_to_linear((102.0 / 255, 153.0 / 255, 255.0 / 255, 1.0))
Beispiel #4
0
 def update_shader_shape_static(self, shape, appearance):
     VolumetricDensityRayMarchingShaderBase.update_shader_shape_static(
         self, shape, appearance)
     shape.instance.setShaderInput("source_color", self.source_color)
     shape.instance.setShaderInput("source_power", self.source_power)
     shape.instance.setShaderInput(
         "emission_color", srgb_to_linear_channel(self.emission_color[0]),
         srgb_to_linear_channel(self.emission_color[1]),
         srgb_to_linear_channel(self.emission_color[2]))
     shape.instance.setShaderInput("emission_power", self.emission_power)
     shape.instance.setShaderInput(
         "absorption_coef",
         LVecBase3(*self.absorption_coef) * self.absorption_factor)
     shape.instance.setShaderInput("mie_coef", self.mie_coef)
     shape.instance.setShaderInput("phase_asymmetry_factor",
                                   self.phase_coef)
Beispiel #5
0
    def testObjectWithViewer(self):

        scene = Scene()

        modelId = '83'
        modelFilename = os.path.join(TEST_SUNCG_DATA_DIR, "object",
                                     str(modelId),
                                     str(modelId) + ".egg")
        assert os.path.exists(modelFilename)
        model = loadModel(modelFilename)
        model.setName('model-' + str(modelId))
        model.show(BitMask32.allOn())

        objectsNp = scene.scene.attachNewNode('objects')
        objNp = objectsNp.attachNewNode('object-' + str(modelId))
        model.reparentTo(objNp)

        # Calculate the center of this object
        minBounds, maxBounds = model.getTightBounds()
        centerPos = minBounds + (maxBounds - minBounds) / 2.0

        # Add offset transform to make position relative to the center
        model.setTransform(TransformState.makePos(-centerPos))

        renderer = None
        viewer = None

        try:
            renderer = Panda3dRenderer(scene, shadowing=False)

            viewer = Viewer(scene, interactive=False)
            viewer.disableMouse()

            viewer.cam.setTransform(
                TransformState.makePos(LVecBase3(5.0, 0.0, 0.0)))
            viewer.cam.lookAt(model)

            for _ in range(20):
                viewer.step()
            time.sleep(1.0)

        finally:
            if renderer is not None:
                renderer.destroy()
            if viewer is not None:
                viewer.destroy()
                viewer.graphicsEngine.removeAllWindows()
Beispiel #6
0
    def testDebugObjectWithRender(self):

        scene = Scene()

        modelId = '83'
        modelFilename = os.path.join(TEST_SUNCG_DATA_DIR, "object",
                                     str(modelId),
                                     str(modelId) + ".egg")
        assert os.path.exists(modelFilename)
        model = loadModel(modelFilename)
        model.setName('model-' + str(modelId))
        model.hide()

        objectsNp = scene.scene.attachNewNode('objects')
        objNp = objectsNp.attachNewNode('object-' + str(modelId))
        model.reparentTo(objNp)

        # Calculate the center of this object
        minBounds, maxBounds = model.getTightBounds()
        centerPos = minBounds + (maxBounds - minBounds) / 2.0

        # Add offset transform to make position relative to the center
        model.setTransform(TransformState.makePos(-centerPos))

        renderer = None
        physics = None
        viewer = None

        try:
            renderer = Panda3dRenderer(scene, shadowing=False)
            physics = Panda3dBulletPhysics(scene, debug=True)

            viewer = Viewer(scene, interactive=False)
            viewer.disableMouse()

            viewer.cam.setTransform(
                TransformState.makePos(LVecBase3(5.0, 0.0, 0.0)))
            viewer.cam.lookAt(model)

            for _ in range(20):
                viewer.step()
            time.sleep(1.0)

        finally:
            self.hulkSmash(renderer, physics, viewer)
Beispiel #7
0
 def update_hpr(self, mouse_pos):
     """Set hpr from mouse position."""
     self.hpr = LVecBase3(-mouse_pos[0] * config.mouse_params.heading_speed,
                          mouse_pos[1] * config.mouse_params.pitch_speed, 0)
Beispiel #8
0
 def __init__(self):
     self.pos = Vec3(0, 0, 7.5)
     self.prepos = self.pos
     self.velocity = Vec3(0, 0, 0)
     self.hpr = LVecBase3(90, 90, 0)
Beispiel #9
0
 def get_scale(self):
     return LVecBase3(1.0, 1.0, 1.0)