Example #1
0
void
CSVGAnimateColor::
animate(double t)
{
  if      (getAttributeName() == "fill") {
    CSVGColor fromColor, toColor;

    svg_.decodeColorString(getFrom(), fromColor);
    svg_.decodeColorString(getTo  (), toColor  );

    CRGBA c = fromColor.rgba()*(1 - t) + toColor.rgba()*t;

    getParent()->setFillColor(c);

    svg_.redraw();
  }
  else if (getAttributeName() == "stroke") {
    CSVGColor fromColor, toColor;

    svg_.decodeColorString(getFrom(), fromColor);
    svg_.decodeColorString(getTo  (), toColor  );

    CRGBA c = fromColor.rgba()*(1 - t) + toColor.rgba()*t;

    getParent()->setStrokeColor(c);

    svg_.redraw();
  }
}
Example #2
0
bool pWorld::raycastAnyBounds(const VxRay& worldRay, pShapesType shapesType, pGroupsMask *groupsMask/* =NULL */,int groups/* =0xffffffff */, float maxDist/* =NX_MAX_F32 */)
{

	if (!getScene())
	{
		return false;
	}

	NxRay _worldRay;
	_worldRay.dir = getFrom(worldRay.m_Direction);
	_worldRay.orig = getFrom(worldRay.m_Origin);
	
	NxShapesType _shapesType = (NxShapesType)shapesType;
	
	NxReal _maxDist=maxDist;
	
	NxGroupsMask *mask  = NULL;
	if (groupsMask)
	{
		mask = new NxGroupsMask();
		mask->bits0 = groupsMask->bits0;
		mask->bits1 = groupsMask->bits1;
		mask->bits2 = groupsMask->bits2;
		mask->bits3 = groupsMask->bits3;

	}
	bool result  = getScene()->raycastAnyBounds(_worldRay,_shapesType,groups,_maxDist,mask);
	return result;

}
Example #3
0
int pWorld::raycastAllShapes(const VxRay& worldRay, pShapesType shapesType, int groups, float maxDist, pRaycastBit hintFlags, const pGroupsMask* groupsMask)
{

	int result = 0;

	NxRay rayx;
	rayx.dir = getFrom(worldRay.m_Direction);
	rayx.orig = getFrom(worldRay.m_Origin);

	pRayCastReport &report = *getRaycastReport();

	NxGroupsMask *mask  = NULL;
	if (groupsMask)
	{
		mask = new NxGroupsMask();
		mask->bits0 = groupsMask->bits0;
		mask->bits1 = groupsMask->bits1;
		mask->bits2 = groupsMask->bits2;
		mask->bits3 = groupsMask->bits3;

	}
	
	result  = getScene()->raycastAllShapes(rayx,report,(NxShapesType)shapesType,groups,maxDist,hintFlags,mask);
	return result;


}
Example #4
0
pWheelContactData* pWheel2::getContact()
{
	NxWheelShape *wShape = getWheelShape();
	if (!wShape)
	{
		return new pWheelContactData();
	}
	
	NxWheelContactData wcd; 
	NxShape* contactShape = wShape->getContact(wcd);
	
	pWheelContactData result;
	result.contactEntity = NULL;


	if (contactShape)
	{

		result.contactForce = wcd.contactForce;
		result.contactNormal = getFrom(wcd.contactNormal);
		result.contactPoint= getFrom(wcd.contactPoint);
		result.contactPosition= wcd.contactPosition;

		
		result.lateralDirection= getFrom(wcd.lateralDirection);
		result.lateralImpulse= wcd.lateralImpulse;
		result.lateralSlip = wcd.lateralSlip;
		
		result.longitudalDirection = getFrom(wcd.longitudalDirection);
		result.longitudalImpulse = wcd.longitudalImpulse;
		result.longitudalSlip= wcd.longitudalSlip;

		pSubMeshInfo *sInfo  = static_cast<pSubMeshInfo*>(contactShape->userData);
		if (sInfo->entID)
		{
			CKObject *obj = (CKObject*)GetPMan()->m_Context->GetObject(sInfo->entID);
			if (obj)
			{
				result.contactEntity = (CK3dEntity*)obj;
			}else
			{
				result.contactEntity = NULL;
			}
		}

		result.otherShapeMaterialIndex = contactShape->getMaterial();
		
		NxMaterial* otherMaterial = contactShape->getActor().getScene().getMaterialFromIndex(contactShape->getMaterial());
		if (otherMaterial)
		{
			pFactory::Instance()->copyTo(result.otherMaterial,otherMaterial);
		}
	}
	return &result;
}
Example #5
0
/**
 * Converts string to (@p direction = @c UTF8_TO) and from
 * (@p direction = @c UTF8_FROM) UTF-8.
 * 
 * Since Elektra provides portability for key names and string values between
 * different codesets, you should use this helper in your backend to convert
 * to and from universal UTF-8 strings, when storing key names, values and
 * comments.
 *
 * Broken locales in applications can cause problems too. Make sure to load
 * the environment locales in your application using
 * @code
setlocale (LC_ALL, "");
 * @endcode
 *
 * Otherwise kdbbUTF8Engine and this plugin will quit
 * with error when non-ascii characters appear.
 *
 * Binary values are not effected.
 *
 * If iconv() or nl_langinfo() is not available on your system, or if iconv()
 * this plugin can't be used.
 *
 * @param direction must be @c UTF8_TO (convert from current non-UTF-8 to
 * 	UTF-8) or @c UTF8_FROM (convert from UTF-8 to current non-UTF-8)
 * @param string before the call: the string to be converted; after the call:
 * 	reallocated to carry the converted string
 * @param inputOutputByteSize before the call: the size of the string including
 * 	leading NULL; after the call: the size of the converted string including
 * 	leading NULL
 * @retval 0 on success
 * @retval -1 on failure
 * @ingroup backendhelper
 *
 */
int kdbbUTF8Engine (Plugin * handle, int direction, char ** string, size_t * inputOutputByteSize)
{
	/* Current solution is not very complete.
	 * Iconv might well be available when a usable nl_langinfo is not.
	 * In this case we it should be possible to determine charset through other means
	 * See http://www.cl.cam.ac.uk/~mgk25/unicode.html#activate for more info on a possible solution */

	char * converted = 0;
	char *readCursor, *writeCursor;
	size_t bufferSize;
	iconv_t converter;

	if (!*inputOutputByteSize) return 0;
	if (!kdbbNeedsUTF8Conversion (handle)) return 0;

	if (direction == UTF8_TO)
		converter = iconv_open (getTo (handle), getFrom (handle));
	else
		converter = iconv_open (getFrom (handle), getTo (handle));

	if (converter == (iconv_t) (-1)) return -1;

	/* work with worst case, when all chars are wide */
	bufferSize = *inputOutputByteSize * 4;
	converted = elektraMalloc (bufferSize);
	if (!converted) return -1;

	readCursor = *string;
	writeCursor = converted;
	/* On some systems and with libiconv, arg1 is const char **.
	 * ICONV_CONST is defined by configure if the system needs this */
	if (iconv (converter, &readCursor, inputOutputByteSize, &writeCursor, &bufferSize) == (size_t) (-1))
	{
		elektraFree (converted);
		iconv_close (converter);
		return -1;
	}

	/* calculate the UTF-8 string byte size, that will be returned */
	*inputOutputByteSize = writeCursor - converted;
	/* store the current kdbbDecoded string for future free */
	readCursor = *string;
	/* allocate an optimal size area to store the converted string */
	*string = elektraMalloc (*inputOutputByteSize);
	/* copy all that matters for returning */
	memcpy (*string, converted, *inputOutputByteSize);
	/* release memory used by passed string */
	elektraFree (readCursor);
	/* release buffer memory */
	elektraFree (converted);
	/* release the conversor engine */
	iconv_close (converter);
	return 0;
}
Example #6
0
void MethodUpdateStatus::onCall(const sg::rpc::Uri& target)
{
    if (!getFrom().has_service_number())
        THROW_APP_EXCEPTION(sg::rpc::EC_RPC_INVALID_PARAMS, "service id is empty.");

    ConfigService::instance()->getServersList().updateServerStatus(
            common::ServerID(getFrom()),
            boost::static_pointer_cast<ServerConnectionHandler>(getHandler()),
            getRequestData().status());

    reply(target);
}
Example #7
0
int elektraIconvSet (Plugin * handle, KeySet * returned, Key * parentKey)
{
	Key * cur;

	if (!kdbbNeedsUTF8Conversion (handle)) return 0;

	ksRewind (returned);

	while ((cur = ksNext (returned)) != 0)
	{
		if (keyIsString (cur))
		{
			/* String or similar type of value */
			size_t convertedDataSize = keyGetValueSize (cur);
			char * convertedData = elektraMalloc (convertedDataSize);

			memcpy (convertedData, keyString (cur), keyGetValueSize (cur));
			if (kdbbUTF8Engine (handle, UTF8_TO, &convertedData, &convertedDataSize))
			{
				ELEKTRA_SET_ERRORF (46, parentKey,
						    "Could not convert string %s, got result %s,"
						    " encoding settings are from %s to %s (but swapped for write)",
						    keyString (cur), convertedData, getFrom (handle), getTo (handle));
				elektraFree (convertedData);
				return -1;
			}
			keySetString (cur, convertedData);
			elektraFree (convertedData);
		}
		const Key * meta = keyGetMeta (cur, "comment");
		if (meta)
		{
			/* String or similar type of value */
			size_t convertedDataSize = keyGetValueSize (meta);
			char * convertedData = elektraMalloc (convertedDataSize);

			memcpy (convertedData, keyString (meta), keyGetValueSize (meta));
			if (kdbbUTF8Engine (handle, UTF8_TO, &convertedData, &convertedDataSize))
			{
				ELEKTRA_SET_ERRORF (46, parentKey,
						    "Could not convert string %s, got result %s,"
						    " encodings settings are from %s to %s (but swapped for write)",
						    keyString (meta), convertedData, getFrom (handle), getTo (handle));
				elektraFree (convertedData);
				return -1;
			}
			keySetMeta (cur, "comment", convertedData);
			elektraFree (convertedData);
		}
	}

	return 1; /* success */
}
Example #8
0
	const char *request::operator[](const char * val)
	{
#define op(a) (strcmp(val, a) == 0)
		if (op("Accept"))              return getAccept();
		else if (op("Accept-Charset"))      return getAccept_Charset();
		else if (op("Accept-Encoding"))     return getAccept_Encoding();
		else if (op("Accept-Language"))     return getAccept_Language();
		else if (op("Authorization"))       return getAuthorization();
		else if (op("Expect"))              return getExpect();
		else if (op("From"))                return getFrom();
		else if (op("If-Match"))            return getIf_Match();
		else if (op("If-Modified-Since"))   return getIf_Modified_since();
		else if (op("If-None-Match"))       return getIf_None_Match();
		else if (op("If-Range"))            return getIf_Range();
		else if (op("If-Unmodified-Since")) return getIf_Unmodified_Since();
		else if (op("Max-Forwards"))        return getMax_Forwards();
		else if (op("Proxy-Authorization")) return getProxy_Authorization();
		else if (op("Range"))               return getRange();
		else if (op("Referer"))             return getReferrer();
		else if (op("TE"))                  return getTE();
		else if (op("User-Agent"))          return getUser_Agent();
		else if (op("URI"))                 return this->URI;
		return NULL;
#undef op
	}
Example #9
0
/*----------------------------------------------------------------------------*/
void SaoBandPosition::onParse(
        StreamAccessLayer &streamAccessLayer, Decoder::State &decoder,
        Plane cIdx)
{
    getFrom(streamAccessLayer, decoder, cabadState(decoder), *this);
    m_bandPosition[int(cIdx)] = getValue();
}
Example #10
0
/*----------------------------------------------------------------------------*/
void SaoOffsetSign::onParse(
        StreamAccessLayer &streamAccessLayer, Decoder::State &decoder,
        Plane cIdx, int i)
{
    getFrom(streamAccessLayer, decoder, cabadState(decoder), *this);
    m_saoOffsetSign[int(cIdx)][i] = getValue();
}
Example #11
0
void ImplAlignandum::shuffle( unsigned int num_iterations,
		Position window_size)
{
	if (window_size == 0)
		window_size = getLength();

	Position first_from = getFrom();

	for (unsigned x = 0; x < num_iterations; ++x)
	{

		Position i,j;
		Position to = getTo();

		while (to > first_from )
		{
			Position from = to - window_size;

			if (from < 0)
			{
				from = 0;
				window_size = to;
			}

			for (i = to - 1; i >= from; --i)
			{
				j = to - getRandomPosition(window_size) - 1;
				swap( i, j );
			}
			to -= window_size;
		}
	}
}
                void NLocalisationPortion::toStruct(_NLocalisationPortion & input)
                {
                    memset(&input, 0, sizeof(_NLocalisationPortion));

                    input.from = getFrom().getValue();
                    input.count = getCount().getValue();
                }
Example #13
0
bool Move::isEquivalent(Move const& m) const
{
	if(m.getTo()==getTo() && m.getFrom()==getFrom() && m.getSpecial()==getSpecial())
	{
		return true;
	}
	return false;
}
Example #14
0
void pJointDistance::setLocalAnchor0(VxVector anchor)
{
	NxDistanceJointDesc descr;		
	NxDistanceJoint*joint  = static_cast<NxDistanceJoint*>(getJoint());	
	if (!joint)return ;	joint->saveToDesc(descr);
	descr.localAnchor[0] =getFrom(anchor);
	joint->loadFromDesc(descr);
}
Example #15
0
 virtual void onCall(const sg::rpc::Uri& target)
 {
     common::ConversationID conv_id(getFrom());
     common::UserPointID usr_ptid(getRequestData().sender_ua_uri());
     common::UserPointID target_ptid(target);
     LOG(info, "recv msg from " << usr_ptid << " to " << target_ptid << " conversation id =: " << conv_id);
     LOG(info, "msgid=" << getRequestData().msg_id() << ", content: " << getRequestData().content());
 }
Example #16
0
UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents)
{
    // FIXME: We may want to handle stylesheets that have multiple owners
    //        http://crbug.com/242125
    if (sheetContents && sheetContents->hasSingleOwnerNode())
        return getFrom(sheetContents->singleOwnerDocument());
    return 0;
}
Example #17
0
btVector3 
tgRodInfo::getConnectionPoint(const btVector3& referencePoint,
                   const btVector3& destinationPoint,
                   const double rotation) const
{
    if (referencePoint == destinationPoint)
    {
      throw 
        std::invalid_argument("Destination point is the reference point.");
    }
    // Find the closest point on the radius from the referencePoint
    const btVector3 cylinderAxis = (getTo() - getFrom()).normalize();
    const btVector3 cylinderAxis2 = (getTo() - getFrom()).normalize();
    // Vector from reference point to destination point
    const btVector3 refToDest =
        (referencePoint - destinationPoint).normalize();

    // Find a vector perpendicular to both the cylinder axis and refToDest
    btVector3 rotationAxis = cylinderAxis.cross(refToDest);
    
    // Handle a vector crossed with itself
    if (rotationAxis.length() == 0.0)
    {
        btScalar a = cylinderAxis[0];
        btScalar b = cylinderAxis[1];
        btScalar c = cylinderAxis[2];
        // Find an arbitrary perpendicular vector
        rotationAxis = btVector3(b - c, -a, a).normalize(); 
    }

    const btVector3 directional =
        cylinderAxis.rotate(rotationAxis, -M_PI / 2.0).normalize();

    // Apply one additional rotation so we can end up anywhere we
    // want on the radius of the rod
    
    // When added to any point along the cylinder axis, this will take you
    // to the surface in the direction of the destinationPoint
    
    const btVector3 surfaceVector = directional.rotate(cylinderAxis2, rotation).normalize()
                                    * m_config.radius;

    // Return the the surface point closest to the reference point in the
    // direction of the destination point. 
    return referencePoint + surfaceVector;
}
Example #18
0
VxVector pJointDistance::getLocalAnchor1()
{
	NxDistanceJointDesc descr;		
	NxDistanceJoint*joint  = static_cast<NxDistanceJoint*>(getJoint());	
	if (!joint)return VxVector();
	joint->saveToDesc(descr);
	return getFrom(descr.localAnchor[1]);
}
Example #19
0
pFluidEmitter*pFluid::createEmitter(const pFluidEmitterDesc& desc)
{

	NxFluidEmitterDesc eDesc ;
	eDesc.setToDefault();

	pFactory::Instance()->copyToEmitterDesc(eDesc,desc);

	int valid = eDesc.isValid();
	if (!valid)
	{
		xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,"Emitter Description not Valid !");
		return NULL;
	}

	CK3dEntity*entityReference = (CK3dEntity*)ctx()->GetObject(desc.entityReference);
	if (!entityReference)
	{
		xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,"You must set a reference object ID in .referenceEntity");
		return NULL;
	}


	eDesc.relPose.M.id();
	eDesc.relPose.M.rotX(-NxHalfPiF32);
	eDesc.relPose.t = NxVec3(0,1.1f,0);

	////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

	NxFluidEmitter *emitter   = getFluid()->createEmitter(eDesc);

	if (!emitter)
		return NULL;
	
	pFluidEmitter * result  = new pFluidEmitter();
	result->setEmitter(emitter);
	result->setFluid(this);
	result->setEntityReference(entityReference->GetID());
	VxVector pos;
	if (desc.frameShape)
	{
		desc.frameShape->GetPosition(&pos);
	}
	emitter->setGlobalPosition(getFrom(pos));
	emitter->userData = result;

	//////////////////////////////////////////////////////////////////////////
	//
	//		Render Settings    :  
	//

	pFluidRenderSettings *rSettings  =  new pFluidRenderSettings(ctx(),desc.entityReference,"pFluidEmitter");
	rSettings->setToDefault();
	rSettings->setEmitter(result);

	return result;
	
}
void MethodDeleteUserConfig::onCall(const sg::rpc::Uri& target)
{
    common::UserID user_id(getFrom());

    APNsProviderService::instance()->
        getUserConfigManager().deleteUserConfig(user_id, true);

    reply(target);
}
Example #21
0
void MethodRegister::onCall(const sg::rpc::Uri& target)
{
    if (!getFrom().has_service_type() || getFrom().service_type().empty())
        THROW_APP_EXCEPTION(sg::rpc::EC_RPC_INVALID_PARAMS, "missing service type field!");

    base::net::SockAddr sockaddr(getHandler()->addr().getAddr().c_str(), getRequestData().routing_port());
    common::ServerID svc_id(getFrom());
    ConfigService::instance()->getServersList().addServer(
            svc_id,
            sockaddr,
            boost::static_pointer_cast<ServerConnectionHandler>(getHandler()),
            getRequestData().info(),
            getRequestData().overwrite_if_exist());

    rpc::RegisterResponse resp;
    resp.set_service_number(svc_id.svc_num);
    reply(target, resp);
}
Example #22
0
std::string MapExpr::toString() {
  std::string ret = "{";
  for (size_t i = 0; i < mapSize(); ++i) {
    if (i > 0) ret.push_back(',');
    ret.append(getFrom(i)->toString()+"->"+getTo(i)->toString());
  }
  ret.push_back('}');
  return ret;
}
Example #23
0
string Move::toString() const
{
	string s = "";
	int i = getSpecial();
	if(i==PIECE_QUEEN) s="Q";
	else if(i==PIECE_KNIGHT) s="N";
	else if(i==PIECE_ROOK) s="R";
	else if(i==PIECE_BISHOP) s="B";
	return (Int2Sq(getFrom()) + Int2Sq(getTo()) + s);
}
Example #24
0
void MethodAckChatMsg::onCall(const sg::rpc::Uri& target)
{
    common::UserPointID user_ptid(getFrom());
    common::UserID sender_user_id(getRequestData().sender_usr_id());

    InstantMessagingService::instance()->getUsersManager().getUser(
            user_ptid)->ackChatMessage(sender_user_id,
                    getRequestData().msg_id());

    reply(target);
}
Example #25
0
int RootOperationData::copyAttr(const std::string& name, Element & attr) const
{
    if (name == SERIALNO_ATTR) { attr = getSerialno(); return 0; }
    if (name == REFNO_ATTR) { attr = getRefno(); return 0; }
    if (name == FROM_ATTR) { attr = getFrom(); return 0; }
    if (name == TO_ATTR) { attr = getTo(); return 0; }
    if (name == SECONDS_ATTR) { attr = getSeconds(); return 0; }
    if (name == FUTURE_SECONDS_ATTR) { attr = getFutureSeconds(); return 0; }
    if (name == ARGS_ATTR) { attr = getArgsAsList(); return 0; }
    return RootData::copyAttr(name, attr);
}
Example #26
0
/*----------------------------------------------------------------------------*/
void SaoOffsetAbs::onParse(
        StreamAccessLayer &streamAccessLayer, Decoder::State &decoder,
        Plane cIdx, int i)
{
    const auto component = toComponent(cIdx);
    int bitDepth = decoder.picture()->bitDepth(component);

    m_cTRMax = (1 << (std::min(bitDepth, 10) - 5)) - 1;
    getFrom(streamAccessLayer, decoder, cabadState(decoder), *this);
    m_saoOffsetAbs[int(cIdx)][i] = getValue();
}
void MethodGetNonce::onCall(const sg::rpc::Uri& target)
{
    common::UserPointID user_ptid(getFrom());

    rpc::GetNonceResponse resp;

    UserAccessService::instance()->getUserPointsManager().getUserPoint(
            user_ptid)->newNonce(resp.mutable_nonce());

    reply(target, resp);
}
Example #28
0
void MapExpr::print(FILE* file, int indent) const {
  fprintf(file, "%*sMapExpr:\n", indent, "");
  fprintf(file, "%*sfromTyp: %s", indent + 2, "",
      getFromTyp()->toString().c_str());
  fprintf(file, "%*stoTyp: %s", indent + 2, "",
      getToTyp()->toString().c_str());
  for (size_t i = 0; i < mapSize(); i++) {
    fprintf(file, "%*sfrom#%d: \n", indent + 2, "", (int)i);
    getFrom(i)->print(file, indent + 4);
    fprintf(file, "%*sto#%d: \n", indent + 2, "", (int)i);
    getTo(i)->print(file, indent + 4);
  }
}
Example #29
0
void pFluid::updateVirtoolsMesh()
{

/*
	updateCloud();
	return;*/
	//todo, move this into a small billboard rendering lib.
	if (!mRenderBuffer)
	{
		unsigned sizeFloat = mMaxParticles * 3 * 4;
		mRenderBuffer = new float[sizeFloat];

		if (mTrackUserData)
		{
			mRenderBufferUserData = new float[mMaxParticles * 4 * 4];
		}

	}

	return ;

	CK3dEntity *dstEnt  = getParticleObject();
	CKMesh *mesh  = getParticleObject()->GetCurrentMesh();

	if (!dstEnt  || !mesh )
	{
		return;
	}
	
	if (mParticleBuffer)
	{

		for (int i = 0 ; i < mesh->GetVertexCount() ; i++)
		{
			
			pParticle *p  = &mParticleBuffer[i];
			if (p)
			{
				VxVector v  = getFrom(p->position);
				VxVector outIV;
				getParticleObject()->InverseTransform(&outIV,&v);
				mesh->SetVertexPosition(i,&outIV);

			}
		}
	}

	mesh->VertexMove();
}
tgBulletSpringCable* tgBasicActuatorInfo::createTgBulletSpringCable()
{
    //std::cout << "tgBasicActuatorInfo::createMuscle2P()" << std::endl;
    
    //std::cout << "  getFromRigidInfo(): " << getFromRigidInfo() << std::endl;
    //std::cout << "  getFromRigidInfo(): " << getFromRigidInfo()->getRigidInfoGroup() << std::endl;
    
    // @todo: need to check somewhere that the rigid bodies have been set...
    btRigidBody* fromBody = getFromRigidBody();
    btRigidBody* toBody = getToRigidBody();

    btVector3 from = getFromRigidInfo()->getConnectionPoint(getFrom(), getTo(), m_config.rotation);
    btVector3 to = getToRigidInfo()->getConnectionPoint(getTo(), getFrom(), m_config.rotation);
	
	std::vector<tgBulletSpringCableAnchor*> anchorList;
	
	tgBulletSpringCableAnchor* anchor1 = new tgBulletSpringCableAnchor(fromBody, from);
	anchorList.push_back(anchor1);
	
	tgBulletSpringCableAnchor* anchor2 = new tgBulletSpringCableAnchor(toBody, to);
	anchorList.push_back(anchor2);
	
    return new tgBulletSpringCable(anchorList, m_config.stiffness, m_config.damping, m_config.pretension);
}