Beispiel #1
0
    def join(self, ent):
        CSimpleActor.join(self, ent)

        # Get engine and scene manager in handy variables
        sm = self.mScene

        # Register the weapon model
        gun = CEngine.models.registerSkelModel(self.model)

        # Create the weapon scene model
        self.gun = manage(sylphis.CSceneModel, sm, gun)
        self.gun.setPosition(sylphis.CVector3(0.0, 0.0, 0.0))
        self.gun.blendAnimCycle('idle', 0.1, 0.1)
        self.gun.setFlags(sylphis.CSceneModel.NOSHADOW
                          | sylphis.CSceneModel.NOCULL)

        # Register the weapon sounds
        self.shotsound = CEngine.mSoundEnv.registerSoundBuffer(self.fire_sound)
        self.drysound = CEngine.mSoundEnv.registerSoundBuffer(
            self.dryfire_sound)
        self.reloadsound = CEngine.mSoundEnv.registerSoundBuffer(
            self.reload_sound)

        # Create the weapon sound source
        self.s = manage(sylphis.CSoundSource, CEngine.mSoundEnv)
        self.s.setLooping(0)

        # Attach the sound source to the weapon node
        self.gun.addChild(self.s)
Beispiel #2
0
    def __init__(self, *args):
        CSimpleActor.__init__(self, *args)
        self.camera = manage(sylphis.CCamera, self.mScene)
        self.camera.setFov(self.fov)
        self.node = self.camera # To be registered on the scenemanager
        self.body = manage(sylphis.CRigidCapsule, 0, None, sylphis.CVector3(self.width, self.height, self.width))

        self.body.setMass(5.0)
        self.body.setDamping(0.1)
        self.body.setMaxAngularVelocity(0.001)
        self.body.setDamageFactor(0.000001)
        self.body.setListener(self)
        self.body.setContents(sylphis.CONTENTS_BODY)
        self.body.setCollisionMask(sylphis.MASK_PLAYERSOLID)
        CPhysicsEnv.registerRigidBody(self.body)

        self.omove = sylphis.CActorMover(self.mScene)
        self.omove.mAccel = 0.1

        self.slistener = manage(sylphis.CSoundListener, CEngine.mSoundEnv)
        self.camera.addChild(self.slistener)

        self.lastPos = sylphis.CVector3(0,0,0)
        self.onGround = 0
        self.jumping = False
        self.count = 0
        self.lastGround = None
        self.flyMode = False

        self.camheight -= self.height / 2.0
Beispiel #3
0
    def join(self, ent):
        CSimpleActor.join(self, ent)

        # Get engine and scene manager in handy variables
        sm = self.mScene

        # Register the weapon model
        gun = CEngine.models.registerSkelModel(self.model)

        # Create the weapon scene model
        self.gun = manage(sylphis.CSceneModel, sm, gun)
        self.gun.setPosition(sylphis.CVector3(0.0, 0.0, 0.0))
        self.gun.blendAnimCycle('idle', 0.1, 0.1)
        self.gun.setFlags(sylphis.CSceneModel.NOSHADOW | sylphis.CSceneModel.NOCULL)

        # Register the weapon sounds
        self.shotsound = CEngine.mSoundEnv.registerSoundBuffer(self.fire_sound)
        self.drysound = CEngine.mSoundEnv.registerSoundBuffer(self.dryfire_sound)
        self.reloadsound = CEngine.mSoundEnv.registerSoundBuffer(self.reload_sound)
        
        # Create the weapon sound source
        self.s = manage(sylphis.CSoundSource, CEngine.mSoundEnv)
        self.s.setLooping(0)

        # Attach the sound source to the weapon node
        self.gun.addChild(self.s)
Beispiel #4
0
    def __init__(self, *args):
        CSimpleActor.__init__(self, *args)
        self.camera = manage(sylphis.CCamera, self.mScene)
        self.camera.setFov(self.fov)
        self.node = self.camera  # To be registered on the scenemanager
        self.body = manage(
            sylphis.CRigidCapsule, 0, None,
            sylphis.CVector3(self.width, self.height, self.width))

        self.body.setMass(5.0)
        self.body.setDamping(0.1)
        self.body.setMaxAngularVelocity(0.001)
        self.body.setDamageFactor(0.000001)
        self.body.setListener(self)
        self.body.setContents(sylphis.CONTENTS_BODY)
        self.body.setCollisionMask(sylphis.MASK_PLAYERSOLID)
        CPhysicsEnv.registerRigidBody(self.body)

        self.omove = sylphis.CActorMover(self.mScene)
        self.omove.mAccel = 0.1

        self.slistener = manage(sylphis.CSoundListener, CEngine.mSoundEnv)
        self.camera.addChild(self.slistener)

        self.lastPos = sylphis.CVector3(0, 0, 0)
        self.onGround = 0
        self.jumping = False
        self.count = 0
        self.lastGround = None
        self.flyMode = False

        self.camheight -= self.height / 2.0
Beispiel #5
0
    def precache(self):
        self.carModel = manage(sylphis.CSceneMD3, self.mScene)
        m = CEngine.models.registerMD3Model('models/jeep.md3')
        #m = CEngine.models.registerSMFModel('models/car.smf')
        self.carModel.setModel(m)

        m = CEngine.models.registerMD3Model('models/tire.md3')
        #m = CEngine.models.registerSMFModel('models/tire.smf')
        self.tireModels = []
        for i in range(4):
            self.tireModels.append(manage(sylphis.CSceneMD3, self.mScene))
            self.tireModels[i].setModel(m)
Beispiel #6
0
    def precache(self):
        self.carModel = manage(sylphis.CSceneMD3, self.mScene)
        m = CEngine.models.registerMD3Model('models/jeep.md3')
        #m = CEngine.models.registerSMFModel('models/car.smf')
        self.carModel.setModel(m)

        m = CEngine.models.registerMD3Model('models/tire.md3')
        #m = CEngine.models.registerSMFModel('models/tire.smf')
        self.tireModels = []
        for i in range(4):
            self.tireModels.append(manage(sylphis.CSceneMD3, self.mScene))
            self.tireModels[i].setModel(m)
Beispiel #7
0
class CMiscSkelModel(CSimpleActor):
    __classname__ = 'misc_skel_model'
    __desc__ = 'A skeletal model'
    __actortype__ = 'e'
    __specs__ = [
        {'name':'model', 'doc':'The filename that contains the model'},
        {'name':'anim', 'doc':'The animation to run on the model. e.g. ''idle'''},
        {'name':'skin', 'doc':'The skin to apply on the model. (Not implemented yet)'}
    ]
    model = ''
    anim = 'idle'
    skin = ''
    
    def __init__(self, *args):
        CSimpleActor.__init__(self, *args)
      
    def join(self, ent):
        CSimpleActor.join(self, ent)
        pi = 3.14159 # FIXME
        try:
            o = split(ent['angles'])
        except KeyError,x:
            ang = ent.get('angle', '0')
            o = ('0', ang, '0')
        self.angles = sylphis.CVector3(-pi * float(o[0]) / 180, pi * float(o[1]) / 180, pi * float(o[2]) / 180)

        model = CEngine.models.registerSkelModel(self.model)

        bt = manage(sylphis.CBoneControler)
        bt.setTranslation(sylphis.CVector3(0,0,0))
        q = sylphis.CQuaternion()
        q.fromAngleAxis(sylphis.CVector3(1,0,0), 10.0)
        bt.setRotation(q)
        bt.setBoneId(0)
        
        sa = manage(sylphis.CSkelAnimation)
        sa.setDuration(100.0)
        sa.addBoneTrack(bt)

        #print "Controlers :", bt, sa

        sm = self.mScene
        m = sylphis.CSceneModel(sm, model)
        m.setPosition(self.origin)
        m.blendAnimCycle(self.anim, 1.0, 0.1)

        m.executeAction(sa, 'test')
        
        m.yaw(self.angles.y)
        m.roll(self.angles.x)

        self.node = m
Beispiel #8
0
    def join(self, ent):
        CJoint.join(self, ent)
        o = split(self.axis)
        self.axis = sylphis.CVector3(float(o[0]), float(o[1]), float(o[2]))
        self.axis.swapHand()

        self.joint = manage(sylphis.CJointSlider, 0, 0)
Beispiel #9
0
    def join(self, ent):
        CSimpleActor.join(self, ent)

        self.light_center.swapHand()

        o = self.radius.split()
        if len(o) == 1: o = (o[0], o[0], o[0])
        elif len(o) == 2: o = (o[0], o[1], (o[0] + o[1]) / 2)
        
        self.radius = (float(o[0]), float(o[2]), float(o[1]))

        sm = self.mScene
        sl = manage(sylphis.CLight, sm)
        sl.setCenter(self.light_center)
        sl.setPosition(self.origin)
        sl.setColor(self.color * self.intensity)
        sl.setIsShadowCaster(self.shadows)
        sl.setSpecular(self.specular)
        sl.setRadius(self.radius[0], self.radius[1], self.radius[2])
        sl.setType(int(self.type))
        sl.setFreq(float(self.freq))
        sl.setPhase(float(self.phase))
        
        if self.filter != 'nofilter':
            self.filterMap = CEngine.textures.registerCubeMap(self.filter)
            sl.setFilter(self.filterMap)

        sl.setAttenuation(CEngine.renderer.registerAttenuation(self.attenuation))
        self.node = sl
        self.time = 0
        self.timedelta = 0
Beispiel #10
0
    def join(self, ent):
        CJoint.join(self, ent)
        o = split(self.axis)
        self.axis = sylphis.CVector3(float(o[0]), float(o[1]), float(o[2]))
        self.axis.swapHand()

        self.joint = manage(sylphis.CJointSlider, 0, 0)
Beispiel #11
0
    def join(self, ent):
        CSimpleActor.join(self, ent)

        self.light_center.swapHand()

        o = self.radius.split()
        if len(o) == 1: o = (o[0], o[0], o[0])
        elif len(o) == 2: o = (o[0], o[1], (o[0] + o[1]) / 2)

        self.radius = (float(o[0]), float(o[2]), float(o[1]))

        sm = self.mScene
        sl = manage(sylphis.CLight, sm)
        sl.setCenter(self.light_center)
        sl.setPosition(self.origin)
        sl.setColor(self.color * self.intensity)
        sl.setIsShadowCaster(self.shadows)
        sl.setSpecular(self.specular)
        sl.setRadius(self.radius[0], self.radius[1], self.radius[2])
        sl.setType(int(self.type))
        sl.setFreq(float(self.freq))
        sl.setPhase(float(self.phase))

        if self.filter != 'nofilter':
            self.filterMap = CEngine.textures.registerCubeMap(self.filter)
            sl.setFilter(self.filterMap)

        sl.setAttenuation(
            CEngine.renderer.registerAttenuation(self.attenuation))
        self.node = sl
        self.time = 0
        self.timedelta = 0
Beispiel #12
0
 def initBody(self):
     self.body = manage(sylphis.CRigidSphere, 0, self.node, 20)
     self.body.setDensity(0.000001)
     self.body.fitToModel(self.node)
     self.body.setListener(self)
     self.body.applyGravity(False)
     CPhysicsEnv.registerRigidBody(self.body)
Beispiel #13
0
 def join(self, ent):
     CSimpleActor.join(self, ent)
     if self.sound != '':
         sb = CEngine.mSoundEnv.registerSoundBuffer(self.sound)
         self.node = manage(sylphis.CSoundSource, CEngine.mSoundEnv)
         self.node.setBuffer(sb)
         self.node.setPosition(self.origin)
         self.node.setLooping(self.loop)
Beispiel #14
0
 def join(self, ent):
     CSimpleActor.join(self, ent)
     if self.sound != '':
         sb = CEngine.mSoundEnv.registerSoundBuffer(self.sound)
         self.node = manage(sylphis.CSoundSource, CEngine.mSoundEnv)
         self.node.setBuffer(sb)
         self.node.setPosition(self.origin)
         self.node.setLooping(self.loop)
Beispiel #15
0
 def join(self, ent):
     CJoint.join(self, ent)
     o = split(self.axis1)
     self.axis1 = sylphis.CVector3(float(o[0]), float(o[1]), float(o[2]))
     self.axis1.swapHand()
     o = split(self.axis2)
     self.axis2 = sylphis.CVector3(float(o[0]), float(o[1]), float(o[2]))
     self.axis2.swapHand()
     self.joint = manage(sylphis.CJointUniversal, 0, 0)
Beispiel #16
0
 def join(self, ent):
     CSimpleActor.join(self, ent)
            	
     m = manage(sylphis.CSceneObject, self.mScene)
     m.setPosition(self.origin)
     print self.angles
     m.setOrientation(self.angles)
     
     self.node = m
Beispiel #17
0
 def join(self, ent):
     CJoint.join(self, ent)
     o = split(self.axis1)
     self.axis1 = sylphis.CVector3(float(o[0]), float(o[1]), float(o[2]))
     self.axis1.swapHand()
     o = split(self.axis2)
     self.axis2 = sylphis.CVector3(float(o[0]), float(o[1]), float(o[2]))
     self.axis2.swapHand()
     self.joint = manage(sylphis.CJointUniversal, 0, 0)
Beispiel #18
0
    def start(self):
        CControlerBase.start(self)
        pathNodeNames = split(self.pathnodes)
        if self.pathtype == LINEAR:
            self.path = manage(sylphis.CInterpolatorVector3)
        else:
            self.path = manage(sylphis.CSplineInterpolatorVector3)
        i = 0.0
        time = 0.0
        for name in pathNodeNames:
            node = self.mCont.actors.getActorByName(name)
            if node is None:
                continue
            if hasattr(node, 'time'):
                time += float(node.time)
            else:
                if i > 0:time += 1 #let the first node be at zero
            self.path.insert(node.origin, time / self.speed)
            #print node, time / self.speed
            i += 1.0

        if self.loop == 0.0:
            self.loop = time / self.speed
        if self.loop == -1.0:
            self.loop = 0.0

        pathNodeNames = split(self.lookatpathnodes)
        if self.lookatpathtype == LINEAR:
            self.lookatpath = manage(sylphis.CInterpolatorVector3)
        else:
            self.lookatpath = manage(sylphis.CSplineInterpolatorVector3)
        i = 0.0
        time = 0.0
        for name in pathNodeNames:
            node = self.mCont.actors.getActorByName(name)
            if node is None:
                continue
            if hasattr(node, 'time'):
                time += float(node.time)
            else:
                if i > 0:time += 1
            self.lookatpath.insert(node.origin, time / self.speed)
            #print node.__classname__, time / self.speed
            i += 1.0
Beispiel #19
0
    def start(self):
        CControlerBase.start(self)
        pathNodeNames = split(self.pathnodes)
        if self.pathtype == LINEAR:
            self.path = manage(sylphis.CInterpolatorVector3)
        else:
            self.path = manage(sylphis.CSplineInterpolatorVector3)
        i = 0.0
        time = 0.0
        for name in pathNodeNames:
            node = self.mCont.actors.getActorByName(name)
            if node is None:
                continue
            if hasattr(node, 'time'):
                time += float(node.time)
            else:
                if i > 0: time += 1  #let the first node be at zero
            self.path.insert(node.origin, time / self.speed)
            #print node, time / self.speed
            i += 1.0

        if self.loop == 0.0:
            self.loop = time / self.speed
        if self.loop == -1.0:
            self.loop = 0.0

        pathNodeNames = split(self.lookatpathnodes)
        if self.lookatpathtype == LINEAR:
            self.lookatpath = manage(sylphis.CInterpolatorVector3)
        else:
            self.lookatpath = manage(sylphis.CSplineInterpolatorVector3)
        i = 0.0
        time = 0.0
        for name in pathNodeNames:
            node = self.mCont.actors.getActorByName(name)
            if node is None:
                continue
            if hasattr(node, 'time'):
                time += float(node.time)
            else:
                if i > 0: time += 1
            self.lookatpath.insert(node.origin, time / self.speed)
            #print node.__classname__, time / self.speed
            i += 1.0
Beispiel #20
0
    def join(self, ent):
        CJoint.join(self, ent)
        o = split(self.axis)
        self.axis = sylphis.CVector3(float(o[0]), float(o[1]), float(o[2]))
        self.axis.swapHand()
        self.loStop = self.lo_stop / 180 * math.pi
        self.hiStop = self.hi_stop / 180 * math.pi
        self.cfm = self.stop_softness

        self.joint = manage(sylphis.CJointHinge, 0, 0)
Beispiel #21
0
    def join(self, ent):
        CJoint.join(self, ent)
        o = split(self.axis)
        self.axis = sylphis.CVector3(float(o[0]), float(o[1]), float(o[2]))
        self.axis.swapHand()
        self.loStop = self.lo_stop / 180 * math.pi
        self.hiStop = self.hi_stop / 180 * math.pi
        self.cfm = self.stop_softness

        self.joint = manage(sylphis.CJointHinge, 0, 0)
Beispiel #22
0
    def join(self, ent):
        e = self.mContainer.getEngine()
        md2 = e.renderables.registerMD2("models/grenade.md2")
        sm = self.mCont.getSceneManager()

        m = manage(sylphis.CRenderableMultiMesh, sm)
        m.setPosition(ent["position"])
        m.addMesh(md2, "textures/grenade")
        self.node = m

        sm.getRootSceneNode().addChild(self.node)
        e.shaders.loadAll()
        self.body = manage(sylphis.CRigidBody)
        self.body.setListener(self)
        self.body.mPosition = self.node.getPosition()
        self.body.mVelocity = ent["velocity"]
        self.body.mBBox.setBounds(sylphis.CVector3(-3, -3, -3), sylphis.CVector3(3, 3, 3))
        sm.registerRigidBody(self.body)

        self.age = 0.0
Beispiel #23
0
 def join(self, ent):
     CSimpleActor.join(self, ent)
     
     from core.particlesystem import manager
     
     self.partdef = manager.registerParticleSystem(self.particledef)
    	
     m = manage(sylphis.CRenderableMultiMesh, self.mScene)
     p = manage(sylphis.CParticleSystem)
     
     p.setDefinition(self.partdef)
     p.setDefaultShader(self.partdef.getMaterial())
     p.setDieAfterUse(False)
     self.mScene.addParticleSystem(p)
     m.getBound().setBounds(sylphis.CVector3(-1000, -1000, -1000), sylphis.CVector3(1000, 1000, 1000))
     m.addMesh(p)
     	
     m.setPosition(self.origin)
     
     self.node = m
     self.particleSystem = p
Beispiel #24
0
    def join(self, ent):
        e = self.mContainer.getEngine()
        md2 = e.renderables.registerMD2("models/grenade.md2")
        sm = self.mCont.getSceneManager()

        m = manage(sylphis.CRenderableMultiMesh, sm)
        m.setPosition(ent['position'])
        m.addMesh(md2, "textures/grenade")
        self.node = m

        sm.getRootSceneNode().addChild(self.node)
        e.shaders.loadAll()
        self.body = manage(sylphis.CRigidBody)
        self.body.setListener(self)
        self.body.mPosition = self.node.getPosition()
        self.body.mVelocity = ent['velocity']
        self.body.mBBox.setBounds(sylphis.CVector3(-3, -3, -3),
                                  sylphis.CVector3(3, 3, 3))
        sm.registerRigidBody(self.body)

        self.age = 0.0
Beispiel #25
0
    def join(self, ent):
        CSimpleActor.join(self, ent)

        sm = self.mCont.getSceneManager()
        sl = manage(sylphis.CLight, sm)
        sl.setPosition(0, 0, 0)
        self.radius = 10.0
        sl.setRadius(self.radius)
        sl.setColor(sylphis.CVector3(1.0, 0.9, 0.6));
        sl.setPosition(self.origin)
        self.node = sl

        self.age = 0.0
Beispiel #26
0
    def join(self, ent):
        CSimpleActor.join(self, ent)

        sm = self.mCont.getSceneManager()
        sl = manage(sylphis.CLight, sm)
        sl.setPosition(0, 0, 0)
        self.radius = 10.0
        sl.setRadius(self.radius)
        sl.setColor(sylphis.CVector3(1.0, 0.9, 0.6))
        sl.setPosition(self.origin)
        self.node = sl

        self.age = 0.0
Beispiel #27
0
    def join(self, ent):
        CSimpleActor.join(self, ent)

        from core.particlesystem import manager

        self.partdef = manager.registerParticleSystem(self.particledef)

        m = manage(sylphis.CRenderableMultiMesh, self.mScene)
        p = manage(sylphis.CParticleSystem)

        p.setDefinition(self.partdef)
        p.setDefaultShader(self.partdef.getMaterial())
        p.setDieAfterUse(False)
        self.mScene.addParticleSystem(p)
        m.getBound().setBounds(sylphis.CVector3(-1000, -1000, -1000),
                               sylphis.CVector3(1000, 1000, 1000))
        m.addMesh(p)

        m.setPosition(self.origin)

        self.node = m
        self.particleSystem = p
Beispiel #28
0
    def join(self, ent):
        CSimpleActor.join(self, ent)
        self.time = 0.0
        sm = self.mCont.getSceneManager()

        if self.model != '':
            model = CEngine.models.registerMD3Model(self.model)
            m = manage(sylphis.CSceneMD3, sm)
            m.setModel(model)
            m.setPosition(self.origin)
            self.node = m
            self.body = manage(sylphis.CRigidSphere, 0, self.node, self.radius)
        else:
            self.body = manage(sylphis.CRigidSphere, 0, None, self.radius)

        if self.hit_sound != '':
            shotsound = CEngine.mSoundEnv.registerSoundBuffer(self.hit_sound)
            self.s = manage(sylphis.CSoundSource, CEngine.mSoundEnv)
            self.s.setBuffer(shotsound)
            self.s.setLooping(0)
            self.s.setListener(self)
            sm.getRootSceneNode().addChild(self.s)
        else:
            pass

        self.body.setListener(self)
        self.body.setPosition(self.origin)
        v = self.angles * self.velocity
        self.body.setVelocity(v)
        self.body.setOrientation(self.angles)
        self.body.setDamping(self.damping)
        #self.body.setSuspendMultiCollitions(0)
        self.body.setDamageFactor(self.damage_factor)
        self.body.noCollitionWith(self.owner.body)
        self.body.mSR.softness = 0.01
        self.body.mSR.bounce = 0.1
        self.body.mSR.bounceCutoff = 0.1
        CPhysicsEnv.registerRigidBody(self.body)
Beispiel #29
0
    def join(self, ent):
        CSimpleActor.join(self, ent)
        self.time = 0.0
        sm = self.mCont.getSceneManager()
        
        if self.model != '':
            model = CEngine.models.registerMD3Model(self.model)
            m = manage(sylphis.CSceneMD3, sm)
            m.setModel(model)
            m.setPosition(self.origin)
            self.node = m
            self.body = manage(sylphis.CRigidSphere, 0, self.node, self.radius)
        else:
            self.body = manage(sylphis.CRigidSphere, 0, None, self.radius)

        if self.hit_sound != '':
            shotsound = CEngine.mSoundEnv.registerSoundBuffer(self.hit_sound)
            self.s = manage(sylphis.CSoundSource, CEngine.mSoundEnv)
            self.s.setBuffer(shotsound)
            self.s.setLooping(0)
            self.s.setListener(self)
            sm.getRootSceneNode().addChild(self.s)
        else:
            pass

        self.body.setListener(self)
        self.body.setPosition(self.origin)
        v = self.angles * self.velocity
        self.body.setVelocity(v)
        self.body.setOrientation(self.angles)
        self.body.setDamping(self.damping)
        #self.body.setSuspendMultiCollitions(0)
        self.body.setDamageFactor(self.damage_factor)
        self.body.noCollitionWith(self.owner.body)
        self.body.mSR.softness = 0.01
        self.body.mSR.bounce = 0.1
        self.body.mSR.bounceCutoff = 0.1
        CPhysicsEnv.registerRigidBody(self.body)
Beispiel #30
0
 def join(self, ent):
     """
     Loads the soundtrack for this world.
     """
     CSimpleActor.join(self, ent)
     o = split(self.ambient_color)
     self.ambientLight = sylphis.CVector3(float(o[0]), float(o[1]), float(o[2]))
     if self.sound_track != '':
         self.soundTrack = CEngine.mSoundEnv.registerSoundBuffer(self.sound_track)
         self.track = manage(sylphis.CSoundSource, CEngine.mSoundEnv)
         self.track.setBuffer(self.soundTrack)
         self.track.setPosition(0,0,0)
         self.track.setSpatial(0)
         self.mScene.getRootSceneNode().addChild(self.track)
Beispiel #31
0
    def join(self, ent):
        self.eng = self.mContainer.getEngine()

        sm = self.mCont.getSceneManager()
        sl = manage(sylphis.CLight, sm)
        sl.setPosition(0, 0, 0)
        self.radius = 10.0
        sl.setRadius(self.radius)
        sl.setColor(sylphis.CVector3(1.0, 0.9, 0.6))
        sl.setPosition(ent['position'])
        sm.getRootSceneNode().addChild(sl)
        sm.getRootSceneNode().addChild(sl)
        self.node = sl

        self.eng.shaders.loadAll()

        self.age = 0.0
Beispiel #32
0
    def join(self, ent):
        self.eng = self.mContainer.getEngine()

        sm = self.mCont.getSceneManager()
        sl = manage(sylphis.CLight, sm)
        sl.setPosition(0, 0, 0)
        self.radius = 10.0
        sl.setRadius(self.radius)
        sl.setColor(sylphis.CVector3(1.0, 0.9, 0.6));
        sl.setPosition(ent['position'])
        sm.getRootSceneNode().addChild(sl)
        sm.getRootSceneNode().addChild(sl)
        self.node = sl
        
        self.eng.shaders.loadAll()

        self.age = 0.0
Beispiel #33
0
 def join(self, ent):
     CJoint.join(self, ent)
     self.joint = manage(sylphis.CJointBall, 0, 0)
Beispiel #34
0
    def initBody(self):
        self.body = manage(sylphis.CRigidBox, 0, self.carModel, CVector3(self.width,self.height, self.length*0.9))
        self.body.setMass(50.0)
        #self.body.fitToModel(self.carModel)
        self.body.setListener(self)
        #self.body.applyGravity(False)
        self.body.setPosition(self.origin)
        self.body.setDamping(0.0000)
        self.body.setAngDamping(2.0)
        self.body.setMaxAngularVelocity(100.0)
        self.body.setDamageFactor(0.001)
        CPhysicsEnv.registerRigidBody(self.body)

        self.tireBody = []
        for i in range(4):
            self.tireBody.append(manage(sylphis.CRigidSphere, 0, self.tireModels[i], 25))
            self.tireBody[i].setMass(2.2)
            self.tireBody[i].fitToModel(self.tireModels[i])
            self.tireBody[i].setListener(self)
            self.tireBody[i].setDamping(0.0001)
            self.tireBody[i].setAngDamping(0.0)
            self.tireBody[i].setMaxAngularVelocity(200.0)
            self.tireBody[i].setDamageFactor(0.001)
            CPhysicsEnv.registerRigidBody(self.tireBody[i])

        pos = self.origin + CVector3(self.width * 0.45, -self.height * 0.4, -self.length * 0.45)
        self.tireBody[0].setPosition(pos)
        pos = self.origin + CVector3(-self.width * 0.45, -self.height * 0.4, -self.length * 0.45)
        self.tireBody[1].setPosition(pos)
        pos = self.origin + CVector3(self.width * 0.45, -self.height * 0.4, self.length * 0.45)
        self.tireBody[2].setPosition(pos)
        pos = self.origin + CVector3(-self.width * 0.45, -self.height * 0.4, self.length * 0.45)
        self.tireBody[3].setPosition(pos)

        joint = []
        #for i in range(2):
        #    joint.append(manage(sylphis.CJointHinge, 0, 0))
            #joint[i].setAxis1(CVector3(0,1,0))
        #    joint[i].setAxis(CVector3(1,0,0))
            #joint[i].setLoStop(0.0)
            #joint[i].setHiStop(0.0)
        #    joint[i].attach(self.body, self.tireBody[i])
        #    joint[i].setAnchor(self.tireBody[i].getPosition())
            
        for i in range(4):
            joint.append(manage(sylphis.CJointDoubleHinge, 0, 0))
            joint[i].attach(self.body, self.tireBody[i])
            joint[i].setAnchor(self.tireBody[i].getPosition())
            joint[i].setAxis1(CVector3(0,1,0))
            if i == 0:
                joint[i].setAxis2(CVector3(1,0,0))
            else:
                joint[i].setAxis2(CVector3(-1,0,0))
            
            joint[i].setSuspensionCFM(0.00005)
            joint[i].setSuspensionERP(0.00012)
            
            
        for i in range(2,4):            
            joint[i].setLoStop(0.0)
            joint[i].setHiStop(0.0)
            
        for i in range(2):            
            joint[i].setLoStop(-0.6)
            joint[i].setHiStop(0.6)
            
        for i in range(4):
            self.tireBody[i].setSleep(False)

            
        self.joint = joint
Beispiel #35
0
        "__a":"1",
        "__dyn":"7AgNeyfyGmaxx2u6aEyx91qeCwKAKGgyi8zQC-C267UKewWhE98nwgUy22EaUgxebkwy8xa5WjzEgDKuEjKewExaFQ12VVojxCUSbAWCDxi5-78O5u5o5aayrhVo9ohxGbwYUmC-UjDQ6Evwwh8gUW5oy5EG2ut5xq48a9Ef8Cu4rGUpCzo-8Gm8z8O784afxK9yUvy8lUGdyU4eQEB0",
        "__af":"j0",
        "__req":"26",
        "__be":"-1",
        "__pc":"EXP4:DEFAULT",
        "__rev":"3161010",
        "__spin_r":"3161010",
        "__spin_b":"trunk",
        "__spin_t":"1500360303"
        }
    content = open("data/friends.html").read()
    data,info = get_info(content,None)
    params["data"] = data
    ts = int(time.time())
    params["__spin_t"] = ts
    url = "https://www.facebook.com/ajax/pagelet/generic.php/AllFriendsAppCollectionPagelet"
    url,html = util.get_page({"url":url,"data":params})
    print(url)
    open("data/friends_page.html","w").write(html)

if "__main__" == __name__:
    '''
    seeds = [{"url":"https://www.sina.com.cn"}]
    fp = open("data/result.txt","a")
    params = (seeds,conf,fp)
    util.manage(util.schedule,params)
    '''
    util.manage(cb)

Beispiel #36
0
 def join(self, ent):
     CJoint.join(self, ent)
     self.joint = manage(sylphis.CJointBall, 0, 0)
Beispiel #37
0
 def precache(self):
     self.model = manage(sylphis.CSceneMD3, self.mScene)
     model = CEngine.models.registerMD3Model('models/bball.md3')
     self.model.setModel(model)
Beispiel #38
0
        try:
            o = split(ent['angles'])
        except KeyError,x:
            ang = ent.get('angle', '0')
            o = ('0', ang, '0')
        self.angles = sylphis.CVector3(-pi * float(o[0]) / 180, pi * float(o[1]) / 180, pi * float(o[2]) / 180)
        self.model = ent.get('model', '')
        try:
            self.shader = ent['shader']
        except KeyError, x:
            self.shader = self.model
        
        #CSimpleActor.start(self)
        sm = self.mScene

        m = manage(sylphis.CSceneMD3, sm)
        
        worldmodel = self.model_id
        if worldmodel is None:
            ext = self.model[-3:]
            if ext == 'md3':
                model = CEngine.models.registerMD3Model(self.model)
            else:
                model = CEngine.models.registerSMFModel(self.model)
        else:
            model = sm.getWorldMapModel(int(worldmodel))

        m.setModel(model)
        m.setPosition(self.origin)
        m.yaw(self.angles.y)
        m.roll(self.angles.x)
Beispiel #39
0
        result = {}
        for cf in conf:
            v = util.get_jpath(obj,cf[1],cf[2] if len(cf)>2 else None,cf[3] if len(cf)>3 else None)
            if v is not None:
                result[cf[0]] = v
        result["id"] = hashlib.md5(url.encode("utf-8")).hexdigest()
        if "content" in result:
            result["content"],result["images"] = replace_image(result["content"],url)
            if "cover" in result and len(result["cover"])>0:
                result["cover"] = imge_transfer(util.parse_url(url,result["cover"]),url)[1]
            if len(result) > 0:
                result2.append(result)
        else:
            util.log_msg("could not parse content from html file,need to check this out.url:%s,referer:%s." % (url,referer))
    else:
        util.log_msg("could not parse data from html file,need to check this out.url:%s,referer:%s." % (url,referer))

def cb(fp):
    #url = "http://www.toutiao.com/"
    #util.get_page({"url":url})
    #ids = ["3217488391","3490514559","6952025338","53052328075","62410217001","17742356838","3667603068","6617382708","6474480676","6126424045","6237062541","6613263338","5721425462","3230889860","5460434242","4588938236","4023651976","6675755348","51848596518","3794154752","5766840891","6939911288","53197227173","52231019020","1439117339","3655831911","5963433422",
    #ids = ["3345437222","3655626426","5963433422","5935444546","6095787239","63826714033","3669967641","4664335991","6960911767","6065077466","5458114046","2921675805","4309017746","3788331986","4143177716","5826315429","52171354099","5446353935","52497881665","3961411576","6303762356","5543282403","3808046799","50099999999"]
    ids = ["3909766048"]
    for uid in ids:
        get_user_info(uid,fp)

if "__main__" == __name__:
    fp = open("data/result.txt","a")
    #util.manage(cb,(fp,))
    util.manage(cb,(None,))
Beispiel #40
0
    def initBody(self):
        self.body = manage(
            sylphis.CRigidBox, 0, self.carModel,
            CVector3(self.width, self.height, self.length * 0.9))
        self.body.setMass(50.0)
        #self.body.fitToModel(self.carModel)
        self.body.setListener(self)
        #self.body.applyGravity(False)
        self.body.setPosition(self.origin)
        self.body.setDamping(0.0000)
        self.body.setAngDamping(2.0)
        self.body.setMaxAngularVelocity(100.0)
        self.body.setDamageFactor(0.001)
        CPhysicsEnv.registerRigidBody(self.body)

        self.tireBody = []
        for i in range(4):
            self.tireBody.append(
                manage(sylphis.CRigidSphere, 0, self.tireModels[i], 25))
            self.tireBody[i].setMass(2.2)
            self.tireBody[i].fitToModel(self.tireModels[i])
            self.tireBody[i].setListener(self)
            self.tireBody[i].setDamping(0.0001)
            self.tireBody[i].setAngDamping(0.0)
            self.tireBody[i].setMaxAngularVelocity(200.0)
            self.tireBody[i].setDamageFactor(0.001)
            CPhysicsEnv.registerRigidBody(self.tireBody[i])

        pos = self.origin + CVector3(self.width * 0.45, -self.height * 0.4,
                                     -self.length * 0.45)
        self.tireBody[0].setPosition(pos)
        pos = self.origin + CVector3(-self.width * 0.45, -self.height * 0.4,
                                     -self.length * 0.45)
        self.tireBody[1].setPosition(pos)
        pos = self.origin + CVector3(self.width * 0.45, -self.height * 0.4,
                                     self.length * 0.45)
        self.tireBody[2].setPosition(pos)
        pos = self.origin + CVector3(-self.width * 0.45, -self.height * 0.4,
                                     self.length * 0.45)
        self.tireBody[3].setPosition(pos)

        joint = []
        #for i in range(2):
        #    joint.append(manage(sylphis.CJointHinge, 0, 0))
        #joint[i].setAxis1(CVector3(0,1,0))
        #    joint[i].setAxis(CVector3(1,0,0))
        #joint[i].setLoStop(0.0)
        #joint[i].setHiStop(0.0)
        #    joint[i].attach(self.body, self.tireBody[i])
        #    joint[i].setAnchor(self.tireBody[i].getPosition())

        for i in range(4):
            joint.append(manage(sylphis.CJointDoubleHinge, 0, 0))
            joint[i].attach(self.body, self.tireBody[i])
            joint[i].setAnchor(self.tireBody[i].getPosition())
            joint[i].setAxis1(CVector3(0, 1, 0))
            if i == 0:
                joint[i].setAxis2(CVector3(1, 0, 0))
            else:
                joint[i].setAxis2(CVector3(-1, 0, 0))

            joint[i].setSuspensionCFM(0.00005)
            joint[i].setSuspensionERP(0.00012)

        for i in range(2, 4):
            joint[i].setLoStop(0.0)
            joint[i].setHiStop(0.0)

        for i in range(2):
            joint[i].setLoStop(-0.6)
            joint[i].setHiStop(0.6)

        for i in range(4):
            self.tireBody[i].setSleep(False)

        self.joint = joint
Beispiel #41
0
conf = {
        "www.sina.com.cn":[
            (util.path_detect("/"),sina_entry)
        ],
        "esf.cq.fang.com":[
            (detect_by_key("level",1),esf_l1_entry),
            (detect_by_key("level",2),esf_l2_entry),
            (detect_by_key("level",3),esf_l3_entry),
        ],
        "news.sina.com.cn":[
            (util.path_detect("/"),sina_news_entry)
        ],
        "ent.sina.com.cn":[
            (util.path_detect(".*html"),sina_ent_entry)
        ],
        "finance.sina.com.cn":[
            (util.path_detect(".*html"),sina_finance_entry)
        ]
}

if "__main__" == __name__:
    rp = open("data/fang3.txt","a")
    #rp = open("data/sina_news.txt","a")
    #seeds = [{"url":"http://esf.cq.fang.com","force":True,"level":1}]
    #seeds = [{"url":"http://www.sina.com.cn","force":True}]
    seeds = [{"url":"http://esf.cq.fang.com/house-a059-b05533/","force":True,"level":3}]
    #seeds = [{"url":"http://news.sina.com.cn/","force":True,"__sleep":1}]
    #seeds = [{"url":"http://finance.sina.com.cn/chanjing/gsnews/2017-12-07/doc-ifyppemf5719998.shtml","force":True,"__sleep":1}]
    params = (seeds,conf,rp)
    util.manage(util.schedule,params)