39 #define MOUSE_GRAB_FORCE 30000.0f
41 SceneMouse::SceneMouse() :
56 MaterialPtr pickLineMaterial = MaterialManager::getSingleton().getByName(
"PickLineMaterial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
57 if (pickLineMaterial.isNull())
59 pickLineMaterial = MaterialManager::getSingleton().create(
"PickLineMaterial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
61 pickLineMaterial->setReceiveShadows(
false);
62 pickLineMaterial->getTechnique(0)->setLightingEnabled(
true);
63 pickLineMaterial->getTechnique(0)->getPass(0)->setDiffuse(0, 0, 1, 0);
64 pickLineMaterial->getTechnique(0)->getPass(0)->setAmbient(0, 0, 1);
65 pickLineMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(0, 0, 1);
67 pickLine->begin(
"PickLineMaterial", RenderOperation::OT_LINE_LIST);
136 std::pair<bool, Real> pair = mouseRay.intersects(actor->ar_bounding_box);
140 for (
int j = 0; j < actor->ar_num_nodes; j++)
142 if (actor->ar_nodes[j].nd_no_mouse_grab)
146 std::pair<bool, Real> pair = mouseRay.intersects(Sphere(actor->ar_nodes[j].AbsPosition, 0.1f));
168 if (it->hk_hook_node->pos ==
minnode)
237 if (ms.buttonDown(OIS::MB_Middle))
252 Real nearest_ray_distance = std::numeric_limits<float>::max();
256 if (actor != player_actor)
258 Vector3 pos = actor->getPosition();
259 std::pair<bool, Real> pair = mouseRay.intersects(Sphere(pos, actor->getMinCameraRadius()));
262 Real ray_distance = mouseRay.getDirection().crossProduct(pos - mouseRay.getOrigin()).length();
263 if (ray_distance < nearest_ray_distance)
265 nearest_ray_distance = ray_distance;
276 Real nearest_camera_distance = std::numeric_limits<float>::max();
277 Real nearest_ray_distance = std::numeric_limits<float>::max();
283 std::pair<bool, Real> pair = mouseRay.intersects(Sphere(pos, 0.25f));
286 Real ray_distance = mouseRay.getDirection().crossProduct(pos - mouseRay.getOrigin()).length();
287 if (ray_distance < nearest_ray_distance || (ray_distance == nearest_ray_distance && pair.second < nearest_camera_distance))
289 nearest_camera_distance = pair.second;
290 nearest_ray_distance = ray_distance;