当前位置: 首页>>代码示例>>C++>>正文


C++ Quad类代码示例

本文整理汇总了C++中Quad的典型用法代码示例。如果您正苦于以下问题:C++ Quad类的具体用法?C++ Quad怎么用?C++ Quad使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Quad类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

void init(int argc, char** argv)
{
  g_eye = glm::vec3(0.0, 0.0, 2.0);
  g_center = glm::vec3(0, 0, 0);
  viewMatrix = glm::lookAt(g_eye, g_center, glm::vec3(0, 1, 0));
  projMatrix = glm::perspective(45.f, 1.f, 1.f, 5.f);

  Quad* q = new Quad();
  q->setDrawCb(drawQuad);
  q->setMaterialColor(glm::vec4(1.f));
  q->m_modelMatrix = glm::mat4(1.f);
  q->m_normalMatrix = glm::mat3(glm::inverseTranspose(viewMatrix * q->m_modelMatrix));
  TinyGL::getInstance()->addResource(MESH, "quad", q);

  Detector d = HARRIS;
  double thresh = 0.9;

  //Basic argument parsing.
  if(argc >= 3) {
    string param = string(argv[1]);
    if(param == "--shi-tomasi" || param == "-s")
      d = SHI_TOMASI;
    param = string(argv[2]);
    stringstream ss(param);
    ss >> thresh;
  } else if(argc == 2) {
开发者ID:Strongc,项目名称:TinyGL,代码行数:26,代码来源:main.cpp

示例2: SharkVertex

Keyframe::Keyframe(map<Vector3f, SharkVertex*, compareVect3> *rawVerts, vector<Quad*> *rawFaces)
{
	//deep copy verts over.
	map<Vector3f, SharkVertex*, compareVect3>::iterator im;
	for(im = rawVerts->begin(); im != rawVerts->end(); im++)
	{
		pair<Vector3f, SharkVertex*> serk = *im;
		SharkVertex * d = new SharkVertex();
		d->sNormal(serk.second->gNormal());
		d->sTransformed(serk.second->gTransformed());
		d->sLocal(serk.second->gLocal());
		uVertices.insert(pair<Vector3f, SharkVertex*>(serk.first, d));
	}

	//create faces.
	vector<Quad*>::iterator iq;
        for(iq = rawFaces->begin(); iq != rawFaces->end(); iq++)
        {
		Quad * nRect = new Quad();
		for(int i = 0; i < 4; i++)
		{
			nRect->sVert(i, uVertices.find((*iq)->gLocalVert(i))->second);
		}
		faces.push_back(nRect);
	}

	//setNormals
	createQuads();
}
开发者ID:KATHYxx,项目名称:SharkSim,代码行数:29,代码来源:Keyframe.cpp

示例3: _draw

void UIRenderer::_draw(const rect_type &rect, const color_t &color) {
    Device &r = Device::instance();
    Quad quad;
	quad.setLocation(_modify_rect(rect, r.scaleInPixel())).setColor(_blend(color));
    r.setTexture(0);
    r.drawQuad(quad);
}
开发者ID:signorinotang,项目名称:vn2d,代码行数:7,代码来源:vnUIRenderer.cpp

示例4: Files

void MapWindow::on_actionOpen_triggered()
{
  QString filename;
  filename = QFileDialog::getOpenFileName(0, "Open File", QDir::home().absolutePath(), "ProjMapper Files (*.pmap)");
  if (!filename.isEmpty()) {
    QFile fd(filename);
    fd.open(QIODevice::ReadWrite);
    QDataStream ds(&fd);
    Quad *q;
    int size;
    ds >> size;
    quadList->clear();
    for (int i = ui->listWidget->count()-1; i >= 0; i--) {
      ui->listWidget->takeItem(i);
    }

    for (int i = 0; i<size; i++) {
      q = new Quad();
      ds >> *q;
      quadList->append(q);
      new QListWidgetItem(q->getName(), ui->listWidget);
      qDebug() << q->getName();
    }
    fd.close();

    emit updateAllDisplays();
  }
开发者ID:flair2005,项目名称:HappyMapper,代码行数:27,代码来源:mapwindow.cpp

示例5: mouseMotion

void mouseMotion(int x, int y) {
  Point *p = new Point(x, H2-y);

  if ((figType == POINTER) && sel) {
	 Figure *f = figureSet[selected];
	 if (cpsel){ // the user is trying to move a control point (modify)
		f->setPoint(cp - figureSet.size(), p);
	 }
	 else { // the user want to move the figure as a block (move)
		// common points
		int xoffset = x - ox;
		int yoffset = oy - y; // openGl invert y coordinate
		int *pt1 = f->getPoint(1)->getCoords();
		int *pt2 = f->getPoint(2)->getCoords();
		// move coordinates basing on offsets 
		Point *p1 = new Point(pt1[0] + xoffset, pt1[1] + yoffset);
		f->setPoint(1, p1);
		Point *p2 = new Point(pt2[0] + xoffset, pt2[1] + yoffset);
		f->setPoint(2, p2);
		
		if (Triangle *t = dynamic_cast<Triangle*>(f)) {
		  int *pt3 = t->getPoint(3)->getCoords();
		  Point *p3 = new Point(pt3[0] + xoffset, pt3[1] + yoffset);
		  t->setPoint(3, p3);
		}
		else if (Quad *q = dynamic_cast<Quad*>(f)) {
		  int *pt3 = q->getPoint(3)->getCoords();
		  int *pt4 = q->getPoint(4)->getCoords();
		  Point *p3 = new Point(pt3[0] + xoffset, pt3[1] + yoffset);
		  q->setPoint(3, p3);
		  Point *p4 = new Point(pt4[0] + xoffset, pt4[1] + yoffset);
		  q->setPoint(4, p4);
		}
	 }
	 ox = x; // refresh coordinates
	 oy = y;
  }
 
  // show the figure while creating
  switch(figType) {
  case LINE: {
	 Line *l = (Line*) figureSet.back();
	 l->setPoint(2, p);
	 break;
  }
  case TRIANGLE: {
	 Triangle *t = (Triangle*) figureSet.back();
	 t->setTriangle(p);
	 break;
  }
  case QUAD: {
	 Quad *q = (Quad*) figureSet.back();
	 q->setQuad(p);
	 break;
  }
  }

  glutPostRedisplay();
}
开发者ID:crittico,项目名称:gldraw,代码行数:59,代码来源:main.cpp

示例6: Quad

void AutoMap::paint(const Vector &pos)
{
	Quad *q = new Quad("particles/WhiteGlow", pos);
	q->setLife(1);
	q->setDecayRate(0.5);
	q->color = paintColor;
	q->followCamera = 1;
	q->setWidthHeight(8,8);
	dsq->game->addRenderObject(q, this->layer);
}
开发者ID:4nakin,项目名称:Aquaria_clean,代码行数:10,代码来源:AutoMap.cpp

示例7: w_Quad_getViewport

int w_Quad_getViewport(lua_State *L)
{
	Quad *quad = luax_checkquad(L, 1);
	Quad::Viewport v = quad->getViewport();
	lua_pushnumber(L, v.x);
	lua_pushnumber(L, v.y);
	lua_pushnumber(L, v.w);
	lua_pushnumber(L, v.h);
	return 4;
}
开发者ID:cyborgize,项目名称:love,代码行数:10,代码来源:wrap_Quad.cpp

示例8: w_Quad_getViewport

	int w_Quad_getViewport(lua_State * L)
	{
		Quad * quad = luax_checktype<Quad>(L, 1, "Quad", GRAPHICS_QUAD_T);
		Quad::Viewport v = quad->getViewport();
		lua_pushnumber(L, v.x);
		lua_pushnumber(L, v.y);
		lua_pushnumber(L, v.w);
		lua_pushnumber(L, v.h);
		return 4;
	}
开发者ID:binji,项目名称:love-nacl,代码行数:10,代码来源:wrap_Quad.cpp

示例9: w_Quad_setViewport

	int w_Quad_setViewport(lua_State * L)
	{
		Quad * quad = luax_checktype<Quad>(L, 1, "Quad", GRAPHICS_QUAD_T);
		Quad::Viewport v;
		v.x = (float) luaL_checknumber(L, 2);
		v.y = (float) luaL_checknumber(L, 3);
		v.w = (float) luaL_checknumber(L, 4);
		v.h = (float) luaL_checknumber(L, 5);
		quad->setViewport(v);
		return 0;
	}
开发者ID:binji,项目名称:love-nacl,代码行数:11,代码来源:wrap_Quad.cpp

示例10: findQuad

void Map::renderQuad(int x, int z, DetailLevel detailLevel)
{
  Quad * quad = findQuad(x, z);
  if (quad != NULL)
  {
    quad->render(detailLevel);
  }
  else
  {
    scheduleTask(x, z);
  }
}
开发者ID:piotrdz,项目名称:FlightSim,代码行数:12,代码来源:map.cpp

示例11: Quad

void LensFlare::addFlare(const std::string &tex, Vector color, int w, int h)
{
	Quad *q = new Quad(tex, Vector(0,0,0));
	q->color = color;
	q->setBlendType(BLEND_ADD);
	if (w != -1)
		q->setWidth(w);
	if (h != -1)
		q->setHeight(h);
	flares.push_back(q);
	addChild(q, PM_POINTER);
}
开发者ID:4nakin,项目名称:Aquaria_clean,代码行数:12,代码来源:LensFlare.cpp

示例12: assert

bool PhysicsMesh::LoadFrom(Mesh * mesh)
{
	// Clear old
	triangles.ClearAndDelete();
	quads.ClearAndDelete();

	name = mesh->name;
	source = mesh->source; 
	aabb = *mesh->aabb;

	for (int i = 0; i < mesh->numFaces; ++i)
	{
		// Just copy shit from it
		MeshFace * faces = &mesh->faces[i];
		assert((faces->numVertices <= 4 || faces->numVertices >= 3) && "Bad vertices count in faces");

		int vi0 = faces->vertices[0],
			vi1 = faces->vertices[1],
			vi2 = faces->vertices[2];

		assert(vi0 < mesh->vertices.Size() && 
			vi0 >= 0);

		Vector3f p1 = mesh->vertices[vi0],
			p2 = mesh->vertices[vi1],
			p3 = mesh->vertices[vi2];

		if (faces->numVertices == 4){
			Vector3f p4 = mesh->vertices[faces->vertices[3]];
			Quad * quad = new Quad();
			quad->Set4Points(p1, p2, p3, p4);
			quads.Add(quad);
		}
		else if (faces->numVertices == 3){
			Triangle * tri = new Triangle();
			tri->Set3Points(p1, p2, p3);
			triangles.Add(tri);
		}
	}
	if (quads.Size() == 0 && triangles.Size() == 0)
		assert(false && "Unable to load physicsmesh from mesh source!");
	else
		std::cout<<"\nCreated physics mesh for \""<<source<<"\": ";
	if (triangles.Size())
		std::cout<<"\n- "<<triangles.Size()<<" triangles";
	if (quads.Size())
		std::cout<<"\n- "<<quads.Size()<<" quads";

	// Re-generate it.
	if (useCollisionShapeOctrees)
		GenerateCollisionShapeOctree();
	return true;
}
开发者ID:erenik,项目名称:engine,代码行数:53,代码来源:PhysicsMesh.cpp

示例13: Face

Quad::Quad(const Quad &quad)
	: Face(quad.getValue())
{
	_nodes = new Node*[4];
	_neighbors = new Element*[4];
	for (unsigned i=0; i<4; i++)
	{
		_nodes[i] = quad._nodes[i];
		_neighbors[i] = quad._neighbors[i];
	}
	_area = quad.getArea();
}
开发者ID:JobstM,项目名称:ogs,代码行数:12,代码来源:Quad.cpp

示例14: setupGeometry

void setupGeometry()
{
  Sphere** spheres;
  Quad* screenQuad;
  Cube** bottom_box;

  bottom_box = new Cube*[5];
  for(int i = 0; i < 5; i++) {
    bottom_box[i] = new Cube();
    bottom_box[i]->setDrawCb(drawArrays);
  }

  bottom_box[0]->setMaterialColor(glm::vec4(0.4, 0.6, 0.0, 1.0));
  bottom_box[1]->setMaterialColor(glm::vec4(0, 0.8, 0.0, 1.0));
  bottom_box[2]->setMaterialColor(glm::vec4(0.6, 0, 0.0, 1.0));
  bottom_box[3]->setMaterialColor(glm::vec4(0.4, 0.6, 0.9, 1.0));
  bottom_box[4]->setMaterialColor(glm::vec4(0, 0, 0.8, 1.0));

  bottom_box[0]->m_modelMatrix = glm::translate(glm::vec3(25, 0, 25)) * glm::scale(glm::vec3(50, 0.1, 50));
  bottom_box[1]->m_modelMatrix = glm::translate(glm::vec3(25, 2.5, 0)) * glm::scale(glm::vec3(50, 5, 0.3));
  bottom_box[2]->m_modelMatrix = glm::translate(glm::vec3(50, 2.5, 25)) * glm::scale(glm::vec3(0.3, 5, 50));
  bottom_box[3]->m_modelMatrix = glm::translate(glm::vec3(25, 2.5, 50)) * glm::scale(glm::vec3(50, 5, 0.3));
  bottom_box[4]->m_modelMatrix = glm::translate(glm::vec3(0, 2.5, 25)) * glm::scale(glm::vec3(0.3, 5, 50));

  for(int i = 0; i < 5; i++) {
    bottom_box[i]->m_normalMatrix = glm::mat3(glm::inverseTranspose(viewMatrix * bottom_box[i]->m_modelMatrix));
    TinyGL::getInstance()->addResource(MESH, "bottom_box" + to_string(i), bottom_box[i]);
  }

  spheres = new Sphere*[NUM_SPHERES];
  for (int i = 0; i < NUM_SPHERES; i++) {
    spheres[i] = new Sphere(60, 60);
    spheres[i]->setDrawCb(drawSphere);
    spheres[i]->setMaterialColor(glm::vec4(1.0, 0.0, 0.0, 1.0));
  }

  for (int i = 0; i < W_SPHERES; i++) {
    for (int j = 0; j < H_SPHERES; j++) {
      spheres[i * W_SPHERES + j]->m_modelMatrix = glm::translate(glm::vec3((i+1) * 4, 1.6, (j+1) * 4)) * glm::scale(glm::vec3(1.5));
      spheres[i * W_SPHERES + j]->m_normalMatrix = glm::mat3(glm::inverseTranspose(viewMatrix * spheres[i * W_SPHERES + j]->m_modelMatrix));
    }
  }

  for (int i = 0; i < NUM_SPHERES; i++)
    TinyGL::getInstance()->addResource(MESH, "sphere" + to_string(i), spheres[i]);

  screenQuad = new Quad();
  screenQuad->setDrawCb(drawQuad);
  screenQuad->setMaterialColor(glm::vec4(0.f, 0.f, 0.f, 1.f));
  screenQuad->m_modelMatrix = glm::mat4(1.f);
  screenQuad->m_normalMatrix = glm::mat3(glm::inverseTranspose(viewMatrix * screenQuad->m_modelMatrix));
  TinyGL::getInstance()->addResource(MESH, "screenQuad", screenQuad);
}
开发者ID:Strongc,项目名称:TinyGL,代码行数:53,代码来源:main.cpp

示例15: Quad

Quad& Mesh:: createQuad
(
  Edge& edgeOne,
  Edge& edgeTwo,
  Edge& edgeThree,
  Edge& edgeFour )
{
  Quad* newQuad = new Quad (
      edgeOne, edgeTwo, edgeThree, edgeFour, _manageQuadIDs.getFreeID());
  newQuad->addParent(*this);
  _content.add(newQuad);
  return *newQuad;
}
开发者ID:Alexander-Shukaev,项目名称:precice,代码行数:13,代码来源:Mesh.cpp


注:本文中的Quad类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。