Ejemplo n.º 1
0
Renderable2D::Renderable2D(std::shared_ptr<Mesh> mesh, std::shared_ptr<Shader> shader, const color& color, 
                           const vec2& pos, const vec2& sz) : _position(pos), _size(sz) {
    this->_shader = shader;
    update_modelmat();
    set_color(color);
    set_mesh(mesh);
}
Ejemplo n.º 2
0
void SoftBody::become_mesh_owner() {
	if (mesh.is_null())
		return;

	if (!mesh_owner) {
		mesh_owner = true;

		Vector<Ref<Material> > copy_materials;
		copy_materials.append_array(materials);

		ERR_FAIL_COND(!mesh->get_surface_count());

		// Get current mesh array and create new mesh array with necessary flag for softbody
		Array surface_arrays = mesh->surface_get_arrays(0);
		Array surface_blend_arrays = mesh->surface_get_blend_shape_arrays(0);
		uint32_t surface_format = mesh->surface_get_format(0);

		surface_format &= ~(Mesh::ARRAY_COMPRESS_VERTEX | Mesh::ARRAY_COMPRESS_NORMAL);
		surface_format |= Mesh::ARRAY_FLAG_USE_DYNAMIC_UPDATE;

		Ref<ArrayMesh> soft_mesh;
		soft_mesh.instance();
		soft_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, surface_arrays, surface_blend_arrays, surface_format);
		soft_mesh->surface_set_material(0, mesh->surface_get_material(0));

		set_mesh(soft_mesh);

		for (int i = copy_materials.size() - 1; 0 <= i; --i) {
			set_surface_material(i, copy_materials[i]);
		}
	}
}
Ejemplo n.º 3
0
Actor::Actor(Stage* stage, ActorID id, MeshID mesh):
    generic::Identifiable<ActorID>(id),
    Object(stage),
    Source(stage),
    render_priority_(RENDER_PRIORITY_MAIN) {

    set_mesh(mesh);
}
Ejemplo n.º 4
0
Archivo: mesh.c Proyecto: jinjoh/NOOR
void make_local_mesh(Mesh *me)
{
	Object *ob;
	Mesh *men;
	int local=0, lib=0;

	/* - only lib users: do nothing
	    * - only local users: set flag
	    * - mixed: make copy
	    */
	
	if(me->id.lib==0) return;
	if(me->id.us==1) {
		me->id.lib= 0;
		me->id.flag= LIB_LOCAL;
		new_id(0, (ID *)me, 0);
		
		if(me->mtface) make_local_tface(me);
		
		return;
	}
	
	ob= G.main->object.first;
	while(ob) {
		if( me==get_mesh(ob) ) {
			if(ob->id.lib) lib= 1;
			else local= 1;
		}
		ob= ob->id.next;
	}
	
	if(local && lib==0) {
		me->id.lib= 0;
		me->id.flag= LIB_LOCAL;
		new_id(0, (ID *)me, 0);
		
		if(me->mtface) make_local_tface(me);
		
	}
	else if(local && lib) {
		men= copy_mesh(me);
		men->id.us= 0;
		
		ob= G.main->object.first;
		while(ob) {
			if( me==get_mesh(ob) ) {				
				if(ob->id.lib==0) {
					set_mesh(ob, men);
				}
			}
			ob= ob->id.next;
		}
	}
}
Ejemplo n.º 5
0
ogl::unit::unit(std::string name, bool center) :
    id(serial++),
    vc(0),
    ec(0),
    my_node(0),
    rebuff(true),
    active(true),
    ubiquitous(false),
    surf(glob->load_surface(name, center))
{
    set_mesh();
}
Ejemplo n.º 6
0
ogl::unit::unit(const unit& that) :
    id(serial++),
    vc(0),
    ec(0),
    my_node(0),
    rebuff(true),
    active(true),
    ubiquitous(false),
    surf(glob->dupe_surface(that.surf))
{
    M = that.M;
    I = that.I;

    set_mesh();
}
Ejemplo n.º 7
0
void make_local_mesh(Mesh *me)
{
	Main *bmain= G.main;
	Object *ob;
	int local=0, lib=0;

	/* - only lib users: do nothing
	 * - only local users: set flag
	 * - mixed: make copy
	 */

	if(me->id.lib==NULL) return;
	if(me->id.us==1) {
		me->id.lib= NULL;
		me->id.flag= LIB_LOCAL;

		new_id(&bmain->mesh, (ID *)me, NULL);
		expand_local_mesh(bmain, me);
		return;
	}

	for(ob= bmain->object.first; ob && ELEM(0, lib, local); ob= ob->id.next) {
		if(me == ob->data) {
			if(ob->id.lib) lib= 1;
			else local= 1;
		}
	}

	if(local && lib==0) {
		me->id.lib= NULL;
		me->id.flag= LIB_LOCAL;

		new_id(&bmain->mesh, (ID *)me, NULL);
		expand_local_mesh(bmain, me);
	}
	else if(local && lib) {
		Mesh *men= copy_mesh(me);
		men->id.us= 0;

		for(ob= bmain->object.first; ob; ob= ob->id.next) {
			if(me == ob->data) {
				if(ob->id.lib==NULL) {
					set_mesh(ob, men);
				}
			}
		}
	}
}
Ejemplo n.º 8
0
void
ElementSideNeighborLayers::internalInit()
{
  auto functor = libmesh_make_unique<DefaultCoupling>();
  functor->set_n_levels(_layers);

  // Need to see if there are periodic BCs - if so we need to dig them out
  auto executioner_ptr = _app.getExecutioner();

  if (executioner_ptr)
  {
    auto & fe_problem = executioner_ptr->feProblem();
    auto & nl_sys = fe_problem.getNonlinearSystem();
    auto & dof_map = nl_sys.dofMap();
    auto periodic_boundaries_ptr = dof_map.get_periodic_boundaries();

    mooseAssert(periodic_boundaries_ptr, "Periodic Boundaries Pointer is nullptr");

    functor->set_mesh(&_mesh.getMesh());
    functor->set_periodic_boundaries(periodic_boundaries_ptr);
  }

  _functor = std::move(functor);
}
Ejemplo n.º 9
0
        void geometry_t::init(const parameter_reader_t* const reader)
        {
            const std::string geom_type = reader->get_attribute("type");

            // PRX_DEBUG_COLOR("MAKING GEOMETRY " << geom_type.c_str(), PRX_TEXT_CYAN);
            if (geom_type == "box")
            {
                const vector_t dims = reader->get_attribute_as<vector_t>("dims");
                if (dims.get_dim() != 3)
                    PRX_FATAL_S("Box must have three-dimensional dims attribute.")
                    set_box(dims[0], dims[1], dims[2]);
            }
            else if (geom_type == "sphere")
                set_sphere(reader->get_attribute_as<double>("radius"));
            else if (geom_type == "cone")
                set_cone(reader->get_attribute_as<double>("radius"),
                         reader->get_attribute_as<double>("height"));
            else if (geom_type == "cylinder")
                set_cylinder(reader->get_attribute_as<double>("radius"),
                             reader->get_attribute_as<double>("height"));
            else if (geom_type == "open_cylinder")
                set_open_cylinder(reader->get_attribute_as<double>("radius"),
                                  reader->get_attribute_as<double>("height"));
            else if (geom_type == "capsule")
                set_capsule(reader->get_attribute_as<double>("radius"),
                            reader->get_attribute_as<double>("height"));
            else if (geom_type == "mesh")
                set_mesh(reader->get_attribute_as<std::string>("filename"));
            else if (geom_type == "point_cloud")
                set_point_cloud();
            else if (geom_type == "heightmap")
                set_heightmap(reader->get_attribute_as<std::string>("filename"));
            else if (geom_type == "polygon")
            {
                const std::vector< double > triangles = reader->get_attribute_as< std::vector<double> >("triangles");
                set_polygon( triangles );
            }
            else
            {
                const std::string trace = reader->trace();
                PRX_FATAL_S("Unrecognized geometry type (" << geom_type.c_str() << ")  in " << trace.c_str());
            }

            if ( reader->has_attribute("scale"))
            {
                scale = reader->get_attribute_as<vector_t>("scale");
                if (scale.get_dim() != 3)
                    PRX_FATAL_S("Scale must have 3 elements at " << reader->trace() );
            }
            else
                set_scale(1.0,1.0,1.0);

            if( reader->has_attribute("material" ) )
            {
                std::string color_string = reader->get_attribute("material");
                if( color_string == "yellow" )
                {    color[0] = 1; color[1] = 1; color[2] = 0; color[3] = 1.0;   }
                else if( color_string == "blue" )
                {    color[0] = 0; color[1] = 0; color[2] = 1; color[3] = 1.0;   }
                else if( color_string == "dark_grey" )
                {    color[0] = 0.25; color[1] = 0.25; color[2] = 0.25; color[3] = 1.0;   }
                else if( color_string == "black" )
                {    color[0] = 0; color[1] = 0; color[2] = 0; color[3] = 1.0;   }
                else if( color_string == "green" )
                {    color[0] = 0; color[1] = 1; color[2] = 0; color[3] = 1.0;   }
                else if( color_string == "red" )
                {    color[0] = 1; color[1] = 0; color[2] = 0; color[3] = 1.0;   } 
                else if( color_string == "silver" )
                {    color[0] = 0.75; color[1] = 0.75; color[2] = 0.75; color[3] = 1.0; }
                else if( color_string == "cyan" )
                {    color[0] = 0.7; color[1] = 1; color[2] = 1; color[3] = 1.0;   }
                else if( color_string == "orange" )
                {    color[0] = 1; color[1] = 0.6; color[2] = 0.05; color[3] = 1.0;   }
                else if( color_string == "brown" )
                {    color[0] = 0.4; color[1] = 0.25; color[2] = 0.0; color[3] = 1.0;}
                else if( color_string == "glass" )
                {    color[0] = 0.5; color[1] = 0.5; color[2] = 0.55; color[3] = 0.18;}
                else
                {    color[0] = 1; color[1] = 1; color[2] = 1; color[3] = 1.0;   }
            }
            else
            {    color[0] = 1; color[1] = 1; color[2] = 1; color[3] = 1.0;   }

        }
Ejemplo n.º 10
0
Renderable2D::Renderable2D(std::shared_ptr<Mesh> mesh, const color& color, const vec2& pos, const vec2& sz) :_position(pos), _size(sz) {
    this->_shader = std::shared_ptr<Shader>(new Shader(BASIC_SHADER_VS_2D, BASIC_SHADER_FS_2D, false));
    update_modelmat();
    set_color(color);
    set_mesh(mesh);
}
Ejemplo n.º 11
0
Renderable3D::Renderable3D(std::shared_ptr<Mesh> mesh, std::shared_ptr<Shader> shader, const color& color) : _transform(mat4()) {
    this->_shader = shader;
    set_color(color);
    set_mesh(mesh);
}
Ejemplo n.º 12
0
Renderable3D::Renderable3D(std::shared_ptr<Mesh> mesh, const color& color) : _transform(mat4()) {
    this->_shader = std::shared_ptr<Shader>(new Shader(BASIC_SHADER_VS_3D, BASIC_SHADER_FS_3D, false));
    set_color(color);
    set_mesh(mesh);
}