NxI32 OBJ::ParseLine(NxI32 lineno,NxI32 argc,const char **argv) // return TRUE to continue parsing, return FALSE to abort parsing process { NxI32 ret = 0; if ( argc >= 1 ) { const char *foo = argv[0]; if ( *foo != '#' ) { if ( _stricmp(argv[0],"v") == 0 && argc == 4 ) { NxF32 vx = (NxF32) atof( argv[1] ); NxF32 vy = (NxF32) atof( argv[2] ); NxF32 vz = (NxF32) atof( argv[3] ); mVerts.push_back(vx); mVerts.push_back(vy); mVerts.push_back(vz); } else if ( _stricmp(argv[0],"vt") == 0 && (argc == 3 || argc == 4)) { // ignore 4rd component if present NxF32 tx = (NxF32) atof( argv[1] ); NxF32 ty = (NxF32) atof( argv[2] ); mTexels.push_back(tx); mTexels.push_back(ty); } else if ( _stricmp(argv[0],"vn") == 0 && argc == 4 ) { NxF32 normalx = (NxF32) atof(argv[1]); NxF32 normaly = (NxF32) atof(argv[2]); NxF32 normalz = (NxF32) atof(argv[3]); mNormals.push_back(normalx); mNormals.push_back(normaly); mNormals.push_back(normalz); } else if ( _stricmp(argv[0],"f") == 0 && argc >= 4 ) { GeometryVertex v[32]; NxI32 vcount = argc-1; for (NxI32 i=1; i<argc; i++) { GetVertex(v[i-1],argv[i] ); } mCallback->NodeTriangle(&v[0],&v[1],&v[2], mTextured); if ( vcount >=3 ) // do the fan { for (NxI32 i=2; i<(vcount-1); i++) { mCallback->NodeTriangle(&v[0],&v[i],&v[i+1], mTextured); } } } } } return ret; }
CPlane CPolygon::GetPlane() const { return CPlane(GetVertex(0), m_normal); }
WShape *WFace::getShape() { return GetVertex(0)->shape(); }
void CGraphics_Threaded::QuadsDrawFreeform(const CFreeformItem *pArray, int Num) { dbg_assert(m_Drawing == DRAWING_QUADS, "called Graphics()->QuadsDrawFreeform without begin"); if(g_Config.m_GfxQuadAsTriangle && !m_UseOpenGL3_3) { for(int i = 0; i < Num; ++i) { GetVertex(m_NumVertices + 6*i)->m_Pos.x = pArray[i].m_X0; GetVertex(m_NumVertices + 6*i)->m_Pos.y = pArray[i].m_Y0; GetVertex(m_NumVertices + 6*i)->m_Tex = m_aTexture[0]; SetColor(GetVertex(m_NumVertices + 6*i), 0); GetVertex(m_NumVertices + 6*i + 1)->m_Pos.x = pArray[i].m_X1; GetVertex(m_NumVertices + 6*i + 1)->m_Pos.y = pArray[i].m_Y1; GetVertex(m_NumVertices + 6*i + 1)->m_Tex = m_aTexture[1]; SetColor(GetVertex(m_NumVertices + 6*i + 1), 1); GetVertex(m_NumVertices + 6*i + 2)->m_Pos.x = pArray[i].m_X3; GetVertex(m_NumVertices + 6*i + 2)->m_Pos.y = pArray[i].m_Y3; GetVertex(m_NumVertices + 6*i + 2)->m_Tex = m_aTexture[3]; SetColor(GetVertex(m_NumVertices + 6*i + 2), 3); GetVertex(m_NumVertices + 6*i + 3)->m_Pos.x = pArray[i].m_X0; GetVertex(m_NumVertices + 6*i + 3)->m_Pos.y = pArray[i].m_Y0; GetVertex(m_NumVertices + 6*i + 3)->m_Tex = m_aTexture[0]; SetColor(GetVertex(m_NumVertices + 6*i + 3), 0); GetVertex(m_NumVertices + 6*i + 4)->m_Pos.x = pArray[i].m_X3; GetVertex(m_NumVertices + 6*i + 4)->m_Pos.y = pArray[i].m_Y3; GetVertex(m_NumVertices + 6*i + 4)->m_Tex = m_aTexture[3]; SetColor(GetVertex(m_NumVertices + 6*i + 4), 3); GetVertex(m_NumVertices + 6*i + 5)->m_Pos.x = pArray[i].m_X2; GetVertex(m_NumVertices + 6*i + 5)->m_Pos.y = pArray[i].m_Y2; GetVertex(m_NumVertices + 6*i + 5)->m_Tex = m_aTexture[2]; SetColor(GetVertex(m_NumVertices + 6*i + 5), 2); } AddVertices(3*2*Num); } else { for(int i = 0; i < Num; ++i) { GetVertex(m_NumVertices + 4*i)->m_Pos.x = pArray[i].m_X0; GetVertex(m_NumVertices + 4*i)->m_Pos.y = pArray[i].m_Y0; GetVertex(m_NumVertices + 4*i)->m_Tex = m_aTexture[0]; SetColor(GetVertex(m_NumVertices + 4*i), 0); GetVertex(m_NumVertices + 4*i + 1)->m_Pos.x = pArray[i].m_X1; GetVertex(m_NumVertices + 4*i + 1)->m_Pos.y = pArray[i].m_Y1; GetVertex(m_NumVertices + 4*i + 1)->m_Tex = m_aTexture[1]; SetColor(GetVertex(m_NumVertices + 4*i + 1), 1); GetVertex(m_NumVertices + 4*i + 2)->m_Pos.x = pArray[i].m_X3; GetVertex(m_NumVertices + 4*i + 2)->m_Pos.y = pArray[i].m_Y3; GetVertex(m_NumVertices + 4*i + 2)->m_Tex = m_aTexture[3]; SetColor(GetVertex(m_NumVertices + 4*i + 2), 3); GetVertex(m_NumVertices + 4*i + 3)->m_Pos.x = pArray[i].m_X2; GetVertex(m_NumVertices + 4*i + 3)->m_Pos.y = pArray[i].m_Y2; GetVertex(m_NumVertices + 4*i + 3)->m_Tex = m_aTexture[2]; SetColor(GetVertex(m_NumVertices + 4*i + 3), 2); } AddVertices(4*Num); } }
//******************************************** // DeleteVertex at the end that are flagged with // sequence_number >= sequence_number //******************************************** int CPath3d::RemovePathEnd(int sequence_number, int ID, double x, double y, double z) { if (TheFrame) TheFrame->GViewDlg.m_view.OpenGLMutex->Lock(); int n = m_ArrayVertex.GetSize()-1; setup_pointer p=TheFrame->GCodeDlg.Interpreter->p_setup; float xtool = p->tool_table[p->selected_tool_slot].xoffset; float ytool = p->tool_table[p->selected_tool_slot].yoffset; float ztool = p->tool_table[p->selected_tool_slot].length; x -= xtool; y -= ytool; z -= ztool; // first verify that the line number is there while (n>=0) { int SeqNum = GetVertex(n)->Get_sequence_number(); if (SeqNum == sequence_number) break; n--; } if (n<0) { if (TheFrame) TheFrame->GViewDlg.m_view.OpenGLMutex->Unlock(); return 1; } // now delete until we find the sequence_number n = m_ArrayVertex.GetSize()-1; while (n>=0) { if (GetVertex(n)->Get_sequence_number() == sequence_number) break; DeleteVertex(n); n--; } if (n<0) { if (TheFrame) TheFrame->GViewDlg.m_view.OpenGLMutex->Unlock(); return 1; } // find which segment we nearly pass through by // finding the minimum distance to all of them double mindist=1e99; int mini=0; n = m_ArrayVertex.GetSize()-2; CVertex3dFast Point(x,y,z); while (n>=0) { double dist = FindDistPointToSegment(GetVertex(n),&Point,GetVertex(n+1)); if (dist < mindist) { mindist = dist; mini = n; } if (GetVertex(n)->Get_sequence_number() != sequence_number || GetVertex(n)->GetID() == ID) break; n--; } // now delete all of the line number // or until we find the ID n = m_ArrayVertex.GetSize()-1; while (n>=0) { if (GetVertex(n)->Get_sequence_number() != sequence_number || GetVertex(n)->GetID() == ID) break; if (n == mini+1) { // instead of deleting the last segment // that goes through the point // modify it to go to the new point GetVertex(n)->Set(x,y,z); break; } DeleteVertex(n); n--; } if (TheFrame) TheFrame->GViewDlg.m_view.OpenGLMutex->Unlock(); if (n<0) return 1; return 0; }
/** * Class operator to get vertex. * @param index is vertex index in collection. * @param return vertex. */ Vertex& VertexSet::operator[](int index) { Vertex* pVertex = GetVertex(index); return *pVertex; }
/// erzeugt Vertex void TerrainRenderer::UpdateVertexPos(const MapPoint pt, const GameWorldViewer* gwv) { GetVertex(pt).pos.pos.x = float(pt.x * TR_W + ( (pt.y & 1) ? TR_W / 2 : 0) ); GetVertex(pt).pos.pos.y = float(pt.y * TR_H - HEIGHT_FACTOR * gwv->GetNode(pt).altitude + HEIGHT_FACTOR * 0x0A ); }
void Mesh::GetVertexes(int *indexes, Vector *V, int n) { for (int i = 0; i < n; ++i) V[i] = GetVertex(indexes[i]); }
/* ================ idAASBuild::GetEdge ================ */ bool idAASBuild::GetEdge( const idVec3& v1, const idVec3& v2, int* edgeNum, int v1num ) { int v2num, hashKey, e; int* vertexNum; aasEdge_t edge; bool found; if( v1num != -1 ) { found = true; } else { found = GetVertex( v1, &v1num ); } found &= GetVertex( v2, &v2num ); // if both vertexes are the same or snapped onto each other if( v1num == v2num ) { *edgeNum = 0; return true; } hashKey = aas_edgeHash->GenerateKey( v1num, v2num ); // if both vertexes where already stored if( found ) { for( e = aas_edgeHash->First( hashKey ); e >= 0; e = aas_edgeHash->Next( e ) ) { vertexNum = file->edges[e].vertexNum; if( vertexNum[0] == v2num ) { if( vertexNum[1] == v1num ) { // negative for a reversed edge *edgeNum = -e; break; } } else if( vertexNum[0] == v1num ) { if( vertexNum[1] == v2num ) { *edgeNum = e; break; } } } // if edge found in hash if( e >= 0 ) { return true; } } *edgeNum = file->edges.Num(); aas_edgeHash->Add( hashKey, file->edges.Num() ); edge.vertexNum[0] = v1num; edge.vertexNum[1] = v2num; file->edges.Append( edge ); return false; }
void NeiVertex::Add(double *Pos,int t){ int v = GetVertex(Pos); Vertex[v].v.push_back(t); for(int d=0;d<3;d++) vPos[v].Pos[d] = Pos[d]; }
/* ================== GetEdge Don't allow four way edges ================== */ static int GetEdge(mapentity_t *entity, const vec3_t p1, const vec3_t p2, const face_t *face) { struct lumpdata *edges = &entity->lumps[LUMP_EDGES]; int v1, v2; int i; unsigned edge_hash_key; hashedge_t *he; if (!face->contents[0]) Error("Face with 0 contents (%s)", __func__); v1 = GetVertex(entity, p1); v2 = GetVertex(entity, p2); edge_hash_key = HashEdge(v1, v2); if (options.BSPVersion == BSPVERSION) { bsp29_dedge_t *edge; for (he = hashedges[edge_hash_key]; he; he = he->next) { i = he->i; edge = (bsp29_dedge_t *)edges->data + i; if (v1 == edge->v[1] && v2 == edge->v[0] && pEdgeFaces1[i] == NULL && pEdgeFaces0[i]->contents[0] == face->contents[0]) { pEdgeFaces1[i] = face; return -(i + cStartEdge); } } /* emit an edge */ i = edges->index; edge = (bsp29_dedge_t *)edges->data + i; if (edges->index >= edges->count) Error("Internal error: didn't allocate enough edges?"); edge->v[0] = v1; edge->v[1] = v2; } else { bsp2_dedge_t *edge = (bsp2_dedge_t *)edges->data; for (he = hashedges[edge_hash_key]; he; he = he->next) { i = he->i; edge = (bsp2_dedge_t *)edges->data + i; if (v1 == edge->v[1] && v2 == edge->v[0] && pEdgeFaces1[i] == NULL && pEdgeFaces0[i]->contents[0] == face->contents[0]) { pEdgeFaces1[i] = face; return -(i + cStartEdge); } } /* emit an edge */ i = edges->index; edge = (bsp2_dedge_t *)edges->data + i; if (edges->index >= edges->count) Error("Internal error: didn't allocate enough edges?"); edge->v[0] = v1; edge->v[1] = v2; } AddHashEdge(v1, v2, edges->index); edges->index++; map.cTotal[LUMP_EDGES]++; pEdgeFaces0[i] = face; return i + cStartEdge; }
nuiPoint& nuiPath::operator[] (int32 index) { return GetVertex(index); }
void MeshGraph2D::ReadEdges(TiXmlDocument &doc) { /// We know we have it since we made it this far. TiXmlHandle docHandle(&doc); TiXmlElement* mesh = docHandle.FirstChildElement("NEKTAR").FirstChildElement("GEOMETRY").Element(); TiXmlElement* field = NULL; /// Look for elements in ELEMENT block. field = mesh->FirstChildElement("EDGE"); ASSERTL0(field, "Unable to find EDGE tag in file."); /// All elements are of the form: "<E ID="#"> ... </E>", with /// ? being the element type. /// Read the ID field first. TiXmlElement *edge = field->FirstChildElement("E"); /// Since all edge data is one big text block, we need to /// accumulate all TEXT data and then parse it. This /// approach effectively skips all comments or other node /// types since we only care about the edge list. We /// cannot handle missing edge numbers as we could with /// missing element numbers due to the text block format. std::string edgeStr; int i,indx; int nextEdgeNumber = -1; // Curved Edges map<int, int> edge_curved; for(i = 0; i < m_curvedEdges.size(); ++i) { edge_curved[m_curvedEdges[i]->m_curveID] = i; } while(edge) { nextEdgeNumber++; int err = edge->QueryIntAttribute("ID",&indx); ASSERTL0(err == TIXML_SUCCESS, "Unable to read edge attribute ID."); // ASSERTL0(indx == nextEdgeNumber, "Edge IDs must begin with zero and be sequential."); TiXmlNode *child = edge->FirstChild(); edgeStr.clear(); if (child->Type() == TiXmlNode::TEXT) { edgeStr += child->ToText()->ValueStr(); } /// Now parse out the edges, three fields at a time. int vertex1, vertex2; std::istringstream edgeDataStrm(edgeStr.c_str()); try { while (!edgeDataStrm.fail()) { edgeDataStrm >> vertex1 >> vertex2; // Must check after the read because we may be // at the end and not know it. If we are at // the end we will add a duplicate of the last // entry if we don't check here. if (!edgeDataStrm.fail()) { PointGeomSharedPtr vertices[2] = {GetVertex(vertex1), GetVertex(vertex2)}; SegGeomSharedPtr edge; if(edge_curved.count(indx) == 0) { edge = MemoryManager<SegGeom>::AllocateSharedPtr(indx, m_spaceDimension, vertices); edge->SetGlobalID(indx); // Set global mesh id } else { edge = MemoryManager<SegGeom>::AllocateSharedPtr(indx, m_spaceDimension, vertices, m_curvedEdges[edge_curved.find(indx)->second]); edge->SetGlobalID(indx); //Set global mesh id } m_segGeoms[indx] = edge; } } } catch(...) { NEKERROR(ErrorUtil::efatal, (std::string("Unable to read edge data: ") + edgeStr).c_str()); } edge = edge->NextSiblingElement("E"); } }
bool FullEdge::ContainsVertex(const Vertex &VCompare) const { return (GetVertex(0) == VCompare || GetVertex(1) == VCompare); }
void TerrainRenderer::UpdateVertexTerrain(const MapPoint pt, const GameWorldViewer& gwv) { const MapNode& node = gwv.GetNode(pt); GetVertex(pt).terrain[0] = node.t1; GetVertex(pt).terrain[1] = node.t2; }
//============================================================================== // // Build And Explore // // This is a standard "Breadth First Search" algorithm for an undirected graph, // but where the neighbor vertices and adjacent edges are actually calculated // on the fly using a couple of utility functions to determine what valid // neighbor states exist. // //============================================================================== int Graph::BuildAndExplore(std::vector<int>& startState, std::vector<int>& endState) { // make this the first vertex: Cleanup(); // for each disk d in the state // if the disk is not the smallest on its peg, continue // for each peg p not equal to the peg the d is on // if (p not occupied by smaller disk) // move disk d to peg p (creating new state and vertex) // make an edge to the new state Vertex *startVtx = GetVertex(startState); startVtx->color = kVertexColor_Grey; // populate the list with the first node std::list<Vertex *> bfsList; bfsList.push_back(startVtx); while (!bfsList.empty()) { Vertex *curVtx = bfsList.front(); bfsList.pop_front(); // calculate all neighbors for this vertex std::vector<int> curState = curVtx->state; for (int diskRad = 0; diskRad < curState.size(); diskRad++) { // in order for this disk to be moveable, it must be the smallest // on its peg if (DiskNotSmallestOnPeg(curState, diskRad)) { continue; } for (int peg = 0; peg < numPegs; peg++) { if (peg == curState[diskRad] || PegHasSmallerDisk(curState, diskRad, peg)) { continue; } std::vector<int> newState = curState; newState[diskRad] = peg; Vertex *newVtx = GetVertex(newState); if (newVtx) { // add edges pointing between them Edge *edge1 = new Edge; edge1->vertexIndex = newVtx->index; edge1->next = curVtx->edgeList; curVtx->edgeList = edge1; Edge *edge2 = new Edge; edge2->vertexIndex = curVtx->index; edge2->next = newVtx->edgeList; newVtx->edgeList = edge2; if (newVtx->color == kVertexColor_White) { newVtx->predecessor = curVtx; newVtx->distance = curVtx->distance+1; newVtx->color = kVertexColor_Grey; newVtx->lastMove[0] = curState[diskRad]+1; newVtx->lastMove[1] = peg+1; bfsList.push_back(newVtx); } } } } curVtx->color = kVertexColor_Black; if (std::equal(curVtx->state.begin(), curVtx->state.end(), endState.begin())) { return curVtx->distance; } } }
int OBJ::ParseLine(int lineno,int argc,const char **argv) // return TRUE to continue parsing, return FALSE to abort parsing process { int ret = 0; if ( argc >= 1 ) { const char *foo = argv[0]; if ( *foo != '#' ) { if (strcmp(argv[0], "v") == 0 && argc == 4 ) { float vx = (float) atof( argv[1] ); float vy = (float) atof( argv[2] ); float vz = (float) atof( argv[3] ); Resize(mVerts, mMaxVerts, mNumVerts, mNumVerts + 3); mVerts[mNumVerts++] = vx; mVerts[mNumVerts++] = vy; mVerts[mNumVerts++] = vz; } else if (strcmp(argv[0],"vt") == 0 && (argc == 3 || argc == 4)) { // ignore 4rd component if present float tx = (float) atof( argv[1] ); float ty = (float) atof( argv[2] ); Resize(mTexels, mMaxTexels, mNumTexels, mNumTexels + 2); mTexels[mNumTexels++] = tx; mTexels[mNumTexels++] = ty; } else if (strcmp(argv[0],"vn") == 0 && argc == 4 ) { float normalx = (float) atof(argv[1]); float normaly = (float) atof(argv[2]); float normalz = (float) atof(argv[3]); Resize(mNormals, mMaxNormals, mNumNormals, mNumNormals + 3); mNormals[mNumNormals++] = normalx; mNormals[mNumNormals++] = normaly; mNormals[mNumNormals++] = normalz; } else if (strcmp(argv[0],"f") == 0 && argc >= 4 ) { GeometryVertex v[32]; int vcount = argc-1; for (int i=1; i<argc; i++) { GetVertex(v[i-1],argv[i] ); } // need to generate a normal! #if 0 // not currently implemented if ( mNormals.empty() ) { Vector3d<float> p1( v[0].mPos ); Vector3d<float> p2( v[1].mPos ); Vector3d<float> p3( v[2].mPos ); Vector3d<float> n; n.ComputeNormal(p3,p2,p1); for (int i=0; i<vcount; i++) { v[i].mNormal[0] = n.x; v[i].mNormal[1] = n.y; v[i].mNormal[2] = n.z; } } #endif mCallback->NodeTriangle(&v[0],&v[1],&v[2], mTextured); if ( vcount >=3 ) // do the fan { for (int i=2; i<(vcount-1); i++) { mCallback->NodeTriangle(&v[0],&v[i],&v[i+1], mTextured); } } } } } return ret; }
/// erzeugt Vertex void TerrainRenderer::UpdateVertexPos(const MapCoord x, const MapCoord y,const GameWorldViewer * gwv) { GetVertex(x,y).pos.pos.x = float(x * TR_W + ( (y&1) ? TR_W/2 : 0) ); GetVertex(x,y).pos.pos.y = float(y * TR_H - HEIGHT_FACTOR * gwv->GetNode(x,y).altitude + HEIGHT_FACTOR * 0x0A ); }
int OBJ::ParseLine(int lineno,int argc,const char **argv) // return TRUE to continue parsing, return FALSE to abort parsing process { int ret = 0; if ( argc >= 1 ) { const char *foo = argv[0]; if ( *foo != '#' ) { if ( stricmp(argv[0],"v") == 0 && argc == 4 ) { float vx = (float) atof( argv[1] ); float vy = (float) atof( argv[2] ); float vz = (float) atof( argv[3] ); mVerts.push_back(vx); mVerts.push_back(vy); mVerts.push_back(vz); } else if ( stricmp(argv[0],"vt") == 0 && argc == 3 ) { float tx = (float) atof( argv[1] ); float ty = (float) atof( argv[2] ); mTexels.push_back(tx); mTexels.push_back(ty); } else if ( stricmp(argv[0],"vn") == 0 && argc == 4 ) { float normalx = (float) atof(argv[1]); float normaly = (float) atof(argv[2]); float normalz = (float) atof(argv[3]); mNormals.push_back(normalx); mNormals.push_back(normaly); mNormals.push_back(normalz); } else if ( stricmp(argv[0],"f") == 0 && argc >= 4 ) { GeometryVertex v[32]; int vcount = argc-1; for (int i=1; i<argc; i++) { GetVertex(v[i-1],argv[i] ); } // need to generate a normal! #if 0 // not currently implemented if ( mNormals.empty() ) { Vector3d<float> p1( v[0].mPos ); Vector3d<float> p2( v[1].mPos ); Vector3d<float> p3( v[2].mPos ); Vector3d<float> n; n.ComputeNormal(p3,p2,p1); for (int i=0; i<vcount; i++) { v[i].mNormal[0] = n.x; v[i].mNormal[1] = n.y; v[i].mNormal[2] = n.z; } } #endif mCallback->NodeTriangle(&v[0],&v[1],&v[2]); if ( vcount >=3 ) // do the fan { for (int i=2; i<(vcount-1); i++) { mCallback->NodeTriangle(&v[0],&v[i],&v[i+1]); } } } } } return ret; }
void NeiVertex::Add(double *Pos,int t){ int v = GetVertex(Pos); Add(v,t,Pos); }
int CGraph::GetElement(int nRow, int nCol) { return GetVertex(nRow*CGameControl_G::s_nCols + nCol); }
//******************************************** // DeleteVertex at the end that are flagged with // sequence_number >= sequence_number //******************************************** int CPath3d::RemovePathEnd(int sequence_number, int ID, double x, double y, double z) { int n = m_ArrayVertex.GetSize()-1; // first verify that the line number is there while (n>=0) { int SeqNum = GetVertex(n)->Get_sequence_number(); if (SeqNum == sequence_number) break; n--; } if (n<0) return 1; // now delete until we find the sequence_number n = m_ArrayVertex.GetSize()-1; while (n>=0) { if (GetVertex(n)->Get_sequence_number() == sequence_number) break; DeleteVertex(n); n--; } if (n<0) return 1; // find which segment we nearly pass through by // finding the minimum distance to all of them double mindist=1e99; int mini=0; n = m_ArrayVertex.GetSize()-2; CVertex3d Point(x,y,z); while (n>=0) { double dist = FindDistPointToSegment(GetVertex(n),&Point,GetVertex(n+1)); if (dist < mindist) { mindist = dist; mini = n; } if (GetVertex(n)->Get_sequence_number() != sequence_number || GetVertex(n)->GetID() == ID) break; n--; } // now delete all of the line number // or until we find the ID n = m_ArrayVertex.GetSize()-1; while (n>=0) { if (GetVertex(n)->Get_sequence_number() != sequence_number || GetVertex(n)->GetID() == ID) break; if (n == mini+1) { // instead of deleting the last segment // that goes through the point // modify it to go to the new point GetVertex(n)->Set(x,y,z); break; } DeleteVertex(n); n--; } if (n<0) return 1; return 0; }
int OBJ::ParseLine(int /*lineno*/,int argc,const char **argv) // return TRUE to continue parsing, return FALSE to abort parsing process { int ret = 0; if ( argc >= 1 ) { const char *foo = argv[0]; if ( *foo != '#' ) { if ( strcasecmp(argv[0],"v") == 0 && argc == 4 ) { float vx = (float) atof( argv[1] ); float vy = (float) atof( argv[2] ); float vz = (float) atof( argv[3] ); mVerts.push_back(vx); mVerts.push_back(vy); mVerts.push_back(vz); } else if ( strcasecmp(argv[0],"vt") == 0 && (argc == 3 || argc == 4)) { // ignore 4rd component if present float tx = (float) atof( argv[1] ); float ty = (float) atof( argv[2] ); mTexels.push_back(tx); mTexels.push_back(ty); } else if ( strcasecmp(argv[0],"vn") == 0 && argc == 4 ) { float normalx = (float) atof(argv[1]); float normaly = (float) atof(argv[2]); float normalz = (float) atof(argv[3]); mNormals.push_back(normalx); mNormals.push_back(normaly); mNormals.push_back(normalz); } else if ( strcasecmp(argv[0],"f") == 0 && argc >= 4 ) { GeometryVertex v[32]; int vcount = argc-1; for (int i=1; i<argc; i++) { GetVertex(v[i-1],argv[i] ); } mCallback->NodeTriangle(&v[0],&v[1],&v[2], mTextured); if ( vcount >=3 ) // do the fan { for (int i=2; i<(vcount-1); i++) { mCallback->NodeTriangle(&v[0],&v[i],&v[i+1], mTextured); } } } } } return ret; }
inline const PGMath::Point3D<T>& Polygon<T, Dim>::operator[](const int& iIndex) const { return GetVertex(iIndex); }
void CGraphics_Threaded::QuadsDrawTL(const CQuadItem *pArray, int Num) { CCommandBuffer::SPoint Center; dbg_assert(m_Drawing == DRAWING_QUADS, "called Graphics()->QuadsDrawTL without begin"); if(g_Config.m_GfxQuadAsTriangle && !m_UseOpenGL3_3) { for(int i = 0; i < Num; ++i) { // first triangle GetVertex(m_NumVertices + 6*i)->m_Pos.x = pArray[i].m_X; GetVertex(m_NumVertices + 6*i)->m_Pos.y = pArray[i].m_Y; GetVertex(m_NumVertices + 6*i)->m_Tex = m_aTexture[0]; SetColor(GetVertex(m_NumVertices + 6*i), 0); GetVertex(m_NumVertices + 6*i + 1)->m_Pos.x = pArray[i].m_X + pArray[i].m_Width; GetVertex(m_NumVertices + 6*i + 1)->m_Pos.y = pArray[i].m_Y; GetVertex(m_NumVertices + 6*i + 1)->m_Tex = m_aTexture[1]; SetColor(GetVertex(m_NumVertices + 6*i + 1), 1); GetVertex(m_NumVertices + 6*i + 2)->m_Pos.x = pArray[i].m_X + pArray[i].m_Width; GetVertex(m_NumVertices + 6*i + 2)->m_Pos.y = pArray[i].m_Y + pArray[i].m_Height; GetVertex(m_NumVertices + 6*i + 2)->m_Tex = m_aTexture[2]; SetColor(GetVertex(m_NumVertices + 6*i + 2), 2); // second triangle GetVertex(m_NumVertices + 6*i + 3)->m_Pos.x = pArray[i].m_X; GetVertex(m_NumVertices + 6*i + 3)->m_Pos.y = pArray[i].m_Y; GetVertex(m_NumVertices + 6*i + 3)->m_Tex = m_aTexture[0]; SetColor(GetVertex(m_NumVertices + 6*i + 3), 0); GetVertex(m_NumVertices + 6*i + 4)->m_Pos.x = pArray[i].m_X + pArray[i].m_Width; GetVertex(m_NumVertices + 6*i + 4)->m_Pos.y = pArray[i].m_Y + pArray[i].m_Height; GetVertex(m_NumVertices + 6*i + 4)->m_Tex = m_aTexture[2]; SetColor(GetVertex(m_NumVertices + 6*i + 4), 2); GetVertex(m_NumVertices + 6*i + 5)->m_Pos.x = pArray[i].m_X; GetVertex(m_NumVertices + 6*i + 5)->m_Pos.y = pArray[i].m_Y + pArray[i].m_Height; GetVertex(m_NumVertices + 6*i + 5)->m_Tex = m_aTexture[3]; SetColor(GetVertex(m_NumVertices + 6*i + 5), 3); if(m_Rotation != 0) { Center.x = pArray[i].m_X + pArray[i].m_Width/2; Center.y = pArray[i].m_Y + pArray[i].m_Height/2; Rotate(Center, GetVertex(m_NumVertices + 6*i), 6); } } AddVertices(3*2*Num); } else { for(int i = 0; i < Num; ++i) { GetVertex(m_NumVertices + 4*i)->m_Pos.x = pArray[i].m_X; GetVertex(m_NumVertices + 4*i)->m_Pos.y = pArray[i].m_Y; GetVertex(m_NumVertices + 4*i)->m_Tex = m_aTexture[0]; SetColor(GetVertex(m_NumVertices + 4*i), 0); GetVertex(m_NumVertices + 4*i + 1)->m_Pos.x = pArray[i].m_X + pArray[i].m_Width; GetVertex(m_NumVertices + 4*i + 1)->m_Pos.y = pArray[i].m_Y; GetVertex(m_NumVertices + 4*i + 1)->m_Tex = m_aTexture[1]; SetColor(GetVertex(m_NumVertices + 4*i + 1), 1); GetVertex(m_NumVertices + 4*i + 2)->m_Pos.x = pArray[i].m_X + pArray[i].m_Width; GetVertex(m_NumVertices + 4*i + 2)->m_Pos.y = pArray[i].m_Y + pArray[i].m_Height; GetVertex(m_NumVertices + 4*i + 2)->m_Tex = m_aTexture[2]; SetColor(GetVertex(m_NumVertices + 4*i + 2), 2); GetVertex(m_NumVertices + 4*i + 3)->m_Pos.x = pArray[i].m_X; GetVertex(m_NumVertices + 4*i + 3)->m_Pos.y = pArray[i].m_Y + pArray[i].m_Height; GetVertex(m_NumVertices + 4*i + 3)->m_Tex = m_aTexture[3]; SetColor(GetVertex(m_NumVertices + 4*i + 3), 3); if(m_Rotation != 0) { Center.x = pArray[i].m_X + pArray[i].m_Width/2; Center.y = pArray[i].m_Y + pArray[i].m_Height/2; Rotate(Center, GetVertex(m_NumVertices + 4*i), 4); } } AddVertices(4*Num); } }