direct.showbase.DistancePhasedNode

from direct.showbase.DistancePhasedNode import BufferedDistancePhasedNode, DistancePhasedNode

Inheritance diagram

digraph inheritance952902a6a6 { bgcolor=transparent; rankdir=BT; size="8.0, 12.0"; "BufferedDistancePhasedNode" [URL="direct.showbase.DistancePhasedNode.html#direct.showbase.DistancePhasedNode.BufferedDistancePhasedNode",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="This class is similar to DistancePhasedNode except you can also"]; "DistancePhasedNode" -> "BufferedDistancePhasedNode" [arrowsize=0.75,style=""]; "DTOOL_SUPER_BASE" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style=""]; "DirectObject" [URL="direct.showbase.DirectObject.html#direct.showbase.DirectObject.DirectObject",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="This is the class that all Direct/SAL classes should inherit from"]; "DistancePhasedNode" [URL="direct.showbase.DistancePhasedNode.html#direct.showbase.DistancePhasedNode.DistancePhasedNode",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="This class defines a PhasedObject,NodePath object that will handle"]; "PhasedObject" -> "DistancePhasedNode" [arrowsize=0.75,style=""]; "DirectObject" -> "DistancePhasedNode" [arrowsize=0.75,style=""]; "NodePath" -> "DistancePhasedNode" [arrowsize=0.75,style=""]; "NodePath" [URL="acron.core.NodePath.html#acron.core.NodePath",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "NodePath" [arrowsize=0.75,style=""]; "PhasedObject" [URL="direct.showbase.PhasedObject.html#direct.showbase.PhasedObject.PhasedObject",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="This class is governs the loading and unloading of successive"]; }
class BufferedDistancePhasedNode(name, bufferParamMap={}, autoCleanup=True, enterPrefix='enter', exitPrefix='exit', phaseCollideMask=1111 1111 1111 1111 1111 1111 1111 1111, fromCollideNode=None)[source]

Bases: DistancePhasedNode

This class is similar to DistancePhasedNode except you can also specify a buffer distance for each phase. Upon entering that phase, its distance will be increased by the buffer amount. Conversely, the distance will be decremented by that amount, back to its original size, upon leaving. In this manner, you can avoid the problem of ‘phase flicker’ as someone repeatedly steps across a static phase border.

You specify the buffer amount in the bufferParamMap parameter to __init__(). It has this format:

bufferParamMap = {'alias':(distance, bufferAmount), ...}
notify = <direct.directnotify.Notifier.Notifier object>
class DistancePhasedNode(name, phaseParamMap={}, autoCleanup=True, enterPrefix='enter', exitPrefix='exit', phaseCollideMask=1111 1111 1111 1111 1111 1111 1111 1111, fromCollideNode=None)[source]

Bases: PhasedObject, DirectObject, NodePath

This class defines a PhasedObject,NodePath object that will handle the phasing of an object in the scene graph according to its distance from some other collider object(such as an avatar).

Since it’s a NodePath, you can parent it to another object in the scene graph, or even inherit from this class to get its functionality.

What you will need to define to use this class:

  • The distances at which you want the phases to load/unload

  • Whether you want the object to clean itself up or not when exitting the largest distance sphere

  • What the load/unload functions are

  • What sort of events to listen for when a collision occurs

  • (Optional) A collision bitmask for the phase collision spheres

  • (Optional) A ‘from’ collision node to collide into our ‘into’ spheres

You specify the distances and function names by the phaseParamMap parameter to __init__(). For example:

phaseParamMap = {'Alias': distance, ...}
...
def loadPhaseAlias(self):
    pass
def unloadPhaseAlias(self):
    pass

If the ‘fromCollideNode’ is supplied, we will set up our own traverser and only traverse below this node. It will send out events of the form ‘<enterPrefix>%in’ and ‘<exitPrefix>%in’ in order to match the main collision traverser’s patterns. Note that this will only be used after a reset or phase change in order to fully transition to the correct phase in a single pass. Most of the time, it will be reacting to events from the main collision traverser.

Important

The following only applies when autoCleanup is True: If you unload the last phase, by either calling cleanup() or by exiting the last phase’s distance, you will need to explicitly call reset() to get the distance phasing to work again. This was done so if either this node or the collider is removed from the scene graph (e.g. avatar teleport), the phased object will clean itself up automatically.

notify = <direct.directnotify.Notifier.Notifier object>