Blender  V3.3
AnimationImporter.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #pragma once
8 
9 #include <map>
10 #include <vector>
11 
12 #include "COLLADAFWAnimation.h"
13 #include "COLLADAFWAnimationCurve.h"
14 #include "COLLADAFWAnimationList.h"
15 #include "COLLADAFWCamera.h"
16 #include "COLLADAFWEffect.h"
17 #include "COLLADAFWInstanceGeometry.h"
18 #include "COLLADAFWLight.h"
19 #include "COLLADAFWMaterial.h"
20 #include "COLLADAFWNode.h"
21 #include "COLLADAFWUniqueId.h"
22 
23 #include "BKE_context.h"
24 
25 #include "DNA_anim_types.h"
26 
27 #include "DNA_camera_types.h"
28 #include "DNA_light_types.h"
29 #include "DNA_object_types.h"
30 #include "DNA_scene_types.h"
31 
32 //#include "ArmatureImporter.h"
33 #include "TransformReader.h"
34 
35 #include "collada_internal.h"
36 
37 class ArmatureImporter;
38 
40  public:
41  /* virtual void change_eul_to_quat(Object *ob, bAction *act) = 0; */
42 };
43 
45  private:
46  bContext *mContext;
47  ArmatureImporter *armature_importer;
48  Scene *scene;
49 
50  std::map<COLLADAFW::UniqueId, std::vector<FCurve *>> curve_map;
51  std::map<COLLADAFW::UniqueId, TransformReader::Animation> uid_animated_map;
52  // std::map<bActionGroup*, std::vector<FCurve*> > fcurves_actionGroup_map;
53  std::map<COLLADAFW::UniqueId, const COLLADAFW::AnimationList *> animlist_map;
54  std::vector<FCurve *> unused_curves;
55  std::map<COLLADAFW::UniqueId, Object *> joint_objects;
56 
57  FCurve *create_fcurve(int array_index, const char *rna_path);
58 
59  void add_bezt(FCurve *fcu,
60  float frame,
61  float value,
63 
67  void animation_to_fcurves(COLLADAFW::AnimationCurve *curve);
68 
69  void fcurve_deg_to_rad(FCurve *cu);
70  void fcurve_scale(FCurve *cu, int scale);
71 
72  void fcurve_is_used(FCurve *fcu);
73 
74  void add_fcurves_to_object(Main *bmain,
75  Object *ob,
76  std::vector<FCurve *> &curves,
77  char *rna_path,
78  int array_index,
79  Animation *animated);
80 
81  int typeFlag;
82 
83  std::string import_from_version;
84 
85  enum lightAnim {
86  // INANIMATE = 0,
87  LIGHT_COLOR = 2,
88  LIGHT_FOA = 4,
89  LIGHT_FOE = 8,
90  };
91 
92  enum cameraAnim {
93  // INANIMATE = 0,
94  CAMERA_XFOV = 2,
95  CAMERA_XMAG = 4,
96  CAMERA_YFOV = 8,
97  CAMERA_YMAG = 16,
98  CAMERA_ZFAR = 32,
99  CAMERA_ZNEAR = 64,
100  };
101 
102  enum matAnim {
103  MATERIAL_SHININESS = 2,
104  MATERIAL_SPEC_COLOR = 4,
105  MATERIAL_DIFF_COLOR = 1 << 3,
106  MATERIAL_TRANSPARENCY = 1 << 4,
107  MATERIAL_IOR = 1 << 5,
108  };
109 
110  enum AnimationType {
111  BC_INANIMATE = 0,
112  BC_NODE_TRANSFORM = 1,
113  };
114 
115  struct AnimMix {
116  int transform;
117  int light;
118  int camera;
119  int material;
120  int texture;
121  };
122 
123  public:
125  : TransformReader(conv), mContext(C), armature_importer(arm), scene(scene)
126  {
127  }
128 
130 
131  void set_import_from_version(std::string import_from_version);
132  bool write_animation(const COLLADAFW::Animation *anim);
133 
135  bool write_animation_list(const COLLADAFW::AnimationList *animlist);
136 
142  void read_node_transform(COLLADAFW::Node *node, Object *ob);
143 #if 0
144  virtual void change_eul_to_quat(Object *ob, bAction *act);
145 #endif
146 
147  void translate_Animations(COLLADAFW::Node *Node,
148  std::map<COLLADAFW::UniqueId, COLLADAFW::Node *> &root_map,
149  std::multimap<COLLADAFW::UniqueId, Object *> &object_map,
150  std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map,
151  std::map<COLLADAFW::UniqueId, Material *> uid_material_map);
152 
157  AnimMix *get_animation_type(
158  const COLLADAFW::Node *node,
159  std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map);
160 
161  void apply_matrix_curves(Object *ob,
162  std::vector<FCurve *> &animcurves,
163  COLLADAFW::Node *root,
164  COLLADAFW::Node *node,
165  COLLADAFW::Transformation *tm);
166 
168  std::vector<FCurve *> &animcurves,
169  COLLADAFW::Node *root,
170  COLLADAFW::Node *node,
171  COLLADAFW::Transformation *tm);
172 
177  void Assign_transform_animations(COLLADAFW::Transformation *transform,
178  const COLLADAFW::AnimationList::AnimationBinding *binding,
179  std::vector<FCurve *> *curves,
180  bool is_joint,
181  char *joint_path);
182 
187  void Assign_color_animations(const COLLADAFW::UniqueId &listid,
188  ListBase *AnimCurves,
189  const char *anim_type);
190  void Assign_float_animations(const COLLADAFW::UniqueId &listid,
191  ListBase *AnimCurves,
192  const char *anim_type);
198  void Assign_lens_animations(const COLLADAFW::UniqueId &listid,
199  ListBase *AnimCurves,
200  double aspect,
201  Camera *cam,
202  const char *anim_type,
203  int fov_type);
204 
205  int setAnimType(const COLLADAFW::Animatable *prop, int type, int addition);
206 
208  void modify_fcurve(std::vector<FCurve *> *curves,
209  const char *rna_path,
210  int array_index,
211  int scale = 1);
212  void unused_fcurve(std::vector<FCurve *> *curves);
218  Object *translate_animation_OLD(COLLADAFW::Node *node,
219  std::map<COLLADAFW::UniqueId, Object *> &object_map,
220  std::map<COLLADAFW::UniqueId, COLLADAFW::Node *> &root_map,
221  COLLADAFW::Transformation::TransformationType tm_type,
222  Object *par_job = NULL);
223 
224  void find_frames(std::vector<float> *frames, std::vector<FCurve *> *curves);
226  void find_frames_old(std::vector<float> *frames,
227  COLLADAFW::Node *node,
228  COLLADAFW::Transformation::TransformationType tm_type);
234  void evaluate_transform_at_frame(float mat[4][4], COLLADAFW::Node *node, float fra);
235 
237  bool evaluate_animation(COLLADAFW::Transformation *tm,
238  float mat[4][4],
239  float fra,
240  const char *node_id);
241 
243  void get_joint_rest_mat(float mat[4][4], COLLADAFW::Node *root, COLLADAFW::Node *node);
244 
246  bool calc_joint_parent_mat_rest(float mat[4][4],
247  float par[4][4],
248  COLLADAFW::Node *node,
249  COLLADAFW::Node *end);
250 
251  float convert_to_focal_length(float in_xfov, int fov_type, float aspect, float sensorx);
252 
253 #ifdef ARMATURE_TEST
254  Object *get_joint_object(COLLADAFW::Node *root, COLLADAFW::Node *node, Object *par_job);
255 #endif
256 
257 #if 0
262  bool evaluate_joint_world_transform_at_frame(
263  float mat[4][4], float par[4][4], COLLADAFW::Node *node, COLLADAFW::Node *end, float fra);
264 #endif
265 
266  void add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurve *fcu);
267 
268  void extra_data_importer(std::string elementName);
269 };
eBezTriple_Interpolation
@ BEZT_IPO_LIN
Object is a sort of wrapper for general info.
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to curves
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
#define C
Definition: RandGen.cpp:25
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
void get_joint_rest_mat(float mat[4][4], COLLADAFW::Node *root, COLLADAFW::Node *node)
float convert_to_focal_length(float in_xfov, int fov_type, float aspect, float sensorx)
void find_frames(std::vector< float > *frames, std::vector< FCurve * > *curves)
void Assign_float_animations(const COLLADAFW::UniqueId &listid, ListBase *AnimCurves, const char *anim_type)
void extra_data_importer(std::string elementName)
bool evaluate_animation(COLLADAFW::Transformation *tm, float mat[4][4], float fra, const char *node_id)
void read_node_transform(COLLADAFW::Node *node, Object *ob)
void Assign_transform_animations(COLLADAFW::Transformation *transform, const COLLADAFW::AnimationList::AnimationBinding *binding, std::vector< FCurve * > *curves, bool is_joint, char *joint_path)
int setAnimType(const COLLADAFW::Animatable *prop, int type, int addition)
void Assign_color_animations(const COLLADAFW::UniqueId &listid, ListBase *AnimCurves, const char *anim_type)
bool write_animation_list(const COLLADAFW::AnimationList *animlist)
AnimMix * get_animation_type(const COLLADAFW::Node *node, std::map< COLLADAFW::UniqueId, const COLLADAFW::Object * > FW_object_map)
Object * translate_animation_OLD(COLLADAFW::Node *node, std::map< COLLADAFW::UniqueId, Object * > &object_map, std::map< COLLADAFW::UniqueId, COLLADAFW::Node * > &root_map, COLLADAFW::Transformation::TransformationType tm_type, Object *par_job=NULL)
void unused_fcurve(std::vector< FCurve * > *curves)
void add_bone_animation_sampled(Object *ob, std::vector< FCurve * > &animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node, COLLADAFW::Transformation *tm)
void add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurve *fcu)
void modify_fcurve(std::vector< FCurve * > *curves, const char *rna_path, int array_index, int scale=1)
bool calc_joint_parent_mat_rest(float mat[4][4], float par[4][4], COLLADAFW::Node *node, COLLADAFW::Node *end)
void find_frames_old(std::vector< float > *frames, COLLADAFW::Node *node, COLLADAFW::Transformation::TransformationType tm_type)
void evaluate_transform_at_frame(float mat[4][4], COLLADAFW::Node *node, float fra)
void apply_matrix_curves(Object *ob, std::vector< FCurve * > &animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node, COLLADAFW::Transformation *tm)
void translate_Animations(COLLADAFW::Node *Node, std::map< COLLADAFW::UniqueId, COLLADAFW::Node * > &root_map, std::multimap< COLLADAFW::UniqueId, Object * > &object_map, std::map< COLLADAFW::UniqueId, const COLLADAFW::Object * > FW_object_map, std::map< COLLADAFW::UniqueId, Material * > uid_material_map)
bool write_animation(const COLLADAFW::Animation *anim)
void Assign_lens_animations(const COLLADAFW::UniqueId &listid, ListBase *AnimCurves, double aspect, Camera *cam, const char *anim_type, int fov_type)
AnimationImporter(bContext *C, UnitConverter *conv, ArmatureImporter *arm, Scene *scene)
void set_import_from_version(std::string import_from_version)
OperationNode * node
Scene scene
Curve curve
Material material
Definition: BKE_main.h:121
Definition: IMB_anim.h:71