int NemSpread<T,INT>::read_elem_vars(int exoid, int index, INT *eb_ids, INT *eb_cnts, INT ***eb_map_ptr, INT **eb_cnts_local) { /* to speed up searches, keep track of element blocks offset on each proc */ std::vector<INT> local_offset(Proc_Info[2]); /* loop over the number of element blocks */ INT eb_offset=0; for (int iblk = 0; iblk < globals.Num_Elem_Blk; iblk++) { read_elem_vars_1(exoid, index, eb_ids, eb_cnts, eb_map_ptr, eb_cnts_local, iblk, eb_offset, TOPTR(local_offset)); /* need to keep track of this for the element number map */ eb_offset += eb_cnts[iblk]; /* need to set up local offsets for next block */ for (int iproc = 0; iproc <Proc_Info[2]; iproc++) local_offset[iproc] += eb_cnts_local[iproc][iblk]; } /* End "for (iblk = 0; iblk < globals.Num_Elem_Blk; iblk++)" */ return 0; }
void orientation_offset(const glm::vec3 &rotation_vector, const float rotation_angle_rad, glm::fquat &offset_this) { glm::vec3 normalized_rotation_vector = glm::normalize(rotation_vector); normalized_rotation_vector *= sinf(rotation_angle_rad / 2.0f); float scalar = cosf(rotation_angle_rad / 2.0f); glm::fquat local_offset( scalar, normalized_rotation_vector.x, normalized_rotation_vector.y, normalized_rotation_vector.z); // assuming right multiplication only for now offset_this = glm::normalize(offset_this * local_offset); }
void updateScene() { std::vector<std::string> lines; lines.push_back("Hello"); lines.push_back("World"); OSG::TextLayoutResult layout_result; OSG::TextLayoutParam layout_param; layout_param.maxExtend = mMaxExtent; layout_param.setLength(mMaxExtent); layout_param.spacing = mLineSpacing; mFace->layout(lines, layout_param, layout_result); OSG::GeometryRefPtr geom_ptr = mTextGeom.get(); OSG::Vec2f bounds = layout_result.textBounds; //std::cout << "Text bounds: " << bounds << std::endl; mFace->fillGeo(geom_ptr, layout_result, mGeoScale, mOffset, OSG::Color3f(0,1,0)); lines.clear(); lines.push_back("OpenSG"); lines.push_back("was"); lines.push_back("here"); OSG::Vec2f local_offset(3,4); mFace->layout(lines, layout_param, layout_result); mFace->addToGeom(geom_ptr, layout_result, mGeoScale, local_offset, OSG::Color3f(0, 0.5f, 0.7f)); const float rand_range(10.0f); for(unsigned i=0;i<100;++i) { std::stringstream str; str << i; OSG::Vec2f rand_offset(OSG::osgRand()*rand_range, OSG::osgRand()*rand_range); mFace->layout(str.str(), layout_param, layout_result); mFace->addToGeom(geom_ptr, layout_result, mGeoScale, rand_offset, OSG::Color3f(OSG::osgRand(), OSG::osgRand(), OSG::osgRand())); } }