Ejemplo n.º 1
0
void
MaterialAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("MaterialAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("smoothing")) != 0)
        SetSmoothing(node->AsBool());
    if((node = searchNode->GetNode("forceMIR")) != 0)
        SetForceMIR(node->AsBool());
    if((node = searchNode->GetNode("cleanZonesOnly")) != 0)
        SetCleanZonesOnly(node->AsBool());
    if((node = searchNode->GetNode("needValidConnectivity")) != 0)
        SetNeedValidConnectivity(node->AsBool());
    if((node = searchNode->GetNode("algorithm")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 5)
                SetAlgorithm(Algorithm(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Algorithm value;
            if(Algorithm_FromString(node->AsString(), value))
                SetAlgorithm(value);
        }
    }
    if((node = searchNode->GetNode("iterationEnabled")) != 0)
        SetIterationEnabled(node->AsBool());
    if((node = searchNode->GetNode("numIterations")) != 0)
        SetNumIterations(node->AsInt());
    if((node = searchNode->GetNode("iterationDamping")) != 0)
        SetIterationDamping(node->AsFloat());
    if((node = searchNode->GetNode("simplifyHeavilyMixedZones")) != 0)
        SetSimplifyHeavilyMixedZones(node->AsBool());
    if((node = searchNode->GetNode("maxMaterialsPerZone")) != 0)
        SetMaxMaterialsPerZone(node->AsInt());
    if((node = searchNode->GetNode("isoVolumeFraction")) != 0)
        SetIsoVolumeFraction(node->AsFloat());
    if((node = searchNode->GetNode("annealingTime")) != 0)
        SetAnnealingTime(node->AsInt());
}
Ejemplo n.º 2
0
void Texture::Request(int32_t State)
{
    Object::Request(State);
    switch (State)
    {
        case Nsb::SMOOTHING:
            SetSmoothing(true);
            break;
        case Nsb::ERASE:
            pWindow->RemoveTexture(this);
            break;
        case Nsb::ENTER:
            pWindow->AddTexture(this);
            break;
    }
}
Ejemplo n.º 3
0
Game::Game(int _width, int _height, char* _title) : window(),
													entities(),
													gwenRenderer(window),
													gwenSkin(&gwenRenderer),
													gwenInput(),
													world(b2Vec2(0.0f, 9.81f)) {
	// Create the window
	sf::ContextSettings settings;
	settings.antialiasingLevel = 8;
	window.create(sf::VideoMode(_width, _height, 32), _title, 7U, settings);

	// Initialize all the stuff here.
	// Set up the gwen skin and initialize the root panel.
	gwenSkin.Init("data/guiskins/skin.png");
	gwenSkin.SetDefaultFont(L"data/fonts/font.ttf");

	// Initialize the root panel
	gwenCanvas = new Gwen::Controls::Canvas(&gwenSkin);
	gwenCanvas->SetSize(window.getSize().x, window.getSize().y);
	gwenCanvas->SetDrawBackground(false);
	gwenCanvas->SetBackgroundColor(Gwen::Color(120, 120, 255, 255));

	// Initialize the input for gwen
	gwenInput.Initialize(gwenCanvas);

	// Set the world scale
	GetCamera().SetZoom(100.0f);
	GetCamera().SetPosition(sf::Vector2f(6.0f, 6.0f));

	// Set the physics time step.
	SetPhysicsStepTime(30.0f);

	// Set smoothing
	SetSmoothing(Game::INTERPOLATION);
	stepratio = 0.0f;

	// Turn friction on
	SetAirFriction(true);

	// Initialize the tool list
	currentTool = -1;
	tools.push_back(new SelectTool(this));
	tools.push_back(new RectangleTool(this));
	tools.push_back(new CircleTool(this));
	tools.push_back(new PolygonTool(this));
	tools.push_back(new RemoveTool(this));
	tools.push_back(new MoveTool(this));
	tools.push_back(new WeldTool(this));
	tools.push_back(new MotorJointTool(this));
	tools.push_back(new RotationTool(this));
	tools.push_back(new BodyTypeTool(this));
	tools.push_back(new DistanceJointTool(this));
	tools.push_back(new FrictionTool(this));
	tools.push_back(new RestitutionTool(this));
	tools.push_back(new DensityTool(this));

	// Add passive tools
	passivetools.push_back(new PanTool(this));
	passivetools.push_back(new ZoomTool(this));

	// Add the ondestroylistener
	world.SetDestructionListener(&destroyListener);

	// Paused physics is off
	pausedphysics = true;

	// Add some ui
	ui = new UIEntity(this);
	entities.Add(ui);
}