예제 #1
0
	void AttachSkySphere(SkySpherePtr p){
		if (mSkySphere)
			mSkySphere->OnDetachedFromScene(mSelfPtr.lock());
		mSkySphere = p;
		if (mSkySphere){			
			mSkySphere->OnAttachedToScene(mSelfPtr.lock());
		}
	}
예제 #2
0
	bool AttachSpatialObject(SpatialSceneObjectPtr pSpatialObject){
		if (!ValueExistsInVector(mSpatialObjects, pSpatialObject)){
			mSpatialObjects.push_back(pSpatialObject);
			pSpatialObject->OnAttachedToScene(mSelfPtr.lock());
			return true;
		}
		return false;
	}
	PointLightPtr CreatePointLight(const Vec3& pos, Real range, const Vec3& color, Real intensity, Real lifeTime, bool manualDeletion)
	{
		auto scene = mScene.lock();
		if (!scene){
			Logger::Log(FB_ERROR_LOG_ARG, "No scene");
			return 0;
		}
		auto newLight = PointLight::Create(scene, pos, range, color, intensity, lifeTime, manualDeletion);
		mPointLights.push_back(newLight);
		return newLight;
	}
예제 #4
0
	bool AttachObject(SceneObjectPtr pObject){
		if (pObject->GetType() == SceneObjectType::SkySphere){
			Logger::Log(FB_ERROR_LOG_ARG, "You cannot attach sky sphere as an object. Use AttachSkySpherer function instead.");
			return false;
		}
		if (!ValueExistsInVector(mObjects, pObject)){
			mObjects.push_back(pObject);
			pObject->OnAttachedToScene(mSelfPtr.lock());
			return true;
		}

		return false;
	}
예제 #5
0
	bool DetachSpatialObject(SpatialSceneObject* pSpatialObject){
		bool deletedAny = false;
		for (auto it = mSpatialObjects.begin(); it != mSpatialObjects.end(); /**/){
			if (it->lock().get() == pSpatialObject){
				it = mSpatialObjects.erase(it);
				deletedAny = true;
			}
			else{
				++it;
			}
		}
		
		if (deletedAny) {
			pSpatialObject->OnDetachedFromScene(mSelfPtr.lock());
		}
		return deletedAny;
	}
예제 #6
0
bool InterestManager::CheckRelevance(UserConnectionPtr conn, Entity* changed_entity, SceneWeakPtr scene_, bool headless)
{
    PROFILE(Interest_Management);

    ScenePtr scene = scene_.lock();

    if (!scene)
        return true;

    EC_Placeable *entity_location = changed_entity->GetComponent<EC_Placeable>().get();

    if(!conn->syncState->locationInitialized || !entity_location) //If the client hasn't informed the server about the orientation yet, do not proceed
        return true;

    bool accepted = false;  //By default, we assume that the update will be rejected

    Quat client_orientation = conn->syncState->clientOrientation.Normalized();

    params_.client_position = conn->syncState->clientLocation;      //Client location vector
    params_.entity_position = entity_location->transform.Get().pos; //Entitys location vector

    float3 d = params_.client_position - params_.entity_position;
    float3 v = params_.entity_position - params_.client_position;   //Calculate the vector between the player and the changed entity by substracting their location vectors
    float3 f = client_orientation.Mul(scene->ForwardVector());      //Calculate the forward vector of the client

    params_.headless = headless;
    params_.dot = v.Dot(f);                                          //Finally the dot product is calculated so we know if the entity is in front of the player or not
    params_.distance = d.LengthSq();
    params_.scene = scene;
    params_.changed_entity = changed_entity;
    params_.connection = conn;
    params_.relAccepted = false;

    if(activeFilter_ != 0)
        accepted = activeFilter_->Filter(params_);

    if(accepted)
    {
        UpdateLastUpdatedEntity(params_.connection, params_.changed_entity->Id());
        return true;
    }
    else
        return false;
}
예제 #7
0
	void DetachSkySphere(){
		if (mSkySphere){
			mSkySphere->OnDetachedFromScene(mSelfPtr.lock());
			mSkySphere = 0;
		}
	}
	ScenePtr GetMainScene() const{
		return mMainScene.lock();
	}