Panda3D

Loading...
Searching...
No Matches
eggSliderData.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 eggSliderData.cxx
10 * @author drose
11 * @date 2001-02-26
12 */
13
14#include "eggSliderData.h"
15#include "eggVertexPointer.h"
16#include "eggScalarTablePointer.h"
17#include "eggSliderPointer.h"
18#include "dcast.h"
19#include "eggPrimitive.h"
20#include "eggVertex.h"
21#include "eggSAnimData.h"
22#include "indent.h"
23
24 TypeHandle EggSliderData::_type_handle;
25
26/**
27 *
28 */
29EggSliderData::
30EggSliderData(EggCharacterCollection *collection,
31 EggCharacterData *char_data) :
32 EggComponentData(collection, char_data)
33{
34}
35
36/**
37 * Returns the value corresponding to this slider position in the nth frame in
38 * the indicated model.
39 */
40 double EggSliderData::
41 get_frame(int model_index, int n) const {
42 EggBackPointer *back = get_model(model_index);
43 if (back == nullptr) {
44 return 0.0;
45 }
46
47 EggSliderPointer *slider;
48 DCAST_INTO_R(slider, back, 0.0);
49
50 return slider->get_frame(n);
51}
52
53/**
54 * Adds the indicated vertex, primitive, or morph table to the data.
55 */
56 void EggSliderData::
57 add_back_pointer(int model_index, EggObject *egg_object) {
58 if (egg_object->is_of_type(EggPrimitive::get_class_type())) {
59 // A primitive!
60 EggBackPointer *back = get_model(model_index);
61 if (back == nullptr) {
62 back = new EggVertexPointer(egg_object);
63 set_model(model_index, back);
64 }
65
66 } else if (egg_object->is_of_type(EggVertex::get_class_type())) {
67 // A vertex!
68 EggBackPointer *back = get_model(model_index);
69 if (back == nullptr) {
70 back = new EggVertexPointer(egg_object);
71 set_model(model_index, back);
72 }
73
74 } else if (egg_object->is_of_type(EggSAnimData::get_class_type())) {
75 // A slider animation table! Woo hoo!
76 EggBackPointer *back = get_model(model_index);
77 if (back == nullptr) {
78 back = new EggScalarTablePointer(egg_object);
79 set_model(model_index, back);
80 }
81
82 } else {
83 nout << "Invalid object added to slider for back pointer.\n";
84 }
85}
86
87/**
88 *
89 */
90 void EggSliderData::
91write(std::ostream &out, int indent_level) const {
92 indent(out, indent_level)
93 << "Slider " << get_name()
94 << " (models:";
95 int num_models = get_num_models();
96 for (int model_index = 0; model_index < num_models; model_index++) {
97 if (has_model(model_index)) {
98 out << " " << model_index;
99 }
100 }
101 out << ")\n";
102}
EggBackPointer
This stores a pointer from an EggJointData or EggSliderData object back to the referencing data in an...
Definition eggBackPointer.h:31
EggCharacterCollection
Represents a set of characters, as read and collected from possibly several model and/or animation eg...
Definition eggCharacterCollection.h:32
EggCharacterData
Represents a single character, as read and collected from several models and animation files.
Definition eggCharacterData.h:52
EggComponentData
This is the base class of both EggJointData and EggSliderData.
Definition eggComponentData.h:34
EggComponentData::get_model
EggBackPointer * get_model(int model_index) const
Returns the back pointer to an egg file for the indicated model if it exists, or NULL if it does not.
Definition eggComponentData.I:42
EggComponentData::get_num_models
int get_num_models() const
Returns the maximum number of back pointers this component may have.
Definition eggComponentData.I:21
EggComponentData::has_model
bool has_model(int model_index) const
Returns true if the component has a back pointer to an egg file somewhere for the indicated model,...
Definition eggComponentData.I:30
EggComponentData::set_model
void set_model(int model_index, EggBackPointer *back)
Sets the back_pointer associated with the given model_index.
Definition eggComponentData.cxx:122
EggScalarTablePointer
This stores a pointer back to an EggSAnimData table (i.e.
Definition eggScalarTablePointer.h:29
EggSliderData::add_back_pointer
virtual void add_back_pointer(int model_index, EggObject *egg_object)
Adds the indicated vertex, primitive, or morph table to the data.
Definition eggSliderData.cxx:57
EggSliderData::get_frame
double get_frame(int model_index, int n) const
Returns the value corresponding to this slider position in the nth frame in the indicated model.
Definition eggSliderData.cxx:41
EggSliderPointer
This is a base class for EggVertexPointer and EggScalarTablePointer.
Definition eggSliderPointer.h:26
EggVertexPointer
This stores a pointer back to a <Vertex>, or to a particular pritimive like a <Polygon>,...
Definition eggVertexPointer.h:28
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
TypedObject::is_of_type
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
Definition typedObject.I:28
dcast.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
eggPrimitive.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
eggSAnimData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
eggScalarTablePointer.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
eggSliderData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
eggSliderPointer.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
eggVertexPointer.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
eggVertex.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
indent
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition indent.cxx:20
indent.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.