本文整理汇总了C++中PolyLine类的典型用法代码示例。如果您正苦于以下问题:C++ PolyLine类的具体用法?C++ PolyLine怎么用?C++ PolyLine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PolyLine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getWindowWidth
void _TBOX_PREFIX_App::drawPcmData()
{
if ( mPcmBuffer.isEmpty() )
return;
// draw the first(left) channel in the PCM buffer
// getData() returns a pointer to the first sample in the buffer
uint32_t bufferLength = mPcmBuffer.getSize() / mPcmBuffer.getNumChannels();
float *leftBuffer = mPcmBuffer.getData();
int displaySize = getWindowWidth();
float scale = displaySize / (float)bufferLength;
PolyLine<Vec2f> leftBufferLine;
gl::color( Color::gray( 0.4f ) );
for( int i = 0; i < bufferLength; i++ )
{
float x = i * scale;
float y = 50 + leftBuffer[i] * 60;
leftBufferLine.push_back( Vec2f( x , y) );
}
gl::draw( leftBufferLine );
}
示例2: defineShapes
void defineShapes(Shapes *S) {
// simplify contours
vector<vector<Point> > contours_poly( contours.size() );
for( int i = 0; i< contours.size(); i++ ) {
approxPolyDP( Mat(contours[i]), contours_poly[i], 1.1, true );
}
RNG rng(12345);
for( int i = 0; i< contours.size(); i++ ) {
PolyLine *PL = new PolyLine();
PL->setPenColor(0,0,0);
if (use_random_colors) { PL->setPenColor(rng.uniform(100,200),rng.uniform(100,200),rng.uniform(100,200)); }
if (contours_poly[i].size()>min_contour_length) {
// printf("Contour:%i [%lu points]\n",i,contours_poly[i].size());
for (int j=0; j<contours_poly[i].size();j++) {
//printf("(%i,%i)",contours[i][j].x,contours[i][j].y);
//if (j!=contours_poly[i].size()-1) { printf(","); }
PL->addPoint(contours_poly[i][j].x,contours_poly[i][j].y);
}
S->addShape(PL);
//printf("\n");
}
}
}
示例3: draw
// Draw
void KissTempoApp::draw()
{
// Clear screen
gl::clear( ColorAf::black() );
// Check sizes
if ( mDataSize > 0 && mWaveform.size() > 0 ) {
// Get dimensions
float windowWidth = (float)getWindowWidth();
float center = windowWidth * 0.5f;
// Draw waveform
float y = 0.0f;
PolyLine<Vec2f> mLine;
uint32_t ampCount = mWaveform.size();
for ( uint32_t i = 0; i < ampCount; i++, y += 6.5f ) {
float x = mWaveform[ i ] * windowWidth;
mLine.push_back( Vec2f( center + x, y ) );
mLine.push_back( Vec2f( center - x, y + 3.25f ) );
}
gl::draw( mLine );
}
// Draw tempo (scale text to improve quality)
gl::pushMatrices();
gl::scale( 0.25f, 0.25f );
mFont->drawString( toString( (int32_t)math<float>::ceil( mTempo ) ) + " BPM", Vec2f( 20.0f * 4.0f, 540.0f * 4.0f ) );
gl::scale( 0.5f, 0.5f );
mFont->drawString( "Press SPACE to reset track", Vec2f( 20.0f * 8.0f, 575.0f * 8.0f ) );
gl::popMatrices();
}
示例4: getWindowWidth
void SoundScapingApp::drawWaveForm() {
//if the buffer is null, for example if this gets called before any PCM data has been buffered
//don't do anything
if( ! mPcmBuffer ) {
return;
}
uint32_t bufferLength = mPcmBuffer->getSampleCount();
audio::Buffer32fRef leftBuffer = mPcmBuffer->getChannelData( audio::CHANNEL_FRONT_LEFT );
audio::Buffer32fRef rightBuffer = mPcmBuffer->getChannelData( audio::CHANNEL_FRONT_RIGHT );
int displaySize = getWindowWidth();
float scale = displaySize / (float)bufferLength;
PolyLine<Vec2f> leftBufferLine;
PolyLine<Vec2f> rightBufferLine;
for( int i = 0; i < bufferLength; i++ ) {
float x = ( i * scale );
//get the PCM value from the left channel buffer
float y = ( ( leftBuffer->mData[i] - 1 ) * - 100 );
leftBufferLine.push_back( Vec2f( x , y) );
y = ( ( rightBuffer->mData[i] - 1 ) * - 100 );
rightBufferLine.push_back( Vec2f( x , y) );
}
gl::color( Color( 0.0f, 0.5f, 1.0f ) );
gl::draw( leftBufferLine );
gl::draw( rightBufferLine );
}
示例5: HitTestSpline
BOOL SplineData::HitTestSpline(GraphicsWindow *gw,HitRegion *hr, int &hitSplineIndex, float &u)
{
DWORD limit = gw->getRndLimits();
gw->setRndLimits(( limit | GW_PICK) & ~GW_ILLUM);
//loop through splines
gw->setTransform(Matrix3(1));
int numLines = mShapeCache.numLines;
gw->setHitRegion(hr);
gw->clearHitCode();
for (int splineIndex = 0; splineIndex < numLines;splineIndex++)
{
if (mSplineElementData[splineIndex]->IsSelected())
{
PolyLine *line = &mShapeCache.lines[splineIndex];
Point3 plist[2];
u = 0.0f;
for (int i = 0; i < 100; i++)
{
plist[0] = line->InterpCurve3D(u,POLYSHP_INTERP_NORMALIZED);
plist[1] = line->InterpCurve3D(u+0.01f,POLYSHP_INTERP_NORMALIZED);
u += 0.01f;
gw->polyline(2, plist, NULL, NULL, 0);
if (gw->checkHitCode())
{
hitSplineIndex = splineIndex;
return TRUE;
}
}
}
}
return FALSE;
}
示例6: draw
void draw()
{
glPushMatrix();
gl::translate(pos);
gl::color(TILECOLOR);
gl::draw(*hex);
gl::color(TILECOLOR2);
glBegin(GL_TRIANGLE_FAN);
PolyLine<Vec2f>::iterator pt;
for(pt = hex->begin(); pt < hex->end(); pt++)
{
gl::vertex(*pt);
}
glEnd();
/*
gl::color(Color(1.0f, .0f, .0f));
for(pt = hex->begin(); pt < hex->end() - 1; pt++)
{
gl::vertex(*pt);
}
*/
for(int i = 0; i < 6; i++)
{
if(connections[i])
{
Vec2f v = (connections[i]->pos - pos)/2.0f;
gl::color(Color(.0f, 1.0f, .0f));
gl::drawLine(Vec2f(.0f, .0f), v);
}
if(state[i])
{
Vec2f p = cart(TILERAD_MIN - 2.0f, -M_PI/2 - i * M_PI/3.0f);
gl::color(Color(1.0f, .0f, .0f));
// gl::drawSolidCircle(p, 5.0f, 32);
Vec2f pnorm = p.normalized();
pnorm.rotate(-M_PI/2.0f);
Vec2f p0 = p - 22.0f * pnorm;
Vec2f p1 = p + 22.0f * pnorm;
gl::drawLine(p0, p1);
}
}
glPopMatrix();
}
示例7:
void PixarDemo2012::generateWaveforms()
{
// DRAW MEM SPEHRES AND WAVEFORMS
// Check init flag
if ( mFft ) {
// Get data in the frequency (transformed) and time domains
float * freqData = mFft->getAmplitude();
float * timeData = mFft->getData();
int32_t dataSize = mFft->getBinSize();
// Cast data size to float
float dataSizef = (float)dataSize;
// Get dimensions
float scale = ( (float)getWindowWidth() - 20.0f ) / dataSizef;
float windowHeight = (float)getWindowHeight();
// Use polylines to depict time and frequency domains
PolyLine<Vec2f> freqLine;
PolyLine<Vec2f> timeLine;
makeBall = 0.0f;
float greatestFreq = 0.0;
// Iterate through data
for ( int32_t i = 0; i < dataSize; i++ ) {
// Do logarithmic plotting for frequency domain
float logSize = math<float>::log( dataSizef );
float x = (float)( ( math<float>::log( (float)i ) / logSize ) * dataSizef );
float y = math<float>::clamp( freqData[ i ] * ( x / dataSizef ) * ( math<float>::log( ( dataSizef - (float)i ) ) ), 0.0f, 2.0f );
if (y > makeBall) makeBall = y;
if(y > greatestFreq)
greatestFreq = y;
// Plot points on lines for tme domain
freqLine.push_back( Vec2f( x * scale + 10.0f, -y * ( windowHeight - 20.0f ) * 1.75f + ( windowHeight - 10.0f ) ) );
timeLine.push_back( Vec2f( (float)i * scale + 10.0f, timeData[ i ] * ( windowHeight - 20.0f ) * 0.25f + ( windowHeight * 0.25f + 10.0f ) ) );
}
//printf("%f\n", greatestFreq);
theMindField.SetAmps(greatestFreq);
// Draw signals
if ( drawFFT ) {
gl::draw( freqLine );
gl::draw( timeLine );
}
}
}
示例8: draw
// Draw
void KissBasicApp::draw()
{
// Clear screen
gl::clear( ColorAf::black() );
// Check init flag
if ( mFft ) {
// Get data in the frequency (transformed) and time domains
float * freqData = mFft->getAmplitude();
float * timeData = mFft->getData();
int32_t dataSize = mFft->getBinSize();
// Cast data size to float
float dataSizef = (float)dataSize;
// Get dimensions
float scale = ( (float)getWindowWidth() - 20.0f ) / dataSizef;
float windowHeight = (float)getWindowHeight();
// Use polylines to depict time and frequency domains
PolyLine<Vec2f> freqLine;
PolyLine<Vec2f> timeLine;
// Iterate through data
for ( int32_t i = 0; i < dataSize; i++ ) {
// Do logarithmic plotting for frequency domain
float logSize = math<float>::log( dataSizef );
float x = (float)( (math<float>::log( (float)i) / logSize ) * dataSizef );
float y = math<float>::clamp( freqData[i] * ( x / dataSizef ) * ( math<float>::log( ( dataSizef - (float)i ) ) ), 0.0f, 2.0f );
// Plot points on lines for tme domain
freqLine.push_back( Vec2f( x * scale + 10.0f, -y * ( windowHeight - 20.0f ) * 0.25f + ( windowHeight - 10.0f ) ) );
timeLine.push_back( Vec2f( (float)i * scale + 10.0f, timeData[ i ] * ( windowHeight - 20.0f ) * 0.25f + ( windowHeight * 0.25f + 10.0f ) ) );
}
// Draw signals
gl::draw( freqLine );
gl::draw( timeLine );
}
}
示例9: draw
// Draw
void KissFileSampleApp::draw()
{
// Clear screen
gl::clear(Color(0.0f, 0.0f, 0.0f));
// Check init flag
if (mFftInit)
{
// Get data
float * mFreqData = mFft.getAmplitude();
float * mTimeData = mFft.getData();
int32_t mDataSize = mFft.getBinSize();
// Get dimensions
float mScale = ((float)getWindowWidth() - 20.0f) / (float)mDataSize;
float mWindowHeight = (float)getWindowHeight();
// Use polylines to depict time and frequency domains
PolyLine<Vec2f> mFreqLine;
PolyLine<Vec2f> mTimeLine;
// Iterate through data
for (int32_t i = 0; i < mDataSize; i++)
{
// Do logarithmic plotting for frequency domain
double mLogSize = log((double)mDataSize);
float x = (float)(log((double)i) / mLogSize) * (double)mDataSize;
float y = math<float>::clamp(mFreqData[i] * (x / mDataSize) * log((double)(mDataSize - i)), 0.0f, 2.0f);
// Plot points on lines
mFreqLine.push_back(Vec2f(x * mScale + 10.0f, -y * (mWindowHeight - 20.0f) * 1.25f + (mWindowHeight - 10.0f)));
mTimeLine.push_back(Vec2f(i * mScale + 10.0f, mTimeData[i] * (mWindowHeight - 20.0f) * 0.3f + (mWindowHeight * 0.15f + 10.0f)));
}
// Draw signals
gl::draw(mFreqLine);
gl::draw(mTimeLine);
}
}
示例10: getWindowWidth
void redEyeApp::drawSpectrum(bool fill) {
if(!mFftLeft) {
return;
}
float *fftBuffer= mFftLeft.get();
float w= getWindowWidth();
float a= getWindowHeight()*0.01f; //spectrum scale
uint32_t fftSize= mBufferSize/2;
PolyLine<Vec2f> line;
for(uint32_t i= 0; i<fftSize; i++) {
float x= (i/(float)(fftSize-1))*w-(w*0.5f);
float y= fftBuffer[i]*a;
line.push_back(Vec2f(x, 0.0f-y));
if(fill) {
line.push_back(Vec2f(x, y));
}
}
gl::draw(line);
}
示例11: glPushMatrix
void shader02vertexApp::drawWaveform(bool fill) {
if(!mPcmBuffer) {
return;
}
glPushMatrix();
gl::translate(getWindowCenter());
float w= getWindowWidth();
float a= getWindowHeight()*0.25f; //wave amplitude
PolyLine<Vec2f> line;
for(uint32_t i= 0; i<mBufferSize; i++) {
float x= (i/(float)(mBufferSize-1))*w-(w*0.5f);
float y= mBufferLeft->mData[i]*a;
line.push_back(Vec2f(x, y));
if(fill) {
line.push_back(Vec2f(x, 0.0f-y));
}
}
gl::draw(line);
glPopMatrix();
}
示例12: ReadyInterpParams
void HelixObject::BuildShape(TimeValue t, PolyShape& ashape) {
// Set the object's interpolation parameters
ReadyInterpParams(t);
// Set the general interval to the one we just got
ivalid = interpValid;
ashape.NewShape();
// Start a PolyLine for our helix...
PolyLine *line = ashape.NewLine();
// Compute some helpful stuff...
int points = (int)(turns * (float)POINTS_PER_TURN);
if(points == 0)
points = 1;
float fPoints = (float)points;
numberOfPieces = 0;
for(int i = 0; i <= points; ++i) {
float pct = (float)i / fPoints;
float r = radius1 + deltaRadius * pct;
float hpct = pct;
if(bias > 0.0f)
hpct = 1.0f - (float)pow(1.0f - pct, power );
else
if(bias < 0.0f)
hpct = (float)pow(pct, power);
float z = height * hpct;
float angle = totalRadians * pct;
float x = r * (float)cos(angle);
float y = r * (float)sin(angle);
DWORD flags = POLYPT_SMOOTH;
if((i % 10) == 0 || i == points) {
flags |= POLYPT_KNOT; // Let it know the piece boundary
if(i > 0)
numberOfPieces++;
}
line->Append(PolyPt(Point3(x,y,z), flags));
}
perPiece = 1.0f / (float)numberOfPieces;
ashape.UpdateSels(); // Make sure it readies the selection set info
ashape.InvalidateGeomCache(FALSE);
lengthOfCurve = ashape.lines[0].CurveLength();
}
示例13: getWindowWidth
void TouchAudioTestApp::drawWaveForm()
{
if( ! mPcmBuffer ) {
return;
}
uint32_t bufferSamples = mPcmBuffer->getSampleCount();
audio::Buffer32fRef leftBuffer = mPcmBuffer->getChannelData( audio::CHANNEL_FRONT_LEFT );
//audio::Buffer32fRef rightBuffer = mPcmBuffer->getChannelData( audio::CHANNEL_FRONT_RIGHT );
float center = getWindowWidth() / 2;
float displaySize = getWindowHeight();
uint32_t endIdx = bufferSamples;
//only draw the last 1024 samples or less
int32_t startIdx = ( endIdx - 1024 );
startIdx = math<int32_t>::clamp( startIdx, 0, endIdx );
float scale = displaySize / (float)( endIdx - startIdx );
//float scale = displaySize / (float)( endIdx );
PolyLine<vec2> line;
gl::color( Color( 1.0f, 0.5f, 0.25f ) );
for( uint32_t i = startIdx, c = 0; i < endIdx; i++, c++ ) {
float y = ( ( leftBuffer->mData[i] - 1 ) * - center );
line.push_back( vec2( y, ( c * scale ) ) );
}
gl::draw( line );
/*glColor3f( 1.0f, 0.96f, 0.0f );
glBegin( GL_LINE_STRIP );
for( int i = 0; i < endIdx; i++ ) {
float y = ( ( rightBuffer->mData[i] - 1 ) * - 100 );
glVertex2f( ( i * scale ) , y );
}
glEnd();*/
}
示例14: TimeValue
//.........这里部分代码省略.........
int vert = 0;
int level;
Point3 offset1, offset2;
for(poly = 0; poly < polys; ++poly) {
Spline3D *spline = bShape.splines[poly];
if(!spline->KnotCount())
continue;
int knots = spline->KnotCount();
for(level = 0; level <= levels; ++level) {
Point3 offset = Point3(0.0f, 0.0f, baseZ + (float)level / (float)levels * zSize);
if(level == 0)
offset1 = offset;
else
if(level == levels)
offset2 = offset;
for(knot = 0; knot < knots; ++knot) {
Point3 p = spline->GetKnotPoint(knot);
pmesh.setVert(vert++, p + offset);
}
}
}
assert(vert == nverts);
BOOL usePhysUVs = GetUsePhysicalScaleUVs();
// Maybe create the texture vertices
if(texturing) {
int tvert = 0;
int level;
for(poly = 0; poly < polys; ++poly) {
Spline3D *spline = bShape.splines[poly];
if(!spline->KnotCount())
continue;
// Make it a polyline
PolyLine pline;
spline->MakePolyLine(pline, 10);
int knots = spline->KnotCount();
for(level = 0; level < TVlevels; ++level) {
float tV = (float)level / (float)(TVlevels - 1);
float vScale = usePhysUVs ? amount : 1.0f;
int lverts = pline.numPts;
int tp = 0;
int texPts = spline->Segments() + 1;
float cumLen = 0.0f;
float totLen = pline.CurveLength();
float uScale = usePhysUVs ? totLen : 1.0f;
Point3 prevPt = pline.pts[0].p;
int plix = 0;
while(tp < texPts) {
Point3 &pt = pline[plix].p;
cumLen += Length(pt - prevPt);
prevPt = pt;
if(pline[plix].flags & POLYPT_KNOT) {
float tU;
if(tp == (texPts - 1))
tU = 1.0f;
else
tU = cumLen / totLen;
pmesh.setTVert(tvert++, UVVert(uScale*tU, vScale*tV, 0.0f));
tp++;
}
plix = (plix + 1) % pline.numPts;
}
}
}
assert(tvert == ntverts);
}
示例15: draw
void Puppeteer::draw()
{
// ----------------------------debug
if (Constants::Debug::DRAW_PUPPETEER_BOUNDS) {
Vec3f origin = Vec3f::zero();
PolyLine<Vec3f> boundsL;
boundsL.push_back(origin - axisVert * armLenL);
boundsL.push_back(origin - axisVert * armLenL + axisHoriz * armLenL);
boundsL.push_back(origin + axisVert * armLenL + axisHoriz * armLenL);
boundsL.push_back(origin + axisVert * armLenL);
boundsL.push_back(origin - axisVert * armLenL);
boundsL.push_back(origin - axisVert * armLenL + normal * armLenL); //
boundsL.push_back(origin - axisVert * armLenL + normal * armLenL + axisHoriz * armLenL);
boundsL.push_back(origin + axisVert * armLenL + normal * armLenL + axisHoriz * armLenL);
boundsL.push_back(origin + axisVert * armLenL + normal * armLenL);
boundsL.push_back(origin - axisVert * armLenL + normal * armLenL);
PolyLine<Vec3f> boundsR;
boundsR.push_back(origin - axisVert * armLenR);
boundsR.push_back(origin - axisVert * armLenR - axisHoriz * armLenR);
boundsR.push_back(origin + axisVert * armLenR - axisHoriz * armLenR);
boundsR.push_back(origin + axisVert * armLenR);
boundsR.push_back(origin - axisVert * armLenR);
boundsR.push_back(origin - axisVert * armLenR + normal * armLenR); //
boundsR.push_back(origin - axisVert * armLenR + normal * armLenR - axisHoriz * armLenR);
boundsR.push_back(origin + axisVert * armLenR + normal * armLenR - axisHoriz * armLenR);
boundsR.push_back(origin + axisVert * armLenR + normal * armLenR);
boundsR.push_back(origin - axisVert * armLenR + normal * armLenR);
gl::pushMatrices();
MayaCamUI* mayaCam = Constants::mayaCam();
gl::setMatrices(mayaCam->getCamera());
float scale = 1.0f;
// original bounding boxes
gl::color(Color(0.5f, 0.5f, 0.5f));
gl::pushModelView();
gl::translate(shoulderL);
gl::draw(boundsL);
gl::popModelView();
gl::pushModelView();
gl::translate(shoulderR);
gl::draw(boundsR);
gl::popModelView();
// normalized bound boxes
gl::color(Color(0, 0, 1));
gl::pushModelView();
gl::translate(-.5f, 0, 0);
gl::scale(scale, scale, scale);
gl::rotate( Quatf(normalizationMatrix) );
gl::draw(boundsL);
gl::popModelView();
gl::pushModelView();
gl::translate(-.5f, 0, 0);
gl::scale(scale, scale, scale);
gl::drawCube(handL, Vec3f(0.1f, 0.1f, 0.1f));
gl::popModelView();
gl::color(Color(0, 1, 0));
gl::pushModelView();
gl::translate(.5f, 0, 0);
gl::scale(scale, scale, scale);
gl::rotate( Quatf(normalizationMatrix) );
gl::draw(boundsR);
gl::popModelView();
gl::pushModelView();
gl::translate(.5f, 0, 0);
gl::scale(scale, scale, scale);
gl::drawCube(handR, Vec3f(0.1f, 0.1f, 0.1f));
gl::popModelView();
gl::popMatrices();
gl::color( Color(1, 1, 1));
}
arduino->draw();
}