summaryrefslogtreecommitdiffstats
path: root/tools/collada/collada.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-09-15 11:33:30 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-09-15 11:33:30 -0300
commit8cab401d08f8e25aa9b2dc710204785858ff3dbb (patch)
tree1a4cec868f937fb24d340ee33fbeba2f1c6fa9f2 /tools/collada/collada.cpp
parent1a2cb755e2d8b9d59178f36702f6dff7235b9088 (diff)
downloadredot-engine-8cab401d08f8e25aa9b2dc710204785858ff3dbb.tar.gz
3D Physics Rework, Other Stuff
-=-=-=-=-=-=-=-=-=-=-=-=-=- 3D Physics: -Fixed "Bounce" parameter in 3D -Fixed bug affecting Area (sometims it would not detect properly) -Vehicle Body has seen heavy work -Added Query API for doing space queries in 3D. Needs some docs though. -Added JOINTS! Adapted Bullet Joints: and created easy gizmos for setting them up: -PinJoint -HingeJoint (with motor) -SliderJoint -ConeTwistJoint -Generic6DOFJoint -Added OBJECT PICKING! based on the new query API. Any physics object now (Area or Body) has the following signals and virtual functions: -input_event (mouse or multitouch input over the body) -mouse_enter (mouse entered the body area) -mouse_exit (mouse exited body area) For Area it needs to be activated manually, as it isn't by default (ray goes thru). Other: -Begun working on Windows 8 (RT) port. Compiles but does not work yet. -Added TheoraPlayer library for improved to-texture and portable video support. -Fixed a few bugs in the renderer, collada importer, collada exporter, etc.
Diffstat (limited to 'tools/collada/collada.cpp')
-rw-r--r--tools/collada/collada.cpp86
1 files changed, 84 insertions, 2 deletions
diff --git a/tools/collada/collada.cpp b/tools/collada/collada.cpp
index c416286c19..e29888b433 100644
--- a/tools/collada/collada.cpp
+++ b/tools/collada/collada.cpp
@@ -322,7 +322,7 @@ void Collada::_parse_image(XMLParser& parser) {
String path = parser.get_attribute_value("source").strip_edges();
if (path.find("://")==-1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- image.path=Globals::get_singleton()->localize_path(state.local_path.get_base_dir()+"/"+path);
+ image.path=Globals::get_singleton()->localize_path(state.local_path.get_base_dir()+"/"+path.percent_decode());
}
} else {
@@ -338,7 +338,7 @@ void Collada::_parse_image(XMLParser& parser) {
if (name=="init_from") {
parser.read();
- String path = parser.get_node_data().strip_edges();
+ String path = parser.get_node_data().strip_edges().percent_decode();
if (path.find("://")==-1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
@@ -1683,6 +1683,10 @@ Collada::Node* Collada::_parse_visual_scene_node(XMLParser& parser) {
} else if (state.idref_joints.has(name))
joint->sid=name; //kind of a cheat but..
+ if (joint->sid!="") {
+ state.sid_to_node_map[joint->sid]=id;
+ }
+
node=joint;
@@ -2243,6 +2247,8 @@ void Collada::_create_skeletons(Collada::Node **p_node) {
Node *node = *p_node;
+
+
if (node->type==Node::TYPE_JOINT) {
// ohohohoohoo it's a joint node, time to work!
@@ -2349,6 +2355,79 @@ void Collada::_merge_skeletons(VisualScene *p_vscene,Node *p_node) {
}
+
+void Collada::_merge_skeletons2(VisualScene *p_vscene) {
+
+ for (Map<String,SkinControllerData>::Element *E=state.skin_controller_data_map.front();E;E=E->next()) {
+
+ SkinControllerData &cd=E->get();
+
+ NodeSkeleton *skeleton=NULL;
+
+ for (Map<String,Transform>::Element *F=cd.bone_rest_map.front();F;F=F->next()) {
+
+ String name;
+
+ if (!state.sid_to_node_map.has(F->key())) {
+ continue;
+ }
+
+ name = state.sid_to_node_map[F->key()];
+
+ if (!state.scene_map.has(name)) {
+ print_line("no foundie node for: "+name);
+ }
+
+ ERR_CONTINUE( !state.scene_map.has(name) );
+
+ Node *node=state.scene_map[name];
+ ERR_CONTINUE( node->type!=Node::TYPE_JOINT );
+ if (node->type!=Node::TYPE_JOINT)
+ continue;
+ NodeSkeleton *sk=NULL;
+
+ while(node && !sk) {
+
+ if (node->type==Node::TYPE_SKELETON) {
+ sk=static_cast<NodeSkeleton*>(node);
+ }
+ node=node->parent;
+ }
+ ERR_CONTINUE( !sk );
+
+ if (!sk)
+ continue; //bleh
+
+ if (!skeleton) {
+ skeleton=sk;
+ continue;
+ }
+
+ if (skeleton!=sk) {
+ //whoa.. wtf, merge.
+ print_line("MERGED BONES!!");
+
+ //NodeSkeleton *merged = E->get();
+ _remove_node(p_vscene,sk);
+ for(int i=0;i<sk->children.size();i++) {
+
+ _joint_set_owner(sk->children[i],skeleton);
+ skeleton->children.push_back( sk->children[i] );
+ sk->children[i]->parent=skeleton;
+
+
+ }
+
+ sk->children.clear(); //take children from it
+ memdelete( sk );
+ }
+ }
+ }
+
+
+
+}
+
bool Collada::_optimize_skeletons(VisualScene *p_vscene,Node *p_node) {
Node *node=p_node;
@@ -2540,6 +2619,9 @@ void Collada::_optimize() {
_merge_skeletons(&vs,vs.root_nodes[i]);
}
+ _merge_skeletons2(&vs);
+
+
for(int i=0;i<vs.root_nodes.size();i++) {
_optimize_skeletons(&vs,vs.root_nodes[i]);
}