Exemplo n.º 1
0
/**
 * loads a node from the given xml file and attaches it to the joint eye
 */
Joint* Gaze::createGazeAux(Joint* eye, const char* filename, const char* filedir)
{
	if(m_gazeaux_res == 0)
	{
		m_gazeaux_res = h3dAddResource(H3DResTypes::SceneGraph, filename, 0);
		if( !h3dIsResLoaded(m_gazeaux_res) )	
			h3dutLoadResourcesFromDisk( filedir );
	}

	H3DNode node = h3dAddNodes( eye->getHordeID(), m_gazeaux_res);
	return Joint::getInstance(node);
}
Exemplo n.º 2
0
/**
 * generates a model node based on a minimal geometry resource and attaches it to the joint eye
 */
Joint* Gaze::createGazeAux(Joint* eye)
{
	if(m_gazeaux_res == 0)
	{
		m_gazeaux_res = h3dAddResource(H3DResTypes::Geometry, "_gazeaux_geo",0);
		if( !h3dIsResLoaded(m_gazeaux_res) )	
			if(!loadGazeAuxRes(m_gazeaux_res))
				GameLog::errorMessage( "IKComponent: failed to load gazeaux resource" );
	}

	H3DNode node = h3dAddModelNode( eye->getHordeID(), "_gazeaux_", m_gazeaux_res);
	return Joint::getInstance(node);
}
Exemplo n.º 3
0
bool Animation::loadFile(Agent_Gender::List gender)
{
	m_file = m_data->getFile(gender);
	std::string filename(m_file->getFilename());

	int resource = h3dAddResource( H3DResTypes::Animation, m_file->getFilename(), 0 );
	if(h3dIsResLoaded(resource))
	{
		// if the resource is already loaded, we'll create a duplicate for this animation to use
		resource = h3dCloneResource(resource, 0);
		setResource(resource);
		return true;
	}

	//find animation path
	std::string path = h3dutGetResourcePath(H3DResTypes::Animation);		
	if ( path.size() > 0 && path[path.size()-1] != '\\' && path[path.size()-1] != '/' )
		path += '/';

	//Open file
	std::ifstream inf( (path + filename).c_str(), std::ios::binary );
	if( inf ) // Resource file found
	{
		// Find size of resource file
		inf.seekg( 0, std::ios::end );
		const int size = inf.tellg();
		// Copy resource file to memory
		char *data = new char[size + 1];
		inf.seekg( 0 );
		inf.read( data, size );
		inf.close();
		// Null-terminate buffer - this is important for XML parsers 
		data[size] = '\0';		
		
		// Load Resource
		h3dLoadResource( resource, data, size );
		setResource(resource);

		delete[] data;
		data = 0;

		return true;
	}
	else
	{
		//file not found
		GameLog::errorMessage( "Animation %s failed to load - file not found", m_file->getFilename() );
		return false;
	}
}
Exemplo n.º 4
0
void unbindSampler(const char* sampler_name)
{
    const char* res_name = _mat_builder->getSamplerRes(sampler_name);
    _mat_builder->removeSampler(sampler_name);
    _mat_builder->build();
    if(res_name != nullptr)
    {
        H3DRes res = h3dFindResource(H3DResTypes::Texture, res_name);
        if(res != 0)
        {
            TextureManager::removeResource(res);
            if(h3dIsResLoaded(res))
                h3dUnloadResource(res);
            h3dRemoveResource(res);
        }
    }
    dumpMessages();
}
Exemplo n.º 5
0
void bindSampler(int tex, const char* sampler_name)
{
    const char* res_name = _mat_builder->getSamplerRes(sampler_name);
    if(res_name != nullptr)
    {
        H3DRes res = h3dFindResource(H3DResTypes::Texture, res_name);
        if(res != 0)
        {
            TextureManager::removeResource(res);
            if(h3dIsResLoaded(res))
                h3dUnloadResource(res);
            h3dRemoveResource(res);
        }
    }
    H3DRes res = TextureManager::getTexRes(tex);
    res_name = h3dGetResName(res);
    _mat_builder->setSampler(sampler_name, res_name);
    _mat_builder->build();
    dumpMessages();
}