28 #include "COLLADABUPlatform.h"
51 const std::string &
id =
node->getName();
52 return id.empty() ?
node->getOriginalId().c_str() :
id.c_str();
61 : weights(skin.weights),
62 joint_data(skin.joint_data),
63 unit_converter(skin.unit_converter),
65 controller_uid(skin.controller_uid),
68 copy_m4_m4(bind_shape_matrix, (
float(*)[4])skin.bind_shape_matrix);
82 dest.setData(src.getData(), src.getCount());
84 dest.yieldOwnerShip();
89 COLLADAFW::IntValuesArray &dest)
91 dest.setData((
int *)src.getData(), src.getCount());
92 dest.yieldOwnerShip();
96 COLLADAFW::UIntValuesArray &dest)
98 dest.setData((
unsigned int *)src.getData(), src.getCount());
99 dest.yieldOwnerShip();
104 transfer_array_data((COLLADAFW::UIntValuesArray &)skin->getJointsPerVertex(), joints_per_vertex);
105 transfer_array_data((COLLADAFW::UIntValuesArray &)skin->getWeightIndices(), weight_indices);
110 const COLLADAFW::FloatOrDoubleArray &weight = skin->getWeights();
111 for (
unsigned int i = 0; i < weight.getValuesCount(); i++) {
120 joints_per_vertex.releaseMemory();
121 weight_indices.releaseMemory();
122 joint_indices.releaseMemory();
133 joint_data.push_back(jd);
138 controller_uid = co->getUniqueId();
141 const COLLADAFW::UniqueIdArray &joint_uids = co->getJoints();
142 for (
unsigned int i = 0; i < joint_uids.getCount(); i++) {
143 joint_data[i].joint_uid = joint_uids[i];
167 this->ob_arm = ob_arm;
173 const COLLADAFW::UniqueId &uid =
node->getUniqueId();
174 std::vector<JointData>::iterator it;
175 for (it = joint_data.begin(); it != joint_data.end(); it++) {
176 if ((*it).joint_uid == uid) {
192 return controller_uid;
202 const COLLADAFW::UniqueId &uid =
node->getUniqueId();
203 std::vector<JointData>::iterator it;
204 for (it = joint_data.begin(); it != joint_data.end(); it++) {
205 if ((*it).joint_uid == uid) {
210 COLLADAFW::NodePointerArray &children =
node->getChildNodes();
211 for (
unsigned int i = 0; i < children.getCount(); i++) {
222 std::map<COLLADAFW::UniqueId, COLLADAFW::Node *> &joint_by_uid,
254 std::vector<JointData>::iterator it;
256 for (it = joint_data.begin(), joint_index = 0; it != joint_data.end(); it++, joint_index++) {
257 const char *name =
"Group";
260 if ((*it).joint_uid == COLLADAFW::UniqueId::INVALID) {
266 if (joint_by_uid.find((*it).joint_uid) != joint_by_uid.end()) {
284 for (
unsigned int vertex = 0, weight = 0; vertex < joints_per_vertex.getCount(); vertex++) {
286 unsigned int limit = weight + joints_per_vertex[vertex];
287 for (; weight < limit; weight++) {
288 int joint = joint_indices[weight], joint_weight = weight_indices[weight];
316 std::map<COLLADAFW::UniqueId, COLLADAFW::Node *> &joint_by_uid,
317 std::vector<COLLADAFW::Node *> &
result)
319 std::vector<COLLADAFW::Node *>::const_iterator it;
321 for (it = root_joints.begin(); it != root_joints.end(); it++) {
322 COLLADAFW::Node *root = *it;
323 std::vector<JointData>::iterator ji;
325 for (ji = joint_data.begin(); ji != joint_data.end(); ji++) {
326 if (joint_by_uid.find((*ji).joint_uid) != joint_by_uid.end()) {
328 COLLADAFW::Node *joint = joint_by_uid[(*ji).joint_uid];
343 if (
node == tree_root) {
347 COLLADAFW::NodePointerArray &children = tree_root->getChildNodes();
348 for (
unsigned int i = 0; i < children.getCount(); i++) {
Blender kernel action and pose functionality.
struct bPoseChannel * BKE_pose_channel_find_name(const struct bPose *pose, const char *name)
struct Scene * CTX_data_scene(const bContext *C)
struct Main * CTX_data_main(const bContext *C)
General operations, lookup, etc. for blender objects.
bool BKE_object_is_child_recursive(const struct Object *ob_parent, const struct Object *ob_child)
void BKE_object_workob_calc_parent(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct Object *workob)
void BKE_object_apply_mat4(struct Object *ob, const float mat[4][4], const bool use_compat, const bool use_parent)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
bool invert_m4_m4(float R[4][4], const float A[4][4])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void DEG_id_tag_update(struct ID *id, int flag)
void ED_vgroup_vert_add(struct Object *ob, struct bDeformGroup *dg, int vertnum, float weight, int assignmode)
struct ModifierData * ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, const char *name, int type)
static const char * bc_get_joint_name(T *node)
void find_root_joints(const std::vector< COLLADAFW::Node * > &root_joints, std::map< COLLADAFW::UniqueId, COLLADAFW::Node * > &joint_by_uid, std::vector< COLLADAFW::Node * > &result)
const COLLADAFW::UniqueId & get_controller_uid()
void transfer_int_array_data_const(const COLLADAFW::IntValuesArray &src, COLLADAFW::IntValuesArray &dest)
void set_controller(const COLLADAFW::SkinController *co)
void link_armature(bContext *C, Object *ob, std::map< COLLADAFW::UniqueId, COLLADAFW::Node * > &joint_by_uid, TransformReader *tm)
Object * set_armature(Object *ob_arm)
void borrow_skin_controller_data(const COLLADAFW::SkinControllerData *skin)
bool uses_joint_or_descendant(COLLADAFW::Node *node)
Object * BKE_armature_from_object()
bool get_joint_inv_bind_matrix(float inv_bind_mat[4][4], COLLADAFW::Node *node)
void add_joint(const COLLADABU::Math::Matrix4 &matrix)
void transfer_uint_array_data_const(const COLLADAFW::UIntValuesArray &src, COLLADAFW::UIntValuesArray &dest)
void set_parent(Object *_parent)
bool find_node_in_tree(COLLADAFW::Node *node, COLLADAFW::Node *tree_root)
void transfer_array_data(T &src, T &dest)
bPoseChannel * get_pose_channel_from_node(COLLADAFW::Node *node)
Object * create_armature(Main *bmain, Scene *scene, ViewLayer *view_layer)
static void dae_matrix_to_mat4_(float out[4][4], const COLLADABU::Math::Matrix4 &in)
bool bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
Object * bc_add_object(Main *bmain, Scene *scene, ViewLayer *view_layer, int type, const char *name)
float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray &array, unsigned int index)