BamReader
from panda3d.core import BamReader
- class BamReader
Bases:
BamEnums
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a BamWriter.
A Bam file can be thought of as a linear collection of objects. Each object is an instance of a class that inherits, directly or indirectly, from TypedWritable. The objects may include pointers to other objects within the Bam file; the BamReader automatically manages these (with help from code within each class) and restores the pointers correctly.
This is the abstract interface and does not specifically deal with disk files, but rather with a DatagramGenerator of some kind, which is simply a linear source of Datagrams. It is probably from a disk file, but it might conceivably be streamed directly from a network or some such nonsense.
Bam files are most often used to store scene graphs or subgraphs, and by convention they are given filenames ending in the extension “.bam” when they are used for this purpose. However, a Bam file may store any arbitrary list of TypedWritable objects; in this more general usage, they are given filenames ending in “.boo” to differentiate them from the more common scene graph files.
See also BamFile, which defines a higher-level interface to read and write Bam files on disk.
Inheritance diagram
- __init__(*args, **kwargs)
- changePointer()
C++ Interface: change_pointer(const BamReader self, const TypedWritable orig_pointer, const TypedWritable new_pointer)
- /**
Indicates that an object recently read from the bam stream should be
replaced with a new object. Any future occurrences of the original object
in the stream will henceforth return the new object instead.
The return value is true if the replacement was successfully made, or false
if the object was not read from the stream (or if change_pointer had
already been called on it).
*/
- change_pointer()
C++ Interface: change_pointer(const BamReader self, const TypedWritable orig_pointer, const TypedWritable new_pointer)
- /**
Indicates that an object recently read from the bam stream should be
replaced with a new object. Any future occurrences of the original object
in the stream will henceforth return the new object instead.
The return value is true if the replacement was successfully made, or false
if the object was not read from the stream (or if change_pointer had
already been called on it).
*/
- file_endian
- file_stdfloat_double
- file_version
- filename
- getCurrentMajorVer()
C++ Interface: get_current_major_ver(BamReader self)
- /**
Returns the major version number of Bam files supported by the current code
base. This must match get_file_major_ver() in order to successfully read a
file.
*/
- getCurrentMinorVer()
C++ Interface: get_current_minor_ver(BamReader self)
- /**
Returns the minor version number of Bam files supported by the current code
base. This must match or exceed get_file_minor_ver() in order to
successfully read a file.
*/
- getFileEndian()
C++ Interface: get_file_endian(BamReader self)
- /**
Returns the endian preference indicated by the Bam file currently being
read. This does not imply that every number is stored using the indicated
convention, but individual objects may choose to respect this flag when
recording data.
*/
- getFileMajorVer()
C++ Interface: get_file_major_ver(BamReader self)
- /**
Returns the major version number of the Bam file currently being read.
*/
- getFileMinorVer()
C++ Interface: get_file_minor_ver(BamReader self)
- /**
Returns the minor version number of the Bam file currently being read.
*/
- getFileStdfloatDouble()
C++ Interface: get_file_stdfloat_double(BamReader self)
- /**
Returns true if the file stores all “standard” floats as 64-bit doubles, or
false if they are 32-bit floats. This is determined by the compilation
flags of the version of Panda that generated this file.
*/
- getFileVersion()
C++ Interface: get_file_version(BamReader self)
- getFilename()
C++ Interface: get_filename(BamReader self)
- /**
If a BAM is a file, then the BamReader should contain the name of the file.
This enables the reader to interpret pathnames in the BAM as relative to
the directory containing the BAM.
*/
- getLoaderOptions()
C++ Interface: get_loader_options(BamReader self)
- /**
Returns the LoaderOptions passed to the loader when the model was
requested, if any.
*/
- getSource()
C++ Interface: get_source(const BamReader self)
- /**
Returns the current source of the BamReader as set by set_source() or the
constructor.
*/
- get_current_major_ver()
C++ Interface: get_current_major_ver(BamReader self)
- /**
Returns the major version number of Bam files supported by the current code
base. This must match get_file_major_ver() in order to successfully read a
file.
*/
- get_current_minor_ver()
C++ Interface: get_current_minor_ver(BamReader self)
- /**
Returns the minor version number of Bam files supported by the current code
base. This must match or exceed get_file_minor_ver() in order to
successfully read a file.
*/
- get_file_endian()
C++ Interface: get_file_endian(BamReader self)
- /**
Returns the endian preference indicated by the Bam file currently being
read. This does not imply that every number is stored using the indicated
convention, but individual objects may choose to respect this flag when
recording data.
*/
- get_file_major_ver()
C++ Interface: get_file_major_ver(BamReader self)
- /**
Returns the major version number of the Bam file currently being read.
*/
- get_file_minor_ver()
C++ Interface: get_file_minor_ver(BamReader self)
- /**
Returns the minor version number of the Bam file currently being read.
*/
- get_file_stdfloat_double()
C++ Interface: get_file_stdfloat_double(BamReader self)
- /**
Returns true if the file stores all “standard” floats as 64-bit doubles, or
false if they are 32-bit floats. This is determined by the compilation
flags of the version of Panda that generated this file.
*/
- get_file_version()
C++ Interface: get_file_version(BamReader self)
- get_filename()
C++ Interface: get_filename(BamReader self)
- /**
If a BAM is a file, then the BamReader should contain the name of the file.
This enables the reader to interpret pathnames in the BAM as relative to
the directory containing the BAM.
*/
- get_loader_options()
C++ Interface: get_loader_options(BamReader self)
- /**
Returns the LoaderOptions passed to the loader when the model was
requested, if any.
*/
- get_source()
C++ Interface: get_source(const BamReader self)
- /**
Returns the current source of the BamReader as set by set_source() or the
constructor.
*/
- init()
C++ Interface: init(const BamReader self)
- /**
Initializes the BamReader prior to reading any objects from its source.
This includes reading the Bam header.
This returns true if the BamReader successfully initialized, false
otherwise.
*/
- isEof()
C++ Interface: is_eof(BamReader self)
- /**
Returns true if the reader has reached end-of-file, false otherwise. This
call is only valid after a call to read_object().
*/
- is_eof()
C++ Interface: is_eof(BamReader self)
- /**
Returns true if the reader has reached end-of-file, false otherwise. This
call is only valid after a call to read_object().
*/
- loader_options
- readObject()
C++ Interface: read_object(const BamReader self)
- /**
Reads a single object from the Bam file. If the object type is known, a
new object of the appropriate type is created and returned; otherwise, NULL
is returned. NULL is also returned when the end of the file is reached.
is_eof() may be called to differentiate between these two cases.
This may be called repeatedly to extract out all the objects in the Bam
file, but typically (especially for scene graph files, indicated with the
.bam extension), only one object is retrieved directly from the Bam file:
the root of the scene graph. The remaining objects will all be retrieved
recursively by the first object.
Note that the object returned may not yet be complete. In particular, some
of its pointers may not be filled in; you must call resolve() to fill in
all the available pointers before you can safely use any objects returned
by read_object().
This flavor of read_object() requires the caller to know what type of
object it has received in order to properly manage the reference counts.
*/
- /**
Reads a single object from the Bam file.
This flavor of read_object() returns both a TypedWritable and a
ReferenceCount pointer to the same object, so the reference count may be
tracked reliably, without having to know precisely what type of object we
have.
@return true on success, or false on failure.
*/
- read_object()
C++ Interface: read_object(const BamReader self)
- /**
Reads a single object from the Bam file. If the object type is known, a
new object of the appropriate type is created and returned; otherwise, NULL
is returned. NULL is also returned when the end of the file is reached.
is_eof() may be called to differentiate between these two cases.
This may be called repeatedly to extract out all the objects in the Bam
file, but typically (especially for scene graph files, indicated with the
.bam extension), only one object is retrieved directly from the Bam file:
the root of the scene graph. The remaining objects will all be retrieved
recursively by the first object.
Note that the object returned may not yet be complete. In particular, some
of its pointers may not be filled in; you must call resolve() to fill in
all the available pointers before you can safely use any objects returned
by read_object().
This flavor of read_object() requires the caller to know what type of
object it has received in order to properly manage the reference counts.
*/
- /**
Reads a single object from the Bam file.
This flavor of read_object() returns both a TypedWritable and a
ReferenceCount pointer to the same object, so the reference count may be
tracked reliably, without having to know precisely what type of object we
have.
@return true on success, or false on failure.
*/
- registerFactory()
C++ Interface: register_factory(TypeHandle handle, object func)
- /**
Registers a factory function that is called when an object of the given
type is encountered within the .bam stream.
@param user_data an optional pointer to be passed along to the function.
*/
- register_factory()
C++ Interface: register_factory(TypeHandle handle, object func)
- /**
Registers a factory function that is called when an object of the given
type is encountered within the .bam stream.
@param user_data an optional pointer to be passed along to the function.
*/
- resolve()
C++ Interface: resolve(const BamReader self)
- /**
This may be called at any time during processing of the Bam file to resolve
all the known pointers so far. It is usually called at the end of the
processing, after all objects have been read, which is generally the best
time to call it.
This must be called at least once after reading a particular object via
read_object() in order to validate that object.
The return value is true if all objects have been resolved, or false if
some objects are still outstanding (in which case you will need to call
resolve() again later).
*/
- setLoaderOptions()
C++ Interface: set_loader_options(const BamReader self, const LoaderOptions options)
- /**
Specifies the LoaderOptions for this BamReader.
*/
- setSource()
C++ Interface: set_source(const BamReader self, DatagramGenerator source)
- /**
Changes the source of future datagrams for this BamReader. This also
implicitly calls init() if it has not already been called.
*/
- set_loader_options()
C++ Interface: set_loader_options(const BamReader self, const LoaderOptions options)
- /**
Specifies the LoaderOptions for this BamReader.
*/
- set_source()
C++ Interface: set_source(const BamReader self, DatagramGenerator source)
- /**
Changes the source of future datagrams for this BamReader. This also
implicitly calls init() if it has not already been called.
*/
- source