Example #1
0
void Velodyne::ConvertRangeToPoints(const hal::LidarMsg& LidarData, //input
                                    std::shared_ptr<LidarMsg> CorrectedData) //output
{
  if((int)LidarData.distance().rows() != mn_NumLasers)
  {
      std::cout<<"Dude!! You said there will be "<< mn_NumLasers << " lasers"
               <<" but i am getting only "
              <<(int)LidarData.distance().rows()<<std::endl;
    return;
  }
  CorrectedData->set_system_time(LidarData.system_time());
  CorrectedData->set_device_time(LidarData.device_time());
  ComputePoints(LidarData, CorrectedData);
  ComputeIntensity(LidarData, CorrectedData);
  md_TimeStamp = LidarData.system_time();
}
Example #2
0
NaDbSurface::NaDbSurface(const NaGeSurface* s)
{
    pSurf = s->Copy();
    glObjType = GLSURFACE;
    glObjID = (int)glObjType + NaDbObject::GetCount();
    SMOOTH = 100;
    CSMOOTH = 100;

    itsShadeRed = 150;
    itsShadeGreen = 150;
    itsShadeBlue = 150;

    itsRed = 200;
    itsGreen = 225;
    itsBlue = 50;

    isoRed = 205;
    isoGreen = 205;
    isoBlue = 255;

    factor = 1;
    pattern = 0x5555;

    SetMaterial(BRONZE);

    pointList = new CListOfPoint3D;
    pointWFUList = new CListOfPoint3D;
    pointWFVList = new CListOfPoint3D;
    normalList = new CListOfPoint3D;
    bpointList = new CListOfPoint3D;

    myListWFUIter.SetList(pointWFUList);
    myListWFVIter.SetList(pointWFVList);

    ComputePoints();
    ComputeWFPoints();
    ComputeBoundLimits();
    InitDisplayList();
}
Example #3
0
bool CHARACTER::RemoveAffect(CAffect * pkAff)
{
	if (!pkAff)
		return false;

	// AFFECT_BUF_FIX
	m_list_pkAffect.remove(pkAff);
	// END_OF_AFFECT_BUF_FIX

	ComputeAffect(pkAff, false);

	// 백기 버그 수정.
	// 백기 버그는 버프 스킬 시전->둔갑->백기 사용(AFFECT_REVIVE_INVISIBLE) 후 바로 공격 할 경우에 발생한다.
	// 원인은 둔갑을 시전하는 시점에, 버프 스킬 효과를 무시하고 둔갑 효과만 적용되게 되어있는데,
	// 백기 사용 후 바로 공격하면 RemoveAffect가 불리게 되고, ComputePoints하면서 둔갑 효과 + 버프 스킬 효과가 된다.
	// ComputePoints에서 둔갑 상태면 버프 스킬 효과 안 먹히도록 하면 되긴 하는데,
	// ComputePoints는 광범위하게 사용되고 있어서 큰 변화를 주는 것이 꺼려진다.(어떤 side effect가 발생할지 알기 힘들다.)
	// 따라서 AFFECT_REVIVE_INVISIBLE가 RemoveAffect로 삭제되는 경우만 수정한다.
	// 시간이 다 되어 백기 효과가 풀리는 경우는 버그가 발생하지 않으므로 그와 똑같이 함.
	//		(ProcessAffect를 보면 시간이 다 되어서 Affect가 삭제되는 경우, ComputePoints를 부르지 않는다.)
	if (AFFECT_REVIVE_INVISIBLE != pkAff->dwType)
	{
		ComputePoints();
	}
	CheckMaximumPoints();

	if (test_server)
		sys_log(0, "AFFECT_REMOVE: %s (flag %u apply: %u)", GetName(), pkAff->dwFlag, pkAff->bApplyOn);

	if (IsPC())
	{
		SendAffectRemovePacket(GetDesc(), GetPlayerID(), pkAff->dwType, pkAff->bApplyOn);
	}

	CAffect::Release(pkAff);
	return true;
}
Example #4
0
BOOL	TTabButtonGadget :: GetRegion ( TRegion &  Region, TRegionType  type )
   {
	TPoint			TabPoints [6] ;
	TPoint			Points    [8] ;
	register BOOL           Status		=  TRUE ;
	register int		i,
				HiliteDelta = HiliteUnits / 2, 	// Servent à épaissir
				ShadowDelta = ShadowUnits / 2 ; // les bordures diagonales
	register int		Width	    = Bounds. Width ( ) ;



	if  ( Overlap )	
		Width += dX ;

	ComputePoints ( TabPoints ) ;


	switch  ( type )
	   {

	// Partie visible : calculer ce qui n'est pas recouvert
	// Il faut bien faire attention de calculer la coordonnée du gadget
	// DANS la fenêtre pour que la région de clipping soit correcte.
		case	VisibleRegion :
		case	OuterRegion :
			for  ( i = 0 ; i < 6 ; i ++ )
			   {
				TabPoints [i]. x += Bounds. left ;
				TabPoints [i]. y += Bounds. top ;
			    }

			Region = TRegion ( TabPoints, 6, ALTERNATE ) ;

			if  ( Overlap  &&  type  ==  VisibleRegion )
				CheckOverlappedRegion ( Region ) ;
			break ;


	// Partie englobant la totalité du gadget, sans la bordure
		case	InnerRegion :
			TabPoints [0]. x	+=  cxBorder ;
			TabPoints [0]. y 	+=  cyBorder ;

			TabPoints [1]. x 	-=  cxBorder ;
			TabPoints [1]. y	+=  cyBorder ;

			TabPoints [2]. x 	-=  cxBorder ;
			TabPoints [2]. y	-=  2 * cyBorder ;

			TabPoints [3]. x	-=  cxBorder ;
			TabPoints [3]. y	-=  2 * cyBorder ;

			TabPoints [4]. x	+=  cxBorder ;
			TabPoints [4]. y 	-=  2 * cyBorder ;

			TabPoints [5]. x	+=  cxBorder ;
			TabPoints [5]. y 	-=  2 * cyBorder ;
				       

	// et avec la bordure
		case	BorderRegion :
			Region = TRegion ( TabPoints, 6, ALTERNATE ) ;
			break ;


	// Partie dessinable
		case	DrawableRegion :
		   {
			int		delta 	=  ( State  ==  Up  ||
							( Overlap  &&  State  ==  Down ) ) ?
							0 : HiliteUnits ;
			register int	W	=  Width          -
						   HiliteUnits        -
						   ShadowUnits        -
						   ( 2 * dX )         -
						   ( 2 * cxBorder ),
					H	=  Bounds. Height ( ) -
						   HiliteUnits	      -
						   ShadowUnits 	      -
						   ( 2 * cyBorder ),
					X	=  cxBorder + HiliteUnits + delta + dX,
					Y 	=  cyBorder + HiliteUnits + delta ;


			Region = TRegion ( TRect ( X, Y, X + W, Y + H ) ) ;
			break ;
		     }


	// Partie éclairée
		case	HiliteRegion :
			Points [0]. x = cxBorder ;
			Points [0]. y = cyBorder ;

			Points [1]. x = Width - cxBorder ;
			Points [1]. y = cyBorder ;

			Points [2]. x = Width - cxBorder ;
			Points [2]. y = cyBorder + HiliteUnits ;

			Points [3]. x = cxBorder + HiliteUnits ;
			Points [3]. y = cyBorder + HiliteUnits ;

			Points [4]. x = cxBorder + HiliteUnits  ;
			Points [4]. y = cySoftCorner - cyBorder - HiliteDelta ;

			Points [5]. x = dX + cxBorder + HiliteUnits + HiliteDelta ;
			Points [5]. y = Bounds. Height ( ) - cyBorder ;

			Points [6]. x = dX + cxBorder ;
			Points [6]. y = Bounds. Height ( ) - cyBorder ;

			Points [7]. x = cxBorder ;
			Points [7]. y = cySoftCorner - cyBorder ;

			Region = TRegion ( Points, 8, ALTERNATE ) ;
			break ;


	// Partie ombrée 
		case	ShadowRegion :
			Points [0]. x = Width - cxBorder ;
			Points [0]. y = cyBorder ;

			Points [1]. x = Width - cxBorder ;
			Points [1]. y = cySoftCorner - cyBorder ;

			Points [2]. x = Width - dX - cxBorder ;
			Points [2]. y = Bounds. Height ( ) - cyBorder ;

			Points [3]. x = dX - 1 ;
			Points [3]. y = Bounds. Height ( ) - cyBorder ;

			Points [4]. x = dX + HiliteUnits - 1 ;
			Points [4]. y = Bounds. Height ( ) - cyBorder - ShadowUnits ;

			Points [5]. x = Width - dX - cxBorder - ShadowDelta ;
			Points [5]. y = Bounds. Height ( ) - cyBorder - ShadowUnits ;
	
			Points [6]. x = Width - cxBorder - ShadowUnits ;
			Points [6]. y = cySoftCorner - cyBorder - ShadowDelta ;

			Points [7]. x = Width - cxBorder - ShadowUnits ;
			Points [7]. y = cyBorder + HiliteUnits ;


			Region = TRegion ( Points, 8, ALTERNATE ) ;
			break ;


		case	OtherShadowRegion :
			Status = FALSE ;
			break ;
				
	
	// Autre : ne devrait jamais arriver
		default :
			Status = false ;
	     }



	return  ( Status ) ;
    }
Example #5
0
void NaDbSurface::SetSurface(const NaGeSurface* s)
{
    pSurf = s->Copy();
    ComputePoints();
    ComputeBoundLimits();
}
Example #6
0
File: App.cpp Project: edvorg/chair
void App::Update(double dt) {
	progress.Update(dt);
	shaker.Update(dt);

	static float time = 0.0f;

	if (!progress.IsPaused()) {
		time += dt;

		world.Step(dt, 1, 2);

		world.SetGravity({ 0, playerGravityState });

		// move back

		const auto camPosDelta = camPos - prevCamPos;
		prevCamPos = camPos;

		backPos -= camPosDelta * 0.75;

		if (backPos < - 100) {
			backPos = 0.0f;
		}

		// convex points

		ComputePoints();

		// cam pos

		ComputeCampPos(dt);

		// body <-> body

		BodyCrossBody(dt);

		// eyes antigrav

		EyesAntigrav();

		// body <-> eye

		BodyCrossEye();

		// borders respawn

		RespawnBorders(false);

		// respawn obstacles

		RespawnObstacles(false);

		// fall out in holes

		FalloutHoles(dt);

		// particles respawn

		RespawnParticles();

		//respawn eyes

		RespawnEyes();

		// handle balancer

		UpdateBalancer(dt);

		// mark stuck bodies

		if (time > 2.0) {
			auto fallenCount = 0;

			for (auto& b : playerBodies) {
				if (std::abs(b->GetLinearVelocity().x) < 6.0f
					&& std::abs(b->GetLinearVelocity().y) < 10.0f
					) {
					playerBodiesStucks[b] += dt;

					if (playerBodiesStucks[b] > 0.75f) {
						playerBodiesFallen[b] = true;
						fallenCount++;
					}
				}
				else {
					playerBodiesStucks[b] = 0;

					if (b->GetPosition().y < 0.0
						|| b->GetPosition().y > 52.0f) {
						playerBodiesFallen[b] = true;
						fallenCount++;
					}
					else {
						playerBodiesFallen[b] = false;
					}
				}
			}

			if (fallenCount > playerBodiesCount / 3 ) {
				progress.RestartGame();

				for (auto& b : playerBodies) {
					const float x = 0 + rand() % 50;
					const float y = 15 + rand() % 30;
					b->SetTransform({ x, y }, 0);
					playerBodiesFallen[b] = false;
					playerBodiesStucks[b] = 0.0f;
				}

				for (auto& e : playerEyesBodies) {
					const float x = 0 + rand() % 50;
					const float y = 15 + rand() % 30;
					e->SetTransform({ x, y }, 0);
				}

				camPos = 0;
				prevCamPos = camPos;
				backPos = 0.0f;
				time = 0.0f;

				ComputePoints();
				RespawnBorders(true);
				RespawnObstacles(true);
				GoSolid();

				playerGameVelocity = playerGameVelocityDefault;
			}
		}
	}
}
Example #7
0
File: App.cpp Project: edvorg/chair
App::App() :
	world(b2Vec2(0, -9.8)),
	playerBodiesPoints(playerBodiesCount),
	playerBodies(playerBodiesCount),
	playerBodiesShapes(playerBodiesCount),
	playerEyesBodiesPoints(playerEyesCount),
	playerEyesBodies(playerEyesCount),
	playerEyesBodiesShapes(playerEyesCount),
	borderShapes(4),
	borderBodies(4) {

	world.SetDebugDraw(new graphics::DebugDraw);

	for (auto i = 0; i < 4; ++i) {
		const auto shape = new b2PolygonShape;
		shape->SetAsBox(100, 3);

		b2BodyDef bdef;

		bdef.awake = false;
		bdef.allowSleep = true;
		bdef.active = true;
		bdef.type = b2_staticBody;

		const auto body = world.CreateBody(&bdef);

		b2FixtureDef fdef;
		fdef.shape = shape;
		fdef.friction = borderFriction;
		fdef.restitution = borderRestitution;
		fdef.filter.categoryBits = borderCategory;

		const auto fixt = body->CreateFixture(&fdef);

		borderShapes[i].reset(shape);
		borderBodies[i] = body;
	}

	for (auto i = 0; i < playerBodiesCount; ++i) {
		const auto shape = new b2PolygonShape;
		shape->SetAsBox(playerBodySize, playerBodySize);

		b2BodyDef bdef;

		bdef.position.x = 0 + rand() % 50;
		bdef.position.y = 15 + rand() % 30;
		bdef.type = b2_dynamicBody;

		const auto body = world.CreateBody(&bdef);

		b2FixtureDef fdef;
		fdef.shape = shape;
		fdef.density = playerBodyDencity;
		fdef.friction = playerBodyFriction;
		fdef.restitution = playerBodyRestitution;
		fdef.filter.categoryBits = playerBodyCategory;

		const auto fixt = body->CreateFixture(&fdef);

		playerBodiesShapes[i].reset(shape);
		playerBodies[i] = body;
		playerBodiesPoints[i] = bdef.position;
		playerBodiesFallen[body] = false;
	}

	for (auto i = 0; i < playerEyesCount; ++i) {
		const auto shape = new b2CircleShape;
		shape->m_radius = playerEyeSize;

		b2BodyDef bdef;

		bdef.position.x = 0 + rand() % 50;
		bdef.position.y = 15 + rand() % 30;
		bdef.type = b2_dynamicBody;

		const auto body = world.CreateBody(&bdef);

		b2FixtureDef fdef;
		fdef.shape = shape;
		fdef.density = playerEyeDencity;
		fdef.friction = playerEyeFriction;
		fdef.restitution = playerEyeRestitution;
		fdef.filter.categoryBits = playerEyeCategory;

		const auto fixt = body->CreateFixture(&fdef);

		playerEyesBodiesShapes[i].reset(shape);
		playerEyesBodies[i] = body;
		playerEyesBodiesPoints[i] = bdef.position;
	}

	{
		const auto shape = new b2PolygonShape;
		shape->SetAsBox(2, 13);

		b2BodyDef bdef;

		bdef.awake = false;
		bdef.allowSleep = true;
		bdef.active = true;
		bdef.type = b2_staticBody;

		const auto body = world.CreateBody(&bdef);

		b2FixtureDef fdef;
		fdef.shape = shape;
		fdef.friction = borderFriction;
		fdef.restitution = borderRestitution;
		fdef.filter.categoryBits = borderCategory;

		const auto fixt = body->CreateFixture(&fdef);

		topObstacleShape.reset(shape);
		topObstacle = body;
	}

	{
		const auto shape = new b2PolygonShape;
		shape->SetAsBox(2, 5);

		b2BodyDef bdef;

		bdef.awake = false;
		bdef.allowSleep = true;
		bdef.active = true;
		bdef.type = b2_staticBody;

		const auto body = world.CreateBody(&bdef);

		b2FixtureDef fdef;
		fdef.shape = shape;
		fdef.friction = borderFriction;
		fdef.restitution = borderRestitution;
		fdef.filter.categoryBits = borderCategory;

		const auto fixt = body->CreateFixture(&fdef);

		bottomObstacleShape.reset(shape);
		bottomObstacle = body;
	}

	{
		const auto shape = new b2PolygonShape;
		shape->SetAsBox(2, 7);

		b2BodyDef bdef;

		bdef.awake = false;
		bdef.allowSleep = true;
		bdef.active = true;
		bdef.type = b2_staticBody;

		const auto body = world.CreateBody(&bdef);

		b2FixtureDef fdef;
		fdef.shape = shape;
		fdef.friction = borderFriction;
		fdef.restitution = borderRestitution;
		fdef.filter.categoryBits = borderCategory;

		const auto fixt = body->CreateFixture(&fdef);

		bottomHighObstacleShape.reset(shape);
		bottomHighObstacle = body;
	}

	{
		const auto shape = new b2PolygonShape;
		shape->SetAsBox(12.5, 2);

		b2BodyDef bdef;

		bdef.awake = false;
		bdef.allowSleep = true;
		bdef.active = true;
		bdef.type = b2_staticBody;
		bdef.position.x = -100.0f;

		const auto body = world.CreateBody(&bdef);

		b2FixtureDef fdef;
		fdef.shape = shape;
		fdef.friction = borderFriction;
		fdef.restitution = borderRestitution;
		fdef.filter.categoryBits = holeCategory;

		const auto fixt = body->CreateFixture(&fdef);

		holeTopShape.reset(shape);
		holeTopBody = body;
	}

	{
		const auto shape = new b2PolygonShape;
		shape->SetAsBox(12.5, 2);

		b2BodyDef bdef;

		bdef.awake = false;
		bdef.allowSleep = true;
		bdef.active = true;
		bdef.type = b2_staticBody;
		bdef.position.x = -100.0f;

		const auto body = world.CreateBody(&bdef);

		b2FixtureDef fdef;
		fdef.shape = shape;
		fdef.friction = borderFriction;
		fdef.restitution = borderRestitution;
		fdef.filter.categoryBits = holeCategory;

		const auto fixt = body->CreateFixture(&fdef);

		holeBottomShape.reset(shape);
		holeBottomBody = body;
	}

	ComputePoints();
	RespawnBorders(true);
}