void CreatePlane(GameObject& obj, Vector4 worldPos, const char* texture) { Vertex v00, v01, v02, v03; v00.normal = Vector4::zero; v01.normal = Vector4::zero; v02.normal = Vector4::zero; v03.normal = Vector4::zero; Poly p0, p1; BitMap bm; if (texture != NULL && bm.Read(texture)) { p0.texture = bm; p1.texture = bm; v00.uv = Vector2(0.0f, 0.0f); v01.uv = Vector2(1.0f, 0.0f); v02.uv = Vector2(0.0f, 1.0f); v03.uv = Vector2(1.0f, 1.0f); } else { v00.color = ColourValue::Gray; v01.color = ColourValue::Gray; v02.color = ColourValue::Gray; v03.color = ColourValue::Gray; } v00.position = Vector4(1, 1, 1, 1); v01.position = Vector4(-1, 1, 1, 1); v02.position = Vector4(1, -1, 1, 1); v03.position = Vector4(-1, -1, 1, 1); obj.vertexListLocal[0] = v00; obj.vertexListLocal[1] = v01; obj.vertexListLocal[2] = v02; obj.vertexListLocal[3] = v03; p0.vertices = obj.vertexListTrans; p0.vertexIndexs[0] = 0; p0.vertexIndexs[1] = 1; p0.vertexIndexs[2] = 3; p1.vertices = obj.vertexListTrans; p1.vertexIndexs[0] = 3; p1.vertexIndexs[1] = 2; p1.vertexIndexs[2] = 0; // 设置物体属性 obj.polyCount = 2; obj.polyList[0] = p0; obj.polyList[1] = p1; obj.vertexCount = 4; obj.worldPos = worldPos; obj.ComputeVertexNormals(); }
DisplacementPatchSampler::DisplacementPatchSampler(const GeometryImage & detailedGeometryMap, const BitMap & detailedGeometryMask, GeometryImage & geometryMap, BitMap & geometryMask) : m_detailedGeometryMap(detailedGeometryMap), m_detailedGeometryMask(detailedGeometryMask), m_geometryMap(geometryMap), m_geometryMask(geometryMask) { nvCheck(geometryMap.width() == geometryMask.width()); nvCheck(geometryMap.height() == geometryMask.height()); }
void BCEscapeAnalyzer::clear_bits(ArgumentMap vars, BitMap &bm) { for (int i = 0; i <= _arg_size; i++) { if (vars.contains(i)) { bm.clear_bit(i); } } }
void OrientedGraph::levelPartition(Partition& pi) const /* Assuming the graph has no oriented cycles, this function writes in pi the partition of the vertices according to their level, where sinks have level 0, then sinks in the remaining poset have level one, etc. NOTE : the implementation is simple-minded : we traverse the graph as many times as there are levels. */ { static BitMap b(0); static BitMap b1(0); b.setSize(size()); b.reset(); b1.setSize(size()); b1.reset(); pi.setSize(size()); Ulong count = 0; Ulong current_level = 0; while (count < size()) { for (SetElt x = 0; x < size(); ++x) { if (b.getBit(x)) continue; const EdgeList e = d_edge[x]; for (Ulong j = 0; j < e.size(); ++j) { if (!b.getBit(e[j])) /* next x */ goto nextx; } /* i we get here, x is the next element in the permutation */ pi[x] = current_level; b1.setBit(x); ++count; nextx: continue; } b.assign(b1); current_level++; } pi.setClassCount(current_level); return; }
BloomFilter::BloomFilter(size_t N, size_t K, const BitMap &bits) : N_(N), M_(bits.size()), K_(K), bits_(bits), pFalse_(computePFalse(N, M_, K)) { }
BloomFilter::BloomFilter(size_t N, size_t K, const BitMap &bits, size_t offset, size_t length) : N_(N), M_(length), K_(K), bits_(length), pFalse_(computePFalse(N, M_, K)) { bits_.copyFrom(bits.toByteArray(), offset, 0, length); }
Texture::Texture(const BitMap& bitmap, GLint minMagFilter,GLint wrapMode): _orgWidth((GLfloat)bitmap.width()), _orgHeight((GLfloat)bitmap.height()){ glGenTextures(1, &_object); glBindTexture(GL_TEXTURE_2D, _object); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,minMagFilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,minMagFilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,wrapMode); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,wrapMode); glTexImage2D(GL_TEXTURE_2D, 0, textureFormatforBitmap(bitmap.format(),true), (GLsizei)bitmap.width(), (GLsizei)bitmap.height(), 0, textureFormatforBitmap(bitmap.format(),false), GL_UNSIGNED_BYTE, bitmap.pixelBuffer()); glGenerateMipmap(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,0); }
int Game_Shutdown(void *parms) { // this function is where you shutdown your game and // release all resources that you allocated renderer.uninitialize(); cube_texture.Close(); // return success return(1); } // end Game_Shutdown
void FpuStackAllocator::merge_cleanup_fpu_stack(LIR_List* instrs, FpuStackSim* cur_sim, BitMap& live_fpu_regs) { #ifndef PRODUCT if (TraceFPUStack) { tty->cr(); tty->print("before cleanup: state: "); cur_sim->print(); tty->cr(); tty->print(" live: "); live_fpu_regs.print_on(tty); tty->cr(); } #endif int slot = 0; while (slot < cur_sim->stack_size()) { int reg = cur_sim->get_slot(slot); if (!live_fpu_regs.at(reg)) { if (slot != 0) { merge_insert_xchg(instrs, cur_sim, slot); } merge_insert_pop(instrs, cur_sim); } else { slot++; } } #ifndef PRODUCT if (TraceFPUStack) { tty->print("after cleanup: state: "); cur_sim->print(); tty->cr(); tty->print(" live: "); live_fpu_regs.print_on(tty); tty->cr(); tty->cr(); } // check if fpu stack only contains live registers for (unsigned int i = 0; i < live_fpu_regs.size(); i++) { if (live_fpu_regs.at(i) != cur_sim->contains(i)) { tty->print_cr("mismatch between required and actual stack content"); break; } } #endif }
void OrientedGraph::permute(const Permutation& a) /* This function permutes the graph according to the permutation a, according to the usual rule : the edges of a(x) should be the image under a of the edge set of x. As usual, permuting values is easy : it is enough to apply a to the elements in the various edgelists. Permuting ranges is trickier, because it involves a^-1. It is assumed of course that a holds a permutation of size size(). */ { static BitMap b(0); static EdgeList e_buf(0); /* permute values */ for (SetElt x = 0; x < size(); ++x) { EdgeList& e = d_edge[x]; for (Ulong j = 0; j < e.size(); ++j) { e[j] = a[e[j]]; } } /* permute ranges */ b.setSize(size()); b.reset(); for (SetElt x = 0; x < size(); ++x) { if (b.getBit(x)) continue; if (a[x] == x) { /* fixed point */ b.setBit(x); continue; } for (SetElt y = a[x]; y != x; y = a[y]) { /* back up values for y */ e_buf.shallowCopy(d_edge[y]); /* put values for x in y */ d_edge[y].shallowCopy(d_edge[x]); /* store backup values in x */ d_edge[x].shallowCopy(e_buf); /* set bit */ b.setBit(y); } b.setBit(x); } }
void savePicAsHeightMap( std::string const& infile, std::string const& outfile ) { ImageIO::init(); BitMap* in = ImageIO::load( infile ); BitMap* out = new BitMap( in->getWidth(), in->getHeight() ); for( int j=0; j<in->getHeight(); j++ ) { for( int i=0; i<in->getWidth(); i++ ) { unsigned int col = in->get( i, j ); int r = ( col >> 16 ) & 0xff; int g = ( col >> 8 ) & 0xff; int b = col & 0xff; int v = (int)( (double)r * 0.2125 + (double)g * 0.7154 + (double)b * 0.0721 ) & 0xff; out->set( i, j, ( 0xff << 24 ) | ( v << 16 ) | ( v << 8 ) | v ); } } ImageIO::save( outfile, *out ); delete out; delete in; }
bool BMP::save( std::string const& filename, BitMap const& map ) { FILE* f = fopen( filename.c_str(), "wb" ); assert( f ); int width = map.getWidth(); int height = map.getHeight(); // bitmap file header unsigned short bfType = 0x4D42; // "BM" unsigned int bfSize = 54 + width * height * 3; unsigned short bfReserved1 = 0; unsigned short bfReserved2 = 0; unsigned int bfOffbits = 54; fwrite( &bfType, 2, 1, f ); fwrite( &bfSize, 4, 1, f ); fwrite( &bfReserved1, 2, 1, f ); fwrite( &bfReserved2, 2, 1, f ); fwrite( &bfOffbits, 4, 1, f ); // bitmap info header unsigned int biSize = 40; // bmih size int biWidth = width; int biHeight = height; unsigned short biPlanes = 1; unsigned short biBitCount = 24; // RGB unsigned int biCompression = 0; // type: RGB unsigned int biSizeImage = width * height * 3; int biXPelsPerMeter = 2925; int biYPelsPerMeter = 2925; unsigned int biClrUsed = 0; unsigned int biClrImportant = 0; fwrite( &biSize, 4, 1, f ); fwrite( &biWidth, 4, 1, f ); fwrite( &biHeight, 4, 1, f ); fwrite( &biPlanes, 2, 1, f ); fwrite( &biBitCount, 2, 1, f ); fwrite( &biCompression, 4, 1, f ); fwrite( &biSizeImage, 4, 1, f ); fwrite( &biXPelsPerMeter, 4, 1, f ); fwrite( &biYPelsPerMeter, 4, 1, f ); fwrite( &biClrUsed, 4, 1, f ); fwrite( &biClrImportant, 4, 1, f ); // write data for( int j=0; j<height; j++ ) { for( int i=0; i<width; i++ ) { unsigned int c = map.get( i, height - j - 1 ); unsigned char b = ( c >> 16 ) & 0xff; unsigned char g = ( c >> 8 ) & 0xff; unsigned char r = c & 0xff; fwrite( &b, 1, 1, f ); fwrite( &g, 1, 1, f ); fwrite( &r, 1, 1, f ); } } fclose( f ); return true; }
void clear_local_oop_map() { _local_oop_map.clear(); }
RC RM_FileScan::GetNextRec(RM_Record &rec) { if (!bInScan) return RM_ERR_NOTINSCAN; RC rc; RID rid; RM_Record tmpRec; while (1) { //std::cout <<"start next : "<< nowPage <<" "<<nowSlot<<"\n"; if (bNextPage) { //std::cout << "before next page:" << nowPage<<"\n"; if (PF_ERR_EOF == fileHandle.pfh.GetNextPage(nowPage, nowPH)) { bInScan = false; return RM_ERR_EOF; } if (rc = nowPH.GetPageNum(nowPage)) return rc; //std::cout << "after next page:" << nowPage<<"\n"; bNextPage = false; nowSlot = -1; continue; } char *pData; if (rc = nowPH.GetData(pData)) return rc; BitMap bitmap; if (rc = fileHandle.GetBitMapFromData(pData, bitmap)) return rc; //bitmap.print(); int nextBit; if (RM_ENDOFPAGE == bitmap.GetNextBit(nowSlot, nextBit)) { if (rc = fileHandle.pfh.UnpinPage(nowPage)) return rc; bNextPage = true; continue; } //std::cout << "nextbit: " << nextBit <<"\n"; nowSlot = nextBit; RID rid; rid.SetPageNum(nowPage); rid.SetSlotNum(nowSlot); // std::cout << "find slot: pageNum:"<<nowPage<<" slotNum:"<<nowSlot<<"\n"; //std::cout << "recordSize:" << fileHandle.header.recordSize<<"\n"; //std::cout << "firstFree :" << fileHandle.header.firstFree <<"\n"; //std::cout << "bitmapOffset :" << fileHandle.header.bitmapOffset <<"\n"; //std::cout << "bitmapSize : " << fileHandle.header.bitmapSize <<"\n"; //std::cout << "numRecordsPerPage : " << fileHandle.header.numRecordsPerPage <<"\n"; //std::cout << "numPages : " << fileHandle.header.numPages <<"\n"; //std::cout << rid.pageNum <<" "<<rid.slotNum<<"\n"; if (rc = fileHandle.GetRecordFromData(pData, rid, tmpRec)) return rc; //for (int i = 0; i < fileHandle.header.recordSize; i++) // std::cout << (int)tmpRec.pData[i] <<" "; //std::cout <<"\n"; //std::cout << "recdata: " << (int)tmpRec.pData[3]<<"\n"; //std::cout << "offset:"<<attrOffset<<" "<<" len:"<<attrLength<<" type:"<<attrType<<"\n"; //std::cout << "compop:"<<this->compOp<<"\n"; char *tmpRecData; if (rc = tmpRec.GetData(tmpRecData)) return rc; if (this->compOp != NO_OP) { bool flag; if (this->compOp != IS_OP && this->compOp != IS_NOT_OP && tmpRec.IsNull(attrNumber)) flag = false; else flag = (* cmp)(tmpRecData + attrOffset, this->value, attrType, attrLength); if (flag) { rec = tmpRec; break; } } else { rec = tmpRec; break; } } return 0; }
BitMap* BMP::load( std::string const& filename ) { FILE* f = fopen( filename.c_str(), "rb" ); assert( f ); // bitmap file header unsigned short bfType; unsigned int bfSize; unsigned short bfReserved1; unsigned short bfReserved2; unsigned int bfOffbits; fread( &bfType, 2, 1, f ); fread( &bfSize, 4, 1, f ); fread( &bfReserved1, 2, 1, f ); fread( &bfReserved2, 2, 1, f ); fread( &bfOffbits, 4, 1, f ); // bitmap info header unsigned int biSize; int biWidth; int biHeight; unsigned short biPlanes; unsigned short biBitCount; unsigned int biCompression; unsigned int biSizeImage; int biXPelsPerMeter; int biYPelsPerMeter; unsigned int biClrUsed; unsigned int biClrImportant; fread( &biSize, 4, 1, f ); fread( &biWidth, 4, 1, f ); fread( &biHeight, 4, 1, f ); fread( &biPlanes, 2, 1, f ); fread( &biBitCount, 2, 1, f ); fread( &biCompression, 4, 1, f ); fread( &biSizeImage, 4, 1, f ); fread( &biXPelsPerMeter, 4, 1, f ); fread( &biYPelsPerMeter, 4, 1, f ); fread( &biClrUsed, 4, 1, f ); fread( &biClrImportant, 4, 1, f ); BitMap* m = new BitMap( biWidth, biHeight ); // read data for( int j=0; j<biHeight; j++ ) { for( int i=0; i<biWidth; i++ ) { unsigned char a, r, g, b; fread( &b, 1, 1, f ); fread( &g, 1, 1, f ); fread( &r, 1, 1, f ); if( biBitCount == 32 ) fread( &a, 1, 1, f ); else if( biBitCount == 24 ) a = 0xff; m->set( i, biHeight - j - 1, ( a << 24 ) | ( b << 16 ) | ( g << 8 ) | r ); } } fclose( f ); return m; }
inline bool ParMarkBitMap::is_obj_beg(idx_t bit) const { return _beg_bits.at(bit); }
inline bool ParMarkBitMap::is_obj_end(idx_t bit) const { return _end_bits.at(bit); }
inline void ParMarkBitMap::clear_range(idx_t beg, idx_t end) { _beg_bits.clear_range(beg, end); _end_bits.clear_range(beg, end); }
// The given argument does not escape the callee. bool is_arg_local(int i) const { return !_conservative && _arg_local.at(i); }
int main(int argc, const char * argv[]) { /* This code tests your bitmap implementation on 24-bit and 32-bit files. The desired output * files are included for comparison purposes. */ /** Test #1: Create a new file with a gradient from yellow to green to cyan (bottom to top) */ //parameterized constructor BitMap *bm = new BitMap(255, 255); //bm->Load("picture.bmp"); for (int x = 0; x < 255; x++) { for (int y = 0; y < 255; y++) { //std::cout << "x: " << x << "y: " << y << std::endl; bm->SetPixel(bm, x, y, 255-y, 255, y, 255); } } /** copy constructor*/ BitMap *a = new BitMap(*bm); /** assignment Operator*/ *a = *a; std::cout << "Get Height function: " << a->GetHeight() << "\n"; std::cout << "Get Width function: " << a->GetWidth() << "\n"; /** Destructor*/ bm->~BitMap(); /*std::cout << "processing test.bmp\n"; bm->Save(bm, "test.bmp");*/ ///* test #2: a 24-bit file with reversed height; add a 40x40 red square in the lower right corner */ //std::cout << "processing picture.bmp\n"; //bm = bm->Load("picture.bmp"); //if (bm == 0) //{ // std::cout << "load of 'picture.bmp' failed\n"; //} //else { // for (int x = 0; x < 40; x++) // { // for (int y = 0; y < 40; y++) // { // bm->SetPixel(bm, (bm->GetWidth())-x-1, y, 255, 0, 0, 255); // } // } // bm->Save(bm, "picture new.bmp"); // free(bm); //} ///** test #3: a 24-bit file; add a 40x40 blue square in the upper right corner */ //std::cout << "processing train.bmp\n"; //bm = bm->Load("train.bmp"); //if (bm == 0) //{ // std::cout << "load of 'train.bmp' failed\n"; //} //else { // for (int x = 0; x < 40; x++) // { // for (int y = 0; y < 40; y++) // { // bm->SetPixel(bm, bm->GetWidth()-x-1, bm->GetHeight()-y-1, 0, 0, 255, 255); // } // } // bm->Save(bm, "train new.bmp"); // free(bm); //} ///** test #4: a 24-bit file with padding; add a 40x40 blue square in the upper right corner */ //std::cout << "processing mountain.bmp\n"; //bm = bm->Load("mountain.bmp"); //if (bm == 0) //{ // std::cout << "load of 'mountain.bmp' failed\n"; //} //else { // // convert to grayscale // for (int x = 0; x < bm->GetWidth(); x++) // { // for (int y = 0; y < bm->GetHeight(); y++) // { // uint8_t r, g, b, a; // bm->GetPixel(bm, x, y, r, g, b, a); // uint8_t average = (r+g+b)/3; // bm->SetPixel(bm, x, y, average, average, average, a); // } // } // bm->Save(bm, "mountain new.bmp"); // free(bm); //} ///** test #4: a 32-bit file with reversed height; extract the green channel */ //std::cout << "processing canmore.bmp\n"; //bm = bm->Load("canmore.bmp"); //if (bm == 0) //{ // std::cout << "load of 'canmore.bmp' failed\n"; //} //else { // for (int x = 0; x < bm->GetWidth(); x++) // { // for (int y = 0; y < bm->GetHeight(); y++) // { // uint8_t r, g, b, a; // bm->GetPixel(bm, x, y, r, g, b, a); // bm->SetPixel(bm, x, y, 0, g, 0, a); // } // } // bm->Save(bm, "canmore new.bmp"); // free(bm); //} // return 0; }
// The given argument does not escape globally, and may be returned. bool is_arg_returned(int i) const { return !_conservative && _arg_returned.at(i); }
void swap(BitMap &l, BitMap &r) { l.swap(r); }
void OrientedGraph::cells(Partition& pi, OrientedGraph* P) const /* Define a preorder relation on the vertices by setting x <= y iff there is an oriented path from x to y. This function puts in pi the partition function corresponding to the equivalence classes of this preorder. We use the Tarjan algorithm, explained in one of the Knuth books, but which I learned from Bill Casselman. The vertices for which the partition function is already defined will be said to be dealt with. These are marked off in an auxiliary bitmap. The algorithm goes as follows. Start with the first vertex that has not been dealt with, say x0. We will have to deal (potentially) with the set of all vertices visible from x0 (i.e >= x0). There will be a stack of vertices, corresponding to a path originating from x0, such that at each point in time, each vertex y >= x0 which is not dealt with will be equivalent to an element of the stack; the least such (in the stack ordering) will be called y_min, so that for instance x0_min = 0. We record these values in an additional table, initialized to some value undefined. Now let x be at the top of the stack. Look at the edges originating from x. Ignore the ones that go to vertices which are dealt with. If there are no edges left, x is minimal and is a class by itself; we can take it off, mark it as dealt with, and continue. Otherwise, run through the edges one by one. Let the edge be x->y. If y_min is defined, this means that y has already been examined, and is not dealt with. But each such element is equivalent to an element in the active stack, so y_min should be one of the elements in the active stack, hence x is visible from y_min: in other words, x and y are equivalent, and we set x_min = y_min if y_min < x_min. Otherwise, y is seen for the first time; then we just put it on the stack. When we are done with the edges of x, we have now the value of x_min which is the inf over the edges originating from x of the y_min. If this value is equal to the stack-position of x, we see that x is minimal in its class, and we get a new class by taking all the successors of x not already dealt with. We then move to the parent of x and continue the process there. */ { static Permutation a(0); static BitMap b(0); static List<Vertex> v(1); static List<const EdgeList*> elist(1); static List<Ulong> ecount(1); static List<Ulong> min(0); pi.setSize(size()); pi.setClassCount(0); b.setSize(size()); b.reset(); min.setSize(size()); min.setZero(); for (Vertex x = 0; x < size(); ++x) min[x] = size(); for (Vertex x = 0; x < size(); ++x) { if (b.getBit(x)) /* x is dealt with */ continue; v[0] = x; v.setSize(1); elist[0] = &edge(x); elist.setSize(1); ecount[0] = 0; ecount.setSize(1); min[x] = 0; Ulong t = 1; while(t) { Vertex y = v[t-1]; Vertex z; const EdgeList& e = *elist[t-1]; for (; ecount[t-1] < e.size(); ++ecount[t-1]) { z = e[ecount[t-1]]; if (b.getBit(z)) continue; if (min[z] == size()) /* z is new */ goto add_path; if (min[y] > min[z]) min[y] = min[z]; } /* at this point we have exhausted the edges of y */ if (min[y] == t-1) { /* take off class */ getClass(*this,y,b,pi,P); } else if (min[y] < min[v[t-2]]) /* if t=1, previous case holds */ min[v[t-2]] = min[y]; t--; continue; add_path: v.setSize(t+1); elist.setSize(t+1); ecount.setSize(t+1); v[t] = z; elist[t] = &edge(z); ecount[t] = 0; min[z] = t; t++; } } return; }
void TextureRegionEditor::_edit_region() { Ref<Texture> texture = NULL; if (node_sprite) texture = node_sprite->get_texture(); else if (node_patch9) texture = node_patch9->get_texture(); else if (obj_styleBox.is_valid()) texture = obj_styleBox->get_texture(); else if (atlas_tex.is_valid()) texture = atlas_tex->get_atlas(); if (texture.is_null()) { return; } autoslice_cache.clear(); Ref<Image> i; i.instance(); if (i->load(texture->get_path()) == OK) { BitMap bm; bm.create_from_image_alpha(i); for (int y = 0; y < i->get_height(); y++) { for (int x = 0; x < i->get_width(); x++) { if (bm.get_bit(Point2(x, y))) { bool found = false; for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) { Rect2 grown = E->get().grow(1.5); if (grown.has_point(Point2(x, y))) { E->get().expand_to(Point2(x, y)); E->get().expand_to(Point2(x + 1, y + 1)); x = E->get().position.x + E->get().size.x - 1; bool merged = true; while (merged) { merged = false; bool queue_erase = false; for (List<Rect2>::Element *F = autoslice_cache.front(); F; F = F->next()) { if (queue_erase) { autoslice_cache.erase(F->prev()); queue_erase = false; } if (F == E) continue; if (E->get().grow(1).intersects(F->get())) { E->get().expand_to(F->get().position); E->get().expand_to(F->get().position + F->get().size); if (F->prev()) { F = F->prev(); autoslice_cache.erase(F->next()); } else { queue_erase = true; //Can't delete the first rect in the list. } merged = true; } } } found = true; break; } } if (!found) { Rect2 new_rect(x, y, 1, 1); autoslice_cache.push_back(new_rect); } } } } } if (node_sprite) rect = node_sprite->get_region_rect(); else if (node_patch9) rect = node_patch9->get_region_rect(); else if (obj_styleBox.is_valid()) rect = obj_styleBox->get_region_rect(); else if (atlas_tex.is_valid()) rect = atlas_tex->get_region(); edit_draw->update(); }
void set_local_is_oop(int index) { _local_oop_map.set_bit(index); }
inline size_t ParMarkBitMap::size() const { return _beg_bits.size(); }
bool local_is_oop(int index) { return _local_oop_map.at(index); }
void CreateCube(GameObject& obj, Vector4 worldPos, const char* texture) { Vertex v00, v01, v02, v03; Vertex v10, v11, v12, v13; Vertex v20, v21, v22, v23; Vertex v30, v31, v32, v33; Vertex v40, v41, v42, v43; Vertex v50, v51, v52, v53; v00.normal = Vector4::zero; v01.normal = Vector4::zero; v02.normal = Vector4::zero; v03.normal = Vector4::zero; v10.normal = Vector4::zero; v11.normal = Vector4::zero; v12.normal = Vector4::zero; v13.normal = Vector4::zero; v20.normal = Vector4::zero; v21.normal = Vector4::zero; v22.normal = Vector4::zero; v23.normal = Vector4::zero; v30.normal = Vector4::zero; v31.normal = Vector4::zero; v32.normal = Vector4::zero; v33.normal = Vector4::zero; v40.normal = Vector4::zero; v41.normal = Vector4::zero; v42.normal = Vector4::zero; v43.normal = Vector4::zero; v50.normal = Vector4::zero; v51.normal = Vector4::zero; v52.normal = Vector4::zero; v53.normal = Vector4::zero; Poly p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11; BitMap bm; if (texture != NULL && bm.Read(texture)) { cube_texture = bm; p0.texture = bm; p1.texture = bm; p2.texture = bm; p3.texture = bm; p4.texture = bm; p5.texture = bm; p6.texture = bm; p7.texture = bm; p8.texture = bm; p9.texture = bm; p10.texture = bm; p11.texture = bm; v00.uv = Vector2(0.0f, 0.0f); v01.uv = Vector2(1.0f, 0.0f); v02.uv = Vector2(0.0f, 1.0f); v03.uv = Vector2(1.0f, 1.0f); v10.uv = Vector2(0.0f, 0.0f); v11.uv = Vector2(1.0f, 0.0f); v12.uv = Vector2(0.0f, 1.0f); v13.uv = Vector2(1.0f, 1.0f); v20.uv = Vector2(0.0f, 0.0f); v21.uv = Vector2(1.0f, 0.0f); v22.uv = Vector2(0.0f, 1.0f); v23.uv = Vector2(1.0f, 1.0f); v30.uv = Vector2(0.0f, 0.0f); v31.uv = Vector2(1.0f, 0.0f); v32.uv = Vector2(0.0f, 1.0f); v33.uv = Vector2(1.0f, 1.0f); v40.uv = Vector2(0.0f, 0.0f); v41.uv = Vector2(1.0f, 0.0f); v42.uv = Vector2(0.0f, 1.0f); v43.uv = Vector2(1.0f, 1.0f); v50.uv = Vector2(0.0f, 0.0f); v51.uv = Vector2(1.0f, 0.0f); v52.uv = Vector2(0.0f, 1.0f); v53.uv = Vector2(1.0f, 1.0f); } else { v00.color = ColourValue::Gray; v01.color = ColourValue::Gray; v02.color = ColourValue::Gray; v03.color = ColourValue::Gray; v10.color = ColourValue::Gray; v11.color = ColourValue::Gray; v12.color = ColourValue::Gray; v13.color = ColourValue::Gray; v20.color = ColourValue::Gray; v21.color = ColourValue::Gray; v22.color = ColourValue::Gray; v23.color = ColourValue::Gray; v30.color = ColourValue::Gray; v31.color = ColourValue::Gray; v32.color = ColourValue::Gray; v33.color = ColourValue::Gray; v40.color = ColourValue::Gray; v41.color = ColourValue::Gray; v42.color = ColourValue::Gray; v43.color = ColourValue::Gray; v50.color = ColourValue::Gray; v51.color = ColourValue::Gray; v52.color = ColourValue::Gray; v53.color = ColourValue::Gray; } v00.position = Vector4(1, 1, 1, 1); v01.position = Vector4(-1, 1, 1, 1); v02.position = Vector4(1, -1, 1, 1); v03.position = Vector4(-1, -1, 1, 1); v10.position = Vector4(1, -1, 1, 1); v11.position = Vector4(-1, -1, 1, 1); v12.position = Vector4(1, -1, -1, 1); v13.position = Vector4(-1, -1, -1, 1); v20.position = Vector4(1, 1, 1, 1); v21.position = Vector4(1, -1, 1, 1); v22.position = Vector4(1, 1, -1, 1); v23.position = Vector4(1, -1, -1, 1); v30.position = Vector4(-1, -1, 1, 1); v31.position = Vector4(-1, 1, 1, 1); v32.position = Vector4(-1, -1, -1, 1); v33.position = Vector4(-1, 1, -1, 1); v40.position = Vector4(1, -1, -1, 1); v41.position = Vector4(-1, -1, -1, 1); v42.position = Vector4(1, 1, -1, 1); v43.position = Vector4(-1, 1, -1, 1); v50.position = Vector4(1, 1, -1, 1); v51.position = Vector4(-1, 1, -1, 1); v52.position = Vector4(1, 1, 1, 1); v53.position = Vector4(-1, 1, 1, 1); obj.vertexListLocal[0] = v00; obj.vertexListLocal[1] = v01; obj.vertexListLocal[2] = v02; obj.vertexListLocal[3] = v03; obj.vertexListLocal[4] = v10; obj.vertexListLocal[5] = v11; obj.vertexListLocal[6] = v12; obj.vertexListLocal[7] = v13; obj.vertexListLocal[8] = v20; obj.vertexListLocal[9] = v21; obj.vertexListLocal[10] = v22; obj.vertexListLocal[11] = v23; obj.vertexListLocal[12] = v30; obj.vertexListLocal[13] = v31; obj.vertexListLocal[14] = v32; obj.vertexListLocal[15] = v33; obj.vertexListLocal[16] = v40; obj.vertexListLocal[17] = v41; obj.vertexListLocal[18] = v42; obj.vertexListLocal[19] = v43; obj.vertexListLocal[20] = v50; obj.vertexListLocal[21] = v51; obj.vertexListLocal[22] = v52; obj.vertexListLocal[23] = v53; p0.vertices = obj.vertexListTrans; p0.vertexIndexs[0] = 0; p0.vertexIndexs[1] = 1; p0.vertexIndexs[2] = 3; p1.vertices = obj.vertexListTrans; p1.vertexIndexs[0] = 3; p1.vertexIndexs[1] = 2; p1.vertexIndexs[2] = 0; p2.vertices = obj.vertexListTrans; p2.vertexIndexs[0] = 4; p2.vertexIndexs[1] = 5; p2.vertexIndexs[2] = 7; p3.vertices = obj.vertexListTrans; p3.vertexIndexs[0] = 7; p3.vertexIndexs[1] = 6; p3.vertexIndexs[2] = 4; p4.vertices = obj.vertexListTrans; p4.vertexIndexs[0] = 8; p4.vertexIndexs[1] = 9; p4.vertexIndexs[2] = 11; p5.vertices = obj.vertexListTrans; p5.vertexIndexs[0] = 11; p5.vertexIndexs[1] = 10; p5.vertexIndexs[2] = 8; p6.vertices = obj.vertexListTrans; p6.vertexIndexs[0] = 12; p6.vertexIndexs[1] = 13; p6.vertexIndexs[2] = 15; p7.vertices = obj.vertexListTrans; p7.vertexIndexs[0] = 15; p7.vertexIndexs[1] = 14; p7.vertexIndexs[2] = 12; p8.vertices = obj.vertexListTrans; p8.vertexIndexs[0] = 16; p8.vertexIndexs[1] = 17; p8.vertexIndexs[2] = 19; p9.vertices = obj.vertexListTrans; p9.vertexIndexs[0] = 19; p9.vertexIndexs[1] = 18; p9.vertexIndexs[2] = 16; p10.vertices = obj.vertexListTrans; p10.vertexIndexs[0] = 20; p10.vertexIndexs[1] = 21; p10.vertexIndexs[2] = 23; p11.vertices = obj.vertexListTrans; p11.vertexIndexs[0] = 23; p11.vertexIndexs[1] = 22; p11.vertexIndexs[2] = 20; // 设置物体属性 obj.polyCount = 12; obj.polyList[0] = p0; obj.polyList[1] = p1; obj.polyList[2] = p2; obj.polyList[3] = p3; obj.polyList[4] = p4; obj.polyList[5] = p5; obj.polyList[6] = p6; obj.polyList[7] = p7; obj.polyList[8] = p8; obj.polyList[9] = p9; obj.polyList[10] = p10; obj.polyList[11] = p11; obj.vertexCount = 24; obj.worldPos = worldPos; obj.ComputeVertexNormals(); }
GeometrySampler::GeometrySampler(GeometryImage & image, BitMap & imageMask) : m_image(image), m_imageMask(imageMask) { nvCheck(image.width() == imageMask.width()); nvCheck(image.height() == imageMask.height()); }
// The given argument escapes the callee, but does not become globally // reachable. bool is_arg_stack(int i) const { return !_conservative && _arg_stack.at(i); }