Panda3D

Loading...
Searching...
No Matches
characterVertexSlider.cxx
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file characterVertexSlider.cxx
10 * @author drose
11 * @date 2005-03-28
12 */
13
14#include "characterVertexSlider.h"
15#include "datagram.h"
16#include "datagramIterator.h"
17#include "bamReader.h"
18#include "bamWriter.h"
19
20 TypeHandle CharacterVertexSlider::_type_handle;
21
22/**
23 * Constructs an invalid object; used only by the bam loader.
24 */
25CharacterVertexSlider::
26CharacterVertexSlider() :
27 VertexSlider(InternalName::get_root())
28{
29}
30
31/**
32 * Constructs a new object that converts vertices from the indicated joint's
33 * coordinate space, into the other indicated joint's space.
34 */
35CharacterVertexSlider::
36CharacterVertexSlider(CharacterSlider *char_slider) :
37 VertexSlider(InternalName::make(char_slider->get_name())),
38 _char_slider(char_slider)
39{
40 // Tell the char_slider that we need to be informed when it moves.
41 _char_slider->_vertex_sliders.insert(this);
42}
43
44/**
45 *
46 */
47CharacterVertexSlider::
48~CharacterVertexSlider() {
49 // Tell the char_slider to stop informing us about its motion.
50 _char_slider->_vertex_sliders.erase(this);
51}
52
53/**
54 * Returns the current slider value.
55 */
56PN_stdfloat CharacterVertexSlider::
57 get_slider() const {
58 return _char_slider->_value;
59}
60
61/**
62 * Tells the BamReader how to create objects of type CharacterVertexSlider.
63 */
64 void CharacterVertexSlider::
65 register_with_read_factory() {
66 BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
67}
68
69/**
70 * Writes the contents of this object to the datagram for shipping out to a
71 * Bam file.
72 */
73 void CharacterVertexSlider::
74 write_datagram(BamWriter *manager, Datagram &dg) {
75 VertexSlider::write_datagram(manager, dg);
76
77 manager->write_pointer(dg, _char_slider);
78}
79
80/**
81 * Receives an array of pointers, one for each time manager->read_pointer()
82 * was called in fillin(). Returns the number of pointers processed.
83 */
84 int CharacterVertexSlider::
85 complete_pointers(TypedWritable **p_list, BamReader *manager) {
86 int pi = VertexSlider::complete_pointers(p_list, manager);
87
88 _char_slider = DCAST(CharacterSlider, p_list[pi++]);
89 _char_slider->_vertex_sliders.insert(this);
90 _name = InternalName::make(_char_slider->get_name());
91
92 return pi;
93}
94
95/**
96 * This function is called by the BamReader's factory when a new object of
97 * type CharacterVertexSlider is encountered in the Bam file. It should
98 * create the CharacterVertexSlider and extract its information from the file.
99 */
100 TypedWritable *CharacterVertexSlider::
101make_from_bam(const FactoryParams &params) {
102 CharacterVertexSlider *object = new CharacterVertexSlider;
103 DatagramIterator scan;
104 BamReader *manager;
105
106 parse_params(params, scan, manager);
107 object->fillin(scan, manager);
108
109 return object;
110}
111
112/**
113 * This internal function is called by make_from_bam to read in all of the
114 * relevant data from the BamFile for the new CharacterVertexSlider.
115 */
116 void CharacterVertexSlider::
117fillin(DatagramIterator &scan, BamReader *manager) {
118 VertexSlider::fillin(scan, manager);
119
120 manager->read_pointer(scan);
121}
bamReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
parse_params
void parse_params(const FactoryParams &params, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
Definition bamReader.I:275
bamWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
characterVertexSlider.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
BamReader::read_pointer
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
Definition bamReader.cxx:610
BamReader::get_factory
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition bamReader.I:177
BamWriter::write_pointer
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
Definition bamWriter.cxx:317
CharacterVertexSlider
This is a specialization on VertexSlider that returns the slider value associated with a particular C...
Definition characterVertexSlider.h:26
CharacterVertexSlider::register_with_read_factory
static void register_with_read_factory()
Tells the BamReader how to create objects of type CharacterVertexSlider.
Definition characterVertexSlider.cxx:65
CharacterVertexSlider::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition characterVertexSlider.cxx:74
CharacterVertexSlider::get_slider
virtual PN_stdfloat get_slider() const
Returns the current slider value.
Definition characterVertexSlider.cxx:57
CharacterVertexSlider::complete_pointers
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
Definition characterVertexSlider.cxx:85
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition datagramIterator.h:30
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition factoryParams.h:36
Factory::register_factory
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
Definition factory.I:73
InternalName
Encodes a string name in a hash table, mapping it to a pointer.
Definition internalName.h:38
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
TypedWritable
Base class for objects that can be written to and read from Bam files.
Definition typedWritable.h:35
TypedWritable::complete_pointers
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
Definition typedWritable.cxx:81
VertexSlider
This is an abstract base class that retains some slider value, which is a linear value that typically...
Definition vertexSlider.h:37
VertexSlider::get_name
get_name
Returns the name of this particular slider.
Definition vertexSlider.h:43
VertexSlider::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition vertexSlider.cxx:77
datagramIterator.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
datagram.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.