int KComplexPath::GetEndVelocity() { BOOL bRetCode = false; int nVelocityX = 0; int nVelocityY = 0; int nVelocityZ = 0; int nTotalFrame = 0; int nEndVelocity = 1000; // default if no pre path IPath* pPath = NULL; bRetCode = m_cSubPaths.empty(); KG_PROCESS_SUCCESS(bRetCode); pPath = m_cSubPaths.back(); KGLOG_PROCESS_ERROR(pPath); nTotalFrame = pPath->GetTotalFrame(); pPath->GetVelocityByDeltaFrame(nTotalFrame, nVelocityX, nVelocityY, nVelocityZ); nEndVelocity = (int)sqrt((double)(nVelocityX * nVelocityX + nVelocityY * nVelocityY + nVelocityZ * nVelocityZ)); Exit1: Exit0: return nEndVelocity; }
void CopyPoints(const IPath& p) { AllocPoints(p.NumPoints()); for (unsigned int n = 0; n < p.NumPoints(); n++) { points[n] = p.GetPoint(n); } }
IPath* KComplexPath::GetPathByDeltaFrame(int nDeltaFrame, int* pRetDeltaFrameInPath) const { IPath* pResultPath = NULL; KCOMPLEX_SUB_PATHS::const_iterator itPaths; int nCurrentFrame = 0; KGLOG_PROCESS_ERROR(nDeltaFrame >= 0); KGLOG_PROCESS_ERROR(nDeltaFrame <= m_nTotalFrame); for (itPaths = m_cSubPaths.begin(); itPaths != m_cSubPaths.end(); ++itPaths) { IPath* pPath = *itPaths; int nTotalFrame = pPath->GetTotalFrame(); if (nDeltaFrame <= nCurrentFrame + nTotalFrame) { pResultPath = pPath; if (pRetDeltaFrameInPath) *pRetDeltaFrameInPath = nDeltaFrame - nCurrentFrame; break; } nCurrentFrame += nTotalFrame; } Exit0: return pResultPath; }
void IPath::copy( const IPath& src, const Matrix33& transform ) { // TODO: transform!!! // BUGBUG setNumCoords( src.getNumCoords() ); setNumSegments( src.getNumSegments() ); _segments = src._segments; *_fcoords = *src._fcoords; }
QTPFS::IPath* QTPFS::PathCache::GetPath(unsigned int pathID, unsigned int pathType) { IPath* path = const_cast<IPath*>(GetConstPath(pathID, pathType)); if (path->GetID() != 0) { numCacheHits[pathType] += 1; } else { numCacheMisses[pathType] += 1; } return path; }
std::map<std::string, Status*> Status::GetAllStatusses() { if (s_allStatusses.size() == 0) { IImageManager* imageManager = PlatformSpecific::GetImageManager(); //otherwise open status XML file typedef vector<XMLNode*>::const_iterator SI; vector<XMLNode*> statusNodes = BmeClient::GetPreferences()->GetIconPrefs()->GetStatusNodes(); for (SI s = statusNodes.begin(); s != statusNodes.end(); ++s) { XMLNode* statusNode = *s; if (statusNode->Name() == "status") { vector<XMLNode*> children = statusNode->Children(); Status* status = new Status(); for (SI c = children.begin(); c != children.end(); ++c) { XMLNode* statusChild = *c; if (statusChild->Name() == "icon") { std::string iconPath = statusChild->StringValue(); IPath* iconFullPath = PlatformSpecific::GetPathManager()->GetIconPrefsPath()->Append(iconPath); Image* statusIcon = imageManager->GetImageFromFile(iconFullPath->ToString()); status->AddIcon(statusIcon); delete iconFullPath; } else if (statusChild->Name() == "message") { status->SetStatusName(statusChild->StringValue()); } else if (statusChild->Name() == "protocol") { status->SetAbbreviation(statusChild->StringValue()); } else if (statusChild->Name() == "visible") { bool userChoice = atoi(statusChild->StringValue().c_str()); status->SetUserChoice(userChoice); } else if (statusChild->Name() == "color") { } } s_allStatusses[status->GetAbbreviation()] = (status); } } delete imageManager; } return s_allStatusses; }
void KComplexPath::Start(int nStartFrame) { KCOMPLEX_SUB_PATHS::iterator itPaths; m_nStartFrame = nStartFrame; for (itPaths = m_cSubPaths.begin(); itPaths != m_cSubPaths.end(); ++itPaths) { IPath* pSubPath = (*itPaths); pSubPath->Start(nStartFrame); nStartFrame += pSubPath->GetTotalFrame(); } }
KPOSITION KComplexPath::GetPosAtFrame(int nFrame) const { KPOSITION Pos; IPath* pPath = NULL; KGLOG_PROCESS_ERROR(nFrame >= m_nStartFrame); KGLOG_PROCESS_ERROR(nFrame <= m_nStartFrame + m_nTotalFrame); pPath = GetPathByDeltaFrame(nFrame - m_nStartFrame, NULL); KGLOG_PROCESS_ERROR(pPath); Pos = pPath->GetPosAtFrame(nFrame); Exit0: return Pos; }
void KComplexPath::GetVelocityByDeltaFrame(int nDeltaFrame, int& nVelocityX, int& nVelocityY, int& nVelocityZ) { IPath* pPath = NULL; int nDeltaFrameInPath = 0; nVelocityX = 0; nVelocityY = 0; nVelocityZ = 0; KGLOG_PROCESS_ERROR(nDeltaFrame >= 0); KGLOG_PROCESS_ERROR(nDeltaFrame <= m_nTotalFrame); KG_PROCESS_SUCCESS(m_nTotalFrame == 0); pPath = GetPathByDeltaFrame(nDeltaFrame, &nDeltaFrameInPath); KGLOG_PROCESS_ERROR(pPath); pPath->GetVelocityByDeltaFrame(nDeltaFrameInPath, nVelocityX, nVelocityY, nVelocityZ); Exit1: Exit0: return; }
bool QTPFS::PathCache::MarkDeadPaths(const SRectangle& r) { #ifdef QTPFS_IGNORE_DEAD_PATHS return false; #endif if (livePaths.empty()) return false; // NOTE: not static, we run in multiple threads CollisionVolume rv; float3 rm; GetRectangleCollisionVolume(r, rv, rm); // "mark" any live path crossing the area of a terrain // deformation, for which some or all of its waypoints // might now be invalid and need to be recomputed // std::list<PathMapIt> livePathIts; for (PathMapIt it = livePaths.begin(); it != livePaths.end(); ++it) { IPath* path = it->second; const float3& pathMins = path->GetBoundingBoxMins(); const float3& pathMaxs = path->GetBoundingBoxMaxs(); // if rectangle does not overlap bounding-box, skip this path if (WS(r.x2) < pathMins.x) { continue; } if (WS(r.z2) < pathMins.z) { continue; } if (WS(r.x1) > pathMaxs.x) { continue; } if (WS(r.z1) > pathMaxs.z) { continue; } // figure out if <path> has at least one edge crossing <r> // we only care about the segments we have not yet visited for (unsigned int i = path->GetPointID(); i < (path->NumPoints() - 1); i++) { const float3& p0 = path->GetPoint(i ); const float3& p1 = path->GetPoint(i + 1); const bool pointInRect0 = ((p0.x >= WS(r.x1) && p0.x < WS(r.x2)) && (p0.z >= WS(r.z1) && p0.z < WS(r.z2))); const bool pointInRect1 = ((p1.x >= WS(r.x1) && p1.x < WS(r.x2)) && (p1.z >= WS(r.z1) && p1.z < WS(r.z2))); const bool havePointInRect = (pointInRect0 || pointInRect1); // NOTE: // box-volume tests in its own space, but points are // in world-space so we must inv-transform them first // (p0 --> p0 - rm, p1 --> p1 - rm) const bool edgeCrossesRect = ((p0.x < WS(r.x1) && p1.x >= WS(r.x2)) && (p0.z >= WS(r.z1) && p1.z < WS(r.z2))) || // H ((p0.z < WS(r.z1) && p1.z >= WS(r.z2)) && (p0.x >= WS(r.x1) && p1.x < WS(r.x2))) || // V CCollisionHandler::IntersectBox(&rv, p0 - rm, p1 - rm, NULL); // remember the ID of each path affected by the deformation if (havePointInRect || edgeCrossesRect) { assert(tempPaths.find(path->GetID()) == tempPaths.end()); deadPaths.insert(std::make_pair<unsigned int, IPath*>(path->GetID(), path)); livePathIts.push_back(it); break; } } } for (std::list<PathMapIt>::const_iterator it = livePathIts.begin(); it != livePathIts.end(); ++it) { livePaths.erase(*it); } return true; }
HRESULT InitGeometry() { ////////////////////////////////////////////////////////////////////////// // Create layer ////////////////////////////////////////////////////////////////////////// CLayer* _layer; scom_new<CLayer>(&_layer); _layer->FinalConstruct(pRenderer); g_layer1 = _layer; scom_new<CLayer>(&_layer); _layer->FinalConstruct(pRenderer); g_layer2 = _layer; size_t ncommands; PathCommand *commands; size_t npoints; VML::Vector2 *points; ////////////////////////////////////////////////////////////////////////// // Border ////////////////////////////////////////////////////////////////////////// PathCommand cmds0[] = { PC_MOVE, PC_BEZIER_2, PC_LINE, PC_BEZIER_2, PC_LINE, PC_BEZIER_2, PC_LINE, PC_BEZIER_2, PC_CLOSE, }; ncommands = 9; commands = cmds0; float w = 120.0f; float h = 70.0f; float r = 10.0f; VML::Vector2 points0[] = { VML::Vector2(w - r, h), VML::Vector2(w, h), VML::Vector2(w, h - r), VML::Vector2(w, -h + r), VML::Vector2(w, -h), VML::Vector2(w - r, -h), VML::Vector2(-w + r,-h), VML::Vector2(-w, -h), VML::Vector2(-w, -h + r), VML::Vector2(-w, h - r), VML::Vector2(-w, h), VML::Vector2(-w + r, h), }; npoints = 12; points = points0; IPath* path = g_layer1->AddNewComponent(); IPathBuffer* buff = path->getPathBuffer(); buff->setPoints(points, npoints); buff->setCommands(commands, ncommands); path->setProperty(PP_FILL_STYLE, FS_GRAD_Y); path->setProperty(PP_FILL_COLOR1, 0xff000000); path->setProperty(PP_FILL_COLOR2, 0xff000000); path->setProperty(PP_STROKE_STYLE, SS_NONE); path->setProperty(PP_STROKE_COLOR1, 0xff000000); path->setProperty(PP_STROKE_COLOR2, 0xff000000); path->setStrokeWidth(2.0f); ////////////////////////////////////////////////////////////////////////// // Text ////////////////////////////////////////////////////////////////////////// PathCommand cmds2[] = { PC_MOVE, PC_LINE, PC_LINE, PC_LINE, PC_CLOSE, PC_MOVE, PC_LINE, PC_LINE, PC_LINE, PC_CLOSE, PC_MOVE, PC_LINE, PC_LINE, PC_LINE, PC_CLOSE, }; ncommands = 15; commands = cmds2; w = 30.0f; h = 20.0f; r = 5.0f; VML::Vector2 points2[] = { VML::Vector2(-w, h), VML::Vector2(w, h), VML::Vector2(w, -h), VML::Vector2(-w, -h), VML::Vector2(-w + r, h - r), VML::Vector2(w - r, h - r), VML::Vector2(w - r, -h + r), VML::Vector2(-w + r, -h + r), VML::Vector2(-w + r*3, h - r*3), VML::Vector2(w - r*3, h - r*3), VML::Vector2(w - r*3, -h + r*3), VML::Vector2(-w + r*3, -h + r*3), }; npoints = 12; points = points2; path = g_layer2->AddNewComponent(); buff = path->getPathBuffer(); buff->setPoints(points, npoints); buff->setCommands(commands, ncommands); path->setProperty(PP_FILL_STYLE, FS_SOLID); path->setProperty(PP_FILL_COLOR1, 0xa06060ff); path->setProperty(PP_FILL_COLOR2, 0xa06060ff); path->setProperty(PP_STROKE_STYLE, SS_LINE_SOLID); path->setProperty(PP_STROKE_COLOR1, 0xf060c0ff); path->setProperty(PP_STROKE_COLOR2, 0xffff0000); path->setStrokeWidth(2.0f); ////////////////////////////////////////////////////////////////////////// // Border ////////////////////////////////////////////////////////////////////////// PathCommand cmds1[] = { PC_MOVE, PC_BEZIER_2, PC_LINE, PC_BEZIER_2, PC_LINE, PC_BEZIER_2, PC_LINE, PC_BEZIER_2, PC_CLOSE, PC_MOVE, PC_LINE, PC_LINE, PC_LINE, PC_CLOSE, }; ncommands = 14; commands = cmds1; w = 100.0f; h = 50.0f; r = 10.0f; VML::Vector2 points1[] = { VML::Vector2(w - r, h), VML::Vector2(w, h), VML::Vector2(w, h - r), VML::Vector2(w, -h + r), VML::Vector2(w, -h), VML::Vector2(w - r, -h), VML::Vector2(-w + r, -h), VML::Vector2(-w, -h), VML::Vector2(-w, -h + r), VML::Vector2(-w, h - r), VML::Vector2(-w, h), VML::Vector2(-w + r, h), VML::Vector2(-30.0f, 20.0f), VML::Vector2(30.0f, 20.0f), VML::Vector2(30.0f, -20.0f), VML::Vector2(-30.0f, -20.0f), }; npoints = 16; points = points1; path = g_layer2->AddNewComponent(); buff = path->getPathBuffer(); buff->setPoints(points, npoints); buff->setCommands(commands, ncommands); path->setProperty(PP_FILL_STYLE, FS_GRAD_Y); path->setProperty(PP_FILL_COLOR1, 0x50c8c8c8); path->setProperty(PP_FILL_COLOR2, 0xfffafafa); path->setProperty(PP_STROKE_STYLE, SS_LINE_SOLID); path->setProperty(PP_STROKE_COLOR1, 0xff707070); path->setProperty(PP_STROKE_COLOR2, 0xffff0000); path->setStrokeWidth(2.0f); g_layer1->AddUser(); g_layer2->AddUser(); return S_OK; }