ivec3 GetRecomendedGPUOffset() { ivec3 pos(CT::GetCenter().x*CPU_VD::full_data.GetSize().x, CT::GetCenter().y*CPU_VD::full_data.GetSize().y, CT::GetCenter().z*CPU_VD::full_data.GetSize().z); pos -= gpu_size_dummy/2; pos -= ivec3::Max(gpu_size_dummy+pos-CPU_VD::full_data.GetSize(),ivec3(0)); pos = ivec3::Max(ivec3(0),pos); return pos; }
void ClipmapRing::reposition(const ivec3& _pos, const ivec3& _innerPos){ ivec3 origin = ring[calcRingIndex(start.x,start.y, start.z)].pos; ivec3 diff = _pos - origin; // we expect the values in diff should be either zero, or unitSize ivec3 normalizedDiff = diff / unitSize; start += normalizedDiff; ivec3 start = ivec3_mod(start, RING_DIM); //int z = 0; { for (int z = 0; z < RING_DIM; z++){ for (int y = 0; y < RING_DIM; y++){ for (int x = 0; x < RING_DIM; x++){ ivec3 thisPos = _pos + ivec3(x, y, z) * unitSize; // find the corresponding node. ivec3 nxyz = ivec3_mod(ivec3(x + start.x, y + start.y, z + start.z), RING_DIM); int idx = calcRingIndex(nxyz.x, nxyz.y, nxyz.z); ivec3 posFromNode = ring[idx].pos; bool inRing; if (noInner)inRing = belongsToNoInner(thisPos, _pos); else inRing = belongsTo(thisPos, _pos, _innerPos); if (inRing){ if (ring[idx].activated == 1){ if (posFromNode == thisPos){ // keep printf_s("keep %d, %d, %d\n", thisPos.x, thisPos.y, thisPos.z); } else{ // remove and regenerate printf_s("remove %d, %d, %d === generate %d, %d, %d\n", posFromNode.x, posFromNode.y, posFromNode.z, thisPos.x, thisPos.y, thisPos.z); ring[idx].pos = thisPos; vcManager->relocateChunk(&ring[idx], thisPos); } } else{ // first allocation printf_s("claim %d, %d, %d\n", thisPos.x, thisPos.y, thisPos.z); ring[idx].activated = 1; ring[idx].pos = thisPos; vcManager->createChunk(thisPos, lod, &ring[idx]); } } else{ if (ring[idx].activated == 1){ printf_s("release %d, %d, %d\n", thisPos.x, thisPos.y, thisPos.z); ring[idx].activated = 0; vcManager->removeChunk(&ring[idx]); } } } } } }
void CursorScanTool::step(int ms) { if (current_stage == ScanStages::SETTING_LOWER || current_stage == ScanStages::SETTING_UPPER || current_stage == ScanStages::EXTENDING) { if (BlockTracing::show_item) { show_item = true; Entity* at = BlockTracing::selected; if (at->entity_class == EntityType::BASEWORLD || at->entity_class == EntityType::SUPEROBJECT || at->entity_class == EntityType::GAMETEMPLATE) { target = (SuperObject*)at; } else { target = at->parent; } if (current_stage == ScanStages::SETTING_LOWER) { lower = BlockTracing::pointed_rounded_pos; box.lower = lower; box.upper = ivec3(lower.x + 1, lower.y + 1, lower.z + 1); } else if (current_stage == ScanStages::SETTING_UPPER) { upper = BlockTracing::pointed_rounded_pos; box.lower = lower; box.upper = upper; box.refit(); box.upper += 1; } else if (current_stage == ScanStages::EXTENDING) { // TODO calculate extending box extended = BlockTracing::pointed_rounded_pos; extending_box.lower = lower; extending_box.upper = upper; extending_box.refit(); extending_box.expand(extended); extending_box.upper += 1; } player_orientation = get_player_direction(); } else { show_item = false; if (current_stage == ScanStages::SETTING_UPPER) { box.upper = ivec3(lower.x + 1, lower.y + 1, lower.z + 1); } } } }
ivec3 Player::get_rounded_forward() { fvec3 dir = angle.get_dir(); if (fabsf(dir.x) > fabsf(dir.z)) { if (dir.x < 0) { return ivec3(-1, 0, 0); } return ivec3(1, 0, 0); } else { if (dir.z < 0) { return ivec3(0, 0, -1); } return ivec3(0, 0, 1); } }
void View2D::UpdateSumMip() { if(!CPU_VD::full_data.GetSlices())return; Progress progress(wxT("Generating 2D MIP,SUM...")); Progress::inst->AddText(wxT("init")); ivec3 size = CPU_VD::full_data.GetSize(); int ww = size.GetByID(axis_x),hh = size.GetByID(axis_y),dd = size.GetByID(axis); short* data; sum.Allocate(ivec3(ww,hh,1),CPU_VD::full_data.GetValueFormat()); mip.Allocate(ivec3(ww,hh,1),CPU_VD::full_data.GetValueFormat()); int* sum1 = new int[ww*hh]; for(int i=0;i<ww*hh;i++) { sum1[i]=0; } mip.SetAllValues(0); ivec3 bb1 = ivec3(0);//CT::GetBoundingBox(0); ivec3 bb2 = CPU_VD::full_data.GetSize()-ivec3(1);//CT::GetBoundingBox(1); ivec3 id; //short min_val = short(bc.x*256*128); //short max_val = short(bc.y*256*128); int*idx=&id.x+axis_x; int*idy=&id.x+axis_y; for(id.z=bb1.z;id.z<=bb2.z;id.z++) { for(id.y=bb1.y;id.y<=bb2.y;id.y++) for(id.x=bb1.x;id.x<=bb2.x;id.x++) { short val = CPU_VD::full_data.GetValue(id); //if(val>=min_val && val<=max_val) { int idd = *idx+ww**idy; sum1[idd] += val; short tmp=mip.GetValue(*idx,*idy,0); if(tmp<val)mip.SetValue(val,*idx,*idy,0); } } Progress::inst->SetPercent((id.z-bb1.z)/(float)(bb2.z-bb1.z)); } dd/=2; for(int i=0;i<ww*hh;i++) { sum.SetValue(sum1[i]/dd,i%ww,i/ww,0); } delete[]sum1; }
namespace CPU_VD { VData full_data; ivec3 gpu_size=ivec3(0); ivec3 gpu_size_dummy=ivec3(512); ivec3 gpu_offset=ivec3(0); float scale=1; vec3 real_gpu_b1(0),real_gpu_b2(0); vec3 GetScale() { return (full_data.spacing*full_data.GetSize().ToVec3())*scale; } vec3 GetFullSize() { return (full_data.spacing*full_data.GetSize().ToVec3())*scale; } void CalcReal() { CPU_VD::real_gpu_b1 = ((CPU_VD::gpu_offset.ToVec3())/CPU_VD::full_data.GetSize().ToVec3())*CPU_VD::GetScale(); CPU_VD::real_gpu_b2 = (((CPU_VD::gpu_offset+CPU_VD::gpu_size).ToVec3())/CPU_VD::full_data.GetSize().ToVec3())*CPU_VD::GetScale(); CT::need_rerender=1; CT::need_rerender2d=1; } void UnInit() { full_data.Clear(); } ivec3 GetRecomendedGPUOffset() { ivec3 pos(CT::GetCenter().x*CPU_VD::full_data.GetSize().x, CT::GetCenter().y*CPU_VD::full_data.GetSize().y, CT::GetCenter().z*CPU_VD::full_data.GetSize().z); pos -= gpu_size_dummy/2; pos -= ivec3::Max(gpu_size_dummy+pos-CPU_VD::full_data.GetSize(),ivec3(0)); pos = ivec3::Max(ivec3(0),pos); return pos; } ivec3 GetIPos(vec3 pos) { return (pos*CPU_VD::full_data.GetSize().ToVec3()).ToIVec3(); } }
VolumeList* Synth2DReader::read(const std::string &fileName) throw (tgt::FileException, std::bad_alloc) { RawVolumeReader rawReader(getProgressBar()); FILE* fin = fopen(fileName.c_str(), "rb"); char buf[4096]; fread(buf, 4096, 1, fin); fclose(fin); Synth2DVolumeHeader* header = (Synth2DVolumeHeader *)buf; if ((header->magic[0] != 'V') || (header->magic[1] != 'O') || (header->magic[2] != 'L') || (header->magic[3] != 'U') || (header->version != 4) || (header->bytesPerChannel != 1) || (header->numChannels != 1 && header->numChannels != 3 && header->numChannels != 4)) throw tgt::CorruptedFileException("error while reading data", fileName); std::string om("I"); if(header->numChannels == 3) om = std::string("RGB"); else if(header->numChannels == 4) om = std::string("RGBA"); ivec3 dims(header->volSize); rawReader.setReadHints(dims, // dimensions of the volume ivec3(1, 1, 1), // thickness of one slice om, // intensity, rgb or rgba image "UCHAR", // one unsigned char per voxel 1, // number of time frames 4096); // header skip VolumeList* volumeList = rawReader.read(fileName); return volumeList; }
ivec3 VoxelEditor::get_pos_vec(const vec3 & v) { int x = int(v.x - voxel->x_offset); int y = int(v.y - voxel->y_offset); int z = int(v.z - voxel->z_offset); return ivec3(x, y, z); }
MarchingCubesRenderer::MarchingCubesRenderer() { _id = ObjectIDGenerator::getInstance().getNextID(); MeshBufferInfo* mbi = new MeshBufferInfo(GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW, GL_TRIANGLES); _mesh = new Mesh(mbi); _meshGS = new Mesh(); viewOrient = vec3(1, 0, 1.5); cubeSize = vec3(48, 48, 48); cubeStep = vec3(2.0f, 2.0f, 2.0f) / cubeSize; dataSize = ivec3(128, 128, 128); isolevel = 40.5f; animate = true; autoWay = true; curData = 0; mode = 1; enableSwizzledWalk = false; wireframe = false; gridData = nullptr; _renderSortValue = IRenderable::DefaultSortValue; }
void MakeSmoothed(Geometry*src_g,Geometry*dst_g,int order) { if(order<2)return; vec3 nrm[3]; for(int i=0;i<src_g->face.size();i++) { for(int ii=0;ii<3;ii++) { nrm[ii] = src_g->norm[src_g->face[i].GetByID(ii)]; //if(vec3::dot(nrm[ii] , src_g->tr[i].norm)<0.5) nrm[ii] = src_g->tr[i].norm; } PN_Triangle pnt(src_g->vert[src_g->face[i].x],src_g->vert[src_g->face[i].y],src_g->vert[src_g->face[i].z], src_g->norm[src_g->face[i].x],src_g->norm[src_g->face[i].y],src_g->norm[src_g->face[i].z], nrm[0],nrm[1],nrm[2], src_g->vert_col[src_g->face[i].x],src_g->vert_col[src_g->face[i].y],src_g->vert_col[src_g->face[i].z]); int v_offset = dst_g->vert.size(); for(int u=0;u<order;u++) for(int v=0;v<order-u;v++) { float fu = u/float(order-1); float fv = v/float(order-1); dst_g->vert.push_back(pnt.GetVertex(fu,fv)); dst_g->norm.push_back(pnt.GetNormal(fu,fv)); dst_g->vert_col.push_back(pnt.GetColor(fu,fv)); } int off0=0,off1=0; for(int u=0;u<order-1;u++) { for(int v=0;v<order-u-1;v++) { int v00 = v_offset + u*order+v-off0; int v01 = v_offset + (u+1)*order+v-off1; int v10 = v_offset + (u)*order+v+1-off0; int v11 = v_offset + (u+1)*order+v+1-off1; dst_g->face.push_back(ivec3(v00,v01,v10)); if(v!=order-u-2) dst_g->face.push_back(ivec3(v01,v11,v10)); } if(u>=0)off1+=u+1; if(u>=1)off0+=u; } } }
VolumeMaxCLProcessor::VolumeMaxCLProcessor() : Processor() , ProcessorKernelOwner(this) , inport_("volume") , outport_("volume") , volumeRegionSize_("region", "Region size", 8, 1, 100) , workGroupSize_("wgsize", "Work group size", ivec3(8), ivec3(0), ivec3(256)) , useGLSharing_("glsharing", "Use OpenGL sharing", true) , supportsVolumeWrite_(false) , tmpVolume_(nullptr) , kernel_(nullptr) { addPort(inport_); addPort(outport_); addProperty(volumeRegionSize_); addProperty(workGroupSize_); addProperty(useGLSharing_); }
void ClipmapRing::createEdgeDescs(ClipmapRing* innerRing, ClipmapRing* outterRing){ const ivec3 adjacencyInfo[6] = { ivec3(-unitSize, 0, 0), ivec3(0, -unitSize, 0), ivec3(0, 0, -unitSize), ivec3(0, -unitSize, -unitSize), ivec3(-unitSize, 0, -unitSize), ivec3(-unitSize, -unitSize, 0) }; for (int z = 0; z < RING_DIM; z++){ for (int y = 0; y < RING_DIM; y++){ for (int x = 0; x < RING_DIM; x++){ bool inRing; ivec3 thisPos = originPos + ivec3(x, y, z) * unitSize; if (noInner)inRing = belongsToNoInner(thisPos, originPos); else inRing = belongsTo(thisPos, originPos, innerCubePos); if (inRing){ ivec3 nxyz = ivec3_mod(ivec3(x + start.x, y + start.y, z + start.z), RING_DIM); int idx = calcRingIndex(nxyz.x, nxyz.y, nxyz.z); VoxelChunk* curChunk = ring[idx].chunk; for (int i = 0; i < 6; i++){ ivec3 adjPos = ring[idx].pos + adjacencyInfo[i]; int adjType = adjacencyTypes(adjPos); if (i < 3){ if (adjType == 0){ // a normal 1 to 1 relationship. const VCNode* adjNode = getNodeByCoord(adjPos); curChunk->createEdgeDesc2D(adjType, 0, 0, adjNode->chunk, i); } else if(adjType == 1){ // now there are 4 chunks that are adjacent to curChunk. // they lie in the ring inside this clipmap ring. VCNode node0, node1, node2, node3; innerRing->getNodesFromInner(adjPos, i, &node0, &node1, &node2, &node3); curChunk->createEdgeDesc2D(adjType, 0, 0, node0.chunk, i); curChunk->createEdgeDesc2D(adjType, 1, 0, node1.chunk, i); curChunk->createEdgeDesc2D(adjType, 0, 1, node2.chunk, i); curChunk->createEdgeDesc2D(adjType, 1, 1, node3.chunk, i); } else if (adjType == -1){ // the adjacent chunk is larger than curChunk. // curChunk only has enough data to describe 1 / 4 of its edge desc. ivec3 local = ivec3_mod(adjPos, unitSize); ivec3 tempAdjPos = adjPos - local; const VCNode* adjNode = outterRing->getNodeByCoord(tempAdjPos); if ( i == 0) curChunk->createEdgeDesc2D(adjType, local.z, local.y, adjNode->chunk, i); } } else{ } } } } } } }
Deform_With_Seg::Deform_With_Seg(void) { near_point = 20; scale_factor = 1.5; color_list.clear(); for (int i = 0; i < 10; i++) { color_list.push_back(ivec3((int)(255 * (float)(rand()) / RAND_MAX), (int)(255 * (float)(rand()) / RAND_MAX), (int)(255 * (float)(rand()) / RAND_MAX))); } }
void View2D::LoadTexture() { if(!CPU_VD::full_data.GetSlices())return; need_texture_reload=0; ivec3 size = CPU_VD::full_data.GetSize(); if(cur_slice<0 || cur_slice>=size.GetByID(axis))return; if(txt2)delete txt2; int ww = size.GetByID(axis_x),hh = size.GetByID(axis_y); VData data(ivec3(ww,hh,1),CPU_VD::full_data.GetValueFormat()); void *dt; if(to_show==0) { if(axis==2) dt = CPU_VD::full_data.GetSlice(cur_slice); else { dt = data.GetSlice(0); if(axis==0) {//ww-y//hh-z for(int j=0;j<hh;j++) for(int i=0;i<ww;i++) { //data[i+ww*j] = *(CPU_VD::full_data.g + cur_slice + size.x*(i+j*size.y)); data.SetValue(CPU_VD::full_data.GetValue(cur_slice,i,j), i,j,0); } }else for(int j=0;j<size.z;j++) for(int i=0;i<size.x;i++) { //data[i+ww*j] = *(CPU_VD::full_data + i + size.x*(cur_slice+j*size.y)); data.SetValue(CPU_VD::full_data.GetValue(i,cur_slice,j), i,j,0); } } }else if(to_show==1) { if(!sum.GetSlices())UpdateSumMip(); dt = sum.GetSlice(0); }else if(to_show==2) { if(!mip.GetSlices())UpdateSumMip(); dt = mip.GetSlice(0); } txt2 = new SimText3D(2,ww,hh,1,1,dt,0,1,data.GetGLFormat()); data.Clear(); }
void ClipmapRing::initPos(ivec3 _pos, int _lod){ lod = _lod; unitSize = 1 << lod; noInner = true; for (int z = 0; z < RING_DIM; z++){ for (int y = 0; y < RING_DIM; y++){ for (int x = 0; x < RING_DIM; x++){ int idx = calcRingIndex(x, y, z); ivec3 thisPos = _pos + ivec3(x, y, z) * unitSize; ring[idx].pos = thisPos; if (belongsToNoInner(thisPos, _pos)){ ring[idx].activated = 1; vcManager->createChunk(ring[idx].pos, lod, &ring[idx]); } } } } originPos = _pos; start = ivec3(0, 0, 0); }
void Renderer6::GenerateSkinData() { m_skinCylinder = new Cylinder(1.0f, 0.25f); int bonesCount = m_chain->GetBones()->size(); int offset = 0; for (int i = 0; i < bonesCount; i++) { vector<float> vertices; vector<GLushort> indices; if (i == 0) { m_skinCylinder->GenerateVertices(vertices, VertexFlagsBoneWeights, ivec3(0, 0, 1)); } else if (i == bonesCount - 1) { m_skinCylinder->GenerateVertices(vertices, VertexFlagsBoneWeights, ivec3(i - 1, i, i)); } else { m_skinCylinder->GenerateVertices(vertices, VertexFlagsBoneWeights, ivec3(i - 1, i, i + 1)); } m_skinCylinder->GenerateLineIndices(indices); for (int j = 0; j < vertices.size(); j++) { m_skinVertices.push_back(vertices[j]); } for (int j = 0; j < indices.size(); j++) { m_skinIndices.push_back(indices[j] + offset); } offset += m_skinCylinder->GetVertexCount(); } glGenBuffers(1, &m_skinVertexBuffer); glBindBuffer(GL_ARRAY_BUFFER, m_skinVertexBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(float) * m_skinVertices.size(), &m_skinVertices[0], GL_STATIC_DRAW); glGenBuffers(1, &m_skinIndexBuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_skinIndexBuffer); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLushort) * m_skinIndices.size(), &m_skinIndices[0], GL_STATIC_DRAW); }
CL::Event Reyes::RendererCL::send_batch(Reyes::Batch& batch, const mat4& matrix, const mat4& proj, const vec4& color, PatchType patch_type, const CL::Event& ready) { // We can't handle more patches on the fly atm int patch_count = std::min<int>(reyes_config.reyes_patches_per_pass(), batch.patch_count); if (patch_count == 0) { return _last_batch; } CL::Event e; const int patch_size = reyes_config.reyes_patch_size(); const int group_width = reyes_config.dice_group_width(); // DICE switch (patch_type) { case BEZIER: _dice_bezier_kernel->set_args(batch.patch_buffer, batch.patch_ids, batch.patch_min, batch.patch_max, _pos_grid, _pxlpos_grid, _depth_grid, matrix, proj); e = _rasterization_queue.enq_kernel(*_dice_bezier_kernel, ivec3(patch_size + group_width, patch_size + group_width, patch_count), ivec3(group_width, group_width, 1), "dice", ready); break; case GREGORY: _dice_gregory_kernel->set_args(batch.patch_buffer, batch.patch_ids, batch.patch_min, batch.patch_max, _pos_grid, _pxlpos_grid, _depth_grid, matrix, proj); e = _rasterization_queue.enq_kernel(*_dice_gregory_kernel, ivec3(patch_size + group_width, patch_size + group_width, patch_count), ivec3(group_width, group_width, 1), "dice", ready); break; } // SHADE _shade_kernel->set_args(_pos_grid, _pxlpos_grid, _block_index, _color_grid, color); e = _rasterization_queue.enq_kernel(*_shade_kernel, ivec3(patch_size, patch_size, patch_count), ivec3(8,8,1), "shade", e); // SAMPLE _sample_kernel->set_args(_block_index, _pxlpos_grid, _color_grid, _depth_grid, _tile_locks, _framebuffer.get_buffer(), _depth_buffer); e = _rasterization_queue.enq_kernel(*_sample_kernel, ivec3(8,8,patch_count * square(patch_size/8)), ivec3(8,8,1), "sample", _framebuffer_cleared | e); _framebuffer_cleared = CL::Event(); _rasterization_queue.flush(); return e; }
void RenderableChunk::update_dimensions() { // TOFU could this be slightly more efficient? a loop over 4k elements isnt the most efficient... // small, large: inclusive-inclusive lower_bound = ivec3(CX, CY, CZ); upper_bound = ivec3(0, 0, 0); if (block_counter == 0) return; block_counter = 0; for (int x = 0; x < CX; x++) { for (int y = 0; y < CY; y++) { for (int z = 0; z < CZ; z++) { if (blk[x][y][z].type) { block_counter++; lower_bound.x = imin(x, lower_bound.x); lower_bound.y = imin(y, lower_bound.y); lower_bound.z = imin(z, lower_bound.z); upper_bound.x = imax(x, upper_bound.x); upper_bound.y = imax(y, upper_bound.y); upper_bound.z = imax(z, upper_bound.z); } } } } }
// ---------------------------------------------------- texture_atlas_clear --- void texture_atlas_clear( texture_atlas_t * self ) { ivec3 node = ivec3(1,1,1); assert( self ); assert( self->data ); vector_clear( self->nodes ); self->used = 0; // We want a one pixel border around the whole atlas to avoid any artefact when // sampling texture node.z = self->width-2; vector_push_back( self->nodes, &node ); memset( self->data, 0, self->width*self->height*self->depth ); }
bool CursorScanTool::confirmed() { if (current_stage == ScanStages::SELECTED) { // copies the area selected into the first cursorobject that is available // TODO copy entities as well CursorItemInfo* info = new CursorItemInfo((uint32_t)get_player()->getID(), (uint32_t)get_player()->assignID(), CursorType::CURSOR_SUPEROBJECT); CursorSuperObject* object = new CursorSuperObject(info);// all templates are made on the bar // TODO giraffes (center chunk and set position to box.lower + box.upper) object->set_pos(box.lower); for (int x = box.lower.x; x < box.upper.x; x++) { for (int y = box.lower.y; y < box.upper.y; y++) { for (int z = box.lower.z; z < box.upper.z; z++) { block_type* blk = target->get_block_integral(x, y, z); object->set_block_integral(x, y, z, *blk); } } } // TOFU what if inventory is open and this gets executed...? get_player()->inventory->add_custom(info); get_item_bar()->set_first_available(object); current_stage = ScanStages::SETTING_LOWER; } else if (current_stage == ScanStages::EXTENDED) { // fills in the extra blocks using the original as a template, over a repeating pattern // TODO copy over models in the area as well with equal frequency for (int x = extending_box.lower.x; x < extending_box.upper.x; x++) { for (int y = extending_box.lower.y; y < extending_box.upper.y; y++) { for (int z = extending_box.lower.z; z < extending_box.upper.z; z++) { if (box.hits(ivec3(x,y,z))) continue; int xm = get_positive_mod((x - box.lower.x), (box.upper.x - box.lower.x)) + box.lower.x; int ym = get_positive_mod((y - box.lower.y), (box.upper.y - box.lower.y)) + box.lower.y; int zm = get_positive_mod((z - box.lower.z), (box.upper.z - box.lower.z)) + box.lower.z; block_type* blk = target->get_block_integral(xm, ym, zm); target->set_block_integral(x, y, z, *blk); } } } current_stage = ScanStages::SELECTED; } current_stage = ScanStages::SETTING_LOWER; return true; }
void Deform_With_Seg::VisualSeg() { vector<ivec3> color_list; color_list.clear(); for(int i =0; i < total_seg_size; i++) { color_list.push_back(ivec3((int)(255*(float)(rand())/RAND_MAX),(int)(255*(float)(rand())/RAND_MAX),(int)(255*(float)(rand())/RAND_MAX))); } for(size_t i = 0; i < target_sample.size(); i++) { int max_index = 0; float max_pro = FLT_MIN; for(size_t j = 0; j < target_seg_prob[i].size(); j++) { if(target_seg_prob[i][j] > max_pro) { max_pro = target_seg_prob[i][j]; max_index = j; } } if(max_pro *total_seg_size < 1 ) { //cout << "err" << endl; //cout <<"weight_ " << i<<" "; //for (size_t ind = 0; ind < total_seg_size; ind++) //{ //cout << target_seg_prob[i][ind]<<" "; //} //cout << endl; FixSef(i); for(size_t j = 0; j < target_seg_prob[i].size(); j++) { if(target_seg_prob[i][j] > max_pro) { max_pro = target_seg_prob[i][j]; max_index = j; } } } target_sample[i].color = color_list[max_index]; target_sample[i].face_id = max_index; } }
void swizzledWalk(int &n, float *gridData, ivec3 pos, ivec3 size, const vec3 &cubeSize){ if(size.x>1){ ivec3 newSize=size/2; swizzledWalk(n, gridData, pos, newSize, cubeSize); swizzledWalk(n, gridData, pos+ivec3(newSize.x, 0, 0), newSize, cubeSize); swizzledWalk(n, gridData, pos+ivec3(0, newSize.y,0), newSize, cubeSize); swizzledWalk(n, gridData, pos+ivec3(newSize.x, newSize.y, 0), newSize, cubeSize); swizzledWalk(n, gridData, pos+ivec3(0, 0, newSize.z), newSize, cubeSize); swizzledWalk(n, gridData, pos+ivec3(newSize.x, 0, newSize.z), newSize, cubeSize); swizzledWalk(n, gridData, pos+ivec3(0, newSize.y, newSize.z), newSize, cubeSize); swizzledWalk(n, gridData, pos+ivec3(newSize.x, newSize.y, newSize.z), newSize, cubeSize); }else{ gridData[n]=(pos.x/cubeSize.x)*2.0f-1.0f; gridData[n+1]=(pos.y/cubeSize.y)*2.0f-1.0f; gridData[n+2]=(pos.z/cubeSize.z)*2.0f-1.0f; n+=3; } }
// ------------------------------------------------------ texture_atlas_new --- texture_atlas_t * texture_atlas_new( const size_t width, const size_t height, const size_t depth ) { texture_atlas_t *self = (texture_atlas_t *) malloc( sizeof(texture_atlas_t) ); // We want a one pixel border around the whole atlas to avoid any artefact when // sampling texture ivec3 node = ivec3(1,1,width-2); assert( (depth == 1) || (depth == 3) || (depth == 4) ); if( self == NULL) { fprintf( stderr, "line %d: No more memory for allocating data\n", __LINE__ ); exit( EXIT_FAILURE ); } self->nodes = vector_new( sizeof(ivec3) ); self->used = 0; self->width = width; self->height = height; self->depth = depth; self->id = 0; vector_push_back( self->nodes, &node ); self->data = (unsigned char *) calloc( width*height*depth, sizeof(unsigned char) ); if( self->data == NULL) { fprintf( stderr, "line %d: No more memory for allocating data\n", __LINE__ ); exit( EXIT_FAILURE ); } return self; }
int main() { void (*pfi)( int ) = print_elements; int ia1[6] = { 1,3,5,7,9,12 }; int ia2[8] = { 0,1,1,2,3,5,8,13 }; int ia3[3] = { 1,3,9 }; int ia4[4] = { 1,3,5,7 }; int ia5[2] = { 2,4 }; vector<int> ivec1( ia1, ia1+6 ); vector<int> ivec2( ia2, ia2+8 ); vector<int> ivec3( ia3, ia3+3 ); vector<int> ivec4( ia4, ia4+4 ); vector<int> ivec5( ia5, ia5+2 ); cout << "ivec1: "; for_each( ivec1.begin(), ivec1.end(), pfi ); cout << "\n"; cout << "ivec2: "; for_each( ivec2.begin(), ivec2.end(), pfi ); cout << "\n"; cout << "ivec3: "; for_each( ivec3.begin(), ivec3.end(), pfi ); cout << "\n"; cout << "ivec4: "; for_each( ivec4.begin(), ivec4.end(), pfi ); cout << "\n"; cout << "ivec5: "; for_each( ivec5.begin(), ivec5.end(), pfi ); cout << "\n\n"; cout << "ivec1 < ivec2 " << (ivec1 < ivec2 ? "true" : "false") << "\n"; cout << "ivec2 < ivec1 " << (ivec2 < ivec1 ? "true" : "false") << "\n\n"; cout << "ivec1 < ivec3 " << (ivec1 < ivec3 ? "true" : "false") << "\n"; cout << "ivec1 < ivec4 " << (ivec1 < ivec4 ? "true" : "false") << "\n"; cout << "ivec1 < ivec5 " << (ivec1 < ivec5 ? "true" : "false") << "\n\n"; cout << "ivec1 == ivec1 " << (ivec1 == ivec1 ? "true" : "false") << "\n"; cout << "ivec1 == ivec4 " << (ivec1 == ivec4 ? "true" : "false") << "\n"; cout << "ivec1 != ivec4 " << (ivec1 != ivec4 ? "true" : "false") << "\n\n"; cout << "ivec1 > ivec2 " << (ivec1 > ivec2 ? "true" : "false") << "\n"; cout << "ivec3 > ivec1 " << (ivec3 > ivec1 ? "true" : "false") << "\n"; cout << "ivec5 > ivec2 " << (ivec5 > ivec2 ? "true" : "false") << "\n"; }
bool GetArrayIndex(vec3 index, out ivec3 arrayIndex) { ivec3 chunk; chunk.x = int(floor(index.x / chunk_size)); chunk.y = int(floor(index.y / chunk_size)); chunk.z = int(floor(index.z / chunk_size)); chunk.x -= (index.x < 0) ? 1 : 0; chunk.y -= (index.y < 0) ? 1 : 0; chunk.z -= (index.z < 0) ? 1 : 0; if( ((chunk.x + 1) < offset.x) || ((chunk.x + 1) > (offset.x + world_size)) || ((chunk.y + 1) < offset.y) || ((chunk.y + 1) > (offset.y + world_size)) || ((chunk.z + 1) < offset.z) || ((chunk.z + 1) > (offset.z + world_size)) ) { return false; // Check if block is invalid, i.e. outside the world } chunk.x = eMod(chunk.x, world_size); chunk.y = eMod(chunk.y, world_size); chunk.z = eMod(chunk.z, world_size); ivec3 block = ivec3(index); block.x = eMod(block.x, chunk_size); block.y = eMod(block.y, chunk_size); block.z = eMod(block.z, chunk_size); arrayIndex = (chunk * chunk_size + block); return true; }
int main(int argc, const char *argv[]) { // Item 46. Consider function objects instead of functions as algorithm parameters. [ effective stl ] // because we can define function operator as inline function, and the compiler is not optimize for functions even if you // specify it as inline function int a[] = {1, 2, 3, 4}; std::vector<int> ivec(a, a + sizeof(a)/sizeof(int)); std::for_each(ivec.begin(), ivec.end(), Double<int>()); std::for_each(ivec.begin(), ivec.end(), print<int>); std::cout << std::endl; std::for_each(ivec.begin(), ivec.end(), doubleFun<int>); std::for_each(ivec.begin(), ivec.end(), print<int>); std::cout << std::endl; // liner search function, find and find_if // for random iterator, find algorithm use loop expand to optimize typedef std::vector<int>::iterator IVecInterator; IVecInterator iter = find(ivec.begin(), ivec.end(), 5); if (iter == ivec.end()) { std::cout << "could not find 5 in the vector ivec" << std::endl; } // similar with assocative container, they both have count and find member function. there is also count algorithm // count, count_if std::cout << "there is " << std::count(ivec.begin(), ivec.end(), 5) << " in the vector ivec" << std::endl; // search the first same or last same value in the two ranges int b[] = {4, 3, 3, 5, 4}; std::vector<int> ivec2(b, b + sizeof(b)/sizeof(int)); // return the first element in range 2 which occur in the range 1, // in this example, range1 is "4, 8, 12, 16", range 2 is "4, 3, 3, 5, 4" // so return 4 IVecInterator firstIter = find_first_of(ivec.begin(), ivec.end(), ivec2.begin(), ivec2.end()); if (firstIter != ivec.end()) { std::cout << *firstIter << std::endl; } IVecInterator secondIter = find_end(ivec.begin(), ivec.end(), ivec2.begin(), ivec2.end()); if (secondIter != ivec.end()) { std::cout << *secondIter << std::endl; } // find subsequence algorithm // adjacent_find ,return the first duplicated element which are adjacent,otherwise return end IVecInterator adjacent = adjacent_find(ivec2.begin(), ivec2.end()); if (adjacent != ivec2.end()) { std::cout << *adjacent << std::endl; } // search subsequence int c[] = {3, 5, 4}; std::vector<int> ivec3(c, c + sizeof(c)/sizeof(int)); IVecInterator subsequence = search(ivec2.begin(), ivec2.end(), ivec3.begin(), ivec3.end()); if (subsequence != ivec2.end()) { std::cout << *subsequence << std::endl; } // IVecInterator n = search_n(ivec3.begin(), ivec3.end(), // binary search // write only alogrithm // fill_n(dest, cnt, val) // generate_n(dest, cnt, Gen) // copy(beg, end, dest) // transform(beg, end, dest, unaryOp) // transform(beg, end, beg2, dest, binaryOp) // merge(beg1, end1, beg2, end2, dest) // merge(beg1, end1, beg2, end2, dest, comp) // sort and partition algorithm // partition, stable_partition // stable_partition(beg, end, unaryPred) // partition(beg, end, unaryPred) // sort, stable_sort, partitial_sort // nth_element // general reorder algorithm // unique, reverse, rotate, remove, remove_if // remove_copy, unique_copy, rotate_copy, random_shuffle // permutation alogrithm // prev_permutation(beg, end), next_permutation(beg, end) int a5[] = {1, 2, 3, 4}; std::vector<int> ivec5(a5, a5 + 4); // alogrithm for next_permutation : std::next_permutation(ivec5.begin(), ivec5.end()); std::for_each(ivec5.begin(), ivec5.end(), print<int>); std::cout << std::endl; std::next_permutation(ivec5.begin(), ivec5.end()); std::for_each(ivec5.begin(), ivec5.end(), print<int>); std::cout << std::endl; // ordered set algorithm : set_union, set_intersection, set_difference, set_symmetric_difference // compare algorithm // min(val1, val2), max(val1, val2), min_element, max_element(beg, end) // math algorithm return 0; }
VolumeCollection* MRCVolumeReader::read(const std::string &url) throw (tgt::FileException, tgt::IOException, std::bad_alloc) { VolumeCollection* volumeCollection = new VolumeCollection(); VolumeURL origin(url); std::string fileName = origin.getPath(); LINFO(fileName); std::ifstream mrc; mrc.open(fileName.c_str(), std::ios::binary); if (!mrc.is_open()) { LWARNING("Can't open stream"); } else { int dim[3]; // grid dimensions i.e. numbers of voxels for each dimension mrc.read((char*)(&dim), sizeof(dim)); std::cout << "X: " << dim[0] << std::endl; // number of columns (fastest changing in map) std::cout << "Y: " << dim[1] << std::endl; // number of rows std::cout << "Z: " << dim[2] << std::endl; // number of sections (slowest changing in map) int numVoxels = dim[0] * dim[1] * dim[2]; // total number of voxels in volume std::cout << "numVoxels: " << numVoxels << std::endl; int dataType; // see below mrc.read((char*)(&dataType), sizeof(dataType)); std::cout << "dataType: " << dataType << std::endl; int dataSize = 0; // i.e. 8-bit, 16-bit or 32-bit if (dataType == 0) dataSize = 1; // signed 8-bit bytes range -128 to 127 else if (dataType == 1) dataSize = 2; // 16-bit halfwords else if (dataType == 2) dataSize = 4; // 32-bit reals else if (dataType == 6) dataSize = 2; // unsigned 16-bit range 0 to 65535 tgtAssert(dataSize, "Datasize is 0 at MRCVolumeReader::read()"); int totalDataSize = dataSize * numVoxels; int start[3]; // numbers of first columns i.e. offset of the volume origin in voxel coordinates mrc.read((char*)(&start), sizeof(start)); std::cout << "startX: " << start[0] << std::endl; // number of columns (fastest changing in map) std::cout << "startY: " << start[1] << std::endl; // number of rows std::cout << "startZ: " << start[2] << std::endl; // number of sections (slowest changing in map) int gridSize[3]; mrc.read((char*)(&gridSize), sizeof(gridSize)); std::cout << "gridSizeX: " << gridSize[0] << std::endl; std::cout << "gridSizeY: " << gridSize[1] << std::endl; std::cout << "gridSizeZ: " << gridSize[2] << std::endl; float cellDimensions[3]; // cell dimensions in angstroms mrc.read((char*)(&cellDimensions), sizeof(cellDimensions)); std::cout << "cellX: " << cellDimensions[0] << std::endl; std::cout << "cellY: " << cellDimensions[1] << std::endl; std::cout << "cellZ: " << cellDimensions[2] << std::endl; float scale[3]; // pixelSpacing i.e. scale from voxel to real-word coordinates scale[0] = cellDimensions[0] / gridSize[0]; scale[1] = cellDimensions[1] / gridSize[1]; scale[2] = cellDimensions[2] / gridSize[2]; std::cout << "pixelSpacingX: " << scale[0] << std::endl; std::cout << "pixelSpacingY: " << scale[1] << std::endl; std::cout << "pixelSpacingZ: " << scale[2] << std::endl; float angles[3]; // cell angles in degrees mrc.read((char*)(&angles), sizeof(angles)); std::cout << "cellAngleX: " << angles[0] << std::endl; std::cout << "cellAngleY: " << angles[1] << std::endl; std::cout << "cellAngleZ: " << angles[2] << std::endl; int axes[3]; // Which axis corresponds to columns, rows and sections (1,2,3 for X,Y,Z) mrc.read((char*)(&axes), sizeof(axes)); std::cout << "axesX: " << axes[0] << std::endl; std::cout << "axesY: " << axes[1] << std::endl; std::cout << "axesZ: " << axes[2] << std::endl; float origin[3]; mrc.seekg(4*49, std::ios::beg); mrc.read((char*)(&origin), sizeof(origin)); std::cout << "originX: " << origin[0] << std::endl; std::cout << "originY: " << origin[1] << std::endl; std::cout << "originZ: " << origin[2] << std::endl; void* data = malloc(totalDataSize); mrc.seekg(1024, std::ios::beg); mrc.read((char*)data, totalDataSize); mrc.close(); VolumeRAM* targetDataset; int a = axes[0]-1; int b = axes[1]-1; int c = axes[2]-1; /**/ if (dataType == 0) { targetDataset = new VolumeAtomic<int8_t>(ivec3(dim[a], dim[b], dim[c])); fillVolume<int8_t>(targetDataset, data, dim, axes); } else if (dataType == 1) { targetDataset = new VolumeAtomic<int16_t>(ivec3(dim[a], dim[b], dim[c])); fillVolume<int16_t>(targetDataset, data, dim, axes); } else if (dataType == 2) { targetDataset = new VolumeAtomic<float>(ivec3(dim[a], dim[b], dim[c])); fillVolume<float>(targetDataset, data, dim, axes); } else if (dataType == 6) { targetDataset = new VolumeAtomic<uint16_t>(ivec3(dim[a], dim[b], dim[c])); fillVolume<uint16_t>(targetDataset, data, dim, axes); } else LERROR("Unsupported data type at MRCVolumeReader::read()"); free(data); angles[0] *= (PI / 180.); angles[1] *= (PI / 180.); angles[2] *= (PI / 180.); float row[3][3]; // X row[0][0] = 1; row[0][1] = 0; row[0][2] = 0; // Y row[1][0] = cos(angles[2]); // cos(gamma) row[1][1] = sin(angles[2]); // sin(gamma) row[1][2] = 0; // Z row[2][0] = cos(angles[1]); // cos(beta) row[2][1] = (cos(angles[0]) - row[2][0] * row[1][0]) / row[1][1]; // [cos(alpha) - cos(beta)*cos(gamma)] / sin(gamma) row[2][2] = sqrt(1 - row[2][0] * row[2][0] - row[2][1] * row[2][1]); // squared length is 1 tgt::Matrix4<float> transform ( row[0][0], row[1][0], row[2][0], 0, row[0][1], row[1][1], row[2][1], 0, row[0][2], row[1][2], row[2][2], 0, 0.0f, 0.0f, 0.0f, 1.0f ); Volume* volumeHandle = new MoleculeVolume( targetDataset, // data vec3(scale[a], scale[b], scale[c]), // scale vec3(start[a]*scale[a], start[b]*scale[b], start[c]*scale[c]), // offset transform // transform ); volumeCollection->add(volumeHandle); } if (!volumeCollection->empty()) volumeCollection->first()->setOrigin(VolumeURL(fileName)); return volumeCollection; }
ivec3 ImageData::getColor(unsigned int x, unsigned int y) const { int idx = (y * w + x) * d; return ivec3( data[idx+0], data[idx+1], data[idx+2]); }
//Software marching cubes //VERY far to be optimal ! void MarchingCubesRenderer::RenderMarchCube(float *data, ivec3 size, ivec3 gridsize, float isolevel){ vec3 gridStep = vec3(2.0, 2.0, 2.0) / vec3(gridsize.x, gridsize.y, gridsize.z); ivec3 dataGridStep = size / gridsize; vec3 *triangles = new vec3[16]; std::vector<Vector3>& positions = _mesh->getPositionVector(); positions.clear(); for (int k = 0; k < gridsize.z - 1; k++) for (int j = 0; j < gridsize.y - 1; j++) for (int i = 0; i < gridsize.x - 1; i++){ GridCell cell; vec3 vcurf(i, j, k); ivec3 vcuri(i, j, k); cell.pos[0] = vcurf*gridStep - 1.0f; ivec3 valPos0 = vcuri*dataGridStep; cell.val[0] = data[valPos0.x + valPos0.y*size.x + valPos0.z*size.x*size.y]; ivec3 valPos; cell.pos[1] = cell.pos[0] + vec3(gridStep.x, 0, 0); if (i == gridsize.x - 1) valPos = valPos0; else valPos = valPos0 + ivec3(dataGridStep.x, 0, 0); cell.val[1] = data[valPos.x + valPos.y*size.x + valPos.z*size.x*size.y]; cell.pos[2] = cell.pos[0] + vec3(gridStep.x, gridStep.y, 0); valPos = valPos0 + ivec3(i == gridsize.x - 1 ? 0 : dataGridStep.x, j == gridsize.y - 1 ? 0 : dataGridStep.y, 0); cell.val[2] = data[valPos.x + valPos.y*size.x + valPos.z*size.x*size.y]; cell.pos[3] = cell.pos[0] + vec3(0, gridStep.y, 0); valPos = valPos0 + ivec3(0, j == gridsize.y - 1 ? 0 : dataGridStep.y, 0); cell.val[3] = data[valPos.x + valPos.y*size.x + valPos.z*size.x*size.y]; cell.pos[4] = cell.pos[0] + vec3(0, 0, gridStep.z); valPos = valPos0 + ivec3(0, 0, k == gridsize.z - 1 ? 0 : dataGridStep.z); cell.val[4] = data[valPos.x + valPos.y*size.x + valPos.z*size.x*size.y]; cell.pos[5] = cell.pos[0] + vec3(gridStep.x, 0, gridStep.z); valPos = valPos0 + ivec3(i == gridsize.x - 1 ? 0 : dataGridStep.x, 0, k == gridsize.z - 1 ? 0 : dataGridStep.z); cell.val[5] = data[valPos.x + valPos.y*size.x + valPos.z*size.x*size.y]; cell.pos[6] = cell.pos[0] + vec3(gridStep.x, gridStep.y, gridStep.z); valPos = valPos0 + ivec3(i == gridsize.x - 1 ? 0 : dataGridStep.x, j == gridsize.y - 1 ? 0 : dataGridStep.y, k == gridsize.z - 1 ? 0 : dataGridStep.z); cell.val[6] = data[valPos.x + valPos.y*size.x + valPos.z*size.x*size.y]; cell.pos[7] = cell.pos[0] + vec3(0, gridStep.y, gridStep.z); valPos = valPos0 + ivec3(0, j == gridsize.y - 1 ? 0 : dataGridStep.y, k == gridsize.z - 1 ? 0 : dataGridStep.z); cell.val[7] = data[valPos.x + valPos.y*size.x + valPos.z*size.x*size.y]; int numvert = Polygonise(cell, isolevel, triangles); //Put the triangles into the mesh for (int n = 0; n < numvert; n++){ positions.push_back(Vector3(triangles[n].x, triangles[n].y, triangles[n].z)); } } if (positions.empty() == false) { GetGLError(); _mesh->constructBuffer(); GetGLError(); _mesh->drawBuffers(); GetGLError(); } }
void MarchingCubesRenderer::draw() { //States setting //glEnable(GL_DEPTH_TEST); //glDisable(GL_ALPHA_TEST); /* vec3 eye = vec3(0, 0, 3); vec3 up(0, 1, 0); vec3 target(0, 0, 0); mat4 mv =glm::lookAt(eye, target, up); //Activate modelview mv = mv * glm::rotate(GLFWTime::getCurrentTime()*0.5f, vec3(0, 1, 0)); //mv = glm::rotate(this->viewOrient.y * 10, vec3(0, 1, 0)); Vector2 size = RenderManager::getInstance().getFramebufferSize(); float aspect = size.x / size.y; float n = 0.01f; float f = 100.0f; float fieldOfView = 0.7f;// 1.74532925f;//100 degrees mat4 projection = glm::perspective(fieldOfView, aspect, n, f); mat4 mvp = projection*mv; */ mat4 m = glm::rotate(GLFWTime::getCurrentTime()*0.5f, vec3(0, 1, 0)); //FROM RENDERER Camera& cam = RenderManager::getInstance().getMainCamera(); mat4 view = cam.getModelview(); mat4 proj = cam.getProjection(); mat4 mv = view *m; mat4 mvp = proj * mv; GetGLError(); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_3D, this->dataFieldTex[curData]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, this->edgeTableTex); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, this->triTableTex); GetGLError(); isolevel = (sin(GLFWTime::getCurrentTime() * 1.5f) + 1.0f) * 0.02f + 0.45f; //isolevel = (sin(GLFWTime::getCurrentTime() * 0.5f) + 1.0f) * 0.2f + 0.4f; //printf("%3.4f\n", isolevel); if(mode != 0){ if(mode==1){ //Shader program binding programObject.bind(); _texture.bindToChannel(0); programObject.setUniform("dataFieldTex", 0); programObject.setUniform("edgeTableTex", 1); programObject.setUniform("triTableTex", 2); programObject.setUniform("isolevel", isolevel); programObject.setUniform("mvp", mvp); programObject.setUniform("ModelViewProjection", mvp); //Decal for each vertex in a marching cube programObject.setUniform("vertDecals[0]", vec3(0.0f, 0.0f, 0.0f)); programObject.setUniform("vertDecals[1]", vec3(cubeStep.x, 0.0f, 0.0f)); programObject.setUniform("vertDecals[2]", vec3(cubeStep.x, cubeStep.y, 0.0f)); programObject.setUniform("vertDecals[3]", vec3(0.0f, cubeStep.y, 0.0f)); programObject.setUniform("vertDecals[4]", vec3(0.0f, 0.0f, cubeStep.z)); programObject.setUniform("vertDecals[5]", vec3(cubeStep.x, 0.0f, cubeStep.z)); programObject.setUniform("vertDecals[6]", vec3(cubeStep.x, cubeStep.y, cubeStep.z)); programObject.setUniform("vertDecals[7]", vec3(0.0f, cubeStep.y, cubeStep.z)); programObject.setUniform("vertDecals[0]", vec3(0.0f, 0.0f, 0.0f)); }else{ //Shader program binding programObjectGS.bind(); programObjectGS.setUniform("dataFieldTex", 0); programObjectGS.setUniform("edgeTableTex", 1); programObjectGS.setUniform("triTableTex", 2); programObjectGS.setUniform("isolevel", isolevel); programObjectGS.setUniform("mvp", mvp); programObjectGS.setUniform("ModelViewProjection", mvp); } //glEnable(GL_LIGHTING); //Switch to wireframe or solid rendering mode //if(wireframe) // glPolygonMode(GL_FRONT_AND_BACK , GL_LINE ); //else // glPolygonMode(GL_FRONT_AND_BACK , GL_FILL ); _meshGS->drawBuffers(); }else{ //THIS IS SOFTWARE MARCHING CUBES programObjectFS.bind(); glActiveTexture(GL_TEXTURE0 ); glBindTexture(GL_TEXTURE_3D, this->dataFieldTex[curData]); programObjectFS.setUniform("dataFieldTex", 0); programObjectFS.setUniform("mvp", mvp); programObjectFS.setUniform("ModelViewProjection", mvp); programObjectFS.setUniform("ModelView", mv); GetGLError(); RenderMarchCube(dataField[curData], ivec3(128,128,128), ivec3(cubeSize.x, cubeSize.y, cubeSize.z), isolevel); GetGLError(); programObjectFS.unbind(); } }