コード例 #1
0
ファイル: SSHowTo.cpp プロジェクト: Robograde/Robograde
void SSHowTo::LoadTextures()
{
	const rString path = "../../../asset/gui/tutorial/";
	gfx::Texture* texture;
	
	texture = tNew( gfx::Texture );
	texture->Init( ( path + "tutorial0.png" ).c_str(), gfx::TEXTURE_2D );
	m_Textures.push_back( texture );

	texture = tNew( gfx::Texture );
	texture->Init( ( path + "tutorial1.png" ).c_str(), gfx::TEXTURE_2D );
	m_Textures.push_back( texture );

	texture = tNew( gfx::Texture );
	texture->Init( ( path + "tutorial2.png" ).c_str(), gfx::TEXTURE_2D );
	m_Textures.push_back( texture );

	texture = tNew( gfx::Texture );
	texture->Init( ( path + "tutorial3.png" ).c_str(), gfx::TEXTURE_2D );
	m_Textures.push_back( texture );

	texture = tNew( gfx::Texture );
	texture->Init( ( path + "tutorial4.png" ).c_str(), gfx::TEXTURE_2D );
	m_Textures.push_back( texture );
}
コード例 #2
0
ファイル: ShaderProgram.cpp プロジェクト: Robograde/Robograde
//Creates a shader with defines
void gfx::ShaderProgram::CreateShader ( ifstream* FileStream, GLenum shaderType, const rString& filename,bool print, ShaderDefineContainer& container )
{
    rString line;
    size_t found;
    rString shaderText;
	getline(*FileStream, line);
	shaderText += line;
	shaderText += "\n";
	shaderText += container.GetAllDefineLines();
    shaderText += container.GetDefinesShaderStage ( shaderType );
    bool end = false;
    while ( !end )
    {
        getline ( *FileStream, line );
        //search for the end of the shader
        found = line.find ( "#include " );
		if ( found != rString::npos )
        {
            int i = static_cast<int> ( found ) + 9; //found + "#include "
            rString s;
            while ( i < static_cast<int> ( line.length() ) )
            {
                s += line[i];
                i++;
            }
            rString str = GetDir ( rString ( filename.c_str() ) ) + s;
            shaderText += LoadText ( str.c_str() );
            shaderText += "\n";
        }
        else
        {
            found = line.find ( "#end_shader" );
			if ( found != rString::npos )
            {
                //break loop
                end = true;
                break;
            }
            else if ( FileStream->eof() )
            {
				Logger::Log( "Could not find end of file " + filename, "ShaderProgram", LogSeverity::ERROR_MSG );
                return;
            }
            else
            {
                shaderText += line;
                shaderText += '\n';
            }

        }

    }
    if ( shaderText.length() > 0 )
    {
		Shader* shader = tNew( Shader );
        shader->CreateFromString ( shaderText, shaderType, filename,print );
        m_Shaders.push_back ( shader );
        shaderText.clear();
    }
}
コード例 #3
0
ファイル: SoundSDL.cpp プロジェクト: Robograde/Robograde
//+----------------------------------------------------------------------------+
//|bool Initialize(AudioEngine* engine, const rString &path, SoundType type)
//\----------------------------------------------------------------------------+
bool SoundSDL::Initialize(AudioEngine* engine, const rString &path, SoundType type)
{
	AudioEngineSDL* audioEngine = reinterpret_cast<AudioEngineSDL*>(engine);
	const SDL_AudioSpec* sysSpec = audioEngine->GetSystemSpec();
	m_AudioEngine = audioEngine;
	m_Type = type;
	m_Name = path;
	m_ChunkSize = sysSpec->size;

	m_AudioCVT = pNew(SDL_AudioCVT);
	m_BufferData = tNew(AudioBuffer);
	m_AudioFile = nullptr;

	///Check which file format the requested audiofile are
	///Only wav and ogg are supported

	///Is wave file
	if(path.find(".wav", 0) != std::string::npos)
	{ 
		m_AudioFile = pNew(WavFileReader);
	}
	///Is ogg file
	else if(path.find(".ogg", 0) != std::string::npos)
	{ 
		m_AudioFile = pNew(OggFileReader);
	}
	///Not supported format
	else
	{
		fprintf(stderr, "SoundSDL. Trying to load unsupported file format %s \n", path.c_str());
		return false;
	}

	m_AudioFile->Initialize();

	///Read as sample, read everything into buffer
	if(type == SoundType::SAMPLE)
	{
		CreateSample(path, m_BufferData, sysSpec);
	}
	///Read as stream, prepare for buffer streaming
	else if(type == SoundType::STREAM)
	{
		CreateStream(path, m_BufferData, sysSpec);
	}
	else
	{
		///This should not happend..
		fprintf(stderr, "SoundSDL. Unexpected error loading %s while setting sound type \n", path.c_str());
		return false;
	}

	return true;
}
コード例 #4
0
void SSResourceManager::AddResource( glm::vec2 position, glm::vec3 scale, glm::quat orientation, const pString& modelPath, bool respawning, float respawnRadius, int respawnType )
{
	float height			= gfx::g_GFXTerrain.GetHeightAtWorldCoord( position.x, position.y );

	ResourceAttributes resource;
	resource.Position		= glm::vec3( position.x, height, position.y );
	resource.Scale			= scale;
	resource.Orientation	= orientation;
	resource.ModelPath		= modelPath;
	resource.Respawning		= respawning;
	resource.RespawnType	= respawnType;
	resource.RespawnRadius	= respawnRadius;
	resource.LastSpawn		= RESOURCE_RESPAWN_FIRST_DELAY * (float) g_Randomizer.SimGenerateRandom( );

	if ( respawning )
		m_Resources.push_back( resource );
	else
	{
		if ( m_InitialSpawn == nullptr )
			m_InitialSpawn = tNew( tVector<ResourceAttributes> );
		m_InitialSpawn->push_back( resource );
	}
}
コード例 #5
0
ファイル: SSGameLobby.cpp プロジェクト: Robograde/Robograde
void SSGameLobby::LoadLevelPreviews( const rVector<rString> levelNames )
{
	m_SpawnPoints.clear();
	for ( auto& level : levelNames )
	{
		gfx::Texture* texture = tNew( gfx::Texture );
		rString levelPath = m_MapsFolder + level + "/" + level + m_LevelPreviewFormat;
		if ( texture->Init( levelPath.c_str(), gfx::TextureType::TEXTURE_2D ) )
			m_LevelTextures.emplace( level, texture );
		else
		{
			if ( texture->Init( m_DefaultLevelTexturePath.c_str(), gfx::TextureType::TEXTURE_2D ) )
				m_LevelTextures.emplace( level, texture );
			else
				Logger::Log( "Failed to load default level texture: " + m_DefaultLevelTexturePath, "SSGameLobby", LogSeverity::ERROR_MSG );
			Logger::Log( "Failed to load level texture: " + levelPath, "SSGameLobby", LogSeverity::ERROR_MSG );
		}

		// Load the scene file
		gfx::ObjectImporter importer;
		bool status = importer.LoadScene( level );

		// Could not load scene file
		if( status == false )
		{
			Logger::Log( "Failed to load level file: " + levelPath, "SSGameLobby", LogSeverity::ERROR_MSG );
		}

		// Get spawn points
		gfx::RoboScene scene;
		status = importer.GetSceneByName( scene, level );
		rVector <gfx::EntityObj> spawnPoints;
		spawnPoints = importer.GetSpawnPointsInScene( 0 );
		rVector<glm::vec2> spawnPointProcessed;
		for( auto& spawnPoint : spawnPoints )
		{
			spawnPointProcessed.push_back( glm::vec2( spawnPoint.Translation[0] / scene.Width, spawnPoint.Translation[2] / scene.Height ) );
		}
		m_SpawnPoints.emplace( level, spawnPointProcessed );

		rVector<gfx::EntityObj> resourceDrops;
		resourceDrops = importer.GetResourcesInScene( 0 );
		rVector<ResourceSpawn> resourceSpawnsProcessed;
		for ( auto& resource : resourceDrops )
		{
			if ( resource.Radius > 0.0f )
			{
				resourceSpawnsProcessed.push_back( ResourceSpawn{ 
					glm::vec2( resource.Translation[0] / scene.Width, resource.Translation[2] / scene.Height ),
					resource.GetDropRate( )} );
			}
		}
		m_ResourceSpawns.emplace( level, resourceSpawnsProcessed );	

		rVector<gfx::EntityObj> researchStations = importer.GetControlPointsInScene( 0 );
		rVector<glm::vec2> researchStationsProcessed;
		for ( auto& research : researchStations )
		{
			researchStationsProcessed.push_back( glm::vec2( research.Translation[0] / scene.Width, research.Translation[2] / scene.Height ) );
		}
		m_ResearchStations.emplace( level, researchStationsProcessed );
	}
}
コード例 #6
0
Rototranslation2D Rototranslation2D::inverse() const {
    Eigen::Rotation2D<double> rot(-this->getAngle());
    Eigen::Vector2d tNew(rot * this->getTranslation());
    tNew = -tNew;
    return Rototranslation2D(rot, tNew);
}