void fill_list(char **tmp, t_flag tab[], t_obj *obj, t_spot *spot) { static int i = 0; i++; if (is_in_tab(tmp[0], tab) == 1) { check_obj(tmp, i); new_obj(tmp, obj); } else if (my_strcompare("SPOT", tmp[0])) { check_spot(tmp, i); new_spot(tmp, spot); } else { fprintf(stderr, "Unknown object line %d\n", i); exit(EXIT_FAILURE); } }
void add_something(osg::Geometry* _geom ) { SpotRenderVertex new_v; std::vector<SpotRenderVertex> vertices_; std::vector<SpotRenderVertex> new_spot(3 * 2, new_v); SpotRenderVertex & cur_v0 = new_spot[0]; cur_v0.v = cg::point_3f(13, 13, 12); SpotRenderVertex & cur_v1 = new_spot[1]; cur_v1.v = cg::point_3f(13, -13, -12); SpotRenderVertex & cur_v2 = new_spot[2]; cur_v2.v = cg::point_3f(-13, -13, 0); SpotRenderVertex & cur_v3 = new_spot[3]; cur_v3.v = cg::point_3f(13, 13, 12); SpotRenderVertex & cur_v4 = new_spot[4]; cur_v4.v = cg::point_3f(-13, -13, 0); SpotRenderVertex & cur_v5 = new_spot[5]; cur_v5.v = cg::point_3f(-13, 13, -12); // append them vertices_.insert(vertices_.end(), new_spot.begin(), new_spot.end()); // create its' vertex osg::Vec3Array * paBoxPointsPos = new osg::Vec3Array; paBoxPointsPos->resize(vertices_.size()); //from_l_->resize(vertices_.size()); //ldir_->resize(vertices_.size()); //dist_falloff_->resize(vertices_.size()); //cone_falloff_->resize(vertices_.size()); //lcolor_->resize(vertices_.size()); for (unsigned i = 0; i < vertices_.size(); ++i) { SpotRenderVertex & cur_v = vertices_[i]; paBoxPointsPos->at(i).set(cur_v.v.x, cur_v.v.y, cur_v.v.z); //from_l_->at(i).set( cur_v.from_l.x, cur_v.from_l.y,cur_v.from_l.z ); //ldir_->at(i).set( cur_v.ldir.x, cur_v.ldir.y, cur_v.ldir.z ); //dist_falloff_->at(i).set( cur_v.dist_falloff.x, cur_v.dist_falloff.y ); //cone_falloff_->at(i).set( cur_v.cone_falloff.x, cur_v.cone_falloff.y ); //lcolor_->at(i).set( cur_v.lcolor.r, cur_v.lcolor.g, cur_v.lcolor.b ); } // set vertex array paBoxPointsPos->setDataVariance(osg::Object::DYNAMIC); _geom->setVertexArray(paBoxPointsPos); _geom->addPrimitiveSet( new osg::DrawArrays( GL_TRIANGLES, 0, vertices_.size() ) ); osg::StateSet* stateset = _geom->getOrCreateStateSet(); osg::Program* program = new osg::Program; osg::Shader* vertex_shader = new osg::Shader(osg::Shader::VERTEX, vertexShaderSource); //program->addShader(vertex_shader); osg::Shader* fragment_shader = new osg::Shader(osg::Shader::FRAGMENT, fragmentShaderSource); program->addShader(fragment_shader); program->setName("LightMap"); stateset->setAttribute(program); };