本文整理汇总了C++中Polygon类的典型用法代码示例。如果您正苦于以下问题:C++ Polygon类的具体用法?C++ Polygon怎么用?C++ Polygon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Polygon类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isHitFromTop
bool isHitFromTop(Polygon p) {
return (this->getTopLeft().getOrdinat() < p.getBottomRight().getOrdinat());
}
示例2: isHitFromRight
bool isHitFromRight(Polygon p) {
return (this->getBottomRight().getAxis() > p.getTopLeft().getAxis());
}
示例3: PixelMap
PixelMap * Camera::render(short aa=1) {
//local variables
int tVW = aa*this->getVWidth();
int tVH = aa*this->getVHeight();
Polygon * tracedPg;
Color tracedColor;
bool end;
//Initialize PixelMap with given dimensions
PixelMap * render = new PixelMap ("render", tVW, tVH);
//apply the new vWidth and Height to Camera
if (aa != 1) {
this->setView(tVW, tVH, this->getVAngle(), true);
}
//reset vPos in Camera
resetVPos();
//generate first ray
generateRay(true);
cout << "\nRendering initialized.\n\tResolution: \t" << tVW/aa << "x" << tVH/aa << " at " << aa << "xAA\n\tPolygons: \t" << allPolygons.size() << endl;
while (true) {
//generate ray for new vPos
generateRay();
//start of new position --> update vector inDivPolygons to pass to trace()
if (this->checkDiv) this->checkDivPgs();
//RayTracing. Returns pointer to the valid polygon from a given vector including pointers to polygons in that division
if (this->getDivSize() != 1) {
tracedPg = this->vRay.trace(&(this->inDivPolygons));
}
else {
tracedPg = this->vRay.trace(); //use all polygons
}
//check for intersection. No intersection: set pixel to backgroundcolor
if (tracedPg->isActive()) {
tracedColor = tracedPg->getColor();
}
else {
tracedColor = black;
}
//set pixel in PixelMap to color of polygon and move to next pixel (2nd arg TRUE) in the PixelMap
render->setPixel(tracedColor, this->getVPos());
//move to the next pixel in vPos. End loop if vPos reached top right
end = nextPixel();
if (end) break;
}
//apply AntiAliasing
*render = render->antiAliase(aa);
cout << "Rendering finished.\n" << endl;
//reset vWidth and Height to old values
if (aa != 1) {
this->setView(tVW/aa, tVH/aa, this->getVAngle(), true);
}
return render;
}
示例4: renderMeshLocally
void SceneMesh::renderMeshLocally() {
Renderer *renderer = CoreServices::getInstance()->getRenderer();
if(skeleton) {
for(int i=0; i < mesh->getPolygonCount(); i++) {
Polygon *polygon = mesh->getPolygon(i);
unsigned int vCount = polygon->getVertexCount();
for(int j=0; j < vCount; j++) {
Vertex *vert = polygon->getVertex(j);
Vector3 norm;
Vector3 aPos = vert->restPosition;
Vector3 tPos;
Number mult = 1;
/*
Number mult = 0;
for(int b =0; b < vert->getNumBoneAssignments(); b++) {
BoneAssignment *bas = vert->getBoneAssignment(b);
mult += bas->weight;
}
mult = 1.0f/mult;
*/
for(int b =0; b < vert->getNumBoneAssignments(); b++) {
BoneAssignment *bas = vert->getBoneAssignment(b);
Bone *bone = bas->bone;
if(bone) {
Matrix4 restMatrix = bone->getRestMatrix();
Matrix4 finalMatrix = bone->getFinalMatrix();
Vector3 vec = restMatrix * aPos;
tPos += finalMatrix * vec * (bas->weight*mult);
Vector3 nvec = vert->restNormal;
nvec = restMatrix.rotateVector(nvec);
nvec = finalMatrix.rotateVector(nvec);
norm += nvec * (bas->weight*mult);
}
}
vert->x = tPos.x;
vert->y = tPos.y;
vert->z = tPos.z;
norm.Normalize();
vert->setNormal(norm.x, norm.y, norm.z);
}
}
mesh->arrayDirtyMap[RenderDataArray::VERTEX_DATA_ARRAY] = true;
mesh->arrayDirtyMap[RenderDataArray::NORMAL_DATA_ARRAY] = true;
mesh->arrayDirtyMap[RenderDataArray::TANGENT_DATA_ARRAY] = true;
}
if(mesh->useVertexColors) {
renderer->pushDataArrayForMesh(mesh, RenderDataArray::COLOR_DATA_ARRAY);
}
renderer->pushDataArrayForMesh(mesh, RenderDataArray::VERTEX_DATA_ARRAY);
renderer->pushDataArrayForMesh(mesh, RenderDataArray::NORMAL_DATA_ARRAY);
renderer->pushDataArrayForMesh(mesh, RenderDataArray::TANGENT_DATA_ARRAY);
renderer->pushDataArrayForMesh(mesh, RenderDataArray::TEXCOORD_DATA_ARRAY);
renderer->drawArrays(mesh->getMeshType());
}
示例5: getPolygon
// ===========================================================================
// method definitions
// ===========================================================================
bool
TraCIServerAPI_Polygon::processGet(TraCIServer& server, tcpip::Storage& inputStorage,
tcpip::Storage& outputStorage) {
// variable & id
int variable = inputStorage.readUnsignedByte();
std::string id = inputStorage.readString();
// check variable
if (variable != ID_LIST && variable != VAR_TYPE && variable != VAR_COLOR && variable != VAR_SHAPE && variable != VAR_FILL
&& variable != ID_COUNT) {
return server.writeErrorStatusCmd(CMD_GET_POLYGON_VARIABLE, "Get Polygon Variable: unsupported variable specified", outputStorage);
}
// begin response building
tcpip::Storage tempMsg;
// response-code, variableID, objectID
tempMsg.writeUnsignedByte(RESPONSE_GET_POLYGON_VARIABLE);
tempMsg.writeUnsignedByte(variable);
tempMsg.writeString(id);
// process request
if (variable == ID_LIST || variable == ID_COUNT) {
std::vector<std::string> ids;
ShapeContainer& shapeCont = MSNet::getInstance()->getShapeContainer();
shapeCont.getPolygons().insertIDs(ids);
if (variable == ID_LIST) {
tempMsg.writeUnsignedByte(TYPE_STRINGLIST);
tempMsg.writeStringList(ids);
} else {
tempMsg.writeUnsignedByte(TYPE_INTEGER);
tempMsg.writeInt((int) ids.size());
}
} else {
Polygon* p = getPolygon(id);
if (p == 0) {
return server.writeErrorStatusCmd(CMD_GET_POLYGON_VARIABLE, "Polygon '" + id + "' is not known", outputStorage);
}
switch (variable) {
case VAR_TYPE:
tempMsg.writeUnsignedByte(TYPE_STRING);
tempMsg.writeString(p->getType());
break;
case VAR_COLOR:
tempMsg.writeUnsignedByte(TYPE_COLOR);
tempMsg.writeUnsignedByte(p->getColor().red());
tempMsg.writeUnsignedByte(p->getColor().green());
tempMsg.writeUnsignedByte(p->getColor().blue());
tempMsg.writeUnsignedByte(p->getColor().alpha());
break;
case VAR_SHAPE:
tempMsg.writeUnsignedByte(TYPE_POLYGON);
tempMsg.writeUnsignedByte(MIN2(static_cast<int>(255), static_cast<int>(p->getShape().size())));
for (unsigned int iPoint = 0; iPoint < MIN2(static_cast<size_t>(255), p->getShape().size()); ++iPoint) {
tempMsg.writeDouble(p->getShape()[iPoint].x());
tempMsg.writeDouble(p->getShape()[iPoint].y());
}
break;
case VAR_FILL:
tempMsg.writeUnsignedByte(TYPE_UBYTE);
tempMsg.writeUnsignedByte(p->getFill() ? 1 : 0);
break;
default:
break;
}
}
server.writeStatusCmd(CMD_GET_POLYGON_VARIABLE, RTYPE_OK, "", outputStorage);
server.writeResponseWithLength(outputStorage, tempMsg);
return true;
}
示例6: Intersects
bool Line::Intersects(const Polygon &polygon) const
{
return polygon.Intersects(*this);
}