Exemple #1
0
void View::Validate() {
	if (!isVisible()) return;
	element = quad2(container.x + padding[BORDER_LEFT],
	                container.y + padding[BORDER_BOTTOM],
	                container.w - padding[BORDER_RIGHT] - padding[BORDER_LEFT],
	                container.h - padding[BORDER_TOP] - padding[BORDER_BOTTOM]);

	// apply alignment
	float x = element.x;
	float y = element.y;
	float w = element.w;
	float h = element.h;
	if (size.x >= 0)
		w = size.x;
	switch (align.x) {
		case ALIGN_CENTER:
			x = element.x + element.w / 2 - w / 2;
			break;
		case ALIGN_RIGHT:
			x = element.x + element.w - w;
			break;
	}
	if (size.y >= 0)
		h = size.y;
	switch (align.y) {
		case ALIGN_CENTER:
			y = element.y + element.h / 2 - h / 2;
			break;
		case ALIGN_TOP:
			y = element.y + element.h - h;
			break;
	}
	element = quad2(x, y, w, h);
}
int main(int argc, char** argv) {
  ros::init(argc, argv, "multiquad_script_test");
  ros::NodeHandle node;
  ros::Rate rate(FRAMES_PER_SEC);

  // Create quads
  Quad quad1("quad01");
  Quad quad2("quad02");

  // Group quads together
  Formation form;
  form.add_quad(quad1);
  form.add_quad(quad2);

  // form.add_script<Takeoff>(new Takeoff(0.0));


  ROS_INFO("Boundary checking starting...");

  while(node.ok()) {
    form.run();
    rate.sleep();
  }

  return 0;
}
Exemple #3
0
// -----------------------------------------------------------------
// Name : setValue
// -----------------------------------------------------------------
void Gauge::setValue(int iVal)
{
    m_iCurValue = iVal;
    int fgw = max(1, m_iWidth * m_iCurValue / m_iRefValue);
    QuadData quad2(0, fgw, 0, m_iHeight, m_pForegroundGeometry->getTexture());
    m_pForegroundGeometry->build(&quad2);
}
Exemple #4
0
// -----------------------------------------------------------------
// Name : rebuildGeometries
// -----------------------------------------------------------------
void Gauge::rebuildGeometries()
{
    QuadData quad(0, m_iWidth, 0, m_iHeight, m_pBackgroundGeometry->getTexture());
    m_pBackgroundGeometry->build(&quad);
    int fgw = max(1, m_iWidth * m_iCurValue / m_iRefValue);
    QuadData quad2(0, fgw, 0, m_iHeight, m_pForegroundGeometry->getTexture());
    m_pForegroundGeometry->build(&quad2);
}
Exemple #5
0
// -----------------------------------------------------------------
// Name : setRetractible
// -----------------------------------------------------------------
void guiFrame::setRetractible(u8 uBorder)
{
    m_uRetractBorder = uBorder;
    m_fRetractTimer = 0;
    m_iRetractState = 2;  // shown
    m_bSticked = false;
    FREE(m_pStickGeo);
    FREE(m_pStickedGeo);
    if (uBorder != 0)
    {
        QuadData quad(0, 15, 0, 15, "stick", getDisplay());
        m_pStickGeo = new GeometryQuads(&quad, VB_Static);
        QuadData quad2(0, 15, 0, 15, "sticked", getDisplay());
        m_pStickedGeo = new GeometryQuads(&quad2, VB_Static);
    }
}
Exemple #6
0
std::vector<std::vector<int> > getFeatures(std::vector<cv::Mat> imLBP){
	int m = imLBP[0].rows / 2;
	int n = imLBP[0].cols / 2;

	std::vector<int> bins = initHistogram();
	std::vector<std::vector<int> > features;

	for (unsigned int k = 0; k < imLBP.size(); k++){
		cv::Mat quad1(m, n, CV_8U);
		cv::Mat quad2(m, n, CV_8U);
		cv::Mat quad3(m, n, CV_8U);
		cv::Mat quad4(m, n, CV_8U);

		for (int i = 0; i < m; i++){
			for (int j = 0; j < n; j++){
				quad1.at<uchar>(i, j) = imLBP[k].at<uchar>(i, j);
				quad2.at<uchar>(i, j) = imLBP[k].at<uchar>(i, j+n);
				quad3.at<uchar>(i, j) = imLBP[k].at<uchar>(i+m, j);
				quad4.at<uchar>(i, j) = imLBP[k].at<uchar>(i+m, j+n);
			}
		}

		std::vector<int> histLBP_1 = histLBP(quad1, bins);
		std::vector<int> histLBP_2 = histLBP(quad2, bins);
		std::vector<int> histLBP_3 = histLBP(quad3, bins);
		std::vector<int> histLBP_4 = histLBP(quad3, bins);

		std::vector<int> feature;
		feature.reserve(histLBP_1.size() + histLBP_2.size() + histLBP_3.size() + histLBP_4.size());
		feature.insert(feature.end(), histLBP_1.begin(), histLBP_1.end());
		feature.insert(feature.end(), histLBP_2.begin(), histLBP_2.end());
		feature.insert(feature.end(), histLBP_3.begin(), histLBP_3.end());
		feature.insert(feature.end(), histLBP_4.begin(), histLBP_4.end());

		features.push_back(feature);
	}

	return features;
}
Exemple #7
0
// -----------------------------------------------------------------
// Name : initGraphics
// -----------------------------------------------------------------
void Map::initGraphics(DisplayEngine * pDisplay)
{
    FREE(m_pTileGeometry);
    QuadData tilequad(0.0f, 1.0f, 0.0f, 1.0f, "maptile init texture", pDisplay);
    m_pTileGeometry = new GeometryQuads(&tilequad, VB_Static);
    assert(m_pTiles != NULL);
    for (u16 x = 0; x < m_iWidth; x++)
    {
        for (u16 y = 0; y < m_iHeight; y++)
        {
            m_pTiles[x][y]->initGraphics(m_pTileGeometry, pDisplay);
            setTileMask(x, y);
            Town * pTown = (Town*) m_pTiles[x][y]->getFirstMapObject(GOTYPE_TOWN);
            if (pTown != NULL)
                pTown->initGraphics(pDisplay);
            Temple * pTemple = (Temple*) m_pTiles[x][y]->getFirstMapObject(GOTYPE_TEMPLE);
            if (pTemple != NULL)
                pTemple->initGraphics(pDisplay);
        }
    }
    FREE(m_pEmptyMapGeometry);
    QuadData mapquad(0.0f, (float) m_iWidth, 0.0f, (float) m_iHeight, "map", pDisplay);
    m_pEmptyMapGeometry = new GeometryQuads(&mapquad, VB_Static);
    FREE(m_pTombGeometry);
    QuadData quad(0.0f, 0.4f, 0.0f, 0.4f, "skull", pDisplay);
    m_pTombGeometry = new GeometryQuads(&quad, VB_Static);
    FREE(m_pFoeBannerGeometry);
    QuadData quad2(0.0f, 0.3f, 0.0f, 0.3f, "attack_icon", pDisplay);
    m_pFoeBannerGeometry = new GeometryQuads(&quad2, VB_Static);
    FREE(m_pCountUnitsBgGeometry1L);
    QuadData quad3(0.0f, 0.4f, 0.0f, 0.3f, "bg-shadowed", pDisplay);
    m_pCountUnitsBgGeometry1L = new GeometryQuads(&quad3, VB_Static);
    FREE(m_pCountUnitsBgGeometry2L);
    QuadData quad4(0.0f, 0.4f, 0.0f, 0.6f, "bg-shadowed", pDisplay);
    m_pCountUnitsBgGeometry2L = new GeometryQuads(&quad4, VB_Static);
}
Exemple #8
0
GF2m quad(const GF2m& b)
{
    GF2m z;
    if (!quad2(b.fn,z.fn)) zero(z.fn);
    return z;
}
Exemple #9
0
Region& Region::Exclude(const Rect &excludeRect)
{
	BeginOperation();
	int index = 0;
	int rectsToCheck = fNumRects;
	while (index < rectsToCheck) {
		Rect &clipRect = fRects[index];

		if (!excludeRect.Intersects(clipRect)) {
			index++;
			continue;
		}

		// This clip rect intersects the excluded rect, and could be divided into
		// as many as eight pieces.  Test for each case.  Note that none of these
		// rectangles overlap!!!!
		Rect quad1(clipRect.left, clipRect.top, excludeRect.left - 1, excludeRect.top - 1);
		if (SPLIT_TEST(clipRect, quad1)) {
			quad1.Intersect(clipRect);
			AddRect(quad1);
		}

		Rect quad2(excludeRect.left, clipRect.top, excludeRect.right, excludeRect.top - 1);
		if (SPLIT_TEST(clipRect, quad2)) {
			quad2.Intersect(clipRect);
			AddRect(quad2);
		}

		Rect quad3(excludeRect.right + 1, clipRect.top, clipRect.right, excludeRect.top - 1);
		if (SPLIT_TEST(clipRect, quad3)) {
			quad3.Intersect(clipRect);
			AddRect(quad3);
		}

		Rect quad4(clipRect.left, excludeRect.top, excludeRect.left - 1, excludeRect.bottom);
		if (SPLIT_TEST(clipRect, quad4)) {
			quad4.Intersect(clipRect);
			AddRect(quad4);
		}

		Rect quad5(excludeRect.right + 1, excludeRect.top, clipRect.right, excludeRect.bottom);
		if (SPLIT_TEST(clipRect, quad5)) {
			quad5.Intersect(clipRect);
			AddRect(quad5);
		}

		Rect quad6(clipRect.left, excludeRect.bottom + 1, excludeRect.left - 1, clipRect.bottom);
		if (SPLIT_TEST(clipRect, quad6)) {
			quad6.Intersect(clipRect);
			AddRect(quad6);
		}

		Rect quad7(excludeRect.left, excludeRect.bottom + 1, excludeRect.right, clipRect.bottom);
		if (SPLIT_TEST(clipRect, quad7)) {
			quad7.Intersect(clipRect);
			AddRect(quad7);
		}

		Rect quad8(excludeRect.right + 1, excludeRect.bottom + 1, clipRect.right, clipRect.bottom);
		if (SPLIT_TEST(clipRect, quad8)) {
			quad8.Intersect(clipRect);
			AddRect(quad8);	
		}

		// This rect has been split, remove it.  Note we don't
		// change the index
		RemoveRect(index);		
		rectsToCheck--;
	}
	EndOperation();
	return *this;
}
int main(int argc, char** argv) {

  // ROS initialization stuff
  ros::init(argc, argv, "quadscript_example");
  ros::NodeHandle node;

  // Set the rate to run everything at. FRAMES_PER_SEC is set in
  // constants_config.h
  ros::Rate rate(FRAMES_PER_SEC);

  // Create Quad objects with the namespace corresponding to the
  // actual quadcopter, or the type of fake quad for FakeQuads.
  FakeQuad fake(WAND_MOVABLE);
  Quad quad1("quad01");
  Quad quad2("quad02");

  // Add quads to a formation to give them access to each other and
  // make group movements easier.
  Formation form;
  form.add_quad(fake);
  form.add_quad(quad1);
  form.add_quad(quad2);

  // Tells the entire formation to takeoff to the specified height.
  // Does not do anything for any FakeQuads in the formation.
  form.add_script<Takeoff>(new Takeoff(0.5));

  // Sets quad1 to the specified position (first 3), with the specified
  // orientation quaternion (last 4)
  quad1.add_script(new SetPose(-1, -0.7, 0.5,   0, 0, 0, -1));

  // Sets quad1's most recently added script to need a wand check, meaning
  // it won't move on to the next script until the wand signal is given.
  quad1.back()->set_needsWandCheck(true);

  // Same for quad2
  quad2.add_script(new SetPose(-1, 0.7, 0.5,   0, 0, 0, -1));
  quad2.back()->set_needsWandCheck(true);

  // Sets quads to follow the 0th index quad in the formation (last arg of ctor),
  // with the offset (x, y, z) specified in first 3 args.
  // 0th index quad in the formation is a WAND_MOVABLE FakeQuad, so the quads
  // will follow the imaginary point set by the FakeQuad.
  quad1.add_script(new FollowOffset(0.6, 0, 0,   0));
  quad2.add_script(new FollowOffset(-0.6, 0, 0,  0));


  // View QuadScripts.h for more details and documentation of how to
  // use specific scripts


  ROS_INFO("Starting...");

  // Loops FRAMES_PER_SEC times per second, running the publisher in each active
  // QuadScript every time. Instead of form.run(), can also use quad#.run() for
  // individual quads.
  while(node.ok()) {
    form.run();
    rate.sleep();
  }

  return 0;
}
Exemple #11
0
int main(int argc, char *argv[]) {

  int ierr = 0;

#ifdef EPETRA_MPI

  // Initialize MPI

  MPI_Init(&argc,&argv);

  Epetra_MpiComm Comm(MPI_COMM_WORLD);

#else

  Epetra_SerialComm Comm;

#endif

  bool verbose = false;

  // Check if we should print results to standard out
  if (argc>1) if (argv[1][0]=='-' && argv[1][1]=='v') verbose = true;

  int verbose_int = verbose ? 1 : 0;
  Comm.Broadcast(&verbose_int, 1, 0);
  verbose = verbose_int==1 ? true : false;

  int MyPID = Comm.MyPID();
  int NumProc = Comm.NumProc();

  if (verbose && MyPID==0)
    cout << Epetra_Version() << endl << endl;

  if (verbose) cout << Comm <<endl;

  int NumVectors = 1;
  int NumMyElements = 4;
  int NumGlobalElements = NumMyElements*NumProc;
  int IndexBase = 0;

  Epetra_Map Map(NumGlobalElements, NumMyElements, IndexBase, Comm);

  EPETRA_TEST_ERR( quad1(Map, verbose), ierr);

  EPETRA_TEST_ERR( quad2(Map, verbose), ierr);

  EPETRA_TEST_ERR( MultiVectorTests(Map, NumVectors, verbose), ierr);

  bool preconstruct_graph = false;

  EPETRA_TEST_ERR( four_quads(Comm, preconstruct_graph, verbose), ierr);

  preconstruct_graph = true;

  EPETRA_TEST_ERR( four_quads(Comm, preconstruct_graph, verbose), ierr);

#ifdef EPETRA_MPI
  MPI_Finalize();
#endif

  return ierr;
}
Exemple #12
0
//----------------------------------------------------------------------------------------------------
DIVAGame::DIVAGame(NoteMap _noteMap)
	:
	m_isStart(false),
	m_currentTime(0.f),
	m_totalTime(0.f),
	m_noteTime(0.f),
	m_noteTimeForward(0.f),
	m_singleTime(0.f),
	m_distanceTime(0.f),

	m_noteMap(_noteMap),
	m_notes(),
	m_emitter(),

	circleTex(L"Texture/Project Diva Freedom/自由模式/NOTE/NOTE/Normal/Normal-Circle.png"),
	crossTex(L"Texture/Project Diva Freedom/自由模式/NOTE/NOTE/Normal/Normal-Cross.png"),
	squareTex(L"Texture/Project Diva Freedom/自由模式/NOTE/NOTE/Normal/Normal-Square.png"),
	triangleTex(L"Texture/Project Diva Freedom/自由模式/NOTE/NOTE/Normal/Normal-Triangle.png"),
	rightTex(L"Texture/Project Diva Freedom/自由模式/NOTE/NOTE/Normal-Array/Normal-Array Right.png"),
	leftTex(L"Texture/Project Diva Freedom/自由模式/NOTE/NOTE/Normal-Array/Normal-Array Left.png"),
	downTex(L"Texture/Project Diva Freedom/自由模式/NOTE/NOTE/Normal-Array/Normal-Array Down.png"),
	upTex(L"Texture/Project Diva Freedom/自由模式/NOTE/NOTE/Normal-Array/Normal-Array Up.png"),
	stripBlueTex(L"Texture/Project Diva Freedom/自由模式/NOTE/Strip/Strip/Strip-Blue.png"),
	stripGreenTex(L"Texture/Project Diva Freedom/自由模式/NOTE/Strip/Strip/Strip-Green.png"),
	stripPinkTex(L"Texture/Project Diva Freedom/自由模式/NOTE/Strip/Strip/Strip-Pink.png"),
	stripRedTex(L"Texture/Project Diva Freedom/自由模式/NOTE/Strip/Strip/Strip-Red.png")
{
	EETexture hitTex[34] = {
		L"Texture/Project Diva Freedom/自由模式/HIT/effect30.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect29.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect28.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect27.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect26.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect25.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect24.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect23.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect22.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect21.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect20.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect19.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect18.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect17.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect16.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect15.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect14.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect13.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect12.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect11.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect10.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect9.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect8.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect7.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect6.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect5.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect4.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect3.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/effect2.png",
		L"Texture/Project Diva Freedom/自由模式/HIT/hit-1(线性减淡).png",
		L"Texture/Project Diva Freedom/自由模式/HIT/hit-2(线性减淡).png",
		L"Texture/Project Diva Freedom/自由模式/HIT/hit-3(线性减淡).png",
		L"Texture/Project Diva Freedom/自由模式/HIT/hit-4(线性减淡).png",
		L"Texture/Project Diva Freedom/自由模式/HIT/sad-01.png",
	};
	// 0
	EESlide hitSlide(Rect_Float(-64, -64, 64, 64), hitTex, 29, 0.0f, false);
	hitSlide.SetInterval(0.05f / 29.f);

	EEAnimationFrame frame0;
	frame0.SetObject(hitSlide);
	frame0.startTime = 0.0f;
	frame0.duration = 0.05f;

	// 1
	EEQuad2D quad1(Rect_Float(-40, -40, 40, 40), hitTex[29]);
	//quad1.SetScale(3.0f);
	EEAnimationFrame frame1;
	frame1.SetObject(quad1);
	frame1.startTime = 0.05f;
	frame1.duration = 0.35f;
	float alpha11 = 0.0f;
	float scale11 = 2.0f;
	frame1.actions.push_back(boost::bind(EEFade, _1, 0.35f, alpha11, _2));
	frame1.actions.push_back(boost::bind(EEScale, _1, 0.35f, scale11, _2));

	// 2
	EEQuad2D quad2(Rect_Float(-40, -40, 40, 40), hitTex[30]);
	EEAnimationFrame frame2;
	frame2.SetObject(quad2);
	frame2.startTime = 0.05f;
	frame2.duration = 0.05f;
	float rotation2 = EE_2PI;
	frame2.actions.push_back(boost::bind(EERotateYX, _1, 0.05f, rotation2, _2, false));

	// 3
	EEQuad2D quad3(Rect_Float(-50, -50, 50, 50), hitTex[31]);
	float alpha30 = 0.8f;
	float alpha31 = 0.0f;
	quad3.SetAlpha(alpha30);
	EEAnimationFrame frame3;
	frame3.SetObject(quad3);
	frame3.startTime = 0.1f;
	frame3.duration = 0.05f;
	frame3.actions.push_back(boost::bind(EEFade, _1, 0.05f, alpha31, _2));

	// 4
	EEQuad2D quad4(Rect_Float(-50, -50, 50, 50), hitTex[32]);
	EEAnimationFrame frame4;
	frame4.SetObject(quad4);
	frame4.startTime = 0.5f;
	frame4.duration = 0.07f;
	float alpha41 = 0.0f;
	float scale41 = 4.0f;
	frame4.actions.push_back(boost::bind(EEFade, _1, 0.07f, alpha41, _2));
	frame4.actions.push_back(boost::bind(EEScale, _1, 0.07f, scale41, _2));

	EEAnimation animation;
	animation.AddFrame(frame0);
	animation.AddFrame(frame2);
	animation.AddFrame(frame3);
	animation.AddFrame(frame1);
	animation.AddFrame(frame4);
	//animation.SetIsLoop(true);

	m_emitter.SetAnimation(&animation);
}
Exemple #13
0
int QUAD2 (int *pdim, double *pa, double *pb, int (*func)(), double *prec,
	  int *pn, double *f, double *scratch)
{
 return(quad2 ((*pdim),(*pa),(*pb),func,prec,(*pn),f,scratch));
}