示例#1
0
    def _checkRayIntersect(self, ray):
        """Check if ray intersects object
        @see: objects.ObjectDepth._checkRayIntersect
        """
        res = ogre.Math.intersects(ray, self.sceneNode._getWorldAABB())
        rvalue, pos = objects.ObjectDepth._checkRayIntersect(self, ray)

        if not rvalue:
            return False, -1

        # works just for a isometric mode
        m = ogre.Matrix4()
        self.getSceneNode().getWorldTransforms(m)
        p = ogre.Matrix4.getTrans(m)

        pl = ogre.Plane(ray.getDirection(), p)
        pr = ray.intersects(pl)
        if not pr.first:
            return False, -1

        d = ray.getPoint(pr.second)

        rvalue = False
        for idx in range(len(self.points)):
            p2 = self.points[idx] + p
            p1 = self.points[idx - 1] + p
            if (((p2.y <= d.y and d.y < p1.y) or (p1.y <= d.y and d.y < p2.y)) and \
                (d.x > (p1.x - p2.x) * (d.y - p2.y) / (p1.y - p2.y) + p2.x)):
                rvalue = not rvalue

        return rvalue, 0
示例#2
0
    def setupScene(self):
        self.sceneManager = self.root.createSceneManager(
            ogre.ST_GENERIC, "Default SceneManager")

        self.camera = self.sceneManager.createCamera("Camera")
        self.camera.nearClipDistance = 5

        self.viewPort = self.root.getAutoCreatedWindow().addViewport(
            self.camera)
        self.sceneManager.ambientLight = 1, 1, 1

        # Setup a ground plane.
        #plane = ogre.Plane ((0, 1, 0), -100)
        #plane = ogre.Plane ((0, 1, 0), 0)
        self.groundPlane = ogre.Plane((0, 1, 0), 0)
        meshManager = ogre.MeshManager.getSingleton()
        meshManager.createPlane('Ground', 'General', self.groundPlane, 5000,
                                5000, 20, 20, True, 1, 5, 5, (0, 0, 1))
        self.ent = self.sceneManager.createEntity('GroundEntity', 'Ground')
        self.sceneManager.getRootSceneNode().createChildSceneNode(
        ).attachObject(self.ent)
        self.ent.setMaterialName('OceanCg')
        self.ent.castShadows = False
        #self.sceneManager.setSkyDome (True, "Examples/CloudySky", 5000, False)
        self.camYawNode = self.sceneManager.getRootSceneNode(
        ).createChildSceneNode(
            'CamNode1',
            #(-400, 200, 400))
            (0, 1500, -2000))
        #node.yaw(ogre.Degree(-45))
        self.camYawNode.yaw(ogre.Degree(0))
        self.camera.lookAt((0, -800, 350))
        self.camPitchNode = self.camYawNode.createChildSceneNode('PitchNode1')
        self.camPitchNode.attachObject(self.camera)
        self.camPitchNode.pitch(ogre.Radian(-0.4))
示例#3
0
    def _checkRayIntersect(self, ray):
        """Check if ray intersects union object.
        Just check if it intersects any of object included to union.
        
        @param ray:    ray for intersection checking
        @type ray:    ogre.Ray
        """
        res, pos = suit.core.objects.ObjectDepth._checkRayIntersect(self, ray)
        if not res:
            return False, -1

        # works just for a isometric mode
        m = ogre.Matrix4()
        self.getSceneNode().getWorldTransforms(m)
        p = ogre.Matrix4.getTrans(m)

        pl = ogre.Plane(ray.getDirection(), p)
        pr = ray.intersects(pl)
        if not pr.first:
            return False, -1

        d = ray.getPoint(pr.second)

        dist = self.center_point.getPosition().distance(d)
        if math.fabs(dist - self.radius) <= self.width / 2.0:
            return True, 0

        return False, -1
示例#4
0
    def setupScene(self):
        self.sceneManager = self.root.createSceneManager(
            ogre.ST_GENERIC, "Default SceneManager")

        self.camera = self.sceneManager.createCamera("Camera")
        self.camera.nearClipDistance = 2

        self.viewPort = self.root.getAutoCreatedWindow().addViewport(
            self.camera)
        self.sceneManager.ambientLight = 100, 100, 100

        # Setup a ground plane.
        #plane = ogre.Plane ((0, 1, 0), -100)
        #plane = ogre.Plane ((0, 1, 0), 0)
        self.groundPlane = ogre.Plane((0, 1, 0), 0)
        meshManager = ogre.MeshManager.getSingleton()
        meshManager.createPlane('Ground', 'General', self.groundPlane, 100,
                                100, 20, 20, True, 1, 5, 5, (0, 0, 1))
        ent = self.sceneManager.createEntity('GroundEntity', 'Ground')
        self.sceneManager.getRootSceneNode().createChildSceneNode(
        ).attachObject(ent)
        ent.setMaterialName('1335851461_1_outline.png')
        #self.sceneManager.setSkyBox (True, "Examples/MorningSkyBox", 5000, False)
        self.camYawNode = self.sceneManager.getRootSceneNode(
        ).createChildSceneNode(
            'CamNode1',
            #(-400, 200, 400))
            (0, 8, 0))
        #node.yaw(ogre.Degree(-45))
        self.camYawNode.yaw(ogre.Degree(0))
        self.camera.lookAt((0, 0, 0))
        self.camPitchNode = self.camYawNode.createChildSceneNode('PitchNode1')
        self.camPitchNode.attachObject(self.camera)
        self.camPitchNode.pitch(ogre.Degree(-90))
示例#5
0
    def _createScene(self):
        #Create a scene and assign it ambient light
        sceneManager = self.sceneManager
        sceneManager.ambientLight = (1, 1, 1)

        #Create ground surface height
        surfaceHeight = -100

        #Setup ground plane and then create a mesh from it
        plane = ogre.Plane((0, 1, 0), surfaceHeight)
        meshManager = ogre.MeshManager.getSingleton()
        meshManager.createPlane('Ground', 'General', plane, 10000, 10000, 20,
                                20, True, 1, 5, 5, (0, 0, 1))
        ent = sceneManager.createEntity('GroundEntity', 'Ground')
        sceneManager.getRootSceneNode().createChildSceneNode().attachObject(
            ent)
        ent.setMaterialName('Splashspacehold')
        ent.castShadows = False
        self.sceneManager.setSkyDome(True, "Examples/CloudySky", 5, 8)

        #Create the enetiy physics for the box
        self.cubeEntity = Entity("Cube", mesh="SpacesuitGlove.mesh")

        #Create the box entity for python ogre
        self.pyOgreBox = sceneManager.createEntity("My Cube",
                                                   self.cubeEntity.mesh)

        #Create a scene and then attach it to the sceneManager
        self.cubeScene = sceneManager.getRootSceneNode().createChildSceneNode(
            "My Cube")

        #Then attach it
        self.cubeScene.attachObject(self.pyOgreBox)

        #This will attach the picup object
        self.pickEntity = pickUp(1, ogre.Vector3(100, 0, 0))

        self.pBox = sceneManager.createEntity("My Pickup",
                                              self.pickEntity.mesh)
        self.pickScene = sceneManager.getRootSceneNode().createChildSceneNode(
            "PickUp", self.pickEntity.pos)
        self.pickScene.scale(3, 3, 3)
        self.pickScene.attachObject(self.pBox)

        #This will test the player object
        self.pEnt = Player()
        self.oBox = sceneManager.createEntity("Player", self.pEnt.mesh)
        self.pScene = sceneManager.getRootSceneNode().createChildSceneNode(
            "player", self.pEnt.pos)
        self.pScene.scale(5, 5, 5)
        self.pScene.attachObject(self.oBox)

        #Create a scene Node that will hold the camera
        #Also, the function that moves the camera up and down requires a parent, in which this will be the parent of the main camera
        parentNode = sceneManager.getRootSceneNode().createChildSceneNode(
            'myCameraNode', (0, 300, 400))

        #Create a child node from which it's relative to the maincamera
        camNode = parentNode.createChildSceneNode('MainCamera')
        camNode.attachObject(self.camera)
示例#6
0
 def set_buoyancy(self, normal):
     """
     @type  normal: Ogre.Vector3
     @param normal: The normal of the buoyancy plane. If none, the object
                    will not be buoyanct
     """
     if normal is not None:
         self._buoyancy_plane = Ogre.Plane(normal, (0,0,0))
     else:
         self._buoyancy_plane = None
示例#7
0
class WidgetMgr(Mgr):
    widgets = []
    idCounter = 0

    def __init__(self, engine):
        Mgr.__init__(self, engine)
        self.x = 0

    def crosslink(self):
        pass

    def initialize(self):
        self.pointsWidget = PointsWidget(self.engine)
        self.timeWidget = TimeWidget(self.engine)
        self.hiddenWidget = HiddenWidget(self.engine)
        self.livesWidget = LivesWidget(self.engine)
        self.gameOver = GameOver(self.engine)
        self.gameWin = GameWin(self.engine)
        self.widgets.append(self.gameWin)
        self.widgets.append(self.gameOver)
        self.widgets.append(self.livesWidget)
        self.widgets.append(self.hiddenWidget)
        self.widgets.append(self.pointsWidget)
        self.widgets.append(self.timeWidget)
        ui = UIOverlay(self.engine)
        self.widgets.append(ui)

    def tick(self, dtime):
        for widget in self.widgets:
            widget.tick(dtime)

    def render(self):
        for widget in self.widgets:
            widget.render()

    xzPlane = ogre.Plane((0, 1, 0), 0)

    def findWorldCoords(self, ms):
        ''' Map to x,z plane from viewport
        '''
        ms.width = self.engine.gfxSystem.viewport.actualWidth
        ms.height = self.engine.gfxSystem.viewport.actualHeight
        mouseRay = self.engine.cameraSystem.camera.getCameraToViewportRay(
            ms.X.abs / float(ms.width), ms.Y.abs / float(ms.height))
        result = mouseRay.intersects(self.xzPlane)
        pos = None
        if result.first:
            pos = mouseRay.getPoint(result.second)
            #self.mousePosWorld = pos
        return pos

    def getNextId(self):
        self.idCounter += 1
        return self.idCounter
示例#8
0
    def distance(self, ray):
        m = ogre.Matrix4()
        self.getSceneNode().getWorldTransforms(m)
        p = ogre.Matrix4.getTrans(m)

        pl = ogre.Plane(ray.getDirection(), p)
        pr = ray.intersects(pl)
        if pr.first:
            d = ray.getPoint(pr.second)
            return (d - p).length()

        return None
示例#9
0
    def _createScene(self):

        self.surfaceHeight = 0

        # Setup a scene with a low level of ambient light.
        sceneManager = self.sceneManager
        sceneManager.ambientLight = (0.78, 0.89, 1)
        sceneManager.shadowTechnique = ogre.SHADOWTYPE_STENCIL_ADDITIVE

        # Setup a mesh entity and attach it to a scene node.
        entity = sceneManager.createEntity('Cube0', 'cube.mesh')
        node = sceneManager.getRootSceneNode().createChildSceneNode(
            'CubeNode0', (0, 0, 0))
        node.attachObject(entity)

        entity = sceneManager.createEntity('Cube1', 'cube.mesh')
        node = sceneManager.getRootSceneNode().createChildSceneNode(
            'CubeNode1', (100, 200, 0))
        node.attachObject(entity)

        plane = ogre.Plane((0, 1, 0), self.surfaceHeight)
        meshManager = ogre.MeshManager.getSingleton()
        meshManager.createPlane("Ground", "General", plane, 10000, 10000, 20,
                                20, True, 1, 5, 5, (0, 0, 1))

        ent = sceneManager.createEntity("GroundEntity", "Ground")
        sceneManager.getRootSceneNode().createChildSceneNode().attachObject(
            ent)
        ent.setMaterialName("Examples/TextureEffect2")
        #ent.setMaterialName("Examples/Rockwall")
        ent.castShadows = False

        self.sceneManager.setSkyDome(True, "Examples/CloudySky", 5, 8)

        # Setup a White point light.
        light = sceneManager.createLight('Light1')
        light.type = ogre.Light.LT_POINT
        light.position = (150, 300, 150)
        light.diffuseColour = (1, 1, 1)
        light.specularColour = (1, 1, 1)

        # Setup the first camera node and pitch node and aim it.
        node = sceneManager.getRootSceneNode().createChildSceneNode(
            'CamNode1', (-400, 200, 400))
        node.yaw(ogre.Degree(-45))
        node = node.createChildSceneNode('PitchNode1')
        node.attachObject(self.camera)

        # Setup the second camera node and pitch node.
        node = sceneManager.getRootSceneNode().createChildSceneNode(
            'CamNode2', (0, 200, 400))
        node.createChildSceneNode('PitchNode2')
示例#10
0
    def createWorld(self):
        # surfaceHeight = -15
        plane = ogre.Plane ((0, 1, 0), -5)
        meshManager = ogre.MeshManager.getSingleton ()
        meshManager.createPlane ('Ground', 'General', plane,
                                     10000, 10000, 20, 20, True, 1, 5, 5, (0, 0, 1))
        groundEnt = self.sceneManager.createEntity('GroundEntity', 'Ground')
        self.sceneManager.getRootSceneNode().createChildSceneNode().attachObject(groundEnt)
        groundEnt.setMaterialName ('Ocean2_Cg')
        groundEnt.castShadows = False

        self.sceneManager.setSkyDome(True, "Examples/CloudySky", 5, 8)
        self.waterPlane = plane
示例#11
0
    def load(self, data_object):
        """
        @type  data_object: tuple
        @param data_object: (scene, parent, kml_node)
        """
        scene, parent, node = data_object

        # Load Object based values
        Object.load(self, (parent, node))

        gfx_node = node['Graphical']
        mesh = gfx_node['mesh']
        material = gfx_node.get('material', None)
        scale = sim.OgreVector3(gfx_node.get('scale', Ogre.Vector3(1, 1, 1)))

        # Handle special mesh generation
        if mesh.startswith('PLANE'):
            if ':' in mesh:
                mesh = mesh.split(':')[1]
            else:
                mesh = 'Plane' + str(Visual._plane_count)

            norm = gfx_node['normal']
            width = gfx_node['width']
            height = gfx_node['height']
            upvec = gfx_node.get('upvec', Ogre.Vector3.UNIT_Y)
            utile = gfx_node.get('utile', 1)
            vtile = gfx_node.get('vtile', 1)

            plane = Ogre.Plane(norm, 0)
            group_name = gfx_node.get(
                'group', Ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)

            xsegments = int(width)
            ysegments = int(height)

            Ogre.MeshManager.getSingletonPtr().createPlane(mesh, \
                group_name, plane, width, height, upVector = upvec,
                uTile = utile, vTile = vtile, xsegments = xsegments,
                ysegments = ysegments)
            Visual._plane_count += 1

        # Orientation defaults: IDENTITY, Position: (0,0,0)
        position, orientation = parse_position_orientation(node)
        Visual._create(self, scene, mesh, material, position, orientation,
                       scale)

        # Check visibility
        if not gfx_node.get('visible', True):
            self._node.setVisible(False)
示例#12
0
    def _buildWall(self, sceneManager, name, richtung, start, stop,
                   wall_height, texture,
                   num_texture):  #richtung: direction - position
        name_floor = "fl_%s_%d" % (name, self.currentVR)
        name_plane = "pl_%s_%d" % (name, self.currentVR)
        name_Ent = "Ent_%s_%d" % (name, self.currentVR)

        if (richtung == 1):
            plane = ogre.Plane()
            plane.normal = ogre.Vector3().UNIT_X
            plane.d = 0
        elif richtung == 2:
            plane = ogre.Plane()
            plane.normal = -ogre.Vector3().UNIT_X
            plane.d = 0
        elif richtung == 3:
            plane = ogre.Plane()
            plane.normal = ogre.Vector3().UNIT_Z
            plane.d = 0
        elif richtung == 4:
            plane = ogre.Plane()
            plane.normal = -ogre.Vector3().UNIT_Z
            plane.d = 0

        vec = [start[0] - stop[0], start[1] - stop[1]]
        vecLen = math.sqrt(vec[0] * vec[0] + vec[1] * vec[1])

        ogre.MeshManager.getSingleton().createPlane(
            name_floor, ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
            plane, vecLen, wall_height, 10, 10, False, 1, num_texture, 1,
            ogre.Vector3().UNIT_Y)
        name_Ent = sceneManager.createEntity(name_plane, name_floor)
        name_Ent.setMaterialName(texture)
        sceneManager.getRootSceneNode().createChildSceneNode(
            ((start[0] + stop[0]) / 2, wall_height / 2,
             (start[1] + stop[1]) / 2)).attachObject(name_Ent)
        return
示例#13
0
 def __init__(self, parent, name):
     self.parent = parent
     plane = ogre.Plane()
     plane.normal = ogre.Vector3(0, 1, 0)
     plane.d = 2
     ogre.MeshManager.getSingleton().createPlane(name, "General", plane,
                                                 200, 200, 1, 1, True, 1, 4,
                                                 4, (0, 0, 1))
     self.sceneFloor = self.parent.createEntity(name, name)
     #self.sceneFloor.setMaterialName('Grid')
     self.sceneFloorNode = self.parent.rootSceneNode.createChildSceneNode()
     self.sceneFloorNode.attachObject(self.sceneFloor)
     self.sceneFloor.castShadows = False
     self.sceneFloor.setVisible(True)
     self.material = None
示例#14
0
def buoyancyCallback(colID, me, orient, pos, plane):
    """
    Here we need to create an Ogre::Plane object representing the surface of 
    the liquid.  In our case, we're just assuming a completely flat plane of 
    liquid, however you could use this function to retrieve the plane
    equation for an animated sea, etc.
    """
    plane1 = Ogre.Plane(Ogre.Vector3(0, 1, 0), Ogre.Vector3(0, 0, 0))

    # we need to copy the normals and 'd' to the plane we were passed...
    plane.normal = plane1.normal
    plane.d = plane1.d

    # pos = Ogre.Vector3(0,0,0)

    return True
示例#15
0
 def setupScene(self):
     '''SETUP SCENEMANAGER'''
     self.sceneManager = self.root.createSceneManager(
         ogre.ST_GENERIC, "Default SceneManager")
     self.sceneManager.setAmbientLight(ogre.ColourValue(1, 1, 1))
     '''SETUP ENVIRONMENT'''
     plane = ogre.Plane((0, 1, 0), 0)
     meshManager = ogre.MeshManager.getSingleton()
     meshManager.createPlane('Ground', 'General', plane, 100000, 100000, 20,
                             20, True, 1, 5, 5, (0, 0, 1))
     ent = self.sceneManager.createEntity('GroundEntity', 'Ground')
     self.sceneManager.getRootSceneNode().createChildSceneNode(
     ).attachObject(ent)
     ent.setMaterialName('Ocean2_Cg')
     ent.castShadows = False
     self.sceneManager.setSkyBox(True, "Examples/MorningSkyBox", 5000,
                                 False)
示例#16
0
    def createPlane(self, name, normal=(0, 1, 0), cons=0.0):

        physical = self._simulator.createGeomPlane(normal, cons)

        # View
        plane = ogre.Plane(normal, cons)

        mm = ogre.MeshManager.getSingleton()
        mm.createPlane(name,
                       ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                       plane, 55500, 55500, 20, 20, True, 1, 5, 5, (0, 0, 1))

        ent = self._sceneManager.createEntity(name, name)
        node = self._sceneManager.getRootSceneNode().createChildSceneNode()
        node.attachObject(ent)
        ent.setMaterialName("Material.001/SOLID")

        self._staticObjects[name] = SceneObject(name, node, physical)
示例#17
0
    def _createScene(self):
        sceneManager = self.sceneManager
        sceneManager.ambientLight = (0, 0, 0)
        sceneManager.shadowTechnique = ogre.SHADOWTYPE_STENCIL_ADDITIVE

        ent = sceneManager.createEntity("Ninja", "ninja.mesh")
        ent.castShadows = True
        sceneManager.getRootSceneNode().createChildSceneNode().attachObject(
            ent)

        plane = ogre.Plane((0, 1, 0), 0)
        meshManager = ogre.MeshManager.getSingleton()
        meshManager.createPlane("Ground", "General", plane, 1500, 1500, 20, 20,
                                True, 1, 5, 5, (0, 0, 1))

        ent = sceneManager.createEntity("GroundEntity", "Ground")
        sceneManager.getRootSceneNode().createChildSceneNode().attachObject(
            ent)
        ent.setMaterialName("Examples/Rockwall")
        ent.castShadows = False

        #point light and properties
        light = sceneManager.createLight("PointLight")
        light.type = ogre.Light.LT_POINT
        light.position = (150, 300, 150)
        light.diffuseColour = (.5, .0, .0)
        light.specularColour = (.5, .0, .0)

        #directional light and properties
        light = sceneManager.createLight("DirectionalLight")
        light.type = ogre.Light.LT_DIRECTIONAL
        light.diffuseColour = (.5, .5, .0)
        light.specularColour = (.75, .75, .75)
        light.direction = (0, -1, 1)

        #spot light and properties
        light = sceneManager.createLight("spotLight")
        light.type = ogre.Light.LT_SPOTLIGHT
        light.diffuseColour = (0, 0, .5)
        light.specularColour = (0, 0, .5)
        light.direction = (-1, -1, 0)
        light.position = (300, 300, 0)
        light.setSpotlightRange(ogre.Degree(35), ogre.Degree(50))
    def _createScene(self):
        #initialize surface height
        self.surfaceHeight = 0

        #make the room slightly lit
        sceneManager = self.sceneManager
        sceneManager.ambientLight = (0.78, 0.89, 1)
        sceneManager.shadowTechnique = ogre.SHADOWTYPE_STENCIL_ADDITIVE

        #add cube that is able to cast shadow to scene
        ent = sceneManager.createEntity("Cube", "cube.mesh")
        ent.castShadows = True
        sceneManager.getRootSceneNode().createChildSceneNode(
            "CubeNode").attachObject(ent)

        #create a plane and register it with mesh manager
        plane = ogre.Plane((0, 1, 0), self.surfaceHeight)
        meshManager = ogre.MeshManager.getSingleton()
        meshManager.createPlane("Ground", "General", plane, 10000, 10000, 20,
                                20, True, 1, 5, 5, (0, 0, 1))

        #Ground plane
        ent = sceneManager.createEntity("GroundEntity", "Ground")
        sceneManager.getRootSceneNode().createChildSceneNode().attachObject(
            ent)
        #ent.setMaterialName("Examples/TextureEffect2")
        ent.setMaterialName("Examples/Rockwall")
        ent.castShadows = False

        node = sceneManager.getRootSceneNode().createChildSceneNode(
            'CamNode1', (-400, 200, 400))
        node.yaw(ogre.Degree(-45))
        node = node.createChildSceneNode('PitchNode1')
        node.attachObject(self.camera)

        self.sceneManager.setSkyDome(True, "Examples/CloudySky", 5, 8)

        #point light and properties
        light = sceneManager.createLight("Sun")
        light.type = ogre.Light.LT_POINT
        light.position = (150, 300, 150)
        light.diffuseColour = (1, 1, 1)
        light.specularColour = (1, 1, 1)
示例#19
0
    def setupScene(self):
        self.sceneManager = self.root.createSceneManager(
            ogre.ST_GENERIC, "Default SceneManager")

        self.camera = self.sceneManager.createCamera("Camera")
        self.camera1 = self.sceneManager.createCamera("Camera1")
        self.camera.setPosition(ogre.Vector3(0, 50, 500))
        self.camera.lookAt(0, 50, 0)

        self.viewPort = self.root.getAutoCreatedWindow().addViewport(
            self.camera, 1, 0, 0, 1, 1)

        self.plane = ogre.Plane((0, 1, 0), 0)
        meshManager = ogre.MeshManager.getSingleton()
        meshManager.createPlane('Ground', 'General', self.plane, 10000, 10000,
                                20, 20, True, 1, 5, 5, (0, 0, 1))
        self.ground = self.sceneManager.createEntity('GroundEntity', 'Ground')
        self.sceneManager.getRootSceneNode().createChildSceneNode(
        ).attachObject(self.ground)
        self.ground.setMaterialName("Examples/GrassFloor")
        self.ground.castShadows = False
        self.sceneManager.setSkyDome(True, "Examples/CloudySky", 5, 8)
示例#20
0
    def _buildFloor(self, sceneManager, width, texture, num_texture):
        name = "floor"
        name_floor = "fl_%s_%d" % (name, self.currentVR)
        name_plane = "pl_%s_%d" % (name, self.currentVR)
        name_Ent = "Ent_%s_%d" % (name, self.currentVR)

        plane = ogre.Plane()
        plane.normal = ogre.Vector3().UNIT_Y
        plane.d = 0

        ogre.MeshManager.getSingleton().createPlane(
            name_floor, ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
            plane, self.corridorEnd[self.currentVR] -
            self.corridorStart[self.currentVR] + width, width, 10, 10, False,
            1, num_texture, 1,
            ogre.Vector3().UNIT_X)
        name_Ent = sceneManager.createEntity(name_plane, name_floor)
        name_Ent.setMaterialName(texture)
        sceneManager.getRootSceneNode().createChildSceneNode(
            (0, 1,
             (self.corridorStart[self.currentVR] +
              self.corridorEnd[self.currentVR]) / 2)).attachObject(name_Ent)
        return
示例#21
0
    def _createScene (self):
        # Create a scene with terrain, sky and fog.
 
        # Setup the fog.
        fadeColour = (.15,.62,.40)
        self.renderWindow.getViewport (0).backgroundColour = fadeColour
        self.sceneManager.setFog (ogre.FOG_EXP2, fadeColour, 0.0, -500, 700)
	#fadeColour = (.14,.37,.62)
	#self.sceneManager.setFog (ogre.FOG_LINEAR, fadeColour, 0.0, 50, 500)
        # Create the terrain
        self.sceneManager.setWorldGeometry ("terrain.cfg")




 
        # Setup a sky plane.
        plane = ogre.Plane ((0, -1, 0), -10)
        self.sceneManager.setSkyBox( True, "Examples/SpaceSkyBox" )
 
	sunParticle = self.sceneManager.createParticleSystem("Sun", "Space/Sun")
	particleNode = self.sceneManager.getRootSceneNode().createChildSceneNode("Particle")
	particleNode.attachObject(sunParticle)
	particleNode.scale(400,400,400)
示例#22
0
class WidgetMgr(Mgr):
    widgets = []
    idCounter = 0

    def __init__(self, engine):
        Mgr.__init__(self, engine)
        self.x = 0


    def crosslink(self):
        pass

    def initialize(self):
        self.framerateWidget = FramerateWidget(self.engine)
        self.widgets.append(self.framerateWidget)

        self.Player1= Player1(self.engine)
        self.widgets.append(self.Player1)

        self.Player2= Player2(self.engine)
        self.widgets.append(self.Player2)

        self.Player1Score= Player1Score(self.engine)
        self.widgets.append(self.Player1Score)

        self.Player2Score= Player2Score(self.engine)
        self.widgets.append(self.Player2Score)

	self.Player1HP = Player1HP(self.engine)
	self.widgets.append(self.Player1HP)

	self.Player2HP = Player2HP(self.engine)
	self.widgets.append(self.Player2HP)


    def tick(self, dtime):
        for widget in self.widgets:
            widget.tick(dtime)
	    if (self.engine.gameMgr.ent1.score >= 1500 or (self.engine.gameMgr.ent1.health == 0)):
	        PopUp1(self.engine).tick(dtime)
		self.engine.gameMgr.ent1.desiredSpeed *= 0
		self.engine.gameMgr.ent2.desiredSpeed *= 0
	    elif (self.engine.gameMgr.ent2.score >= 1500 or (self.engine.gameMgr.ent2.health == 0)):
	        PopUp2(self.engine).tick(dtime)
		self.engine.gameMgr.ent1.desiredSpeed *= 0
		self.engine.gameMgr.ent2.desiredSpeed *= 0

    def render(self):
        for widget in self.widgets:
            widget.render()


    xzPlane = ogre.Plane((0, 1, 0), 0)
    def findWorldCoords(self, ms):
        ''' Map to x,z plane from viewport
        '''
        ms.width = self.engine.gfxSystem.viewport.actualWidth 
        ms.height = self.engine.gfxSystem.viewport.actualHeight
        mouseRay = self.engine.cameraSystem.camera.getCameraToViewportRay(ms.X.abs/float(ms.width), ms.Y.abs/float(ms.height))
        result  =  mouseRay.intersects(self.xzPlane)
        pos = None
        if result.first:
            pos =  mouseRay.getPoint(result.second)
            #self.mousePosWorld = pos
        return pos


    
    def getNextId(self):
        self.idCounter += 1
        return self.idCounter
示例#23
0
    def _createScene(self):
        self.entMgr = EntityManager()
        # Setup a scene with a high level of ambient light.
        sceneManager = self.sceneManager
        #sceneManager.ambientLight = 0.25, 0.25, 0.25
        #more light
        sceneManager.ambientLight = 1.0, 1.0, 1.0

        surfaceHeight = -100
        # Setup a ground plane at -100 height so the entire cube shows up
        plane = ogre.Plane((0, 1, 0), surfaceHeight)
        meshManager = ogre.MeshManager.getSingleton()
        #large plane 10000x10000
        meshManager.createPlane('Ground', 'General', plane, 10000, 10000, 20,
                                20, True, 1, 5, 5, (0, 0, 1))
        ent = sceneManager.createEntity('GroundEntity', 'Ground')
        sceneManager.getRootSceneNode().createChildSceneNode().attachObject(
            ent)
        ent.setMaterialName('Examples/Water2')
        ent.castShadows = False
        #Like nice sky
        self.sceneManager.setSkyDome(True, "Examples/CloudySky", 5, 8)
        # Setup the first camera node and pitch node and aim it.
        camnode = sceneManager.getRootSceneNode().createChildSceneNode(
            'CamNode1', (0, 50, 500))
        #camnode.yaw(ogre.Degree(-45))

        node = camnode.createChildSceneNode('PitchNode1')
        node.attachObject(self.camera)

        # create game engine's entities from our as4 class (with small changes)

        #These are entities that are created with base class 'Entity'
        #For personal development
        #self.entMgr.createEntity("Cigarette", mesh = 'cigarette.mesh')
        #self.entMgr.createEntity("Boat0", mesh = '5086_Boat.mesh')
        #self.entMgr.createEntity("Boat1", mesh = 'boat.mesh')
        #self.entMgr.createEntity("CVN",  mesh = 'cvn68.mesh')
        #self.entMgr.createEntity("DDG",  mesh = 'ddg51.mesh')

        #self.entMgr.createEntity("Sail", mesh = 'sailboat.mesh')
        #self.entMgr.createEntity("Sleek", mesh = 'sleek.mesh')

        #self.entMgr.createEntity("Alien", mesh = 'alienship.mesh')
        #self.entMgr.createEntity("Monterey", mesh = '3699_Monterey_189_92.mesh')
        #self.entMgr.createEntity("WaterCraft", mesh = '4685_Personal_Watercr.mesh')

        #self.entMgr.createEntity("Missile", mesh = 'missile.mesh')

        #This functions will create all 10 types of ships using 10 entity subclasses
        #For as4 requirement
        self.entMgr.createDemo()

        #Round Robin to the first ship
        self.entMgr.next()
        offset = -1000

        for i in range(0, 11):
            self.curEnt = self.entMgr.getSelected()
            self.curEnt.pos = ogre.Vector3(offset, 0, 0)

            # create corresponding ogre ent
            self.pEnt = sceneManager.createEntity(self.curEnt.id,
                                                  self.curEnt.mesh)
            self.pEnt.position = ogre.Vector3(offset, 0, 0)

            # create scene node to attach pEnt to
            self.curEntSceneNode = sceneManager.getRootSceneNode(
            ).createChildSceneNode(self.curEnt.id + 'node',
                                   ogre.Vector3(offset, 0, 0))
            self.curEntSceneNode.attachObject(self.pEnt)

            self.curEnt.aspects[1].attachNode(self.curEntSceneNode)

            self.entMgr.next()
            offset += 255

            #Lazy Hack to have all boats facing right
            if i == 9:
                self.curEntSceneNode.yaw(ogre.Degree(90))
                self.curEntSceneNode.scale(ogre.Vector3(.1, .1, .1))
            elif i == 8:
                self.curEntSceneNode.yaw(ogre.Degree(90))
            elif i == 7:
                self.curEntSceneNode.scale(ogre.Vector3(10, 10, 10))
            elif i == 11:
                self.curEntSceneNode.scale(ogre.Vector3(15, 15, 15))

        # Setup the second camera node and pitch node.
        # don't need this
        node = sceneManager.getRootSceneNode().createChildSceneNode(
            'CamNode2', (0, 200, 400))
        node.createChildSceneNode('PitchNode2')