Blender V4.3
AnimationImporter.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include <map>
12#include <vector>
13
14#include "COLLADAFWAnimation.h"
15#include "COLLADAFWAnimationCurve.h"
16#include "COLLADAFWAnimationList.h"
17#include "COLLADAFWCamera.h"
18#include "COLLADAFWEffect.h"
19#include "COLLADAFWInstanceGeometry.h"
20#include "COLLADAFWLight.h"
21#include "COLLADAFWMaterial.h"
22#include "COLLADAFWNode.h"
23#include "COLLADAFWUniqueId.h"
24
25#include "BKE_context.hh"
26
27#include "DNA_anim_types.h"
28
29#include "DNA_camera_types.h"
30#include "DNA_light_types.h"
31#include "DNA_object_types.h"
32#include "DNA_scene_types.h"
33
34// #include "ArmatureImporter.h"
35#include "TransformReader.h"
36
37#include "collada_internal.h"
38
40
42 public:
43 // virtual void change_eul_to_quat(Object *ob, bAction *act) = 0;
44};
45
47 private:
48 bContext *mContext;
49 ArmatureImporter *armature_importer;
50 Scene *scene;
51
52 std::map<COLLADAFW::UniqueId, std::vector<FCurve *>> curve_map;
53 std::map<COLLADAFW::UniqueId, TransformReader::Animation> uid_animated_map;
54 // std::map<bActionGroup*, std::vector<FCurve*> > fcurves_actionGroup_map;
55 std::map<COLLADAFW::UniqueId, const COLLADAFW::AnimationList *> animlist_map;
56 std::vector<FCurve *> unused_curves;
57 std::map<COLLADAFW::UniqueId, Object *> joint_objects;
58
59 FCurve *create_fcurve(int array_index, const char *rna_path);
60
61 void add_bezt(FCurve *fcu,
62 float frame,
63 float value,
65
69 void animation_to_fcurves(COLLADAFW::AnimationCurve *curve);
70
71 void fcurve_deg_to_rad(FCurve *cu);
72 void fcurve_scale(FCurve *cu, int scale);
73
74 void fcurve_is_used(FCurve *fcu);
75
76 int typeFlag;
77
78 std::string import_from_version;
79
80 enum lightAnim {
81 // INANIMATE = 0,
82 LIGHT_COLOR = 2,
83 LIGHT_FOA = 4,
84 LIGHT_FOE = 8,
85 };
86
87 enum cameraAnim {
88 // INANIMATE = 0,
89 CAMERA_XFOV = 2,
90 CAMERA_XMAG = 4,
91 CAMERA_YFOV = 8,
92 CAMERA_YMAG = 16,
93 CAMERA_ZFAR = 32,
94 CAMERA_ZNEAR = 64,
95 };
96
97 enum matAnim {
98 MATERIAL_SHININESS = 2,
99 MATERIAL_SPEC_COLOR = 4,
100 MATERIAL_DIFF_COLOR = 1 << 3,
101 MATERIAL_TRANSPARENCY = 1 << 4,
102 MATERIAL_IOR = 1 << 5,
103 };
104
105 enum AnimationType {
106 BC_INANIMATE = 0,
107 BC_NODE_TRANSFORM = 1,
108 };
109
110 struct AnimMix {
111 int transform;
112 int light;
113 int camera;
114 int material;
115 int texture;
116 };
117
118 public:
120 : TransformReader(conv), mContext(C), armature_importer(arm), scene(scene)
121 {
122 }
123
125
126 void set_import_from_version(std::string import_from_version);
127 bool write_animation(const COLLADAFW::Animation *anim);
128
130 bool write_animation_list(const COLLADAFW::AnimationList *animlist);
131
137 void read_node_transform(COLLADAFW::Node *node, Object *ob);
138 // virtual void change_eul_to_quat(Object *ob, bAction *act);
139
140 void translate_Animations(COLLADAFW::Node *Node,
141 std::map<COLLADAFW::UniqueId, COLLADAFW::Node *> &root_map,
142 std::multimap<COLLADAFW::UniqueId, Object *> &object_map,
143 std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map,
144 std::map<COLLADAFW::UniqueId, Material *> uid_material_map);
145
150 AnimMix *get_animation_type(
151 const COLLADAFW::Node *node,
152 std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map);
153
155 std::vector<FCurve *> &animcurves,
156 COLLADAFW::Node *root,
157 COLLADAFW::Node *node,
158 COLLADAFW::Transformation *tm);
159
164 void Assign_transform_animations(COLLADAFW::Transformation *transform,
165 const COLLADAFW::AnimationList::AnimationBinding *binding,
166 std::vector<FCurve *> *curves,
167 bool is_joint,
168 char *joint_path);
169
174 void Assign_color_animations(const COLLADAFW::UniqueId &listid,
175 ListBase *AnimCurves,
176 const char *anim_type);
177 void Assign_float_animations(const COLLADAFW::UniqueId &listid,
178 ListBase *AnimCurves,
179 const char *anim_type);
185 void Assign_lens_animations(const COLLADAFW::UniqueId &listid,
186 ListBase *AnimCurves,
187 double aspect,
188 Camera *cam,
189 const char *anim_type,
190 int fov_type);
191
192 int setAnimType(const COLLADAFW::Animatable *prop, int type, int addition);
193
195 void modify_fcurve(std::vector<FCurve *> *curves,
196 const char *rna_path,
197 int array_index,
198 int scale = 1);
199 void unused_fcurve(std::vector<FCurve *> *curves);
200
201 void find_frames(std::vector<float> *frames, std::vector<FCurve *> *curves);
202
208 void evaluate_transform_at_frame(float mat[4][4], COLLADAFW::Node *node, float fra);
209
211 bool evaluate_animation(COLLADAFW::Transformation *tm,
212 float mat[4][4],
213 float fra,
214 const char *node_id);
215
217 void get_joint_rest_mat(float mat[4][4], COLLADAFW::Node *root, COLLADAFW::Node *node);
218
220 bool calc_joint_parent_mat_rest(float mat[4][4],
221 float par[4][4],
222 COLLADAFW::Node *node,
223 COLLADAFW::Node *end);
224
225 float convert_to_focal_length(float in_xfov, int fov_type, float aspect, float sensorx);
226
227 void add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurve *fcu);
228};
eBezTriple_Interpolation
@ BEZT_IPO_LIN
Object is a sort of wrapper for general info.
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 Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture 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:29
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)
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)
void unused_fcurve(std::vector< FCurve * > *curves)
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 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)
TransformReader(UnitConverter *conv)
local_group_size(16, 16) .push_constant(Type texture