void BlockPhysicsComponent::rasterize(Polygon2 const &polygon) { Polygon2 localPolygon; for (int i = 0; i < polygon.getSize(); ++i) { b2Vec2 worldPoint(polygon.vertices[i].x, polygon.vertices[i].y); b2Vec2 localPoint = body_->GetLocalPoint(worldPoint); localPolygon.vertices.push_back(Vector2(localPoint.x, localPoint.y)); } Box2 bounds = localPolygon.getBoundingBox(); int minX = int(10.0f * bounds.p1.x + 0.05f); int minY = int(10.0f * bounds.p1.y + 0.05f); int maxX = int(10.0f * bounds.p2.x + 0.05f); int maxY = int(10.0f * bounds.p2.y + 0.05f); for (int y = minY; y <= maxY; ++y) { for (int x = minX; x <= maxX; ++x) { Vector2 localPoint(0.1f * float(x), 0.1f * float(y)); if (localPolygon.containsPoint(localPoint)) { for (int dy = -1; dy <= 1; ++dy) { for (int dx = -1; dx <= 1; ++dx) { if (dx == 0 || dy == 0) { setElement(x + dx, y + dy, 1); } } } } } } }
void SpriteTests::testTrickyIntersections() { AutoreleasePool::begin(); Sprite* space_ship = new Sprite(new MockView); space_ship->setPosition(Vector2(0.0f, 0.0f)); // Obstacle Polygon2 points; points.push_back(Vector2(36.714285714286f, 29.857142857143f)); points.push_back(Vector2(40.285714285714f, 29.714285714286f)); points.push_back(Vector2(40.142857142857f, 1.0f)); points.push_back(Vector2(30.0f, 0.85714285714286f)); points.push_back(Vector2(30.428571428571f, 13.285714285714f)); Sprite* obstacle = new Sprite(new MockView(points)); CPTAssert(!space_ship->collide(obstacle, t, dt)); CPTAssert(!obstacle->collide(space_ship, t, dt)); space_ship->setPosition(Vector2(9.7f, -2.7f)); CPTAssert(!space_ship->collide(obstacle, t, dt)); CPTAssert(!obstacle->collide(space_ship, t, dt)); space_ship->setPosition(Vector2(11.9f, 7.71f)); CPTAssert(!space_ship->collide(obstacle, t, dt)); CPTAssert(!obstacle->collide(space_ship, t, dt)); space_ship->setPosition(Vector2(11.99f, 7.89f)); CPTAssert(!space_ship->collide(obstacle, t, dt)); CPTAssert(!obstacle->collide(space_ship, t, dt)); Group* g = new Group; g->addKid(obstacle); ShapeGroup* group = new ShapeGroup(g->iterator()); CPTAssert(!space_ship->collide(group, t, dt)); CPTAssert(!group->collide(space_ship, t, dt)); space_ship->setPosition(Vector2(9.7f, -2.7f)); CPTAssert(!space_ship->collide(group, t, dt)); CPTAssert(!group->collide(space_ship, t, dt)); space_ship->setPosition(Vector2(11.9f, 7.71f)); CPTAssert(!space_ship->collide(group, t, dt)); CPTAssert(!group->collide(space_ship, t, dt)); g->release(); group->release(); space_ship->release(); obstacle->release(); AutoreleasePool::end(); }
bool Polygon2::containsAllOf(const Polygon2 &polygon) const { // If any vertex of @polygon is outside the boundary of @this, then // @polygon is not wholly inside @this for (int polyI = 0; polyI < polygon.size(); polyI++) { if ( !contains( polygon[polyI] ) ) { return false; } } // If any edge of @polygon intersects @this, then // @polygon is not wholly contained within @this int edgeIPrev = polygon.size() - 1; for (int edgeI = 0; edgeI < polygon.size(); edgeI++) { Segment2 edge( polygon[edgeIPrev], polygon[edgeI] ); if ( checkEdgeIntersection( edge ) ) { return false; } edgeIPrev = edgeI; } return true; }
void Box2DDebugDraw::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) { RenderManager::Instance()->SetColor(color.r, color.g, color.b, 1.0f); Polygon2 polygon; for (int32 i = 0; i < vertexCount; ++i) { polygon.AddPoint(Vector2(vertices[i].x * ptdRatio + cameraPos.x, -vertices[i].y * ptdRatio + cameraPos.y)); } RenderHelper::Instance()->DrawPolygon(polygon, true); RenderManager::Instance()->ResetColor(); /*glEnable(GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(0.5f * color.r, 0.5f * color.g, 0.5f * color.b, 0.5f); glBegin(GL_TRIANGLE_FAN); for (int32 i = 0; i < vertexCount; ++i) { glVertex2f(vertices[i].x, vertices[i].y); } glEnd(); glDisable(GL_BLEND); glColor4f(color.r, color.g, color.b, 1.0f); glBegin(GL_LINE_LOOP); for (int32 i = 0; i < vertexCount; ++i) { glVertex2f(vertices[i].x, vertices[i].y); } glEnd();*/ }
bool doIntersect(const Polygon2& p, const Line2& line) { for (auto edge = p.edges_begin(); edge != p.edges_end(); ++edge) { if (do_intersect(*edge, line)) { return true; } } return false; }
static bool pathFrom(const Graph& g, Vertex t, const Vertices& p, Polygon2& path) { while (t != p[t]) { path.push_back(g[t]); t = p[t]; } path.push_back(g[t]); return true; }
void Box2DDebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) { RenderManager::Instance()->SetColor(color.r, color.g, color.b, 1.0f); Polygon2 polygon; const float32 k_segments = 16.0f; const float32 k_increment = 2.0f * b2_pi / k_segments; float32 theta = 0.0f; for (int32 i = 0; i < k_segments; ++i) { b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); //glVertex2f(v.x, v.y); polygon.AddPoint(Vector2(v.x * ptdRatio + cameraPos.x, -v.y * ptdRatio + cameraPos.y)); theta += k_increment; } RenderHelper::Instance()->DrawPolygon(polygon, true); RenderManager::Instance()->ResetColor(); /*const float32 k_segments = 16.0f; const float32 k_increment = 2.0f * b2_pi / k_segments; float32 theta = 0.0f; glEnable(GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(0.5f * color.r, 0.5f * color.g, 0.5f * color.b, 0.5f); glBegin(GL_TRIANGLE_FAN); for (int32 i = 0; i < k_segments; ++i) { b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); glVertex2f(v.x, v.y); theta += k_increment; } glEnd(); glDisable(GL_BLEND); theta = 0.0f; glColor4f(color.r, color.g, color.b, 1.0f); glBegin(GL_LINE_LOOP); for (int32 i = 0; i < k_segments; ++i) { b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); glVertex2f(v.x, v.y); theta += k_increment; } glEnd(); b2Vec2 p = center + radius * axis; glBegin(GL_LINES); glVertex2f(center.x, center.y); glVertex2f(p.x, p.y); glEnd();*/ }
TEST_CASE_F(ComputePolygonOrientation_GivenLowestLeftmostTriangleIsDegenerate_ReturnsCorrectOrientation, Fixture) { Polygon2 polygon; polygon.push_back(Vector2Type(0.0, 1.0)); polygon.push_back(Vector2Type(1.0, 1.0)); polygon.push_back(Vector2Type(0.0, 0.0)); polygon.push_back(Vector2Type(0.0, 0.0)); TriangulatorType triangulator; const TriangulatorType::Orientation orientation = triangulator.compute_polygon_orientation(polygon); EXPECT_EQ(TriangulatorType::CW, orientation); }
void Collisions::ProjectPolygon(const Vector2 & axis, Polygon2 & poly, float32 & min, float32 & max) { Vector2 * points = poly.GetPoints(); float32 proj = DotProduct(points[0], axis); min = proj; max = proj; for (int32 pi = 1; pi < poly.GetPointCount(); ++pi) { proj = DotProduct(points[pi], axis); if (proj < min) min = proj; if (proj > max) max = proj; } }
/*! Find number of times ray intersects polygon defined by iterators */ int Line2::noIntersections(const Polygon2& poly) const { int n = 0; Vector2 v, v_prev; Point2 p, p_prev; ConstPointIterator2 begin = poly.begin(); ConstPointIterator2 end = poly.end(); ConstPointIterator2 it; for (it = begin+1; it != end; ++it) { if (intersect(Segment2(*(it-1), *it))) ++n; } if (intersect(Segment2(*(end-1), *begin))) ++n; return n; }
void RenderTargetTestScreen::Update(float32 timeElapsed) { ftime += timeElapsed; if (ftime > 5.0f) { UIHoleTransition *ft = new UIHoleTransition(); Polygon2 testPoly; testPoly.AddPoint(Vector2(50, 85)); testPoly.AddPoint(Vector2(size.x - 50, 50)); testPoly.AddPoint(Vector2(size.x - 25, size.y - 85)); testPoly.AddPoint(Vector2(80, size.y - 50)); Matrix3 t, invT, r; t.BuildTranslation(size/-2); invT.BuildTranslation(size/2); r.BuildRotation(DegToRad(10)); Matrix3 res = t * r * invT; testPoly.Transform(res); testPoly.Scale(size/2, 2.0f); ft->SetDuration(10.f); ft->SetPolygon(testPoly); UIScreenManager::Instance()->SetScreen(SCREEN_STATIC_TEXT, ft); SafeRelease(ft); ftime = 0; } }
void RenderHelper::DrawPolygon( const Polygon2 & polygon, bool closed) { int ptCount = polygon.pointCount; if (ptCount >= 2) { vertexStream->Set(TYPE_FLOAT, 2, 0, polygon.GetPoints()); RenderManager::Instance()->SetRenderEffect(RenderManager::FLAT_COLOR); RenderManager::Instance()->SetRenderData(renderDataObject); RenderManager::Instance()->DrawArrays(PRIMITIVETYPE_LINESTRIP, 0, ptCount); if (closed) { Vector2 line[2] = {Vector2(polygon.GetPoints()[0]), Vector2(polygon.GetPoints()[ptCount-1])}; vertexStream->Set(TYPE_FLOAT, 2, 0, line); RenderManager::Instance()->DrawArrays(PRIMITIVETYPE_LINESTRIP, 0, 2); } } }
void RenderHelper::DrawCircle(const Vector2 & center, float32 radius) { Polygon2 pts; float32 angle = SEGMENT_LENGTH / radius; int ptsCount = (int)(2 * PI / angle) + 1; for (int k = 0; k < ptsCount; ++k) { float32 angle = ((float)k / (ptsCount - 1)) * 2 * PI; float32 sinA = sinf(angle); float32 cosA = cosf(angle); Vector2 pos = center - Vector2(sinA * radius, cosA * radius); pts.AddPoint(pos); } DrawPolygon(pts, false); }
/*! The collision polygon calculated isn't optimal. We do it because it is used for drawing. For collision handling it is poor. \todo Refactor so collision and drawing polygon don't need to be the same */ PointsView::PointsView(Points2::iterator begin, Points2::iterator end) : iPoints(begin, end) { // Find rectangular polygon that will enclose all // added points Rect2 r; Points2::iterator it; for (it = begin; it != end; ++it) { r = r.surround(*it); } Polygon2 p; p.push_back(r.bottomLeft()); p.push_back(r.bottomRight()); p.push_back(r.topRight()); p.push_back(r.topLeft()); setCollisionPolygon(p); }
void Box2DDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color) { RenderManager::Instance()->SetColor(color.r, color.g, color.b, 1.0f); Polygon2 polygon; const float32 k_segments = 16.0f; const float32 k_increment = 2.0f * b2_pi / k_segments; float32 theta = 0.0f; for (int32 i = 0; i < k_segments; ++i) { b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); //glVertex2f(v.x, v.y); polygon.AddPoint(Vector2(v.x * ptdRatio + cameraPos.x, -v.y * ptdRatio + cameraPos.y)); theta += k_increment; } RenderHelper::Instance()->DrawPolygon(polygon, true); RenderManager::Instance()->ResetColor(); }
/*! Gets polygon from array of points stored at index t in lua stack. We assume array is a table of the form {{x = 1, y = 2}, {x = 3, y = 4}}. Polygon is returned in p. */ void getPolygon(lua_State* L, int t, Polygon2& p) { luaL_checktype(L, t, LUA_TTABLE); // Make sure we get a table with points as first argument lua_pushnil(L); // first key (ready traversal of table) while (lua_next(L, t) != 0) { // ‘key’ is at index -2 and ‘value’ at index -1 p.push_back(Vector2_pull(L,-1)); lua_pop(L, 1); // removes ‘value’; keeps ‘key’ for next iteration } }
void Box2DDebugDraw::DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) { /*glColor3f(color.r, color.g, color.b); glBegin(GL_LINE_LOOP); for (int32 i = 0; i < vertexCount; ++i) { glVertex2f(vertices[i].x, vertices[i].y); } glEnd();*/ RenderManager::Instance()->SetColor(color.r, color.g, color.b, 1.0f); Polygon2 polygon; for (int32 i = 0; i < vertexCount; ++i) { polygon.AddPoint(Vector2(vertices[i].x * ptdRatio + cameraPos.x, -vertices[i].y * ptdRatio + cameraPos.y)); } RenderHelper::Instance()->DrawPolygon(polygon, true); RenderManager::Instance()->ResetColor(); }
void CueTable::addPockets(Polygon2& shape, int numOfHoles){ vector< Edge2 > edges = shape.getEdges(); for(int i = 0; i < numOfHoles; ){ Edge2 edge = edges[rand() % edges.size()]; float alpha = linearRand(0.0f, 1.0f); if(insertPocket(shape, lerp(edge[0],edge[1],alpha))){ i++; } } }
void CreateTranslatorForPolygon( const Polygon2& poly, CoordTranslator2& trans) { if (poly.empty()) return; trans.mSrcMin = poly[0]; trans.mSrcMax = poly[0]; for (int n = 1; n < poly.size(); ++n) { trans.mSrcMin.x_ = min(trans.mSrcMin.x(), poly[n].x()); trans.mSrcMin.y_ = min(trans.mSrcMin.y(), poly[n].y()); trans.mSrcMax.x_ = max(trans.mSrcMax.x(), poly[n].x()); trans.mSrcMax.y_ = max(trans.mSrcMax.y(), poly[n].y()); } trans.mDstMin.x_ = 0.0; trans.mDstMax.y_ = 0.0; trans.mDstMax.x_ = (trans.mSrcMax.x() - trans.mSrcMin.x()) * DEG_TO_MTR_LAT * cos((trans.mSrcMin.y() + trans.mSrcMax.y()) * 0.5 * DEG_TO_RAD); trans.mDstMax.y_ = (trans.mSrcMax.y() - trans.mSrcMin.y()) * DEG_TO_MTR_LAT; }
void RenderHelper::FillPolygon(const Polygon2 & polygon) { int ptCount = polygon.pointCount; if (ptCount >= 3) { vertexStream->Set(TYPE_FLOAT, 2, 0, polygon.GetPoints()); RenderManager::Instance()->SetRenderEffect(RenderManager::FLAT_COLOR); RenderManager::Instance()->SetRenderData(renderDataObject); RenderManager::Instance()->DrawArrays(PRIMITIVETYPE_TRIANGLEFAN, 0, ptCount); } }
bool GraphImp2::shortestPath(Trapezoid2* source, Trapezoid2* target, Polygon2& path) const { assert(iGraph != 0); assert(source != 0 && target != 0); Graph& g = *iGraph; // Find source and target vertex in graph Vertex s = vertex(source->tag(), g); Vertex t = vertex(target->tag(), g); Vertices p(num_vertices(g)); // Predecessor map Reals d(num_vertices(g)); // Distance map // A* will find ALL shortest paths like Dijkstra so we need to throw exception when goal has been found try { astar_search( g, s, DistanceHeuristic(iGraph, t), weight_map(get(&EdgeProperty::weight, g)). predecessor_map(make_iterator_property_map(p.begin(), get(vertex_index, g))). distance_map(make_iterator_property_map(d.begin(), get(vertex_index, g))). visitor(GoalVisitor(t)) ); } catch (FoundGoalException e) { Vertex t = vertex(target->tag(), g); // Store coordinates of shortest path while (t != p[t]) { path.push_back(g[t]); t = p[t]; } path.push_back(g[t]); reverse(path.begin(), path.end()); return true; } return false; }
/*! Find closest intersection point on polygon */ bool Line2::intersection(const Polygon2& poly, Vector2& result) const { assert(false); // TODO: Think this is buggy. Why substact origin() from v and why no test on end to begin part bool found_point = false; Vector2 v, v_prev; Point2 p, p_prev; ConstPointIterator2 begin = poly.begin(); ConstPointIterator2 end = poly.end(); ConstPointIterator2 it; for (it = begin+1; it != end; ++it) { if (!intersection(Segment2(*(it-1), *it), p)) continue; v = p - origin(); if (v.squaredLength() >= v_prev.squaredLength()) continue; v_prev = v; p_prev = p; found_point = true; } result = p_prev; return found_point; }
void LevelLoader::createGameObjects(SvgParser::ElementVector const &elements, Matrix3 const &matrix) { typedef SvgParser::ElementVector::const_iterator Iterator; for (Iterator i = elements.begin(); i != elements.end(); ++i) { ColorTag color = i->color.tag(); if (Box2 const *box = boost::get<Box2>(&i->shape)) { Polygon2 polygon(*box); Polygon2 transformedPolygon = transform(polygon, matrix * i->matrix); if (transformedPolygon.clockwise()) { transformedPolygon.reverse(); } createPolygonGameObject(transformedPolygon, color); } else if (Circle2 const *circle = boost::get<Circle2>(&i->shape)) { Circle2 transformedCircle = transform(*circle, matrix * i->matrix); createCircleGameObject(transformedCircle, color); } else if (Polygon2 const *polygon = boost::get<Polygon2>(&i->shape)) { Polygon2 transformedPolygon = transform(*polygon, matrix * i->matrix); if (transformedPolygon.clockwise()) { transformedPolygon.reverse(); } createPolygonGameObject(transformedPolygon, color); } } }
void BlockPhysicsComponent::create() { Vector2 centroid = polygon_.getCentroid(); float angle = -M_PI + 2.0f * M_PI * actor_->getGame()->getRandomFloat(); b2BodyDef bodyDef; bodyDef.position.Set(centroid.x, centroid.y); bodyDef.angle = angle; bodyDef.userData = actor_; body_ = physicsManager_->getWorld()->CreateBody(&bodyDef); b2Vec2 vertices[b2_maxPolygonVertices]; int32 vertexCount = std::min(int32(polygon_.vertices.size()), b2_maxPolygonVertices); for (int32 i = 0; i < vertexCount; ++i) { b2Vec2 vertex(polygon_.vertices[i].x, polygon_.vertices[i].y); vertices[i] = body_->GetLocalPoint(vertex); localPolygon_.vertices.push_back(Vector2(vertices[i].x, vertices[i].y)); } b2PolygonShape shape; shape.Set(vertices, vertexCount); b2FixtureDef fixtureDef; fixtureDef.shape = &shape; fixtureDef.density = 2.5f; fixtureDef.filter.groupIndex = -1; body_->CreateFixture(&fixtureDef); Polygon2 innerPolygon = polygon_; innerPolygon.pad(-0.15f); for (int32 i = 0; i < vertexCount; ++i) { b2Vec2 vertex(innerPolygon.vertices[i].x, innerPolygon.vertices[i].y); vertices[i] = body_->GetLocalPoint(vertex); } b2PolygonShape innerShape; innerShape.Set(vertices, vertexCount); body_->CreateFixture(&innerShape, 0.0f); rasterize(polygon_); }
bool Polygon2::containsPartOf(const Polygon2 &polygon) const { // If any vertex of @polygon is inside the boundary of @this, then // @polygon is partially inside @this for (int polyI = 0; polyI < polygon.size(); polyI++) { if ( contains( polygon[polyI] ) ) { return true; } } // If any vertex of @this is inside the boundary of @polygon, then // @polygon is partially inside @this for (int vertexI = 0; vertexI < vertices.size(); vertexI++) { if ( polygon.contains( vertices[vertexI] ) ) { return true; } } // If any edge of @polygon intersects @this, then // @polygon is partially inside @this int edgeIPrev = polygon.size() - 1; for (int edgeI = 0; edgeI < polygon.size(); edgeI++) { Segment2 edge( polygon[edgeIPrev], polygon[edgeI] ); if ( checkEdgeIntersection( edge ) ) { return true; } edgeIPrev = edgeI; } // No intersection at all return false; }
void ResultScreen::DrawStatImage(Rect rect) { RenderHelper *helper = RenderHelper::Instance(); RenderManager *manager = RenderManager::Instance(); for(uint32 i = 0; i < testData.GetItemCount(); ++i) { FpsStatItem item = testData.GetItem(i); Rect curRect = testData.TranslateRect(item.rect, rect); for(uint32 j = 0; j < SECTORS_COUNT; j++) { manager->SetColor(SettingsManager::Instance()->GetColorByFps(item.avFps[j])); Polygon2 curSector; curSector.AddPoint(curRect.GetCenter()); curSector.AddPoint(GetVecInRect(curRect, DegToRad((SECTORS_COUNT - j) * 45.f - 22.5f))); curSector.AddPoint(GetVecInRect(curRect, DegToRad((SECTORS_COUNT - j) * 45.f))); curSector.AddPoint(GetVecInRect(curRect, DegToRad((SECTORS_COUNT - j) * 45.f + 22.5f))); helper->FillPolygon(curSector); manager->SetColor(Color::Black()); helper->DrawPolygon(curSector, true); } } }
/** * This was indentified as a trouble area. Numbers were produced from * recording points which caused trouble in simulator. */ void SpriteTests::testSpecialIntersect() { AutoreleasePool::begin(); Polygon2 ship_points; ship_points.push_back(Vector2(8.59, -3.69)); ship_points.push_back(Vector2(10.59, -2.69)); ship_points.push_back(Vector2(8.59, -1.69)); MockView* view = new MockView(ship_points); Sprite* space_ship = new Sprite(view); space_ship->setPosition(Vector2(0.0f, 0.0f)); // Obstacle Polygon2 points; // points.push_back(Vector2(16.7143, 9.85714)); // points.push_back(Vector2(20.2857, 9.71429)); // points.push_back(Vector2(20.1429, -19)); // points.push_back(Vector2(10, -19.1429)); // points.push_back(Vector2(10.4286, -6.71429)); points.push_back(Vector2(10.4286, -6.71429)); points.push_back(Vector2(10, -19.1429)); points.push_back(Vector2(20.1429, -19)); points.push_back(Vector2(20.2857, 9.71429)); points.push_back(Vector2(16.7143, 9.85714)); Sprite* obstacle = new Sprite(new MockView(points)); obstacle->setPosition(Vector2(0.0f, 0.0f)); CPTAssert(!space_ship->collide(obstacle, t, dt)); CPTAssert(!obstacle->collide(space_ship, t, dt)); space_ship->release(); obstacle->release(); AutoreleasePool::end(); }
void RenderHelper::DrawPolygonPoints(const Polygon2 & polygon) { int ptCount = polygon.pointCount; if (ptCount >= 1) { #if defined (__DAVAENGINE_OPENGL__) glPointSize(3.0f); #endif vertexStream->Set(TYPE_FLOAT, 2, 0, polygon.GetPoints()); RenderManager::Instance()->SetRenderEffect(RenderManager::FLAT_COLOR); RenderManager::Instance()->SetRenderData(renderDataObject); RenderManager::Instance()->DrawArrays(PRIMITIVETYPE_POINTLIST, 0, ptCount); #if defined (__DAVAENGINE_OPENGL__) glPointSize(1.0f); #endif } }
void CueTable::createTableMesh(Polygon2& shape){ tableMesh = new Mesh(); float size = 5.0f; vec3 offset = vec3(0,1,0) * size; for(auto& edge : shape.getEdges()){ vec3 v0 = vec3 (edge[0].x, 0, edge[0].y); vec3 v1 = vec3 (edge[1].x, 0, edge[1].y); vec3 v2 = v0 + offset; vec3 v3 = v1 + offset; tableMesh->beginTriangle(); tableMesh->vertex(v2); tableMesh->vertex(v1); tableMesh->vertex(v0); tableMesh->color(vec3(0.0, 1.0, 0.0)); tableMesh->color(vec3(0.0, 1.0, 0.0)); tableMesh->color(vec3(0.0, 1.0, 0.0)); tableMesh->calculateNormals(); tableMesh->endTriangle(); tableMesh->beginTriangle(); tableMesh->vertex(v2); tableMesh->vertex(v3); tableMesh->vertex(v1); tableMesh->color(vec3(0.0, 1.0, 0.0)); tableMesh->color(vec3(0.0, 1.0, 0.0)); tableMesh->color(vec3(0.0, 1.0, 0.0)); tableMesh->calculateNormals(); tableMesh->endTriangle(); } tableMesh->build(); }
bool RectShape2::intersection(const Polygon2& poly, Points2& ) const { return poly.intersect(iRect); }