Пример #1
0
double SAngleDownloadPlanner::calculatePriority(ProxyObjectPtr proxy)
{
    if (camera == NULL || !proxy) return 0;

    float radius = proxy->bounds().radius();
    Vector3d objLoc(proxy->location().position());
    Vector3d cameraLoc = camera->getPosition();

    if (withinBound(radius, objLoc, cameraLoc)) return 0.99;

    Vector3d diff = cameraLoc - objLoc;
    SolidAngle sa = SolidAngle::fromCenterRadius((Vector3f)diff, radius);
    float priority = (sa.asFloat())/(SolidAngle::Max.asFloat());
    return (double)priority;
}
Пример #2
0
void ObjectHost::connect(
    Object* obj, const SolidAngle& init_sa, uint32 init_max_results,
    ConnectedCallback connect_cb,
    MigratedCallback migrate_cb, StreamCreatedCallback stream_created_cb,
    DisconnectedCallback disconnected_cb
)
{
    Sirikata::SerializationCheck::Scoped sc(&mSerialization);

    mObjects[obj->uuid()] = obj;

    TimedMotionVector3f init_loc = obj->location();
    TimedMotionQuaternion init_orient(Time::null(), MotionQuaternion(Quaternion::identity(), Quaternion::identity()));
    BoundingSphere3f init_bounds = obj->bounds();

    SpaceObjectReference sporef(SpaceID::null(),ObjectReference(obj->uuid()));

    // We need to encode for new, generic format, assuming basic solid angle
    // query processor
    String query;

    using namespace boost::property_tree;
    bool with_query = init_sa != SolidAngle::Max;
    if (with_query) {
        try {
            ptree pt;
            pt.put("angle", init_sa.asFloat());
            pt.put("max_results", init_max_results);
            std::stringstream data_json;
            write_json(data_json, pt);
            query = data_json.str();
        }
        catch(json_parser::json_parser_error exc) {
            return;
        }
    }

    mSessionManager.connect(
        sporef, init_loc, init_orient, init_bounds, "", "", query,
	std::tr1::bind(&ObjectHost::dispatchConnectedCallback, this, _1, _2, _3, connect_cb),
	migrate_cb, stream_created_cb, disconnected_cb
    );
}