CPlayerObj* CTO2GameServerShell::CreatePlayer(HCLIENT hClient, ModelId ePlayerModelId ) { ObjectCreateStruct theStruct; INIT_OBJECTCREATESTRUCT(theStruct); theStruct.m_Rotation.Init(); VEC_INIT(theStruct.m_Pos); theStruct.m_Flags = 0; HCLASS hClass = g_pLTServer->GetClass("CPlayerObj"); GameStartPoint* pStartPoint = FindStartPoint(LTNULL); if (pStartPoint) { g_pLTServer->GetObjectPos(pStartPoint->m_hObject, &(theStruct.m_Pos)); } CPlayerObj* pPlayer = NULL; if (hClass) { theStruct.m_UserData = ePlayerModelId; //pStartPoint->GetPlayerModelId(); pPlayer = (CPlayerObj*) g_pLTServer->CreateObject(hClass, &theStruct); } return pPlayer; }
/////////////////////////////////////////////////////////////////////////////////////////// // FindGoodResetPoint() // // A good reset point is one near other commited areas so that // we know that when we've made the longest strips its because // we're stripifying in the same general orientation. // NvFaceInfo* NvStripifier::FindGoodResetPoint(NvFaceInfoVec &faceInfos, NvEdgeInfoVec &edgeInfos){ // we hop into different areas of the mesh to try to get // other large open spans done. Areas of small strips can // just be left to triangle lists added at the end. NvFaceInfo *result = NULL; if(result == NULL) { int numFaces = faceInfos.size(); int startPoint; if(bFirstTimeResetPoint) { //first time, find a face with few neighbors (look for an edge of the mesh) startPoint = FindStartPoint(faceInfos, edgeInfos); bFirstTimeResetPoint = false; } else startPoint = (int)(((float) numFaces - 1) * meshJump); if(startPoint == -1) { startPoint = (int)(((float) numFaces - 1) * meshJump); //meshJump += 0.1f; //if (meshJump > 1.0f) // meshJump = .05f; } int i = startPoint; do { // if this guy isn't visited, try him if (faceInfos[i]->m_stripId < 0){ result = faceInfos[i]; break; } // update the index and clamp to 0-(numFaces-1) if (++i >= numFaces) i = 0; } while (i != startPoint); // update the meshJump meshJump += 0.1f; if (meshJump > 1.0f) meshJump = .05f; } // return the best face we found return result; }
void CVICOS::Execute() { CalculateCauchyMatrices(); FindStartPoint(); CalculateValidated(); }
int main(){ Convexhull h; vector<Point> point; vector<Point> result; vector<Point> internal; while(1){ int i,option,n; cout << "Please choose method: (1)brute force (2)Jarvis's march (3)exit" <<endl; cin >> option; ifstream finput("Input.txt"); internal.clear(); point.clear(); result.clear(); finput >> n; // Ū¤F´XÓ¦r¤¸ for(i=0; i<n; i++){ double x,y; finput >> x >> y; Point a = Point(x,y); point.push_back(a); } struct timeval tv, tv2; unsigned long long int start_utime, end_utime; if(option == 1){ gettimeofday(&tv, NULL); h.FindConvexHull_bf(point, result); gettimeofday(&tv2, NULL); start_utime = tv.tv_sec*1000000 + tv.tv_usec; end_utime = tv2.tv_sec*1000000 + tv2.tv_usec; } else if(option == 2){ gettimeofday(&tv, NULL); h.FindConvexHull_jm(point, result); gettimeofday(&tv2, NULL); start_utime = tv.tv_sec*1000000 + tv.tv_usec; end_utime = tv2.tv_sec*1000000 + tv2.tv_usec; } else break; cout << "cost time: " << end_utime - start_utime << " us" <<endl; internal = h.FindInternalPoint(point,result); ofstream foutput("Output.txt"); foutput << internal.size() << endl; vector<Point> upper; vector<Point> lower; upper.clear(); lower.clear(); for(i=0; i<internal.size(); i++){ if(internal[i].y >= 0) upper.push_back(internal[i]); else lower.push_back(internal[i]); } sort(upper.begin(), upper.end(), up_compare); sort(lower.begin(), lower.end(), low_compare); for(i=0; i<upper.size(); i++) foutput << upper[i].x << " " << upper[i].y << endl; for(i=0; i<lower.size(); i++) foutput << lower[i].x << " " << lower[i].y << endl; foutput << endl; foutput << result.size() << endl; Point start_p = FindStartPoint(result); upper.clear(); lower.clear(); for(i=0; i<result.size(); i++){ if(result[i] == start_p) continue; if(result[i].y > start_p.y) upper.push_back(result[i]); else lower.push_back(result[i]); } sort(upper.begin(), upper.end(), up_compare); sort(lower.begin(), lower.end(), low_compare); foutput << start_p.x << " " << start_p.y << endl; for(i=0; i<upper.size(); i++) foutput << upper[i].x << " " << upper[i].y << endl; for(i=0; i<lower.size(); i++) foutput << lower[i].x << " " << lower[i].y << endl; } return 0; }