14 #include "COLLADABUPlatform.h"
38 const std::string &
id =
node->getName();
39 return id.empty() ?
node->getOriginalId().c_str() :
id.c_str();
45 : weights(skin.weights),
46 joint_data(skin.joint_data),
47 unit_converter(skin.unit_converter),
49 controller_uid(skin.controller_uid),
52 copy_m4_m4(bind_shape_matrix, (
float(*)[4])skin.bind_shape_matrix);
67 dest.yieldOwnerShip();
71 COLLADAFW::IntValuesArray &
dest)
73 dest.setData((
int *)
src.getData(),
src.getCount());
74 dest.yieldOwnerShip();
78 COLLADAFW::UIntValuesArray &
dest)
80 dest.setData((
unsigned int *)
src.getData(),
src.getCount());
81 dest.yieldOwnerShip();
86 transfer_array_data((COLLADAFW::UIntValuesArray &)skin->getJointsPerVertex(), joints_per_vertex);
87 transfer_array_data((COLLADAFW::UIntValuesArray &)skin->getWeightIndices(), weight_indices);
92 const COLLADAFW::FloatOrDoubleArray &weight = skin->getWeights();
93 for (
unsigned int i = 0; i < weight.getValuesCount(); i++) {
102 joints_per_vertex.releaseMemory();
103 weight_indices.releaseMemory();
104 joint_indices.releaseMemory();
112 joint_data.push_back(jd);
117 controller_uid = co->getUniqueId();
120 const COLLADAFW::UniqueIdArray &joint_uids = co->getJoints();
121 for (
unsigned int i = 0; i < joint_uids.getCount(); i++) {
122 joint_data[i].joint_uid = joint_uids[i];
145 this->ob_arm = ob_arm;
151 const COLLADAFW::UniqueId &uid =
node->getUniqueId();
152 std::vector<JointData>::iterator it;
153 for (it = joint_data.begin(); it != joint_data.end(); it++) {
154 if ((*it).joint_uid == uid) {
170 return controller_uid;
175 const COLLADAFW::UniqueId &uid =
node->getUniqueId();
176 std::vector<JointData>::iterator it;
177 for (it = joint_data.begin(); it != joint_data.end(); it++) {
178 if ((*it).joint_uid == uid) {
183 COLLADAFW::NodePointerArray &children =
node->getChildNodes();
184 for (
unsigned int i = 0; i < children.getCount(); i++) {
195 std::map<COLLADAFW::UniqueId, COLLADAFW::Node *> &joint_by_uid,
227 std::vector<JointData>::iterator it;
229 for (it = joint_data.begin(), joint_index = 0; it != joint_data.end(); it++, joint_index++) {
230 const char *name =
"Group";
233 if ((*it).joint_uid == COLLADAFW::UniqueId::INVALID) {
239 if (joint_by_uid.find((*it).joint_uid) != joint_by_uid.end()) {
257 for (
unsigned int vertex = 0, weight = 0; vertex < joints_per_vertex.getCount(); vertex++) {
259 unsigned int limit = weight + joints_per_vertex[vertex];
260 for (; weight < limit; weight++) {
261 int joint = joint_indices[weight], joint_weight = weight_indices[weight];
290 std::map<COLLADAFW::UniqueId, COLLADAFW::Node *> &joint_by_uid,
291 std::vector<COLLADAFW::Node *> &
result)
293 std::vector<COLLADAFW::Node *>::const_iterator it;
295 for (it = root_joints.begin(); it != root_joints.end(); it++) {
296 COLLADAFW::Node *root = *it;
297 std::vector<JointData>::iterator ji;
299 for (ji = joint_data.begin(); ji != joint_data.end(); ji++) {
300 if (joint_by_uid.find((*ji).joint_uid) != joint_by_uid.end()) {
302 COLLADAFW::Node *joint = joint_by_uid[(*ji).joint_uid];
317 if (
node == tree_root) {
321 COLLADAFW::NodePointerArray &children = tree_root->getChildNodes();
322 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_apply_mat4(struct Object *ob, const float mat[4][4], bool use_compat, bool use_parent)
void BKE_object_workob_calc_parent(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct Object *workob)
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)
SyclQueue void void * src