VBO::VBO(RAS_DisplayArray *data, unsigned int indices) { this->data = data; this->size = data->m_vertex.size(); this->indices = indices; this->stride = sizeof(RAS_TexVert); // Determine drawmode if (data->m_type == data->QUAD) this->mode = GL_QUADS; else if (data->m_type == data->TRIANGLE) this->mode = GL_TRIANGLES; else this->mode = GL_LINE; // Generate Buffers glGenBuffersARB(1, &this->ibo); glGenBuffersARB(1, &this->vbo_id); // Fill the buffers with initial data UpdateIndices(); UpdateData(); // Establish offsets this->vertex_offset = (void*)(((RAS_TexVert*)0)->getXYZ()); this->normal_offset = (void*)(((RAS_TexVert*)0)->getNormal()); this->tangent_offset = (void*)(((RAS_TexVert*)0)->getTangent()); this->color_offset = (void*)(((RAS_TexVert*)0)->getRGBA()); this->uv_offset = (void*)(((RAS_TexVert*)0)->getUV(0)); }
void stCurveView::AddKnob() { stCurveKnob **tmp_knob; tmp_knob=new stCurveKnob*[knob_count+1]; uint8 i; for (i=0;i<knob_count;i++) tmp_knob[i]=knob[i]; tmp_knob[knob_count]=new stCurveKnob(knob[knob_count-1]->Position()+BPoint(10,0),BRect(knob[knob_count-1]->XPosition(),0,width,m_height),m_message); AddChild(tmp_knob[knob_count]); knob_count++; delete []knob; knob = tmp_knob; BPoint memory1; BPoint memory2; bool copy=false; for (i=0;i<knob_count;i++) { if (copy) { memory2=knob[i]->Position(); knob[i]->MoveTo(memory1); memory1=memory2; } else if (knob[i]->IsFocus() && i!=knob_count-1) { copy=true; memory1=BPoint((knob[i+1]->Position().x+knob[i]->Position().x)/2,(knob[i+1]->Position().y+knob[i]->Position().y)/2); } } CalcLimits(); UpdateIndices(); }
void stCurveView::DeleteKnob() { if (knob_count==1) return; stCurveKnob **tmp_knob; tmp_knob=new stCurveKnob*[knob_count-1]; uint8 i,j=0; bool removed=false; for (i=0;i<knob_count;i++) { if ((knob[i]->IsFocus() || i==knob_count-1) && !removed) // we don't want to remove more than one knob { // if no knob has the focus we delete the last one if (i>0) knob[i-1]->MakeFocus(); else knob[i+1]->MakeFocus(); RemoveChild(knob[i]); removed=true; i++; if (i==knob_count) continue; } tmp_knob[j++]=knob[i]; } knob_count--; delete []knob; knob=tmp_knob; CalcLimits(); Invalidate(); UpdateIndices(); }
stCurveView::stCurveView(BRect bounds, const char *name, BMessage *message) : BView(bounds,"CurveView",B_FOLLOW_NONE,B_NAVIGABLE/*_JUMP*/+B_WILL_DRAW) { m_name = name; BFont name_font(be_plain_font); font_height height; name_font.GetHeight(&height); m_name_pos = BPoint(bounds.Width() - name_font.StringWidth(name) - 1.0, height.ascent + 1.0); SetFont(&name_font); m_message = message; knob_count = 1; knob=new stCurveKnob*[knob_count]; m_height=bounds.Height(); width=bounds.Width(); uint8 i; for (i=0;i<knob_count;i++) knob[i]=new stCurveKnob(BPoint(i,m_height),BRect(0,0,100,100),m_message); for (i=0;i<knob_count;i++) AddChild(knob[i]); CalcLimits(); SetViewColor(B_TRANSPARENT_COLOR); SetLowColor(200,200,200); SetHighColor(136,136,234); UpdateIndices(); }
/// <summary> /// Allocates space for the indices and sets them. /// </summary> void TerrainIndexBlock::MakeBasicIndices() { //allocate the memory int nTriangles = (m_size-1)*(m_size-1)*2; m_indices = new unsigned short[nTriangles*3]; if( !m_indexBuffer.Init( *m_screen, nTriangles*3, IB16Bit) ) CVar.WriteLine( "TerrainIndexBlock: Could not initialize index buffer" ); UpdateIndices(); }
static void ScanArticle(streamtokenizer *st, article *a, int articleIndex, rssData *allData ) { int numWords = 0; char word[1024]; char longestWord[1024] = {'\0'}; while (STNextToken(st, word, sizeof(word))) { if (strcasecmp(word, "<") == 0) { SkipIrrelevantContent(st); // in html-utls.h } else { RemoveEscapeCharacters(word); if (WordIsWellFormed(word)) { numWords++; char *dummy = word; if ( WordNotInStopwords(&allData->stopwords, word)) { /** Try looking up the word. If the word is not in the indices, create a new indexEntry * initialized with the word and an empty vector and enter it into the hashset */ indexEntry entry = {word}; indexEntry *found = HashSetLookup(&allData->indices, &entry); if (found == NULL) { entry.word = strdup(dummy); VectorNew(&entry.articles, sizeof(wordcountEntry), NULL, 10); HashSetEnter(&allData->indices, &entry); } // now we act as if the entry was in the index all along found = (indexEntry*)HashSetLookup( &allData->indices, &entry); UpdateIndices(&found->articles, articleIndex); } if (strlen(word) > strlen(longestWord)) strcpy(longestWord, word); } } } printf("\tWe counted %d well-formed words [including duplicates].\n", numWords); printf("\tThe longest word scanned was \"%s\".", longestWord); if (strlen(longestWord) >= 15 && (strchr(longestWord, '-') == NULL)) printf(" [Ooooo... long word!]"); printf("\n"); }
void MeshMender::ProcessBinormals(TriangleList& possibleNeighbors, std::vector< Vertex >& theVerts, std::vector< unsigned int >& mappingNewToOldVert, D3DXVECTOR3 workingPosition) { NeighborGroupList neighborGroups;//a fresh group for each pass //reset each triangle to prepare for smoothing group building unsigned int i; for(i =0; i < possibleNeighbors.size(); ++i ) { m_Triangles[ possibleNeighbors[i] ].Reset(); } //now start building groups CanSmoothBinormalsChecker canSmoothBinormalsChecker; for(i =0; i < possibleNeighbors.size(); ++i ) { Triangle* currTri = &(m_Triangles[ possibleNeighbors[i] ]); assert(currTri); if(!currTri->handled) { BuildGroups(currTri,possibleNeighbors, neighborGroups, theVerts, &canSmoothBinormalsChecker ,MinBinormalsCreaseCosAngle ); } } std::vector<D3DXVECTOR3> groupBinormalVectors; for(i=0; i<neighborGroups.size(); ++i) { D3DXVECTOR3 gbinormal(0,0,0); for(unsigned int t = 0; t < neighborGroups[i].size(); ++t)//for each triangle in the group, { TriID tID = neighborGroups[i][t]; gbinormal+= m_Triangles[tID].binormal; } gbinormal = glm::normalize(gbinormal.GLMvec());//D3DXVec3Normalize( &gbinormal, &gbinormal ); groupBinormalVectors.push_back(gbinormal); } //next step, ensure that triangles in different groups are not //sharing vertices. and give the shared vertex their new group vector std::set<size_t> otherGroupsIndices; for( i = 0; i < neighborGroups.size(); ++i ) { TriangleList& curGroup = neighborGroups[ i ]; std::set<size_t> thisGroupIndices; for( size_t t = 0; t < curGroup.size(); ++t ) //for each tri { TriID tID = curGroup[ t ]; for(size_t indx = 0; indx < 3 ; ++indx)//for each vert in that tri { //if it is at the positions in question if( theVerts[ m_Triangles[tID].indices[indx] ].pos == workingPosition) { //see if another group is already using this vert if(otherGroupsIndices.find( m_Triangles[tID].indices[indx] ) != otherGroupsIndices.end() ) { //then we need to make a new vertex Vertex ov; ov = theVerts[ m_Triangles[tID].indices[indx] ]; ov.binormal = groupBinormalVectors[i]; size_t oldIndex = m_Triangles[tID].indices[indx]; size_t newIndex = theVerts.size(); theVerts.push_back(ov); AppendToMapping( oldIndex , m_originalNumVerts , mappingNewToOldVert); UpdateIndices(oldIndex,newIndex,curGroup); } else { //otherwise, just update it with the new vector theVerts[ m_Triangles[tID].indices[indx] ].binormal = groupBinormalVectors[i]; } //store that we have used this index, so other groups can check thisGroupIndices.insert(m_Triangles[tID].indices[indx]); } } } for(std::set<size_t>::iterator it = thisGroupIndices.begin(); it!= thisGroupIndices.end() ; ++it) { otherGroupsIndices.insert(*it); } } }
int32 nuiMetaPainter::GetOffsetFromOperationIndex(int32 index) const { UpdateIndices(); NGL_ASSERT(index < mOperationIndices.size()); return mOperationIndices[index]; }