Example #1
0
 def create_node(self):
     rel_base = Point3(self.base - (self.midpoint - Point3(0, 0, 0)))
     rel_top = Point3(self.top - (self.midpoint - Point3(0, 0, 0)))
     self.geom = GeomBuilder().add_ramp(self.color, rel_base, rel_top,
                                        self.width,
                                        self.thickness).get_geom_node()
     return NodePath(self.geom)
Example #2
0
 def add_solid(self, node):
     mesh = BulletConvexHullShape()
     mesh.add_geom(GeomBuilder().add_ramp(self.color, self.base, self.top,
                                          self.width, self.thickness,
                                          LRotationf(*self.hpr)).get_geom())
     node.add_shape(mesh)
     return node
Example #3
0
 def add_solid(self, node):
     mesh = BulletConvexHullShape()
     mesh.add_geom(GeomBuilder().add_dome(self.color, self.center,
                                          self.radius,
                                          self.samples, self.planes,
                                          LRotationf(*self.hpr)).get_geom())
     node.add_shape(mesh)
     return node
Example #4
0
class Ramp(PhysicalObject):
    """
    A ramp.
    """
    def __init__(self,
                 base,
                 top,
                 width,
                 thickness,
                 color,
                 mass,
                 hpr,
                 name=None):
        super(Ramp, self).__init__(name)
        self.base = Point3(*base)
        self.top = Point3(*top)
        self.width = width
        self.thickness = thickness
        self.color = color
        self.mass = mass
        self.hpr = hpr
        self.midpoint = Point3((self.base + self.top) / 2.0)

    def create_node(self):
        rel_base = Point3(self.base - (self.midpoint - Point3(0, 0, 0)))
        rel_top = Point3(self.top - (self.midpoint - Point3(0, 0, 0)))
        self.geom = GeomBuilder().add_ramp(self.color, rel_base, rel_top,
                                           self.width,
                                           self.thickness).get_geom_node()
        return NodePath(self.geom)

    def create_solid(self):
        node = BulletRigidBodyNode(self.name)
        mesh = BulletConvexHullShape()
        mesh.add_geom(self.geom.get_geom(0))
        node.add_shape(mesh)
        return node

    def add_solid(self, node):
        mesh = BulletConvexHullShape()
        mesh.add_geom(GeomBuilder().add_ramp(self.color, self.base, self.top,
                                             self.width, self.thickness,
                                             LRotationf(*self.hpr)).get_geom())
        node.add_shape(mesh)
        return node

    def add_to(self, geom_builder):
        geom_builder.add_ramp(self.color, self.base, self.top, self.width,
                              self.thickness, LRotationf(*self.hpr))

    def attached(self):
        self.move(self.midpoint)
        self.rotate(*self.hpr)
Example #5
0
 def create_node(self):
     extent = self.size / 2.0
     geom_points = [
         Point3(0, -extent, -extent),
         Point3(0, extent, extent),
         Point3(0, -extent, extent)
     ]
     self.geom = GeomBuilder('tri').add_tri(self.color,
                                            geom_points).get_geom_node()
     self.node = self.world.render.attach_new_node(self.geom)
     self.colorhandle = self.node.find('**/*')
     return self.node
Example #6
0
class Dome(PhysicalObject):
    """
    A dome.
    """
    def __init__(self,
                 radius,
                 samples,
                 planes,
                 color,
                 mass,
                 center,
                 hpr,
                 name=None):
        super(Dome, self).__init__(name)
        self.radius = radius
        self.samples = samples
        self.planes = planes
        self.color = color
        self.mass = mass
        self.center = center
        self.hpr = hpr

    def create_node(self):
        self.geom = GeomBuilder().add_dome(self.color, (0, 0, 0), self.radius,
                                           self.samples,
                                           self.planes).get_geom_node()
        return NodePath(self.geom)

    def create_solid(self):
        node = BulletRigidBodyNode(self.name)
        mesh = BulletConvexHullShape()
        mesh.add_geom(self.geom.get_geom(0))
        node.add_shape(mesh)
        return node

    def add_solid(self, node):
        mesh = BulletConvexHullShape()
        mesh.add_geom(GeomBuilder().add_dome(self.color, self.center,
                                             self.radius,
                                             self.samples, self.planes,
                                             LRotationf(*self.hpr)).get_geom())
        node.add_shape(mesh)
        return node

    def add_to(self, geom_builder):
        rot = LRotationf(*self.hpr)
        geom_builder.add_dome(self.color, self.center, self.radius,
                              self.samples, self.planes, rot)

    def attached(self):
        self.move(self.center)
        self.rotate_by(*self.hpr)
Example #7
0
class Ramp(PhysicalObject):
    """
    A ramp.
    """

    def __init__(self, base, top, width, thickness, color, mass, hpr, name=None):
        super(Ramp, self).__init__(name)
        self.base = Point3(*base)
        self.top = Point3(*top)
        self.width = width
        self.thickness = thickness
        self.color = color
        self.mass = mass
        self.hpr = hpr
        self.midpoint = Point3((self.base + self.top) / 2.0)

    def create_node(self):
        rel_base = Point3(self.base - (self.midpoint - Point3(0, 0, 0)))
        rel_top = Point3(self.top - (self.midpoint - Point3(0, 0, 0)))
        self.geom = GeomBuilder().add_ramp(self.color, rel_base, rel_top, self.width, self.thickness).get_geom_node()
        return NodePath(self.geom)

    def create_solid(self):
        node = BulletRigidBodyNode(self.name)
        mesh = BulletConvexHullShape()
        mesh.add_geom(self.geom.get_geom(0))
        node.add_shape(mesh)
        return node

    def add_solid(self, node):
        mesh = BulletConvexHullShape()
        mesh.add_geom(
            GeomBuilder()
            .add_ramp(self.color, self.base, self.top, self.width, self.thickness, LRotationf(*self.hpr))
            .get_geom()
        )
        node.add_shape(mesh)
        return node

    def add_to(self, geom_builder):
        geom_builder.add_ramp(self.color, self.base, self.top, self.width, self.thickness, LRotationf(*self.hpr))

    def attached(self):
        self.move(self.midpoint)
        self.rotate(*self.hpr)
Example #8
0
 def fade_in(self):
     # blackout card
     bgeom = GeomBuilder().add_rect([0,0,0,1],-5,-5,0,5,5,0).get_geom_node()
     b = render.attach_new_node(bgeom)
     b.set_pos(self.cam.get_pos(render))
     b.set_hpr(self.cam.get_hpr(render))
     b_move_by = render.get_relative_vector(self.cam, Vec3(0,0,-2))
     b.set_pos(b, b_move_by)
     b.set_color(0,0,0)
     b.set_transparency(TransparencyAttrib.MAlpha)
     # fade from full opacity to no opacity
     cintv = LerpColorScaleInterval(b, 1.5, (1,1,1,0), (1,1,1,1))
     def _unhide_ui():
         self.doc.GetElementById('content').style.display = 'block'
         b.detach_node()
     # show ui after lerp is finished
     showui = Func(_unhide_ui)
     Sequence(cintv,showui).start()
Example #9
0
class Dome (PhysicalObject):
    """
    A dome.
    """

    def __init__(self, radius, samples, planes, color, mass, center, hpr, name=None):
        super(Dome, self).__init__(name)
        self.radius = radius
        self.samples = samples
        self.planes = planes
        self.color = color
        self.mass = mass
        self.center = center
        self.hpr = hpr

    def create_node(self):
        self.geom = GeomBuilder().add_dome(self.color, (0, 0, 0), self.radius, self.samples, self.planes).get_geom_node()
        return NodePath(self.geom)

    def create_solid(self):
        node = BulletRigidBodyNode(self.name)
        mesh = BulletConvexHullShape()
        mesh.add_geom(self.geom.get_geom(0))
        node.add_shape(mesh)
        return node

    def add_solid(self, node):
        mesh = BulletConvexHullShape()
        mesh.add_geom(GeomBuilder().add_dome(self.color, self.center, self.radius, self.samples, self.planes, LRotationf(*self.hpr)).get_geom())
        node.add_shape(mesh)
        return node

    def add_to(self, geom_builder):
        rot = LRotationf(*self.hpr)
        geom_builder.add_dome(self.color, self.center, self.radius, self.samples, self.planes, rot)

    def attached(self):
        self.move(self.center)
        self.rotate_by(*self.hpr)
Example #10
0
    def attached(self):
        if not self.world.camera:
            self.node = self.world.scene.attach_new_node('sky')
            return
        geom = GeomNode('sky')
        bounds = self.world.camera.node().get_lens().make_bounds()
        dl = bounds.getMin()
        ur = bounds.getMax()
        z = dl.getZ() * 0.99

        geom.add_geom(
            GeomBuilder('sky').add_rect((1, 1, 1, 1), dl.getX(), dl.getY(), 0,
                                        ur.getX(), ur.getY(), 0).get_geom())
        self.node = self.world.scene.attach_new_node(geom)
        self.node.set_shader(Shader.load('Shaders/Sky.sha'))
        self.node.set_shader_input('camera', self.world.camera)
        self.node.set_shader_input('sky', self.node)
        self.node.set_shader_input('groundColor', *self.ground)
        self.node.set_shader_input('skyColor', *self.color)
        self.node.set_shader_input('horizonColor', *self.horizon)
        self.node.set_shader_input('gradientHeight', self.scale, 0, 0, 0)
        self.node.reparent_to(self.world.camera)
        self.node.set_pos(self.world.camera, 0, 0, z)
Example #11
0
 def create_node(self):
     rel_base = Point3(self.base - (self.midpoint - Point3(0, 0, 0)))
     rel_top = Point3(self.top - (self.midpoint - Point3(0, 0, 0)))
     self.geom = GeomBuilder().add_wedge(self.color, rel_base, rel_top, self.width).get_geom_node()
     return NodePath(self.geom)
Example #12
0
 def create_node(self):
     composite_geom = GeomBuilder('composite')
     for obj in self.objects:
         obj.add_to(composite_geom)
     return NodePath(composite_geom.get_geom_node())
Example #13
0
 def create_node(self):
     self.geom = GeomBuilder().add_dome(self.color, (0, 0, 0), self.radius, self.samples, self.planes).get_geom_node()
     return NodePath(self.geom)
Example #14
0
 def create_node(self):
     composite_geom = GeomBuilder('composite')
     for obj in self.objects:
         obj.add_to(composite_geom)
     return NodePath(composite_geom.get_geom_node())
Example #15
0
 def create_node(self):
     return NodePath(
         GeomBuilder('block').add_block(self.color, (0, 0, 0),
                                        self.size).get_geom_node())
Example #16
0
 def create_node(self):
     return NodePath(
         GeomBuilder('ramp').add_block(
             self.color, (0, 0, 0),
             (self.thickness, self.width, self.length)).get_geom_node())
Example #17
0
 def create_node(self):
     self.geom = GeomBuilder().add_dome(self.color, (0, 0, 0), self.radius,
                                        self.samples,
                                        self.planes).get_geom_node()
     return NodePath(self.geom)