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);
116 const OIS::MouseState ms = _arg.state;
134 std::pair<bool, Real> pair = mouseRay.intersects(actor->ar_bounding_box);
138 for (
int j = 0; j < actor->ar_num_nodes; j++)
140 if (actor->ar_nodes[j].nd_no_mouse_grab)
144 std::pair<bool, Real> pair = mouseRay.intersects(Sphere(actor->ar_nodes[j].AbsPosition, 0.1f));
166 if (it->hk_hook_node->pos ==
minnode)
231 const OIS::MouseState ms = _arg.state;
233 if (ms.buttonDown(OIS::MB_Middle))
248 Real nearest_ray_distance = std::numeric_limits<float>::max();
252 if (actor != player_actor)
254 Vector3 pos = actor->getPosition();
255 std::pair<bool, Real> pair = mouseRay.intersects(Sphere(pos, actor->getMinCameraRadius()));
258 Real ray_distance = mouseRay.getDirection().crossProduct(pos - mouseRay.getOrigin()).length();
259 if (ray_distance < nearest_ray_distance)
261 nearest_ray_distance = ray_distance;
272 Real nearest_camera_distance = std::numeric_limits<float>::max();
273 Real nearest_ray_distance = std::numeric_limits<float>::max();
279 std::pair<bool, Real> pair = mouseRay.intersects(Sphere(pos, 0.25f));
282 Real ray_distance = mouseRay.getDirection().crossProduct(pos - mouseRay.getOrigin()).length();
283 if (ray_distance < nearest_ray_distance || (ray_distance == nearest_ray_distance && pair.second < nearest_camera_distance))
285 nearest_camera_distance = pair.second;
286 nearest_ray_distance = ray_distance;