本文整理汇总了C++中Trail类的典型用法代码示例。如果您正苦于以下问题:C++ Trail类的具体用法?C++ Trail怎么用?C++ Trail使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Trail类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Trail
void TrailMod::act() {
// module follows ship, constantly spawns trail atoms that block/hurt
// trails disappear after a while
// can be toggled on/off to save power
//gm->add(/* new trail of the current type at this pos */)->initall(gm,x,y);
Trail* t = new Trail(host);
gm->add(t);
t->initall(gm,host->x,host->y,team);
t->lifedelay(200);
}
示例2: mouseDrag
void mouseDrag (const MouseEvent& e) override
{
Trail* t = getTrail (e.source);
if (t == nullptr)
{
t = new Trail (e.source);
t->path.startNewSubPath (e.getPosition().toFloat());
trails.add (t);
}
t->pushPoint (e.getPosition().toFloat(), e.mods);
repaint();
}
示例3: mouseDrag
void mouseDrag (const MouseEvent& e) override
{
Trail* t = getTrail (e.source);
if (t == nullptr)
{
t = new Trail (e.source);
t->path.startNewSubPath (e.position);
trails.add (t);
}
t->pushPoint (e.position, e.mods, e.pressure);
repaint();
}
示例4: DrawTrail
void DrawTrail(const Trail& tr, const Graph& g)
{
if (tr.empty())
{
return;
}
int prev = tr[0];
for (unsigned int i = 1; i < tr.size(); i++)
{
const GraphEdge& edge = g.GetEdge(tr[i], prev);
prev = tr[i];
DrawEdge(edge, g);
}
}
示例5: OPTION_TITLE
CString OptionRow::GetRowTitle() const
{
CString sLineName = m_RowDef.name;
CString sTitle = THEME_TITLES ? OPTION_TITLE(sLineName) : sLineName;
// HACK: tack the BPM onto the name of the speed line
if( sLineName.CompareNoCase("speed")==0 )
{
bool bShowBpmInSpeedTitle = SHOW_BPM_IN_SPEED_TITLE;
if( GAMESTATE->m_pCurCourse )
{
Trail* pTrail = GAMESTATE->m_pCurTrail[GAMESTATE->m_MasterPlayerNumber];
ASSERT( pTrail != NULL );
const int iNumCourseEntries = pTrail->m_vEntries.size();
if( iNumCourseEntries > MAX_COURSE_ENTRIES_BEFORE_VARIOUS )
bShowBpmInSpeedTitle = false;
}
if( bShowBpmInSpeedTitle )
{
DisplayBpms bpms;
if( GAMESTATE->m_pCurSong )
{
Song* pSong = GAMESTATE->m_pCurSong;
pSong->GetDisplayBpms( bpms );
}
else if( GAMESTATE->m_pCurCourse )
{
Course *pCourse = GAMESTATE->m_pCurCourse;
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType;
Trail* pTrail = pCourse->GetTrail( st );
ASSERT( pTrail );
pTrail->GetDisplayBpms( bpms );
}
if( bpms.IsSecret() )
sTitle += ssprintf( " (??" "?)" ); /* split so gcc doesn't think this is a trigraph */
else if( bpms.BpmIsConstant() )
sTitle += ssprintf( " (%.0f)", bpms.GetMin() );
else
sTitle += ssprintf( " (%.0f-%.0f)", bpms.GetMin(), bpms.GetMax() );
}
}
return sTitle;
}
示例6: updateApp
//--------------------------------------------------------------
void testApp::updateApp(){
ofPoint * pos;
Trail *trail;
bool bInsideLetter;
vector<ofPoint> growings;
for(int i=0; i<trails.size(); i++){
trail = &trails[i];
pos = &trail->position;
// If trail isn't in a letter yet
if(trail->letterId == -1) {
trail->update(screenBounds);
if(!ofInsidePoly( trail->position, screenBounds.getVertices() )){
trails.erase(trails.begin()+i);
i--;
continue;
}
// look if it has found a letter now
for(int j=0; j<letters.size(); j++){
if( ofInsidePoly( *pos, letters[j].getVertices() ) ) {
trail->letterId = j;
}
}
}
else {
trail->update(letters[trail->letterId]);
if (trails[i].bActive) {
growings.push_back(trails[i].position);
}
}
}
triangle.clear();
if(growings.size()>=3)
triangle.triangulate( growings, growings.size() );
}
示例7: borderDetailedAlignMatrix
// Fills the complement of the radius of the trail with minus infties.
// The return value true means success. Failure means that during the fill,
// we intersected the outside of the quasidiagonal area.
// In this case, the operation is not finished.
bool borderDetailedAlignMatrix( AlignMatrix& alignMatrix, const Trail& trail, int radius )
{
int huBookSize = alignMatrix.size();
int enBookSize = alignMatrix.otherSize();
int huPos, enPos;
for ( huPos=0; huPos<huBookSize; ++huPos )
{
int rowStart = alignMatrix.rowStart(huPos);
int rowEnd = alignMatrix.rowEnd(huPos);
for ( enPos=rowStart; enPos<rowEnd; ++enPos )
{
alignMatrix.cell(huPos,enPos) = outsideOfRadiusValue;
}
}
// We seriously use the fact that many-to-zero segments are subdivided into one-to-zero segments.
// Inside setBox, an exception is thrown if we try to write outside the quasidiagonal.
// If we catch such an exception, it means that the quasidiagonal is not thick enough.
// In this case, we abandon the whole align, just to be sure.
try
{
for ( int i=0; i<trail.size(); ++i )
{
setBox( alignMatrix, trail[i].first, trail[i].second, radius, insideOfRadiusValue );
}
}
catch ( const char* errorType )
{
massert( std::string(errorType) == "out of quasidiagonal" )
return false;
}
bool verify = true;
if (verify)
{
int numberOfEvaluatedItems(0);
for ( huPos=0; huPos<huBookSize; ++huPos )
{
int rowStart = alignMatrix.rowStart(huPos);
int rowEnd = alignMatrix.rowEnd(huPos);
for ( enPos=rowStart; enPos<rowEnd; ++enPos )
{
if (alignMatrix[huPos][enPos]==insideOfRadiusValue)
{
++numberOfEvaluatedItems;
}
}
}
std::cerr << numberOfEvaluatedItems << " items inside the border." << std::endl;
}
return true;
}
示例8: ASSERT
void BPMDisplay::SetBpmFromCourse( const Course* pCourse )
{
ASSERT( pCourse != NULL );
ASSERT( GAMESTATE->GetCurrentStyle(PLAYER_INVALID) != NULL );
StepsType st = GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType;
Trail *pTrail = pCourse->GetTrail( st );
// GetTranslitFullTitle because "Crashinfo.txt is garbled because of the ANSI output as usual." -f
ASSERT_M( pTrail != NULL, ssprintf("Course '%s' has no trail for StepsType '%s'", pCourse->GetTranslitFullTitle().c_str(), StringConversion::ToString(st).c_str() ) );
m_fCycleTime = (float)COURSE_CYCLE_SPEED;
if( (int)pTrail->m_vEntries.size() > CommonMetrics::MAX_COURSE_ENTRIES_BEFORE_VARIOUS )
{
SetVarious();
return;
}
DisplayBpms bpms;
pTrail->GetDisplayBpms( bpms );
SetBPMRange( bpms );
}
示例9: countIntersectionOfTrails
int countIntersectionOfTrails( const Trail& sx, const Trail& sy )
{
int inter(0);
Trail::const_iterator sxt = sx.begin();
Trail::const_iterator syt = sy.begin();
Trail::const_iterator sxe = sx.end();
Trail::const_iterator sye = sy.end();
for ( ; sxt!=sxe && syt!=sye ; )
{
if ( *sxt < *syt )
++sxt;
else if ( *sxt > *syt )
++syt;
else
{
++inter;
++sxt;
++syt;
}
}
return inter;
}
示例10: scoreTrailOrBisentenceList
// A bit of an abuse of the fact that Trail and BisentenceList are typedef'd to the same structure.
double scoreTrailOrBisentenceList( const Trail& trailAuto, const Trail& trailHand )
{
int score = countIntersectionOfTrails( trailAuto, trailHand );
std::cerr << trailAuto.size()-score << " misaligned out of " << trailHand.size() << " correct items, "
<< trailAuto.size() << " bets." << std::endl;
std::cerr << "Precision: " << 1.0*score/trailAuto.size()
<< ", Recall: " << 1.0*score/trailHand.size() << std::endl;
double ratio = 1.0*(trailAuto.size()-score)/trailAuto.size();
return ratio;
}
示例11: trailToBisentenceList
void trailToBisentenceList( const Trail& bestTrail,
BisentenceList& bisentenceList )
{
bisentenceList.clear();
int trailSize = bestTrail.size();
for ( int pos=0; pos<trailSize-1; ++pos )
{
if ( oneToOne(bestTrail,pos) )
{
bisentenceList.push_back(bestTrail [pos]);
}
}
}
示例12: switch
bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) const
{
trail.Init();
// XXX: Why are beginner and challenge excluded here? -Wolfman2000
// No idea, probably an obsolete design decision from ITG, removing
// exclusion here, but there's some other area that prevents it too. -Kyz
/*
switch( cd )
{
case Difficulty_Beginner:
return false;
case Difficulty_Challenge:
return false;
default: break;
}
*/
// Construct a new Trail, add it to the cache, then return it.
// Different seed for each course, but the same for the whole round:
RandomGen rnd( GAMESTATE->m_iStageSeed + GetHashForString(m_sMainTitle) );
vector<CourseEntry> tmp_entries;
if( m_bShuffle )
{
/* Always randomize the same way per round. Otherwise, the displayed course
* will change every time it's viewed, and the displayed order will have no
* bearing on what you'll actually play. */
tmp_entries = m_vEntries;
random_shuffle( tmp_entries.begin(), tmp_entries.end(), rnd );
}
const vector<CourseEntry> &entries = m_bShuffle ? tmp_entries:m_vEntries;
// This can take some time, so don't fill it out unless we need it.
vector<Song*> vSongsByMostPlayed;
vector<Song*> AllSongsShuffled;
trail.m_StepsType = st;
trail.m_CourseType = GetCourseType();
trail.m_CourseDifficulty = cd;
trail.m_vEntries.reserve(entries.size());
// Set to true if CourseDifficulty is able to change something.
bool bCourseDifficultyIsSignificant = (cd == Difficulty_Medium);
// Resolve each entry to a Song and Steps.
if( trail.m_CourseType == COURSE_TYPE_ENDLESS )
{
GetTrailUnsortedEndless(entries, trail, st, cd, rnd, bCourseDifficultyIsSignificant);
}
else
{
vector<SongAndSteps> vSongAndSteps;
for (auto e = entries.begin(); e != entries.end(); ++e)
{
SongAndSteps resolved; // fill this in
SongCriteria soc = e->songCriteria;
Song *pSong = e->songID.ToSong();
if( pSong )
{
soc.m_bUseSongAllowedList = true;
soc.m_vpSongAllowedList.push_back( pSong );
}
soc.m_Tutorial = SongCriteria::Tutorial_No;
soc.m_Locked = SongCriteria::Locked_Unlocked;
if( !soc.m_bUseSongAllowedList )
soc.m_iMaxStagesForSong = 1;
StepsCriteria stc = e->stepsCriteria;
stc.m_st = st;
stc.m_Locked = StepsCriteria::Locked_Unlocked;
const bool bSameSongCriteria = e != entries.begin() && ( e - 1 )->songCriteria == soc;
const bool bSameStepsCriteria = e != entries.begin() && ( e - 1 )->stepsCriteria == stc;
if( pSong )
{
StepsUtil::GetAllMatching( pSong, stc, vSongAndSteps );
}
else if( vSongAndSteps.empty() || !( bSameSongCriteria && bSameStepsCriteria ) )
{
vSongAndSteps.clear();
StepsUtil::GetAllMatching( soc, stc, vSongAndSteps );
}
// It looks bad to have the same song 2x in a row in a randomly generated course.
// Don't allow the same song to be played 2x in a row, unless there's only
// one song in vpPossibleSongs.
if( trail.m_vEntries.size() > 0 && vSongAndSteps.size() > 1 )
{
const TrailEntry &teLast = trail.m_vEntries.back();
RemoveIf( vSongAndSteps, SongIsEqual( teLast.pSong ) );
}
// if there are no songs to choose from, abort this CourseEntry
if( vSongAndSteps.empty() )
//.........这里部分代码省略.........
示例13: vec3
void Choreo3DApp::draw()
{
//gl::clear( ColorA::gray( background ) );
gl::clear(ColorAf(testBK));
//THIS MAY NEED TO BE CLEANED UP
vector<std::string> dataVector = {"CCL_JOINT_CCL3_00_skip10.json"};
if( CURRENT_DATA_SET != LOADED_DATA_SET){
// paused = true;
// jointList = {};
jointList = ccl::loadMotionCaptureFromJson(getAssetPath(dataVector[CURRENT_DATA_SET]));
FRAME_COUNT = 0;
TOTAL_FRAMES = jointList[0].jointPositions.size(); //SHOULD PROBABLY PUT A TRY/CATCH HERE
std::cout << "total frames: " << TOTAL_FRAMES << ", total joints:"<< jointList.size() << std::endl;
gl::VboMeshRef body = gl::VboMesh::create( geom::Sphere().subdivisions( 16 ).radius(4) );
//CREATE A CONTAINER TO STORE THE INITIAL POSITIONS FOR INITIALISING THE JOINTS
std::vector<glm::vec3> positions;
// CREATE THE SPHERES AT THE INITIAL JOINT LOCATIONS
for ( int i = 0; i < jointList.size(); ++i ) {
glm::vec3 jointAt = jointList[i].jointPositions[i];
float instanceX = jointAt.x;
float instanceY = jointAt.y;
float instanceZ = jointAt.z;
// float instanceZ = 0;
positions.push_back( vec3( instanceX, instanceY, instanceZ));
}
//std::cout << "positions: " << positions[0] << std::endl;
// create the VBO which will contain per-instance (rather than per-vertex) data
mInstanceDataVbo = gl::Vbo::create( GL_ARRAY_BUFFER, positions.size() * sizeof(vec3), positions.data(), GL_DYNAMIC_DRAW );
// we need a geom::BufferLayout to describe this data as mapping to the CUSTOM_0 semantic, and the 1 (rather than 0) as the last param indicates per-instance (rather than per-vertex)
geom::BufferLayout instanceDataLayout;
instanceDataLayout.append( geom::Attrib::CUSTOM_0, 3, 0, 0, 1 /* per instance */ );
//NOW ADD IT TO THE VBO MESH THAT WE INITIAL CREATED FOR THE BODY / SKELETON
body->appendVbo( instanceDataLayout, mInstanceDataVbo );
//FINALLY, BUILD THE BATCH, AND MAP THE CUSTOM_0 ATTRIBUTE TO THE "vInstancePosition" GLSL VERTEX ATTRIBUTE
mSphereBatch = gl::Batch::create( body, mGlsl, { { geom::Attrib::CUSTOM_0, "vInstancePosition" } } );
LOADED_DATA_SET = CURRENT_DATA_SET;
}
gl::setMatrices( mCamera );
if (showGrid)renderScene();
Color( dancerColor[0], dancerColor[1], dancerColor[2] );
//gl::ScopedModelMatrix modelScope;
if(markersActive)mSphereBatch->drawInstanced( jointList.size() );
if(skeletonActive)skeleton.renderSkeleton();
if(ribbonsActive)drawRibbons();
if(trailsActive)handTrail.render(dancerColor);
}
示例14: setFrameRate
void Choreo3DApp::update()
{
setFrameRate(frameRate);
//DISABLE CAMERA INTERACTION IF MOUSE IS OVER UI REGION
if (getMousePos().x > 3 * getWindowWidth()/4. && camActive)
{
camActive = false;
mCamUi.disconnect();
mCamUi.disable();
cout << "disabling camera UI" << endl;
} else {
if (!camActive)
{
mCamUi.connect(getWindow());
mCamUi.enable();
}
camActive = true;
cout << "enabling camera UI" << endl;
}
mGlsl->uniform("uColor", markerColour );
if (!paused)
{
//UPDATE POSITIONS
//MAP INSTANCE DATA TO VBO
//WRITE NEW POSITIONS
//UNMAP
glm::vec3 *newPositions = (glm::vec3*)mInstanceDataVbo->mapReplace();
for( int i = 0; i < jointList.size(); ++i )
{
float instanceX = jointList[i].jointPositions[FRAME_COUNT].x;
float instanceY = jointList[i].jointPositions[FRAME_COUNT].y;
float instanceZ = jointList[i].jointPositions[FRAME_COUNT].z;
vec3 newPos(vec3(instanceX,instanceY, instanceZ)); //CREATE A NEW VEC3 FOR UPDATING THE VBO
framePositions[i] = newPos;
}
//REPLACE VEC3s IN VBO BY INCREMENTING THE POINTER
for (int i = 0; i < framePositions.size(); i++){
*newPositions++ = framePositions[i];
}
handTrail.update(framePositions[26], dancerColor);
// std::cout << framePositions[17] << std::endl;
skeleton.update(framePositions);
mInstanceDataVbo->unmap();
// std::cout << "position: " << positions[0] << std::endl;
if (ribbonsActive)updateRibbons();
//MANUALLY INCREMENT THE FRAME, IF THE FRAME_COUNT EXCEEDS TOTAL FRAMES, RESET THE COUNTER
if (FRAME_COUNT < TOTAL_FRAMES)
{
FRAME_COUNT += 1;
} else {
FRAME_COUNT = 0;
}
//std::cout << getAverageFps() << std:: endl;
// std::cout << "frame rate: " << getAverageFps() << ", frame count: " << FRAME_COUNT << std::endl;
//define changed color
// Color temp = Color(dancerColor[0],dancerColor[1],dancerColor[2]);
mCurrentFrame++; //MANUALLY ADVANCE THE CURRENT FRAME - WITH RESPECT TO THE DANCERS
}
updateGui();
}
示例15: trelliToLadder
void trelliToLadder( const TrelliMatrix& trellis, Trail& bestTrail )
{
bestTrail.clear();
// The -1 is needed because the trellis matrix is one larger than the similarity matrix.
// This points to its downmost rightmost element.
const int huBookSize = trellis.size()-1;
const int enBookSize = trellis.otherSize()-1;
int huPos=huBookSize;
int enPos=enBookSize;
bool logging = false;
if (logging) std::cerr << std::endl;
bool over = false;
bool hopelesslyBadTrail = false;
bestTrail.push_back(std::make_pair(huPos,enPos));
while (true)
{
unsigned char trelli = trellis[huPos][enPos];
// std::cerr << huPos << "," << enPos << "," << (int)trelli << std::endl;
if ((huPos==0) || (enPos==0))
break;
switch (trelli)
{
case Diag :
{
--huPos;
--enPos;
break;
}
case HuSkip :
{
--huPos;
break;
}
case EnSkip :
{
--enPos;
break;
}
case HuHuEnSkip :
{
huPos -= 2;
--enPos;
break;
}
case HuEnEnSkip :
{
--huPos;
enPos -= 2;
break;
}
case Dead :
{
over = true;
break;
}
default:
{
hopelesslyBadTrail = true;
over = true;
break;
}
}
if (over)
break;
bestTrail.push_back(std::make_pair(huPos,enPos));
if (logging)
{
std::cerr << huPos << " \t" << enPos << std::endl;
}
}
if (hopelesslyBadTrail)
{
bestTrail.clear();
bestTrail.push_back(std::make_pair(huBookSize,enBookSize));
bestTrail.push_back(std::make_pair(0,0));
std::cerr << "Error: hopelessly bad trail." << std::endl;
}
std::reverse(bestTrail.begin(), bestTrail.end() );
}