void DrawNode::drawCircle(const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY, const Color4F &color) { const float coef = 2.0f * (float)M_PI/segments; Vec2 *vertices = new (std::nothrow) Vec2[segments+2]; if( ! vertices ) return; for(unsigned int i = 0;i <= segments; i++) { float rads = i*coef; GLfloat j = radius * cosf(rads + angle) * scaleX + center.x; GLfloat k = radius * sinf(rads + angle) * scaleY + center.y; vertices[i].x = j; vertices[i].y = k; } if(drawLineToCenter) { vertices[segments+1].x = center.x; vertices[segments+1].y = center.y; drawPoly(vertices, segments+2, true, color); } else drawPoly(vertices, segments+1, true, color); CC_SAFE_DELETE_ARRAY(vertices); }
double DkPageExtractionPlugin::jaccardIndex(const QSize & imgSize, const QPolygonF & gt, const QPolygonF & computed) const { cv::Mat gtImg = nmc::DkImage::qImage2Mat(drawPoly(imgSize, gt)); cv::Mat evImg = nmc::DkImage::qImage2Mat(drawPoly(imgSize, computed)); double andVal = (double)cv::sum(gtImg & evImg)[0]; double orVal = (double)cv::sum(gtImg | evImg)[0]; return andVal/orVal; }
/* ================== BotDrawDebugPolygons ================== */ void BotDrawDebugPolygons(void (*drawPoly)(int color, int numPoints, float *points), int value) { static cvar_t *bot_debug, *bot_groundonly, *bot_reachability, *bot_highlightarea; bot_debugpoly_t *poly; int i, parm0; if (!debugpolygons) return; //bot debugging if (!bot_debug) bot_debug = Cvar_Get("bot_debug", "0", 0); // if (sv.botEnable && bot_debug->integer) { //show reachabilities if (!bot_reachability) bot_reachability = Cvar_Get("bot_reachability", "0", 0); //show ground faces only if (!bot_groundonly) bot_groundonly = Cvar_Get("bot_groundonly", "1", 0); //get the hightlight area if (!bot_highlightarea) bot_highlightarea = Cvar_Get("bot_highlightarea", "0", 0); // parm0 = 0; if (svs.clients[0].lastUsercmd.buttons & BUTTON_ATTACK) parm0 |= 1; if (bot_reachability->integer) parm0 |= 2; if (bot_groundonly->integer) parm0 |= 4; botlib_export->BotLibVarSet("bot_highlightarea", bot_highlightarea->string); botlib_export->Test(parm0, NULL, svs.clients[0].gentity->r.currentOrigin, svs.clients[0].gentity->r.currentAngles); } //end if //draw all debug polys for (i = 0; i < bot_maxdebugpolys; i++) { poly = &debugpolygons[i]; if (!poly->inuse) continue; drawPoly(poly->color, poly->numPoints, (float *) poly->points); //Com_Printf("poly %i, numpoints = %d\n", i, poly->numPoints); } }
void BotDrawDebugPolygons( void ( * drawPoly )( int color, int numPoints, float* points ), int value ) { static Cvar* bot_debug, * bot_highlightarea; bot_debugpoly_t* poly; int i; if ( !bot_enable ) { return; } if ( !debugpolygons ) { return; } //bot debugging if ( !bot_debug ) { bot_debug = Cvar_Get( "bot_debug", "0", 0 ); } //get the hightlight area if ( !bot_highlightarea ) { bot_highlightarea = Cvar_Get( "bot_highlightarea", "0", 0 ); } if ( bot_debug->integer ) { BotLibVarSet( "bot_highlightarea", bot_highlightarea->string ); } //draw all debug polys for ( i = 0; i < bot_maxdebugpolys; i++ ) { poly = &debugpolygons[ i ]; if ( !poly->inuse ) { continue; } drawPoly( poly->color, poly->numPoints, ( float* )poly->points ); } }
LabelBMFontBounds::LabelBMFontBounds() { auto s = Director::getInstance()->getWinSize(); auto layer = LayerColor::create(Color4B(128,128,128,255)); addChild(layer, -10); // LabelBMFont auto label1 = LabelBMFont::create("Testing Glyph Designer", "fonts/boundsTestFont.fnt"); addChild(label1); label1->setPosition(Vec2(s.width/2, s.height/2)); auto drawNode = DrawNode::create(); auto labelSize = label1->getContentSize(); auto origin = Director::getInstance()->getWinSize(); origin.width = origin.width / 2 - (labelSize.width / 2); origin.height = origin.height / 2 - (labelSize.height / 2); Vec2 vertices[4]= { Vec2(origin.width, origin.height), Vec2(labelSize.width + origin.width, origin.height), Vec2(labelSize.width + origin.width, labelSize.height + origin.height), Vec2(origin.width, labelSize.height + origin.height) }; drawNode->drawPoly(vertices, 4, true, Color4F(1.0, 1.0, 1.0, 1.0)); addChild(drawNode); }
void DrawNode::drawCardinalSpline(PointArray *config, float tension, unsigned int segments, const Color4F &color) { auto vertices = (Vec2*)CC_ALLOCA((segments + 1) * sizeof(Vec2)); ssize_t p; float lt; float deltaT = 1.f / config->count(); for (unsigned i = 0; i <= segments; ++i) { float dt = (float)i / segments; // border if( dt == 1 ) { p = config->count() - 1; lt = 1; } else { p = dt / deltaT; lt = (dt - deltaT * (float)p) / deltaT; } // Interpolate Vec2 pp0 = config->getControlPointAtIndex(p-1); Vec2 pp1 = config->getControlPointAtIndex(p+0); Vec2 pp2 = config->getControlPointAtIndex(p+1); Vec2 pp3 = config->getControlPointAtIndex(p+2); Vec2 newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, tension, lt); vertices[i].x = newPos.x; vertices[i].y = newPos.y; } drawPoly(vertices, segments+1, false, color); }
/* ================== BotDrawDebugPolygons ================== */ void BotDrawDebugPolygons( void ( *drawPoly )( int color, int numPoints, float *points ), int value ) { static cvar_t *bot_debug, *bot_groundonly, *bot_reachability, *bot_highlightarea; static cvar_t *bot_testhidepos; bot_debugpoly_t *poly; int i, parm0; #ifdef PRE_RELEASE_DEMO return; #endif if ( !bot_enable ) { return; } //bot debugging if ( !bot_debug ) { bot_debug = Cvar_Get( "bot_debug", "0", 0 ); } //show reachabilities if ( !bot_reachability ) { bot_reachability = Cvar_Get( "bot_reachability", "0", 0 ); } //show ground faces only if ( !bot_groundonly ) { bot_groundonly = Cvar_Get( "bot_groundonly", "1", 0 ); } //get the hightlight area if ( !bot_highlightarea ) { bot_highlightarea = Cvar_Get( "bot_highlightarea", "0", 0 ); } // if ( !bot_testhidepos ) { bot_testhidepos = Cvar_Get( "bot_testhidepos", "0", 0 ); } // if ( bot_debug->integer ) { parm0 = 0; if ( svs.clients[0].lastUsercmd.buttons & BUTTON_ATTACK ) { parm0 |= 1; } if ( bot_reachability->integer ) { parm0 |= 2; } if ( bot_groundonly->integer ) { parm0 |= 4; } botlib_export->BotLibVarSet( "bot_highlightarea", bot_highlightarea->string ); botlib_export->BotLibVarSet( "bot_testhidepos", bot_testhidepos->string ); botlib_export->Test( parm0, NULL, svs.clients[0].gentity->r.currentOrigin, svs.clients[0].gentity->r.currentAngles ); } //end if for ( i = 0; i < MAX_DEBUGPOLYS; i++ ) { poly = &debugpolygons[i]; if ( !poly->inuse ) { continue; } drawPoly( poly->color, poly->numPoints, (float *) poly->points ); //Com_Printf("poly %i, numpoints = %d\n", i, poly->numPoints); } }
void display( ) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(1,1,0.); glRotatef(angle,1.,1.,1.); glScalef(.5,.5,.5); //draw the cube drawPoly(0,3,2,1,0); drawPoly(2,3,7,6,1); drawPoly(0,4,7,3,2); drawPoly(1,2,6,5,3); drawPoly(4,5,6,7,4); drawPoly(0,1,5,4,5); /*//Second Square glTranslatef(0,0,0); glRotatef(angle,1.,1.,1.); glScalef(0.5,0.5,.5); //draw the cube drawPoly(0,3,2,1,0); drawPoly(2,3,7,6,1); drawPoly(0,4,7,3,2); drawPoly(1,2,6,5,3); drawPoly(4,5,6,7,4); drawPoly(0,1,5,4,5); */ glutSwapBuffers(); glFlush(); }
void GLWidget::createDisplayLists() { _modelDisplayListIndex = glGenLists(2); // Solid glNewList(_modelDisplayListIndex, GL_COMPILE); glColor3f(0.44, 0.6, 0.95); // Set model color. for ( unsigned int i = 0; i < _model->numPoly(); ++i ) { glLoadName(i); drawPoly( _model->getPolyAt(i), false ); } glEndList(); // Solid + wire glNewList(_modelDisplayListIndex+1, GL_COMPILE); glCallList(_modelDisplayListIndex); glColor3f(1.0, 1.0, 1.0); // Set wire color. for ( unsigned int i = 0; i < _model->numPoly(); ++i ) drawPoly( _model->getPolyAt(i), true ); glEndList(); }
int main(void) { gfx_open(400,400,"Bounce"); int stillGoing = 1; float dt = 0.01; float xpos =rand() %400+1; float ypos =rand() %400+1; float xvel =(double)rand()/RAND_MAX * 10.0 - 5.0; float yvel =(double)rand()/RAND_MAX * 10.0 - 5.0; float RIGHT_EDGE = 400; float LEFT_EDGE = 0; float TOP = 0; float BOTTOM = 400; while(stillGoing){ xpos += xvel; ypos += yvel; if(xpos <= LEFT_EDGE || xpos >= RIGHT_EDGE) xvel *=-1; if(ypos <= TOP || ypos >= BOTTOM) yvel *= -1; gfx_clear(); drawPoly(30,xpos,ypos); gfx_flush(); usleep(10000); if(gfx_event_waiting()){ char c = gfx_wait(); if(c==1){ xpos = gfx_xpos(); ypos = gfx_ypos(); xvel =(double)rand()/RAND_MAX * 10.0 - 5.0; yvel =(double)rand()/RAND_MAX * 10.0 - 5.0; } else if (c=='q' || c=='Q'){ break; } } } return 0; }
void DrawNode::drawCircle(const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY, const Color4F& color) { const float coef = 2.f * (float)M_PI/segments; auto vertices = (Vec2*)CC_ALLOCA((segments + 2) * sizeof(Vec2)); for (auto i = 0u; i <= segments; ++i) { float rads = i*coef; GLfloat j = radius * cosf(rads + angle) * scaleX + center.x; GLfloat k = radius * sinf(rads + angle) * scaleY + center.y; vertices[i].x = j; vertices[i].y = k; } if(drawLineToCenter) { vertices[segments+1].x = center.x; vertices[segments+1].y = center.y; drawPoly(vertices, segments+2, true, color); } else drawPoly(vertices, segments+1, true, color); }
void PauseLayer::AddSpriteBorder(MenuItemImage *sp) { auto drawNode = DrawNode::create(); auto p = sp->getPosition(); Size s = Director::getInstance()->getVisibleSize(); Vec2 ps[4] = { Vec2(p.x - s.width*0.13, p.y - s.height*0.04), Vec2(p.x + s.width*0.13, p.y - s.height*0.04), Vec2(p.x + s.width*0.13, p.y + s.height*0.04), Vec2(p.x - s.width*0.13, p.y + s.height*0.04), }; drawNode->drawPoly(ps, 4, true, Color4F(1.0, 1.0, 1.0, 1.0)); this->addChild(drawNode); }
void DrawNode::drawQuadBezier(const Vec2& origin, const Vec2& control, const Vec2& destination, unsigned int segments, const Color4F& color) { auto vertices = (Vec2*)CC_ALLOCA((segments + 1) * sizeof(Vec2)); float t = 0.f; for (auto i = 0u; i < segments; ++i) { vertices[i].x = powf(1 - t, 2) * origin.x + 2.f * (1 - t) * t * control.x + t * t * destination.x; vertices[i].y = powf(1 - t, 2) * origin.y + 2.f * (1 - t) * t * control.y + t * t * destination.y; t += 1.f / segments; } vertices[segments].x = destination.x; vertices[segments].y = destination.y; drawPoly(vertices, segments+1, false, color); }
void DrawNode::drawCubicBezier(const Vec2& origin, const Vec2& control1, const Vec2& control2, const Vec2& destination, unsigned int segments, const Color4F& color) { auto vertices = (Vec2*)CC_ALLOCA((segments + 1) * sizeof(Vec2)); float t = 0; for (unsigned int i = 0; i < segments; i++) { vertices[i].x = powf(1 - t, 3) * origin.x + 3.f * powf(1 - t, 2) * t * control1.x + 3.f * (1 - t) * t * t * control2.x + t * t * t * destination.x; vertices[i].y = powf(1 - t, 3) * origin.y + 3.f * powf(1 - t, 2) * t * control1.y + 3.f * (1 - t) * t * t * control2.y + t * t * t * destination.y; t += 1.f / segments; } vertices[segments].x = destination.x; vertices[segments].y = destination.y; drawPoly(vertices, segments+1, false, color); }
void DrawNode::drawCubicBezier(const Vec2 &origin, const Vec2 &control1, const Vec2 &control2, const Vec2 &destination, unsigned int segments, const Color4F &color) { Vec2* vertices = new (std::nothrow) Vec2[segments + 1]; if( ! vertices ) return; float t = 0; for (unsigned int i = 0; i < segments; i++) { vertices[i].x = powf(1 - t, 3) * origin.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * destination.x; vertices[i].y = powf(1 - t, 3) * origin.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * destination.y; t += 1.0f / segments; } vertices[segments].x = destination.x; vertices[segments].y = destination.y; drawPoly(vertices, segments+1, false, color); CC_SAFE_DELETE_ARRAY(vertices); }
/* first we see if we even need to draw by checking if it is in the camera, via cameraGetLoc() cameraGetLoc() returns a drawable rect (if camera is zoomed it needs to translate) which draw can use. DRAW SHOULD NEVER AFFECT GAME WORLD */ void drawObject(dioneObject *obj) { SDL_Rect drawable; SDL_bool in_camera; in_camera = cameraGetLoc(&(obj->l), &drawable); if (in_camera == SDL_FALSE) { return; } /* drawable is now in pixels not world units. We can just draw it like it is! */ switch (TYPEOF(obj)) { case OBJ_LINE: drawLine((lineObject*)obj, &drawable); break; case OBJ_PEOPLE: drawPerson((humanObject*)obj, &drawable); break; case OBJ_WAVE: drawWave((waveObject*)obj, &drawable); break; case OBJ_CUSTOM: (((customObject*)obj)->drawFunc)(obj); break; case OBJ_POLY: drawPoly((polyObject*)obj, &drawable); break; case OBJ_BEZIER: drawBezier((bezierObject*)obj, &drawable); break; case OBJ_TEXTURE: drawTexture((textureObject*)obj, &drawable); break; case OBJ_TEXT: drawText((textObject*)obj, &drawable); break; default: /* I never want to be here */ print_message(MSG_VERBOSE_ERROR, MSG_FLAG_NONE, "[draw] I have no idea how to handle this obj: %x!", obj); } }
void DrawNode::drawCardinalSpline(PointArray *config, float tension, unsigned int segments, const Color4F &color) { Vec2* vertices = new (std::nothrow) Vec2[segments + 1]; if( ! vertices ) return; ssize_t p; float lt; float deltaT = 1.0f / config->count(); for( unsigned int i=0; i < segments+1;i++) { float dt = (float)i / segments; // border if( dt == 1 ) { p = config->count() - 1; lt = 1; } else { p = dt / deltaT; lt = (dt - deltaT * (float)p) / deltaT; } // Interpolate Vec2 pp0 = config->getControlPointAtIndex(p-1); Vec2 pp1 = config->getControlPointAtIndex(p+0); Vec2 pp2 = config->getControlPointAtIndex(p+1); Vec2 pp3 = config->getControlPointAtIndex(p+2); Vec2 newPos = ccCardinalSplineAt( pp0, pp1, pp2, pp3, tension, lt); vertices[i].x = newPos.x; vertices[i].y = newPos.y; } drawPoly(vertices, segments+1, false, color); CC_SAFE_DELETE_ARRAY(vertices); }
void GLWidget::paintGL() { // Clear buffers. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if ( _model->isLoaded() ) { // Draw current selection. if ( !_hitMode ) { glColor3f(0.5, 1.0, 0.5); std::set<unsigned int>::const_iterator it = _currentSelection.begin(); for (;it != _currentSelection.end(); ++it) drawPoly( _model->getPolyAt(*it), false ); } // Draw complete model. if (_renderMode == SOLID_WIRE) glCallList(_modelDisplayListIndex+1); else glCallList(_modelDisplayListIndex); } }
void CM_DrawDebugSurface( void (*drawPoly)(int color, int numPoints, bfixed *points) ) { static cvar_t *cv; #ifndef BSPC static cvar_t *cv2; #endif const patchCollide_t *pc; facet_t *facet; winding_t *w; int i, j, k, n; int curplanenum, planenum, curinward, inward; planeDef_t plane; bvec3_t mins = {-BFIXED(15,0), -BFIXED(15,0), -BFIXED(28,0)}, maxs = {BFIXED(15,0), BFIXED(15,0), BFIXED(28,0)}; //bvec3_t mins = {BFIXED_0, BFIXED_0, BFIXED_0}, maxs = {BFIXED_0, BFIXED_0, BFIXED_0}; bvec3_t v1; avec3_t v2; #ifndef BSPC if ( !cv2 ) { cv2 = Cvar_Get( "r_debugSurface", "0", 0 ); } if (cv2->integer != 1) { BotDrawDebugPolygons(drawPoly, cv2->integer); return; } #endif if ( !debugPatchCollide ) { return; } #ifndef BSPC if ( !cv ) { cv = Cvar_Get( "cm_debugSize", "2", 0 ); } #endif pc = debugPatchCollide; for ( i = 0, facet = pc->facets ; i < pc->numFacets ; i++, facet++ ) { for ( k = 0 ; k < facet->numBorders + 1; k++ ) { // if (k < facet->numBorders) { planenum = facet->borderPlanes[k]; inward = facet->borderInward[k]; } else { planenum = facet->surfacePlane; inward = qfalse; //continue; } VectorCopy( pc->planes[ planenum ].pd.normal, plane.normal ); plane.dist=pc->planes[ planenum ].pd.dist; //planenum = facet->surfacePlane; if ( inward ) { VectorSubtract( avec3_origin, plane.normal, plane.normal ); plane.dist = -plane.dist; } plane.dist += MAKE_BFIXED(cv->value); //* for (n = 0; n < 3; n++) { if (plane.normal[n] > AFIXED_0) v1[n] = maxs[n]; else v1[n] = mins[n]; } //end for VectorNegate(plane.normal, v2); plane.dist += FIXED_ABS(FIXED_VEC3DOT(v1, v2)); //*/ w = BaseWindingForPlane( plane.normal, plane.dist ); for ( j = 0 ; j < facet->numBorders + 1 && w; j++ ) { // if (j < facet->numBorders) { curplanenum = facet->borderPlanes[j]; curinward = facet->borderInward[j]; } else { curplanenum = facet->surfacePlane; curinward = qfalse; //continue; } // if (curplanenum == planenum) continue; VectorCopy( pc->planes[ curplanenum ].pd.normal, plane.normal ); plane.dist=pc->planes[ curplanenum ].pd.dist; if ( !curinward ) { VectorSubtract( avec3_origin, plane.normal, plane.normal ); plane.dist = -plane.dist; } // if ( !facet->borderNoAdjust[j] ) { plane.dist -= MAKE_BFIXED(cv->value); // } for (n = 0; n < 3; n++) { if (plane.normal[n] > AFIXED_0) v1[n] = maxs[n]; else v1[n] = mins[n]; } //end for VectorNegate(plane.normal, v2); plane.dist -= FIXED_ABS(FIXED_VEC3DOT(v1, v2)); ChopWindingInPlace( &w, plane.normal, plane.dist, BFIXED(0,1) ); } if ( w ) { if ( facet == debugFacet ) { drawPoly( 4, w->numpoints, w->p[0] ); //Com_Printf("blue facet has %d border planes\n", facet->numBorders); } else { drawPoly( 1, w->numpoints, w->p[0] ); } FreeWinding( w ); } else Com_Printf("winding chopped away by border planes\n"); } } // draw the debug block { bvec3_t v[3]; VectorCopy( debugBlockPoints[0], v[0] ); VectorCopy( debugBlockPoints[1], v[1] ); VectorCopy( debugBlockPoints[2], v[2] ); drawPoly( 2, 3, v[0] ); VectorCopy( debugBlockPoints[2], v[0] ); VectorCopy( debugBlockPoints[3], v[1] ); VectorCopy( debugBlockPoints[0], v[2] ); drawPoly( 2, 3, v[0] ); } #if 0 bvec3_t v[4]; v[0][0] = pc->bounds[1][0]; v[0][1] = pc->bounds[1][1]; v[0][2] = pc->bounds[1][2]; v[1][0] = pc->bounds[1][0]; v[1][1] = pc->bounds[0][1]; v[1][2] = pc->bounds[1][2]; v[2][0] = pc->bounds[0][0]; v[2][1] = pc->bounds[0][1]; v[2][2] = pc->bounds[1][2]; v[3][0] = pc->bounds[0][0]; v[3][1] = pc->bounds[1][1]; v[3][2] = pc->bounds[1][2]; drawPoly( 4, v[0] ); #endif }
void draw3ds(obj3ds* object) { int i; for(i = 0; i < object->triNumber; i++) drawPoly(object->triangles[i]); }
void CM_DrawDebugSurface( void ( *drawPoly )( int color, int numPoints, float *points ) ) { static cvar_t *cv; #ifndef BSPC static cvar_t *cv2; #endif const patchCollide_t *pc; facet_t *facet; winding_t *w; int i, j, k, n; int curplanenum, planenum, curinward, inward; float plane[4]; vec3_t mins = {-15, -15, -28}, maxs = {15, 15, 28}; //vec3_t mins = {0, 0, 0}, maxs = {0, 0, 0}; vec3_t v1, v2; #ifndef BSPC if ( !cv2 ) { cv2 = Cvar_Get( "r_debugSurface", "0", 0 ); } if ( cv2->integer != 1 ) { BotDrawDebugPolygons( drawPoly, cv2->integer ); return; } #endif if ( !debugPatchCollide ) { return; } #ifndef BSPC if ( !cv ) { cv = Cvar_Get( "cm_debugSize", "2", 0 ); } #endif pc = debugPatchCollide; for ( i = 0, facet = pc->facets ; i < pc->numFacets ; i++, facet++ ) { for ( k = 0 ; k < facet->numBorders + 1; k++ ) { // if ( k < facet->numBorders ) { planenum = facet->borderPlanes[k]; inward = facet->borderInward[k]; } else { planenum = facet->surfacePlane; inward = qfalse; //continue; } Vector4Copy( pc->planes[ planenum ].plane, plane ); //planenum = facet->surfacePlane; if ( inward ) { VectorSubtract( vec3_origin, plane, plane ); plane[3] = -plane[3]; } plane[3] += cv->value; //* for ( n = 0; n < 3; n++ ) { if ( plane[n] > 0 ) { v1[n] = maxs[n]; } else { v1[n] = mins[n];} } //end for VectorNegate( plane, v2 ); plane[3] += fabs( DotProduct( v1, v2 ) ); //*/ w = BaseWindingForPlane( plane, plane[3] ); for ( j = 0 ; j < facet->numBorders + 1 && w; j++ ) { // if ( j < facet->numBorders ) { curplanenum = facet->borderPlanes[j]; curinward = facet->borderInward[j]; } else { curplanenum = facet->surfacePlane; curinward = qfalse; //continue; } // if ( curplanenum == planenum ) { continue; } Vector4Copy( pc->planes[ curplanenum ].plane, plane ); if ( !curinward ) { VectorSubtract( vec3_origin, plane, plane ); plane[3] = -plane[3]; } // if ( !facet->borderNoAdjust[j] ) { plane[3] -= cv->value; // } for ( n = 0; n < 3; n++ ) { if ( plane[n] > 0 ) { v1[n] = maxs[n]; } else { v1[n] = mins[n];} } //end for VectorNegate( plane, v2 ); plane[3] -= fabs( DotProduct( v1, v2 ) ); ChopWindingInPlace( &w, plane, plane[3], 0.1f ); } if ( w ) { if ( facet == debugFacet ) { drawPoly( 4, w->numpoints, w->p[0] ); //Com_Printf("blue facet has %d border planes\n", facet->numBorders); } else { drawPoly( 1, w->numpoints, w->p[0] ); } FreeWinding( w ); } else { Com_Printf( "winding chopped away by border planes\n" ); } } } // draw the debug block { vec3_t v[3]; VectorCopy( debugBlockPoints[0], v[0] ); VectorCopy( debugBlockPoints[1], v[1] ); VectorCopy( debugBlockPoints[2], v[2] ); drawPoly( 2, 3, v[0] ); VectorCopy( debugBlockPoints[2], v[0] ); VectorCopy( debugBlockPoints[3], v[1] ); VectorCopy( debugBlockPoints[0], v[2] ); drawPoly( 2, 3, v[0] ); } #if 0 vec3_t v[4]; v[0][0] = pc->bounds[1][0]; v[0][1] = pc->bounds[1][1]; v[0][2] = pc->bounds[1][2]; v[1][0] = pc->bounds[1][0]; v[1][1] = pc->bounds[0][1]; v[1][2] = pc->bounds[1][2]; v[2][0] = pc->bounds[0][0]; v[2][1] = pc->bounds[0][1]; v[2][2] = pc->bounds[1][2]; v[3][0] = pc->bounds[0][0]; v[3][1] = pc->bounds[1][1]; v[3][2] = pc->bounds[1][2]; drawPoly( 4, v[0] ); #endif }
void soundMap::drawFuzzShape(StaticFuzzObject blob) { if (blob.toAnimate != "done") { int heighestAlpha = ofMap(blob.HighestVolume, 0, 100, 0, 255); float widthIncludingSpread = blob.width* blob.spreadFactor; ofEnableAlphaBlending(); if(blob.clipToRoom == 9) { int alpha = 0; ofSetColor(blob.color,heighestAlpha/4); ofEllipse(blob.posX, blob.posY, widthIncludingSpread/1.5 , widthIncludingSpread/1.5); ofSetColor(blob.color, heighestAlpha/2); ofEllipse(blob.posX, blob.posY, blob.width, blob.width); } else { vector<ofVec2f> littleCircle , bigCircle, roomz; getCircleCoords(ofVec2f(blob.posX, blob.posY), blob.width/2, littleCircle); getCircleCoords(ofVec2f(blob.posX, blob.posY), (widthIncludingSpread/1.5)/2, bigCircle); //temp = //ofLog() << blob.roomNum-1; vector< ofPoint > pointsInRoom = rooms[blob.clipToRoom-1].getVertices(); //svgPaths.paths[blob.roomNum-1]->getOutline()[1].getVertices(); for (int i=0; i < pointsInRoom.size(); i++) { ofVec2f point; point.x = pointsInRoom[i].x; point.y = pointsInRoom[i].y; roomz.push_back(point); } vector<vector<ofVec2f> > polys; polys.push_back(bigCircle); polys.push_back(roomz); vector<vector<ofVec2f> > out; clipper.doIntersection(polys, out); polys.clear(); ofSetColor(blob.color,heighestAlpha/4); for(int i = 0; i < out.size(); i++) { drawPoly(out[i]); } out.clear(); vector<vector<ofVec2f> > polys2; polys2.push_back(littleCircle); polys2.push_back(roomz); vector<vector<ofVec2f> > out2; clipper.doIntersection(polys2, out2); polys2.clear(); ofSetColor(blob.color, heighestAlpha/2); for(int i = 0; i < out2.size(); i++) { drawPoly(out2[i]); } out.clear(); ofDisableAlphaBlending(); } } }