本文整理汇总了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) {
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}