Panda3D
mayaBlendDesc.cxx
1 // Filename: mayaBlendDesc.cxx
2 // Created by: drose (10Feb04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "mayaBlendDesc.h"
16 #include "config_mayaegg.h"
17 
18 TypeHandle MayaBlendDesc::_type_handle;
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: MayaBlendDesc::Constructor
22 // Access: Public
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 MayaBlendDesc::
26 MayaBlendDesc(MFnBlendShapeDeformer &deformer, int weight_index) :
27  _deformer(deformer.object()),
28  _weight_index(weight_index)
29 {
30  ostringstream strm;
31  strm << _deformer.name().asChar() << "." << _weight_index;
32  set_name(strm.str());
33 
34  _anim = (EggSAnimData *)NULL;
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: MayaBlendDesc::Destructor
39 // Access: Public
40 // Description:
41 ////////////////////////////////////////////////////////////////////
42 MayaBlendDesc::
43 ~MayaBlendDesc() {
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: MayaBlendDesc::set_slider
48 // Access: Public
49 // Description: Moves the Maya slider associated with this blend
50 // shape to the indicated value. This will move all the
51 // affected vertices.
52 ////////////////////////////////////////////////////////////////////
53 void MayaBlendDesc::
54 set_slider(PN_stdfloat value) {
55  MStatus status = _deformer.setWeight(_weight_index, value);
56  if (!status) {
57  mayaegg_cat.warning()
58  << "Unable to set slider " << get_name() << "\n";
59  }
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: MayaBlendDesc::get_slider
64 // Access: Public
65 // Description: Returns the current position of the Maya slider
66 // associated with this blend shape.
67 ////////////////////////////////////////////////////////////////////
68 PN_stdfloat MayaBlendDesc::
69 get_slider() const {
70  return _deformer.weight(_weight_index);
71 }
72 
73 ////////////////////////////////////////////////////////////////////
74 // Function: MayaBlendDesc::clear_egg
75 // Access: Private
76 // Description: Clears the egg pointers from this blend desc.
77 ////////////////////////////////////////////////////////////////////
78 void MayaBlendDesc::
79 clear_egg() {
80  _anim = (EggSAnimData *)NULL;
81 }
Corresponding to an <S$Anim> entry, this stores a single column of numbers, for instance for a morph ...
Definition: eggSAnimData.h:28
void set_slider(PN_stdfloat value)
Moves the Maya slider associated with this blend shape to the indicated value.
PN_stdfloat get_slider() const
Returns the current position of the Maya slider associated with this blend shape. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85