void MyDeformableObjectNode::updatePhysicsBodies(int vertexIndex) {
    if (mPrintDebugOutput) {
        std::cout << mDebugOutputPrefix << "MyDeformableObjectNode::updatePhysicsBodies(vertexIndex: " << vertexIndex << ")" << std::endl;
    }

    if (!mPhysicsObjects.empty()) {

        unsigned int index, objectCount;

        dcollide::Vertex* vertex;
        MyODEDeformableTestAppGeom* geom;


        if (vertexIndex != -1) {
            index = vertexIndex;
            objectCount = vertexIndex+1;
        } else {
            index = 0;
            objectCount = mPhysicsObjects.size();
        }

        const std::vector<dcollide::Vertex*>& vertices
            = getProxy()->getShape()->getMesh()->getVertices();
        for (/* nop */; index < objectCount; ++index) {

            geom = mPhysicsObjects[index];
            vertex = vertices[index];

            dcollide::Vector3 bodyPosition = vertex->getWorldPosition();

            if (mPrintDebugOutput) {
                if (index == objectCount-1) {
                    const dReal* odePosition = 0;
                    odePosition = dBodyGetPosition(geom->getBody());

                    std::cout << mDebugOutputPrefix << "----------" << std::endl;
                    std::cout << mDebugOutputPrefix << "ODE Position (before move): " << odePosition[0] << ", " << odePosition[1] << ", " << odePosition[2] << std::endl;
                    std::cout << mDebugOutputPrefix << "D-Collide World Position: " << bodyPosition << std::endl << std::endl;
                }
            }

            geom->setMoveNodeOnBodyMoved(false);
            dBodySetPosition(geom->getBody(),  bodyPosition.getX(),
                                               bodyPosition.getY(),
                                               bodyPosition.getZ());
            geom->setMoveNodeOnBodyMoved(true);

            if (mPrintDebugOutput) {
                if (index == objectCount-1) {
                    const dReal* odePosition = 0;
                    odePosition = dBodyGetPosition(geom->getBody());
                    std::cout << mDebugOutputPrefix << "ODE Position (after move): " << odePosition[0] << ", " << odePosition[1] << ", " << odePosition[2] << std::endl << std::endl;
                }
            }
        }
    }
}
Пример #2
0
void Entity::resetLocation(Time ti, const Location &newLocation) {
    SILOG(ogre,debug,"ResetLocation "<<this<<" to "<<newLocation.getPosition()<<"; "<<newLocation.getOrientation());
    if (!getProxy().isStatic(ti)) {
        setStatic(false);
    } else {
        setOgrePosition(newLocation.getPosition());
        setOgreOrientation(newLocation.getOrientation());
    }
}
Пример #3
0
CameraEntity::~CameraEntity() {
    if ((!mViewport) || (mViewport && mRenderTarget)) {
        detach();
    }
    Ogre::Camera*toDestroy=getOgreCamera();
    init(NULL);
    mScene->getSceneManager()->destroyCamera(toDestroy);
    getProxy().CameraProvider::removeListener(this);
}
Пример #4
0
void Entity::setParent(const ProxyObjectPtr &parent, Time ti, const Location &absLocation, const Location &relLocation)
{
    Entity *parentEntity = mScene->getEntity(parent);
    if (!parentEntity) {
        SILOG(ogre,fatal,"No Entity has been created for proxy " << parent->getObjectReference() <<
              " which is to become parent of "<<getProxy().getObjectReference());
        return;
    }
    addToScene(parentEntity->mSceneNode);
}
Пример #5
0
bool post_file(UploadInfo& upinfo)
{
	std::string POSTURL = getUploadUrl(); //"http://radaronline.sinaapp.com/post.php?fa=po";

	CURL *curl = curl_easy_init();

	std::string proxy = getProxy();

	if (proxy != "0") curl_easy_setopt(curl, CURLOPT_PROXY, proxy.c_str());
	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_console);

	//const char* FILENAME =  "a.txt";

	//FILE *fptr;

	//if ((fptr = fopen(FILENAME, "w")) == NULL) {//for receive response data
	//	fprintf(stderr, "fopen file error: %s\n", FILENAME);
	//	exit(1);
	//}
	//curl_easy_setopt(curl, CURLOPT_WRITEDATA, fptr);

	curl_httppost *formpost = 0, *lastptr = 0;



	for (auto it = upinfo.post_form.begin(); it != upinfo.post_form.end(); it++)
	{
		curl_formadd(&formpost, &lastptr, CURLFORM_PTRNAME, it->first.c_str(), CURLFORM_PTRCONTENTS, it->second.c_str(), CURLFORM_END);
	}

	for (auto it = upinfo.rfiles.begin(); it != upinfo.rfiles.end(); it++)
	{
		curl_formadd(&formpost, &lastptr, CURLFORM_PTRNAME, "rfiles[]", CURLFORM_FILE, it->c_str(), CURLFORM_END);
	}

	curl_easy_setopt(curl, CURLOPT_URL, POSTURL.c_str());
	curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);

	std::string errors(CURL_ERROR_SIZE, ' ');
	curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &*errors.begin());

	CURLcode res = curl_easy_perform(curl);

	if (res != CURLE_OK)
	{
		applog << "post error occur: " << errors << '\n';
		//std::cout <<" curl_easy_strerror:"<< curl_easy_strerror(res) << '\n';
		return false;
	}

	curl_easy_cleanup(curl);

	return true;

}
Пример #6
0
//------------------------------------------------------------------------------
void Tank::dropObject()
{
    assert(carried_object_);

    positionCarriedObject();
    
    s_log << Log::debug('l')
          << *this
          << " dropped "
          << *carried_object_
          << "\n";
    
    carried_object_ = NULL;

    physics::OdeRigidBody * this_body = getProxy() ? getProxy() : getTarget();
    for (unsigned i=0; i< num_carried_object_geoms_; ++i)
    {
        delete this_body->detachGeom(this_body->getGeoms().size()-1);
    }
    num_carried_object_geoms_ = 0;
}
Пример #7
0
		void doPing(int dest, int n) {
			CkPrintf("[chare=%d,pe=%d]: %d: doPing called, dest = %d\n", 
					getuChareSet()->getId(), getuChareSet()->getPe(), getId(), dest);
			if (!pingDone) {
				for (int i = 0; i < n; i++) 
					getProxy()[dest]->ping(getId(), i);
				//pingDone = true;
			}

			//if (pingDone && pongDone)
			//	done(CkCallback(CkIndex_Main::done(), mainProxy));
		}
Пример #8
0
CnfExp* CnfPass::produceDisjunction(Solver& solver, Edge e) {
    Edge largestEdge;
    CnfExp* accum = fillArgs(e, true, largestEdge);
    if (accum == NULL) accum = new CnfExp(false);

    // This is necessary to check to make sure that we don't start out
    // with an accumulator that is "too large".

    /// @todo Strictly speaking, introProxy doesn't *need* to free
    /// memory, then this wouldn't have to reallocate CnfExp

    /// @todo When this call to introProxy is made, the semantic
    /// negation pointer will have been destroyed.  Thus, it will not
    /// be possible to use the correct proxy.  That should be fixed.

    // at this point, we will either have NULL, or a destructible expression
    if (accum->clauseSize() > CLAUSE_MAX)
        accum = new CnfExp(introProxy(solver, largestEdge, accum, largestEdge.isNeg()));

    int i = _args.size();
    while (i != 0) {
        Edge arg(_args[--i]);
        if (arg.isVar()) {
            accum->disjoin(atomLit(arg));
        } else {
            CnfExp* argExp = (CnfExp*) arg->ptrAnnot(arg.isNeg());
            assert(argExp != NULL);

            bool destroy = (--arg->intAnnot(arg.isNeg()) == 0);
            if (isProxy(argExp)) { // variable has been introduced
                accum->disjoin(getProxy(argExp));
            } else if (argExp->litSize() == 0) {
                accum->disjoin(argExp, destroy);
            } else {
                // check to see if we should introduce a proxy
                int aL = accum->litSize();      // lits in accum
                int eL = argExp->litSize();     // lits in argument
                int aC = accum->clauseSize();   // clauses in accum
                int eC = argExp->clauseSize();  // clauses in argument

                if (eC > CLAUSE_MAX || (eL * aC + aL * eC > eL + aC + aL + aC)) {
                    accum->disjoin(introProxy(solver, arg, argExp, arg.isNeg()));
                } else {
                    accum->disjoin(argExp, destroy);
                    if (destroy) arg->ptrAnnot(arg.isNeg()) = NULL;
                }
            }
        }
    }

    return accum;
}
Пример #9
0
Entity::~Entity() {
    OgreSystem::SceneEntitiesMap::iterator iter =
        mScene->mSceneEntities.find(mProxy->getObjectReference());
    if (iter != mScene->mSceneEntities.end()) {
        // will fail while in the OgreSystem destructor.
        mScene->mSceneEntities.erase(iter);
    }
    if (mMovingIter != mScene->mMovingEntities.end()) {
        mScene->mMovingEntities.erase(mMovingIter);
        mMovingIter = mScene->mMovingEntities.end();
    }
    getProxy().ProxyObjectProvider::removeListener(this);
    getProxy().PositionProvider::removeListener(this);
    removeFromScene();
    init(NULL);
    mSceneNode->detachAllObjects();
    /* detaches all children from the scene.
       There should be none, as the server should have adjusted their parents.
     */
    mSceneNode->removeAllChildren();
    mScene->getSceneManager()->destroySceneNode(mSceneNode);
}
/*!
 * \brief Performs an deformation on the deposited proxy
 * 
 * NOTICE: The size of given vector must match the Vertex count of the mesh
 *         which should be deformed.  
 */
void MyDeformableObjectNode::deform(const std::vector<dcollide::Vector3>& vertexMoveArray) {
    if (mPrintDebugOutput) {
        std::cout << mDebugOutputPrefix << "MyDeformableObjectNode::deform(const std::vector<dcollide::Vector3>& vertexMoveArray)" << std::endl;
    }

    if (!getProxy()) {
        return;
    }

    mProxy->deform(vertexMoveArray);

    mBoundingVolumeDirty = true;
}
Пример #11
0
void Ti::TiView::onTouch(bb::cascades::TouchEvent* event)
{
	Ti::TiEventParameters clickEvent;
	if(clickSource != NULL) {
		clickEvent.addParam("source", clickSource->getProxy());
	}
	clickEvent.addParam("x", Ti::TiHelper::PixelsToDP(event->localX()));
	clickEvent.addParam("y", Ti::TiHelper::PixelsToDP(event->localY()));
	switch(event->touchType())
	{
	case bb::cascades::TouchType::Down:
	{
		clickEvent.addParam("type", Ti::TiConstants::EventTouchStart);
		getProxy()->fireEvent(Ti::TiConstants::EventTouchStart, clickEvent);
		break;
	}
	case bb::cascades::TouchType::Move:
	{
		clickEvent.addParam("type", Ti::TiConstants::EventTouchMove);
		getProxy()->fireEvent(Ti::TiConstants::EventTouchMove, clickEvent);
		break;
	}
	case bb::cascades::TouchType::Up:
	{
		clickEvent.addParam("type", Ti::TiConstants::EventTouchEnd);
		getProxy()->fireEvent(Ti::TiConstants::EventTouchEnd, clickEvent);
		break;
	}
	case bb::cascades::TouchType::Cancel:
	{
		clickEvent.addParam("type", Ti::TiConstants::EventTouchCancel);
		getProxy()->fireEvent(Ti::TiConstants::EventTouchCancel, clickEvent);
		break;
	}
	default:
		break;
	}
}
Пример #12
0
void Ti::TiView::onPinchCancelledEvent(bb::cascades::PinchEvent* event)
{
	Ti::TiEventParameters clickEvent;
	if(clickSource != NULL) {
		clickEvent.addParam("source", clickSource->getProxy());
	}
	clickEvent.addParam("x", Ti::TiHelper::PixelsToDP(event->x()));
	clickEvent.addParam("y", Ti::TiHelper::PixelsToDP(event->y()));

	clickEvent.addParam("type", Ti::TiConstants::EventPinch);
	getProxy()->fireEvent(Ti::TiConstants::EventPinch, clickEvent);

	clickSource = NULL;
}
void MyDeformableObjectNode::rotate(const dcollide::Matrix& rotation, bool respectOrientation) {
    if (mPrintDebugOutput) {
        std::cout << mDebugOutputPrefix << "MyDeformableObjectNode::rotate(const dcollide::Matrix& rotation)" << std::endl;
    }

    if (!getProxy()) {
        return;
    }

    mProxy->rotate(rotation, respectOrientation);

    mBoundingVolumeDirty = true;
    updatePhysicsBodies();
}
Пример #14
0
		void ping(int callee, int order) { 
				CkPrintf("[chare=%d,pe=%d]: %d: ping #%d called by %d\n", 
						getuChareSet()->getId(), getuChareSet()->getPe(), getId(), order, callee);
				getProxy()[callee]->pong(getId(), order+1000);

				if ((pingCounters[callee] + 1) != order) {
					CkError("Ping order failure: callee = %d, counter = %d, order = %d\n", 
							callee, pingCounters[callee], order);
					CkAbort("Ping order failure");
				}
				else
					pingCounters[callee]++;

				//doPong(callee);
		}
Пример #15
0
//------------------------------------------------------------------------------
void TankMine::frameMove(float dt)
{
    RigidBody::frameMove(dt);

    if(getProxy()) return; // handle only on server side

    if(lifetime_ <= 0.0f)
    {
        scheduleForDeletion();
    }
    else
    {
        lifetime_ -= dt;
    }
    
}
void MyDeformableObjectNode::setRotation(const dcollide::Matrix& rotation, bool movePhysicsBody) {
    if (mPrintDebugOutput) {
        std::cout << mDebugOutputPrefix << "MyDeformableObjectNode::setRotation(const dcollide::Matrix& rotation, bool movePhysicsBody)" << std::endl;
    }

    if (!getProxy()) {
        return;
    }

    mProxy->setRotation(rotation);

    mBoundingVolumeDirty = true;

    if (movePhysicsBody) {
        updatePhysicsBodies();
    }
}
Пример #17
0
void connection::connectToServer(QTcpSocket *socket)
{
	
	if ( getProxy())
	{
	socket->setProxy(currentProxy);
//	QNetworkProxy::setApplicationProxy(getProxy());
        QSettings settings(QSettings::defaultFormat(), QSettings::UserScope, "qutim/qutim."+m_profile_name+"/ICQ."+icqUin, "accountsettings");
        //QSettings settings(QSettings::defaultFormat(), QSettings::UserScope, "qutim/qutim."+m_profile_name, "icqsettings");
	
	QString host = settings.value("connection/host", "login.icq.com").toString();
	quint16 port = settings.value("connection/port", 5190).toInt();
	connectedToBos = false;
	socket->connectToHost(host,port);
	}
	
}
void MyDeformableObjectNode::setPosition(float x, float y, float z, bool movePhysicsBody) {
    if (mPrintDebugOutput) {
        std::cout << mDebugOutputPrefix << "setPosition(x: " << x <<", y: " << y << ", z: " << z << ", movePhysicsBody: " << movePhysicsBody << ")" << std::endl;
    }

    if (!getProxy()) {
        return;
    }

    mProxy->setPosition(x, y, z);

    mBoundingVolumeDirty = true;

    if (movePhysicsBody) {
        updatePhysicsBodies();
    }
}
Пример #19
0
CameraEntity::CameraEntity(OgreSystem *scene,
                           const std::tr1::shared_ptr<ProxyCameraObject> &pco,
                           std::string ogreName)
    : Entity(scene,
             pco,
             ogreName.length()?ogreName:ogreName=ogreCameraName(pco->getObjectReference()),
             NULL),
      mRenderTarget(NULL),
      mViewport(NULL) {
    getProxy().CameraProvider::addListener(this);
    String cameraName = ogreName;
    if (scene->getSceneManager()->hasCamera(cameraName)) {
        init(scene->getSceneManager()->getCamera(cameraName));
    } else {
        init(scene->getSceneManager()->createCamera(cameraName));
    }
    getOgreCamera()->setNearClipDistance(scene->getOptions()->referenceOption("nearplane")->as<float32>());
    getOgreCamera()->setFarClipDistance(scene->getOptions()->referenceOption("farplane")->as<float32>());
}
Пример #20
0
	void EndpointServiceProxy::deliverMsg(const long connectionId, const string& msg, long mid, int msgType){
		MilliTimer tStart;
		ReadLock lock(mutex_);
		EndpointServicePrx proxy = getProxy(connectionId);

		if(!proxy){
			LOG_ERROR("EndpointServiceProxy::deliverMsg => get proxy failure : cid = " << connectionId);
			return;
		}

		try{
			proxy->deliverMsg(connectionId, msg);
		}catch(std::exception& e){
			std::cout<<"EndpointServicePrx deliverMsg catch exception ="<<e.what()<<std::endl;
		}catch(...){
			std::cout<<"EndpointServicePrx deliverMsg unknow exception"<<std::endl;
		}
		LOG_TIME("EndpointServicePrx::deliverMsg|" << tStart.elapsed() );
		return;
	}
void DefaultSharedWorkerRepository::connectToWorker(PassRefPtr<SharedWorker> worker, PassOwnPtr<MessagePortChannel> port, const KURL& url, const String& name, ExceptionCode& ec)
{
    MutexLocker lock(m_lock);
    ASSERT(worker->scriptExecutionContext()->securityOrigin()->canAccess(SecurityOrigin::create(url).get()));
    // Fetch a proxy corresponding to this SharedWorker.
    RefPtr<SharedWorkerProxy> proxy = getProxy(name, url);
    proxy->addToWorkerDocuments(worker->scriptExecutionContext());
    if (proxy->url() != url) {
        // Proxy already existed under alternate URL - return an error.
        ec = URL_MISMATCH_ERR;
        return;
    }
    // If proxy is already running, just connect to it - otherwise, kick off a loader to load the script.
    if (proxy->thread())
        proxy->thread()->runLoop().postTask(SharedWorkerConnectTask::create(port));
    else {
        RefPtr<SharedWorkerScriptLoader> loader = adoptRef(new SharedWorkerScriptLoader(worker, port.release(), proxy.release()));
        loader->load(url);
    }
}
Пример #22
0
void ProxyEntity::extrapolateLocation(TemporalValue<Location>::Time current) {
    Location loc (getProxy().extrapolateLocation(current));
    setOgrePosition(loc.getPosition());
    setOgreOrientation(loc.getOrientation());
}
Пример #23
0
void OnlineStateFilterAdapter::updateOnlineState(int userId,int onlinestate) {
	return getProxy(0)->updateOnlineState(userId, onlinestate);
}
Пример #24
0
/**
 *  Causes the object to be positioned in front of the tank every
 *  frame.
 *
 *  Adds all non-sensor geoms from object to the tank's
 *  body. Collision callbacks for tank are not installed on the picked
 *  up object!
 */
bool Tank::pickupObject(RigidBody * object)
{
    assert(!carried_object_);
    
    carried_object_ = object;
    Vector docking_offset = params_.get<Vector>("tank.docking_pos");

    if (getLocation() == CL_SERVER_SIDE)
    {
        // First we have to check whether the LOS to the object is given.

        // Use turret pos because tank position will likely be below terrain...
        Vector tank_pos    = target_object_->getPosition() + target_object_->vecToWorld(turret_pos_);
        Vector docking_pos = target_object_->getPosition() + target_object_->vecToWorld(docking_offset);
        Vector ab = docking_pos - tank_pos;

        pickup_los_given_ = true;
    
        physics::OdeRayGeom ray(ab.length());
        ray.set(tank_pos, ab);
        target_object_->getSimulator()->getStaticSpace()->collide(
            &ray, physics::CollisionCallback(this, &Tank::pickupRayCollisionCallback));
        if (pickup_los_given_)
        {
            target_object_->getSimulator()->getActorSpace()->collide(
                &ray, physics::CollisionCallback(this, &Tank::pickupRayCollisionCallback));
        }

        if (!pickup_los_given_)
        {
            carried_object_ = NULL;
            return false;
        }
    }
    
    s_log << Log::debug('l')
          << *this
          << " now carries "
          << *object
          << "\n";

    physics::OdeRigidBody * obj_body  = object->getProxy() ? object->getProxy() : object->getTarget();
    physics::OdeRigidBody * this_body = getProxy()         ? getProxy()         : getTarget();

    Matrix offset(true);
    offset.getTranslation() = docking_offset;
    
    for (unsigned g=0; g<obj_body->getGeoms().size(); ++g)
    {
        if (obj_body->getGeoms()[g]->isSensor()) continue;
        
        physics::OdeGeom * clone = obj_body->getGeoms()[g]->instantiate();

        clone->setName(clone->getName() + "-clone");
        clone->setMass(0.0f);
        clone->setOffset(offset);
        clone->setSpace(this_body->getSimulator()->getActorSpace());
        
        this_body->addGeom(clone);

        clone->setCategory(obj_body->getGeoms()[g]->getCategory());

        ++num_carried_object_geoms_;
    }

    return true;
}
Пример #25
0
void OnlineStateFilterAdapter::updateOnlineStateBatch(const MyUtil::Int2IntMap& data) {
	return getProxy(0)->updateOnlineStateBatch(data);
}
Пример #26
0
PowerTransferPrx PowerTransferAdapter::getManager(int id) {
        return getProxy(id);
}
Пример #27
0
MyUtil::ByteSeq OnlineStateFilterAdapter::getOnlineStateMinMax(int minId,int maxId) {
	return getProxy(0)->getOnlineStateMinMax(minId, maxId);
}
Пример #28
0
ProxyEntity::~ProxyEntity() {
    getProxy().MeshProvider::removeListener(this);

    getProxy().ProxyObjectProvider::removeListener(this);
    getProxy().PositionProvider::removeListener(this);
}
Пример #29
0
BoundingSphere3f ProxyEntity::bounds() {
    return getProxy().getBounds();
}
Пример #30
0
bool ProxyEntity::isDynamic() const {
    return Entity::isDynamic() || !getProxy().isStatic();
}