Exemplo n.º 1
0
void Mushroom::createPhyBody() {
	b2BodyDef b2BodyDef;
	b2BodyDef.type = b2_dynamicBody;
	//b2BodyDef.bullet = true;
	b2BodyDef.fixedRotation = true;
	b2BodyDef.position = b2Vec2(c2b(this->getPosition().x),
	c2b(this->getPosition().y));
	b2PhyBody = PhyWorld::shareWorld()->CreateBody(&b2BodyDef);
	//b2PhyBody->SetLinearDamping(1.0f);
	float width = c2b(this->getContentSize().width / 2);
	float height = c2b(this->getContentSize().height / 2);
	b2PolygonShape b2Shape;
	b2Vec2 points[6];
	points[5] = b2Vec2(-width, 0);
	points[4] = b2Vec2(-width, height);
	points[3] = b2Vec2(width, height);
	points[2] = b2Vec2(width, 0);
	points[1] = b2Vec2(width * 0.6f, -height);
	points[0] = b2Vec2(-width * 0.6f, -height);
	b2Shape.Set(points, 6);

//	b2Shape.SetAsBox(c2b(this->getContentSize().width / 2),
//	c2b(this->getContentSize().height / 2));

// Define the dynamic body fixture.
	b2FixtureDef fixtureDef;
	fixtureDef.shape = &b2Shape;
	fixtureDef.density = 5.0f;
	fixtureDef.friction = 1.0f;
	// Add the shape to the body.
	b2PhyBody->CreateFixture(&fixtureDef);
	//b2PhyBody->SetLinearDamping(0.0f);
	b2PhyBody->SetLinearVelocity(b2Vec2_zero);
	b2PhyBody->SetUserData(this);
}
Exemplo n.º 2
0
/*
 | according to rfc3720, the binary string
 | cannot be larger than 1024 - but i can't find it :-) XXX
 | not enforced yet.
 */
int
str2bin(char *str, char **rsp)
{
     char	*src, *dst, *tmp;
     int	i, len = 0;

     src = str;
     tmp = NULL;
     if(strncasecmp("0x", src, 2) == 0) {
	  src += 2;
	  len = strlen(src);
	  
	  if((tmp = malloc((len+1)/2)) == NULL) {
	       // XXX: print some error?
	       return 0;
	  }
	  dst = tmp;
	  if(len & 1)
	       *dst++ = c2b(*src++);
	  while(*src) {
	       *dst = c2b(*src++) << 4;
	       *dst++ |= c2b(*src++);
	  }
	  len = dst - tmp;
     } else
     if(strncasecmp("0b", src , 2) == 0) {
	  // base64
	  unsigned char b6;

	  src += 2;
	  len = strlen(src) / 4 * 3;
	  if((tmp = malloc(len)) == NULL) {
	       // XXX: print some error?
	       return 0;
	  }
	  dst = tmp; 
	  i = 0;
	  while(*src && ((b6 = c64tobin(*src++)) != 64)) {
	       switch(i % 4) {
	       case 0:
		    *dst = b6 << 2;
		    break;
	       case 1:
		    *dst++ |= b6 >> 4;
		    *dst = b6 << 4;
		    break;
	       case 2:
		    *dst++ |= b6 >> 2;
		    *dst = b6 << 6;
		    break;
	       case 3:
		    *dst++ |= b6;
		    break;
	       }
	       i++;
	  }
	  len = dst - tmp;
     }
Exemplo n.º 3
0
static DWORD s2b(BYTE dst[], const char *src)
{
  DWORD i;
	DWORD l = strlen(src) / 2;

	for (i=0; i<l; i++)
		dst[i] = (BYTE) ((c2b(src[2*i])<<4) + c2b(src[2*i+1]));

	return l;
}
Exemplo n.º 4
0
int main(int argc, char ** argv)
{

  ISvcLocator *svc = NULL;

  std::cout << "Looking for classes..." << std::endl;
  std::auto_ptr<MyInterface> c1a( AlgFactory_t::create("Class1", "c1a", svc) );
  std::auto_ptr<MyInterface> c2a( AlgFactory_t::create("Class2", "c2a", svc) );
  call(c1a.get());
  call(c2a.get());

  std::cout << "Looking for IDs..." << std::endl;
  std::auto_ptr<MyInterface> c1b( AlgFactory_t::create("1", "c1b", svc) );
  std::auto_ptr<MyInterface> c2b( AlgFactory_t::create("2", "c2b", svc) );
  call(c1b.get());
  call(c2b.get());

  try {
    AlgFactory_t::create("3", "c1b", svc);
  } catch (Gaudi::PluginService::Exception &e) {
    std::cout << "PluginService::Exception -> " << e.what() << std::endl;
  }

  std::cout << "Done!" << std::endl;
}