Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • e31fa09
  • /
  • src
  • /
  • Scene.cpp
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:fe2827c3f90fde3e7bdcd4ba8d468bcef3c084e1
directory badge
swh:1:dir:a182c55e93ceee8e3a35d88e8da2daa576d94fc5

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Scene.cpp
#include "Scene.h"
#include "Cloth.h"
#include "Obstacles.h"
#include "Shape.h"
#include "Preprocessor.h"
#include "Collisions.h"
#include "Constraints.h"
#include "GeneralizedSolver.h"
#include "matlabOutputs.h"

#include "external\ArcSim\dynamicremesh.hpp"

#ifdef EOLC_ONLINE
#include "online\MatrixStack.h"
#include "online\Program.h"
#endif // EOLC_ONLINE


using namespace std;
using namespace Eigen;

Scene::Scene() : 
	h(0.005),
	grav(Vector3d(0.0,0.0,-9.8)),
	part(0)
{
	cloth = make_shared<Cloth>();
	obs = make_shared<Obstacles>();
	GS = make_shared<GeneralizedSolver>();
}

void Scene::load(const string &RESOURCE_DIR)
{
	obs->load(RESOURCE_DIR);
}

void Scene::init(const bool online, const bool exportObjs)
{
#ifdef EOLC_ONLINE
	if (online) {
		cloth->init();
		obs->init();
	}
#endif

	cloth->consts->init(obs);

	if (exportObjs) {

	}
}

void printstate(Mesh& mesh)
{
	for (int n = 0; n < mesh.nodes.size(); n++) {
		if (mesh.nodes[n]->EoL) {
			cout << mesh.nodes[n]->EoL_state << endl;
		}
	}
}

void Scene::step()
{
	if (part != 0) {
		cout << "Please finish the partial step before making a full step" << endl;
		return;
	}
	cloth->updatePreviousMesh();
	dynamic_remesh(cloth->mesh);
	set_indices(cloth->mesh);
	CD(cloth->mesh, obs, cls);
	//dynamic_remesh(cloth->mesh);
	preprocess(cloth->mesh, cls);
	//reindex_nodes(cloth->mesh.nodes);
	set_indices(cloth->mesh);
	cout << "pre" << endl;
	dynamic_remesh(cloth->mesh);
	set_indices(cloth->mesh);
	//preprocessClean(cloth->mesh);
	//set_indices(cloth->mesh);
	//cloth->consts->fill(cloth->mesh, obs, h);
	//printstate(cloth->mesh);
	//cloth->velocityTransfer();
	//cloth->updateBuffers();
	cloth->step(GS, obs, grav, h);
	obs->step(h);
	cls.clear();
	mesh2m(cloth->mesh, "mesh.m", true);
	cout << "step" << endl;
}

void Scene::partialStep()
{
	if (part == 0) {
		dynamic_remesh(cloth->mesh);
		set_indices(cloth->mesh);
		CD(cloth->mesh, obs, cls);
		cout << "CD" << endl;
	}
	else if (part >= 1 && part < 8) {
		preprocessPart(cloth->mesh, cls, part);
		set_indices(cloth->mesh);
		cloth->updateBuffers();
		mesh2m(cloth->mesh, "mesh.m", true);
	}
	else if (part == 8) {
		dynamic_remesh(cloth->mesh);
		set_indices(cloth->mesh);
		cloth->updateBuffers();
	}
	else if (part == 9) {
		cloth->updateBuffers();
		cout << "Finished step" << endl;
		cls.clear();
		part = -1;
	}
	part++;
}

#ifdef EOLC_ONLINE
void Scene::draw(std::shared_ptr<MatrixStack> MV, const std::shared_ptr<Program> p) const
{
	obs->draw(MV,p);

	glUniform3fv(p->getUniform("kdFront"), 1, Vector3f(1.0, 0.5, 0.5).data());
	glUniform3fv(p->getUniform("kdBack"), 1, Vector3f(1.0, 0.5, 0.5).data());
	cloth->draw(MV, p);
}

void Scene::drawSimple(std::shared_ptr<MatrixStack> MV, const std::shared_ptr<Program> p) const
{
	obs->drawSimple(MV, p);
	cloth->consts->drawSimple(MV, p);
	cloth->drawSimple(MV, p);
}
#endif // EOLC_ONLINE

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API