Example #1
0
void
UiSettings::saveSettings()
{
    QSettings s( "CS224", "snow" );

    s.setValue( "windowPosition", windowPosition() );
    s.setValue( "windowSize", windowSize() );

    s.setValue( "fillNumParticles", fillNumParticles() );
    s.setValue( "fillResolution", fillResolution() );
    s.setValue( "fillDensity", fillDensity() );

    s.setValue("exportDensity", exportDensity());
    s.setValue("exportVelocity",exportVelocity());
    s.setValue( "exportFPS", exportFPS());
    s.setValue( "maxTime", maxTime());

    s.setValue( "gridPositionX", gridPosition().x );
    s.setValue( "gridPositionY", gridPosition().y );
    s.setValue( "gridPositionZ", gridPosition().z );

    s.setValue( "gridDimensionX", gridDimensions().x );
    s.setValue( "gridDimensionY", gridDimensions().y );
    s.setValue( "gridDimensionZ", gridDimensions().z );

    s.setValue( "gridResolution", gridResolution() );

    s.setValue( "timeStep", timeStep() );
    s.setValue( "implicit", implicit() );
    s.setValue("materialPreset", materialPreset());

    s.setValue( "showContainers", showContainers() );
    s.setValue( "showContainersMode", showContainersMode() );
    s.setValue( "showColliders", showColliders() );
    s.setValue( "showCollidersMode", showCollidersMode() );
    s.setValue( "showGrid", showGrid() );
    s.setValue( "showGridMode", showGridMode() );
    s.setValue( "showGridData", showGridData() );
    s.setValue( "showGridDataMode", showGridDataMode() );
    s.setValue( "showParticles", showParticles() );
    s.setValue( "showParticlesMode", showParticlesMode() );
}
Example #2
0
void
UiSettings::loadSettings()
{
    QSettings s( "CS224", "snow" );

    windowPosition() = s.value( "windowPosition", QPoint(0,0) ).toPoint();
    windowSize() = s.value( "windowSize", QSize(1000,800) ).toSize();

    fillNumParticles() = s.value( "fillNumParticles", 512*128 ).toInt();
    fillResolution() = s.value( "fillResolution", 0.05f ).toFloat();
    fillDensity() = s.value( "fillDensity", 150.f ).toFloat();

    exportDensity() = s.value("exportDensity", false).toBool();
    exportVelocity() = s.value("exportVelocity", false).toBool();

    exportFPS() = s.value("exportFPS", 24).toInt();
    maxTime() = s.value("maxTime", 3).toFloat();

    gridPosition() = vec3( s.value("gridPositionX", 0.f).toFloat(),
                           s.value("gridPositionY", 0.f).toFloat(),
                           s.value("gridPositionZ", 0.f).toFloat() );


    gridDimensions() = glm::ivec3( s.value("gridDimensionX", 128).toInt(),
                                   s.value("gridDimensionY", 128).toInt(),
                                   s.value("gridDimensionZ", 128).toInt() );

    gridResolution() = s.value( "gridResolution", 0.05f ).toFloat();

    timeStep() = s.value( "timeStep", 1e-5 ).toFloat();
    implicit() = s.value( "implicit", true ).toBool();
    materialPreset() = s.value( "materialPreset", MAT_DEFAULT).toInt();

    showContainers() = s.value( "showContainers", true ).toBool();
    showContainersMode() = s.value( "showContainersMode", WIREFRAME ).toInt();
    showColliders() = s.value( "showColliders", true ).toBool();
    showCollidersMode() = s.value( "showCollidersMode", SOLID ).toInt();
    showGrid() = s.value( "showGrid", false ).toBool();
    showGridMode() = s.value( "showGridMode", MIN_FACE_CELLS ).toInt();
    showGridData() = s.value( "showGridData", false ).toBool();
    showGridDataMode() = s.value( "showGridDataMode", NODE_DENSITY ).toInt();
    showParticles() = s.value( "showParticles", true ).toBool();
    showParticlesMode() = s.value( "showParticlesMode", PARTICLE_MASS ).toInt();

    selectionColor() = glm::vec4( 0.302f, 0.773f, 0.839f, 1.f );
}
Example #3
0
//-----------------------------------------------------------------------------------------------
float Generate2DNoise( float x, float y, float gridSize )
{
	float INVERSE_GRID_SIZE = 1.0f / gridSize;

	//Find location in grid space
	float xWithRespectToGridSize = x * INVERSE_GRID_SIZE;
	float yWithRespectToGridSize = y * INVERSE_GRID_SIZE;
	int	  gridX = static_cast< int >( floor( xWithRespectToGridSize ) );
	int   gridY = static_cast< int >( floor( yWithRespectToGridSize ) );
	float xInGrid = xWithRespectToGridSize - gridX;
	float yInGrid = yWithRespectToGridSize - gridY;

	//Smooth values
	FloatVector2 gridPosition( SmoothStep( xInGrid ), SmoothStep( yInGrid ) );

	//Create Random Gradients
	FloatVector2 gradient00 = GeneratePseudoRandomUnitVectorAtPosition( gridX,		gridY );
	FloatVector2 gradientX0 = GeneratePseudoRandomUnitVectorAtPosition( gridX + 1,	gridY );
	FloatVector2 gradient0Y = GeneratePseudoRandomUnitVectorAtPosition( gridX,		gridY + 1 );
	FloatVector2 gradientXY = GeneratePseudoRandomUnitVectorAtPosition( gridX + 1,	gridY + 1 );

	FloatVector2 vectorToCorner00( gridPosition.x,		 gridPosition.y );
	FloatVector2 vectorToCornerX0( gridPosition.x - 1.f, gridPosition.y );
	FloatVector2 vectorToCorner0Y( gridPosition.x,		 gridPosition.y - 1.f );
	FloatVector2 vectorToCornerXY( gridPosition.x - 1.f, gridPosition.y - 1.f );

	//Dot Product
	float influence00 = DotProduct( gradient00, vectorToCorner00 );
	float influenceX0 = DotProduct( gradientX0, vectorToCornerX0 );
	float influence0Y = DotProduct( gradient0Y, vectorToCorner0Y );
	float influenceXY = DotProduct( gradientXY, vectorToCornerXY );

	//Weighted Average
	float influenceLowerSide = influence00 + gridPosition.x * ( influenceX0 - influence00 );
	float influenceUpperSide = influence0Y + gridPosition.x * ( influenceXY - influence0Y );
	float influenceCenter = influenceLowerSide + gridPosition.y * ( influenceUpperSide - influenceLowerSide );
	assert( influenceCenter <= 1.f);
	assert( influenceCenter >= -1.f);
	return influenceCenter;
}
Example #4
0
Segment::Segment(const gl::Vec2u& index)
	: folder("resources/segments/" + std::to_string(index.x) + " " + std::to_string(index.y)),
	baseImg(gl::Rectangle(gridPosition(index), GLfloat(World::scale)), gl::Texture(folder + "/base.png")),
	topImg(gl::Rectangle(gridPosition(index), GLfloat(World::scale)), gl::Texture(folder + "/top.png")) {}