data_chunk* VDPMLoader::adaptive_refinement_server_rendering() { VDPMMesh::HalfedgeHandle v0v1; float fovy = viewing_parameters_.fovy(); float tolerance_square = viewing_parameters_.tolerance_square(); float tan_value = tanf(fovy / 2.0f); kappa_square_ = 4.0f * tan_value * tan_value * tolerance_square; split_counter = 0; ecol_counter = 0; for ( vfront_.begin(); !vfront_.end(); ) { VHierarchyNodeHandle node_handle = vfront_.node_handle(), parent_handle = vhierarchy_.parent_handle(node_handle); if (vhierarchy_.is_leaf_node(node_handle) != true && qrefine(node_handle) == true) { force_vsplit(node_handle); } else if (vhierarchy_.is_root_node(node_handle) != true && ecol_legal(parent_handle, v0v1) == true && qrefine(parent_handle) != true) { ++ecol_counter; ecol(parent_handle, v0v1); } else { vfront_.next(); } } // free memories tagged as 'deleted' mesh_.garbage_collection(false, true, true); mesh_.update_face_normals(); _glHandler->update_viewing_parameters(viewing_parameters_); if (split_counter > 0 || ecol_counter > 0) { draw_mesh(); return _glHandler->getFrameBufferAsJPEGinMen(); } else{ data_chunk * returnData = (data_chunk *) malloc(sizeof(data_chunk)); char * header = "svrender"; memcpy(returnData->HEADER, header, 8); returnData->size = 0; returnData->data = NULL; return returnData; } }
void VDPMLoader::rollback_split(data_chunk * vsplitdata) { Vsplit * vsltdata = (Vsplit *)vsplitdata->data; int size = vsplitdata->size / VSPLIT_LENGTH; std::cout << "Need to roll back " << size << " vsplits" << std::endl; VDPMMesh::HalfedgeHandle v0v1; for(int i = size - 1; i >= 0; i --){ Vsplit aVsplit = vsltdata[i]; //std::cout << "node_index" << aVsplit.node_index << std::endl; VHierarchyNodeHandle node_handle = index2handle_map[aVsplit.node_index]; //std::cout << "rollback node idx = " << node_handle.idx() << std::endl; if(ecol_legal(node_handle, v0v1)){ ecol(node_handle, v0v1); } else{ std::cout << "unable to ecol node : " << node_handle.idx() << std::endl; } } std::cout << "rollback finish! size of vfront " << vfront_.size()<<std::endl; }
/** DEPRECATED: return true if Ants expected location is the given location * @arg location to check * @return true if Ants expected location is the given location **/ bool Ant::isExpectedLocation(const Location &l) const{ if(l.row==erow()&&l.col==ecol()) return true; return false; }
/** DEPRECATED: return true if Ant a is at the expected location * @arg Ant to check * @return true if Ants expected location the same as the given ant **/ bool Ant::isExpectedLocation(const Ant &a) const{ if(a.row()==erow()&&a.col()==ecol()) return true; return false; }
bool ModelRenderPass::init(Model *m) { // blend mode switch (blendmode) { case BM_OPAQUE: // 0 glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); break; case BM_TRANSPARENT: // 1 glDisable(GL_BLEND); glEnable(GL_ALPHA_TEST); break; case BM_ALPHA_BLEND: // 2 glDisable(GL_ALPHA_TEST); glEnable(GL_BLEND); // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // default blend func break; case BM_ADDITIVE: // 3 glDisable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_COLOR, GL_ONE); break; case BM_ADDITIVE_ALPHA: // 4 glDisable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); break; default: // ??? glDisable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR); } if (nozwrite) { glDepthMask(GL_FALSE); } if (cull) { glEnable(GL_CULL_FACE); } else { glDisable(GL_CULL_FACE); } glBindTexture(GL_TEXTURE_2D, texture); if (usetex2) { glActiveTextureARB(GL_TEXTURE1); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture2); } if (unlit) { glDisable(GL_LIGHTING); // unfogged = unlit? glDisable(GL_FOG); } if (useenvmap) { // env mapping glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); const GLint maptype = GL_SPHERE_MAP; //const GLint maptype = GL_REFLECTION_MAP_ARB; glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, maptype); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, maptype); } if (texanim!=-1) { glMatrixMode(GL_TEXTURE); glPushMatrix(); m->texanims[texanim].setup(); } Vec4D ocol(1,1,1,m->trans); Vec4D ecol(0,0,0,0); // emissive colors if (color!=-1) { Vec3D c = m->colors[color].color.getValue(m->anim,m->animtime); ocol.w *= m->colors[color].opacity.getValue(m->anim,m->animtime); if (unlit) { ocol.x = c.x; ocol.y = c.y; ocol.z = c.z; } else { ocol.x = ocol.y = ocol.z = 0; } ecol = Vec4D(c, 1.0f); } glMaterialfv(GL_FRONT, GL_EMISSION, ecol); // opacity if (opacity!=-1) { ocol.w *= m->transparency[opacity].trans.getValue(m->anim,m->animtime); } // color glColor4fv(ocol); if (blendmode<=1 && ocol.w!=1.0f) glEnable(GL_BLEND); return (ocol.w > 0) || (ecol.lengthSquared() > 0); }