コード例 #1
0
def setup_shadows():
    global sMgr
    sMgr = ShadowManager(render)
    sMgr.setAmbient(0.2)  # Most of these five are the default
    sMgr.setHardness(20)  # values so it was kinda unnecessary to
    sMgr.setFov(40)  # set them explicitly but I wanted to
    sMgr.setNearFar(10, 120)  # show how to set them anyway.
    sMgr.light.setPos(10, -10, 100)
    sMgr.light.lookAt(0)
コード例 #2
0
def setup_shadows():
    global sMgr
    sMgr = ShadowManager(render)
    sMgr.setAmbient(0.2)     # Most of these five are the default
    sMgr.setHardness(20)     # values so it was kinda unnecessary to
    sMgr.setFov(40)          # set them explicitly but I wanted to
    sMgr.setNearFar(10, 120) # show how to set them anyway.
    sMgr.light.setPos(10, -10, 100)
    sMgr.light.lookAt(0)
コード例 #3
0
class World(object):
    def __init__(self):

        # Make a way out of here!
        base.accept("escape", exit)

        # Initiate the shadows
        self.sMgr = ShadowManager(render)
        self.sMgr.setAmbient(0.2)  # Most of these five are the default
        self.sMgr.setHardness(20)  # values so it was kinda unnecessary to
        self.sMgr.setFov(40)  # set them explicitly but I wanted to
        self.sMgr.setNearFar(10, 100)  # show how to set them anyway.

        # Create the 'table'
        self.table = loader.loadModel("tableplane.egg")
        self.table.reparentTo(render)
        tableTex = loader.loadTexture("tree-bark-89a.jpg")
        tableTex.setMinfilter(
            Texture.FTLinearMipmapLinear)  # Enable texture mipmapping
        self.table.setTexture(tableTex)

        # Load the teapot
        self.teapot = loader.loadModel("teapot")
        self.teapot.setTwoSided(True)
        self.teapot.reparentTo(render)
        # The teapot has no texture, so you have to tell it to the ShadowManager
        # Otherwise the model will turn up black.
        self.sMgr.flagUntexturedObject(self.teapot)

        # Set intervals to move the teapot
        self.teapot.hprInterval(5.0, Vec3.zero(), Vec3(360, 0, 0)).loop()
        Sequence(self.teapot.posInterval(2.0, Point3.zero(), Point3(2, 0, 1)),
                 self.teapot.posInterval(2.0, Point3(2, 0, 1),
                                         Point3.zero())).loop()

        # Setup the camera
        base.disableMouse()
        camPivot = render.attachNewNode("cameraPivotPoint")
        base.cam.reparentTo(camPivot)
        base.camLens.setNearFar(1, 1000)
        base.camLens.setFov(75)
        base.cam.setPos(-10, -10, 15)
        base.cam.lookAt(self.teapot)

        # Setup an interval to rotate the camera around camPivot
        camPivot.hprInterval(15.0, Vec3.zero(), Vec3(360, 0, 0)).loop()

        # Position the shadow camera
        self.sMgr.light.setPos(0, 20, 15)
        self.sMgr.light.lookAt(self.teapot)
        self.sMgr.light.node().showFrustum()  # Show the frustrum
コード例 #4
0
class World(object):
  def __init__(self):
    
    # Make a way out of here!
    base.accept("escape", exit)

    # Initiate the shadows
    self.sMgr = ShadowManager(render)
    self.sMgr.setAmbient(0.2)     # Most of these five are the default
    self.sMgr.setHardness(20)     # values so it was kinda unnecessary to
    self.sMgr.setFov(40)          # set them explicitly but I wanted to
    self.sMgr.setNearFar(10, 100) # show how to set them anyway.

    # Create the 'table'
    self.table = loader.loadModel("tableplane.egg")
    self.table.reparentTo(render)
    tableTex = loader.loadTexture("tree-bark-89a.jpg")
    tableTex.setMinfilter(Texture.FTLinearMipmapLinear) # Enable texture mipmapping
    self.table.setTexture(tableTex)

    # Load the teapot
    self.teapot = loader.loadModel("teapot")
    self.teapot.setTwoSided(True)
    self.teapot.reparentTo(render)
    # The teapot has no texture, so you have to tell it to the ShadowManager
    # Otherwise the model will turn up black.
    self.sMgr.flagUntexturedObject(self.teapot)

    # Set intervals to move the teapot
    self.teapot.hprInterval(5.0, Vec3.zero(), Vec3(360, 0, 0)).loop()
    Sequence(self.teapot.posInterval(2.0, Point3.zero(), Point3(2, 0, 1)), self.teapot.posInterval(2.0, Point3(2, 0, 1), Point3.zero())).loop()

    # Setup the camera
    base.disableMouse()
    camPivot = render.attachNewNode("cameraPivotPoint")
    base.cam.reparentTo(camPivot)
    base.camLens.setNearFar(1,1000)
    base.camLens.setFov(75)
    base.cam.setPos(-10,-10,15)
    base.cam.lookAt(self.teapot)
    
    # Setup an interval to rotate the camera around camPivot
    camPivot.hprInterval(15.0, Vec3.zero(), Vec3(360, 0, 0)).loop()
    
    # Position the shadow camera
    self.sMgr.light.setPos(0,20,15)
    self.sMgr.light.lookAt(self.teapot)
    self.sMgr.light.node().showFrustum() # Show the frustrum
コード例 #5
0
    return task.cont


def createGeneralBoxes():
    for i in range(10):
        # Setup the geometry
        temp = modelcreator.createBox(world, space)
        temp.body.setPosition(randint(-15, 15), randint(-15, 15),
                              randint(-15, 15))
        objects.append((temp.model, temp.body))


modelcreator = ModelCreator()

text = OnscreenText("")
sMgr = ShadowManager(render)
sMgr.setAmbient(0.2)  # Most of these five are the default
sMgr.setHardness(20)  # values so it was kinda unnecessary to
sMgr.setFov(40)  # set them explicitly but I wanted to
sMgr.setNearFar(10, 100)  # show how to set them anyway.
sMgr.light.setPos(10, -10, 50)
sMgr.light.lookAt(0)
#sMgr.light.node().showFrustum()

createWorldAndStuff()
entityCreator = EntityCreator(space, world)
keylistener = KeyListener()
objects = []

vehicle = entityCreator.createQuadrocopter()
objects.extend(vehicle.objects)
コード例 #6
0
    contactgroup.empty()
    return task.cont
         
        
def createGeneralBoxes():
    for i in range(10):        
        # Setup the geometry
        temp = modelcreator.createBox(world, space)
        temp.body.setPosition(randint(-15,15),randint(-15,15),randint(-15,15))
        objects.append((temp.model, temp.body))


modelcreator = ModelCreator()

text = OnscreenText("")
sMgr = ShadowManager(render)
sMgr.setAmbient(0.2)     # Most of these five are the default
sMgr.setHardness(20)     # values so it was kinda unnecessary to
sMgr.setFov(40)          # set them explicitly but I wanted to
sMgr.setNearFar(10, 100) # show how to set them anyway.
sMgr.light.setPos(10, -10, 50)
sMgr.light.lookAt(0)
#sMgr.light.node().showFrustum()

createWorldAndStuff()
entityCreator = EntityCreator(space,world)
keylistener = KeyListener()
objects = []

vehicle = entityCreator.createQuadrocopter()
objects.extend(vehicle.objects)