cameras: redo some stuff
This commit is contained in:
parent
4af8d55d09
commit
d77e593932
4 changed files with 15 additions and 14 deletions
|
@ -13,6 +13,7 @@ class DistributedElectionCamera(DistributedNode):
|
|||
|
||||
def generate(self):
|
||||
self.assign(render.attachNewNode('DistributedElectionCamera'))
|
||||
self.camAttach = self.attachNewNode('CameraAttach')
|
||||
DistributedNode.generate(self)
|
||||
camera = loader.loadModel('phase_4/models/events/camera.egg')
|
||||
camera.reparentTo(self)
|
||||
|
@ -41,7 +42,8 @@ class DistributedElectionCamera(DistributedNode):
|
|||
self.posInterval(2.5, (x, y, z), blendType='easeInOut'),
|
||||
)
|
||||
movement = Sequence(
|
||||
Parallel(self.posInterval(time-elapsed, Point3(x, y, z)), self.camBody.hprInterval(time-elapsed, (h, p, 0))),
|
||||
Parallel(self.posInterval(time, Point3(x, y, z)), self.camBody.hprInterval(time, (h + 180, p, 0)), self.camAttach.hprInterval(time, (h, p, 0))),
|
||||
Func(idleInterval.loop)
|
||||
)
|
||||
movement.start()
|
||||
movement.setT(elapsed)
|
||||
|
|
|
@ -27,7 +27,7 @@ class DistributedElectionCameraAI(DistributedNodeAI):
|
|||
time = dist/10.0 + 1.5 #constant rate of 10 unit/s with some extra time just in case
|
||||
self.b_setState('Move', globalClockDelta.getRealNetworkTime(), x, y, z, h, p, 0)
|
||||
taskMgr.remove('finish%d' % self.doId)
|
||||
taskMgr.doMethodLater(time, self.__finishMove, 'finish%d' % self.doId, extraArgs=[x, y, z, h, p])
|
||||
taskMgr.doMethodLater(time, self.__finishMove, 'finish%d' % self.doId, extraArgs=[x, y, z])
|
||||
|
||||
|
||||
def _dist(self, x, y, z):
|
||||
|
@ -37,19 +37,21 @@ class DistributedElectionCameraAI(DistributedNodeAI):
|
|||
x, y, z = object.getPos()
|
||||
dist = self._dist(x, y - 10.0, z + 7.0)
|
||||
time = dist/10.0 + 1.5
|
||||
self.b_setState('Follow', globalClockDelta.getRealNetworkTime(), 0, -15, 7, 0, 345, object.doId)
|
||||
self.b_setState('Follow', globalClockDelta.getRealNetworkTime(), 0, -15, 7, -90, -15, object.doId)
|
||||
taskMgr.remove('finish%d' % self.doId)
|
||||
taskMgr.doMethodLater(time, self.__finishMove, 'finish%d' % self.doId, extraArgs=[0, -15, 7, 0, 345])
|
||||
taskMgr.doMethodLater(time, self.__finishMove, 'finish%d' % self.doId, extraArgs=[0, -15, 7])
|
||||
|
||||
def _watch(self, object):
|
||||
x, y, z = object.getPos()
|
||||
dist = self._dist(x, y + 10.0, z + 7.0)
|
||||
time = dist/10.0 + 1.5
|
||||
self.b_setState('Follow', globalClockDelta.getRealNetworkTime(), 0, 15, 7, 180, 345, object.doId)
|
||||
self.b_setState('Follow', globalClockDelta.getRealNetworkTime(), 0, 15, 7, 90, -15, object.doId)
|
||||
taskMgr.remove('finish%d' % self.doId)
|
||||
taskMgr.doMethodLater(time, self.__finishMove, 'finish%d' % self.doId, extraArgs=[0, 15, 7, 180, 345])
|
||||
taskMgr.doMethodLater(time, self.__finishMove, 'finish%d' % self.doId, extraArgs=[0, 15, 7])
|
||||
|
||||
|
||||
|
||||
def __finishMove(self, x, y, z, h, p):
|
||||
self.b_setPosHpr(x, y, z, h, p, 0)
|
||||
def __finishMove(self, x, y, z):
|
||||
self.setPos(x, y, z)
|
||||
self.d_setXY(x, y)
|
||||
self.d_setZ(z)
|
|
@ -69,15 +69,12 @@ class DistributedElectionCameraManager(DistributedObject):
|
|||
self.mainCam = new
|
||||
if self.mainCam != 0:
|
||||
if new in self.cr.doId2do:
|
||||
self.camera.reparentTo(self.cr.doId2do[new])
|
||||
if self.cameraViewEnabled:
|
||||
camNP = NodePath(self.winCam)
|
||||
camNP.reparentTo(self.cr.doId2do[new])
|
||||
self.camera.reparentTo(self.cr.doId2do[new].camAttach)
|
||||
else:
|
||||
self.acceptOnce('generate-%d' % new, self.setCam)
|
||||
|
||||
def setCam(self, cam):
|
||||
self.camera.reparentTo(cam)
|
||||
self.camera.reparentTo(cam.camAttach)
|
||||
|
||||
def setCameraIds(self, ids):
|
||||
self.cameraIds = ids
|
||||
|
|
|
@ -17,7 +17,7 @@ class DistributedElectionCameraManagerAI(DistributedObjectAI):
|
|||
cam = DistributedElectionCameraAI(simbase.air)
|
||||
cam.setState('Waiting', globalClockDelta.getRealNetworkTime(), 31, -5, 8, -80, -5, 0)
|
||||
cam.generateWithRequired(2000)
|
||||
cam.b_setPosHpr(0, 0, 10, -90, -5, 0)
|
||||
cam.b_setPosHpr(0, 0, 10, 0, 0, 0)
|
||||
cameras.append(cam.getDoId())
|
||||
self.setMainCamera(cameras[0])
|
||||
self.setCameraIds(cameras)
|
||||
|
|
Loading…
Reference in a new issue