// Given a set of coordinates in local creature space, // see if any bone is in contact public string IsContactBone(XnaGeometry.Vector2 pt_in, float radius) { MeshBoneUtil.MeshBone cur_bone = target_creature.render_composition.getRootBone(); return ProcessContactBone(pt_in, radius, cur_bone); }
public string ProcessContactBone(XnaGeometry.Vector2 pt_in, float radius, MeshBoneUtil.MeshBone bone_in) { string ret_name = ""; XnaGeometry.Vector4 diff_vec = bone_in.getWorldEndPt() - bone_in.getWorldStartPt(); XnaGeometry.Vector2 cur_vec = new XnaGeometry.Vector2(diff_vec.X, diff_vec.Y); float cur_length = (float)cur_vec.Length(); XnaGeometry.Vector2 unit_vec = cur_vec; unit_vec.Normalize(); XnaGeometry.Vector2 norm_vec = new XnaGeometry.Vector2(unit_vec.Y, unit_vec.X); XnaGeometry.Vector2 src_pt = new XnaGeometry.Vector2(bone_in.getWorldStartPt().X, bone_in.getWorldStartPt().Y); XnaGeometry.Vector2 rel_vec = pt_in - src_pt; float proj = (float)XnaGeometry.Vector2.Dot(rel_vec, unit_vec); if( (proj >= 0) && (proj <= cur_length)) { float norm_proj = (float)XnaGeometry.Vector2.Dot(rel_vec, norm_vec); if(norm_proj <= radius) { return bone_in.getKey(); } } List<MeshBone> cur_children = bone_in.getChildren(); foreach(MeshBone cur_child in cur_children) { ret_name = ProcessContactBone(pt_in, radius, cur_child); if(!(ret_name.Equals(""))) { break; } } return ret_name; }
public CreatureUVSwapPacket(XnaGeometry.Vector2 local_offset_in, XnaGeometry.Vector2 global_offset_in, XnaGeometry.Vector2 scale_in, int tag_in) { local_offset = local_offset_in; global_offset = global_offset_in; scale = scale_in; tag = tag_in; }