from direct.distributed.DistributedSmoothNode import DistributedSmoothNode, globalActivateSmoothing
DistributedSmoothNode module: contains the DistributedSmoothNode class
- class DistributedSmoothNode(cr)
This specializes DistributedNode to add functionality to smooth motion over time, via the SmoothMover C++ object defined in DIRECT.
- __init__(self, cr)
- activateSmoothing(self, smoothing, prediction)
Enables or disables the smoothing of other avatars’ motion. This used to be a global flag, but now it is specific to each avatar instance. However, see globalActivateSmoothing() in this module.
If smoothing is off, no kind of smoothing will be performed, regardless of the setting of prediction.
This is not necessarily predictive smoothing; if predictive smoothing is off, avatars will be lagged by a certain factor to achieve smooth motion. Otherwise, if predictive smoothing is on, avatars will be drawn as nearly as possible in their current position, by extrapolating from old position reports.
This assumes you have a client repository that knows its localAvatarDoId – stored in self.cr.localAvatarDoId
- clearSmoothing(self, bogus=None)
- d_returnResync(self, avId, timestampB, serverTime, uncertainty)
- d_setParent(self, parentToken)
- d_suggestResync(self, avId, timestampA, timestampB, serverTime, uncertainty)
- doSmoothTask(self, task)
This forces the node to reposition itself to its latest known position. This may result in a pop as the node skips the last of its lerp points.
- peerToPeerResync(self, avId, timestamp, serverTime, uncertainty)
This function re-reads the position from the node itself and clears any old position reports for the node. This should be used whenever show code bangs on the node position and expects it to stick.
- returnResync(self, avId, timestampB, serverTimeSec, serverTimeUSec, uncertainty)
A reply sent by a client whom we recently sent suggestResync to, this reports the client’s new delta information so we can adjust our clock as well.
- setComponentH(self, h)
- setComponentL(self, l)
- setComponentP(self, p)
- setComponentR(self, r)
- setComponentT(self, timestamp)
- setComponentTLive(self, timestamp)
- setComponentX(self, x)
- setComponentY(self, y)
- setComponentZ(self, z)
- setSmH(self, h, timestamp=None)
- setSmHpr(self, h, p, r, timestamp=None)
- setSmPos(self, x, y, z, timestamp=None)
- setSmPosHpr(self, x, y, z, h, p, r, timestamp=None)
- setSmPosHprL(self, l, x, y, z, h, p, r, timestamp=None)
- setSmStop(self, timestamp=None)
- setSmXY(self, x, y, timestamp=None)
- setSmXYH(self, x, y, h, timestamp)
- setSmXYZH(self, x, y, z, h, timestamp=None)
- setSmXZ(self, x, z, timestamp=None)
- setSmZ(self, z, timestamp=None)
- setSmoothWrtReparents(self, flag)
This function updates the position of the node to its computed smoothed position. This may be overridden by a derived class to specialize the behavior.
This function starts the task that ensures the node is positioned correctly every frame. However, while the task is running, you won’t be able to lerp the node or directly position it.
This function stops the task spawned by startSmooth(), and allows show code to move the node around directly.
- suggestResync(self, avId, timestampA, timestampB, serverTimeSec, serverTimeUSec, uncertainty)
This message is sent from one client to another when the other client receives a timestamp from this client that is so far out of date as to suggest that one or both clients needs to resynchronize their clock information.
- wrtReparentTo(self, parent)
- globalActivateSmoothing(smoothing, prediction)
Globally activates or deactivates smoothing and prediction on all DistributedSmoothNodes currently in existence, or yet to be generated.