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
15#include "datagram.h"
16#include "datagramIterator.h"
17#include "bamReader.h"
18#include "bamWriter.h"
19
20TypeHandle 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 */
57get_slider() const {
58 return _char_slider->_value;
59}
60
61/**
62 * Tells the BamReader how to create objects of type CharacterVertexSlider.
63 */
68
69/**
70 * Writes the contents of this object to the datagram for shipping out to a
71 * Bam file.
72 */
74write_datagram(BamWriter *manager, Datagram &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 */
85complete_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 */
100TypedWritable *CharacterVertexSlider::
101make_from_bam(const FactoryParams &params) {
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 */
116void CharacterVertexSlider::
117fillin(DatagramIterator &scan, BamReader *manager) {
118 VertexSlider::fillin(scan, manager);
119
120 manager->read_pointer(scan);
121}
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition bamReader.I:177
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
This is a morph slider within the character.
This is a specialization on VertexSlider that returns the slider value associated with a particular C...
static void register_with_read_factory()
Tells the BamReader how to create objects of type CharacterVertexSlider.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual PN_stdfloat get_slider() const
Returns the current slider value.
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
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
Encodes a string name in a hash table, mapping it to a pointer.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
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().
This is an abstract base class that retains some slider value, which is a linear value that typically...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.