QTerrainNode::~QTerrainNode()
{
	if (m_heightMapID != 0)
		h3dRemoveResource(m_heightMapID);
	if (m_materialID != 0)
		h3dRemoveResource(m_materialID);
}
QEmitterNode::~QEmitterNode()
{
	if (m_matResource != 0)
		h3dRemoveResource(m_matResource);
	if (m_effectResource != 0)
		h3dRemoveResource(m_effectResource);
}
CheckBox::~CheckBox(void)
{
	for (int i = 0; i < 4; i++) {
		if (checkedTex[i] != -1)
		h3dRemoveResource(checkedTex[i]);

		if (uncheckedTex[i] != -1)
		h3dRemoveResource(uncheckedTex[i]);
	}
}
示例#4
0
Slider::~Slider(void)
{
	delete button;

	if (disabledTex != -1)
	h3dRemoveResource(disabledTex);

	if (normalTex != -1)
	h3dRemoveResource(normalTex);

	if (highlightTex != -1)
	h3dRemoveResource(highlightTex);
}
示例#5
0
Button::~Button(void)
{
	if (disabledTex != -1)
	h3dRemoveResource(disabledTex);

	if (pressedTex != -1)
	h3dRemoveResource(pressedTex);

	if (normalTex != -1)
	h3dRemoveResource(normalTex);

	if (highlightTex != -1)
	h3dRemoveResource(highlightTex);
}
示例#6
0
Cursor::~Cursor(void)
{
	if (actionTex != -1)
	h3dRemoveResource(actionTex);

	if (moveTex != -1)
	h3dRemoveResource(moveTex);

	if (normalTex != -1)
	h3dRemoveResource(normalTex);

	if (actualTex != -1)
	h3dRemoveResource(actualTex);
}
示例#7
0
void SceneGraphComponent::unloadTerrainGeoRes()
{
	if( m_terrainGeoRes != 0 )
	{
		h3dRemoveResource( m_terrainGeoRes );
		h3dReleaseUnusedResources();
		m_terrainGeoRes = 0;
	}
}
void QTerrainNode::setHeightMap(const Texture& heightMap)
{
	if (signalsBlocked())
	{
		m_xmlNode.setAttribute("heightmap", heightMap.FileName);
		h3dRemoveResource(m_heightMapID);
		m_heightMapID = h3dAddResource( H3DResTypes::Texture, qPrintable(heightMap.FileName), 0 );		
		h3dutLoadResourcesFromDisk(".");
		h3dSetNodeParamI(m_hordeID, H3DEXTTerrain::HeightTexResI, m_heightMapID);
	}
	else if (heightMap != QTerrainNode::heightMap())
		m_model->undoStack()->push(new QXmlNodePropertyCommand("Set HeightMap", this, "HeightMap", QVariant::fromValue(heightMap), TerrainHeightMapID));	
}
void QTerrainNode::setMaterial(const Material& material)
{
	if (signalsBlocked())
	{
		m_xmlNode.setAttribute("material", material.FileName);
		h3dRemoveResource(m_materialID);
		m_materialID = h3dAddResource( H3DResTypes::Material, qPrintable(material.FileName), 0 );		
		h3dutLoadResourcesFromDisk(".");
		h3dSetNodeParamI(m_hordeID, H3DEXTTerrain::MatResI, m_materialID);
	}
	else if (material != QTerrainNode::material())
		m_model->undoStack()->push(new QXmlNodePropertyCommand("Set Material", this, "Material", QVariant::fromValue(material), TerrainMaterialID));
}
void QEmitterNode::setEffect(const Effect& effect)
{
	if (signalsBlocked())
	{
		m_xmlNode.setAttribute("particleEffect", effect.FileName);
		if (m_effectResource != 0)
			h3dRemoveResource(m_effectResource);
		m_effectResource = h3dAddResource( H3DResTypes::ParticleEffect, qPrintable(effect.FileName), 0 );
		h3dutLoadResourcesFromDisk(".");
		h3dSetNodeParamI(m_hordeID, H3DEmitter::PartEffResI, m_effectResource);
	}
	else if (effect != QEmitterNode::effect())
		m_model->undoStack()->push(new QXmlNodePropertyCommand("Set Effect", this, "Effect", QVariant::fromValue(effect), EmitterMaterialID));
}
示例#11
0
void QEmitterNode::setMaterial(const Material& material)
{
    if (signalsBlocked())
    {
        m_xmlNode.setAttribute("material", material.FileName);
        if (m_matResource != 0)
            h3dRemoveResource(m_matResource);
        m_matResource = h3dAddResource( H3DResTypes::Material, qPrintable(material.FileName), 0 );
//        h3dutLoadResourcesFromDisk(".");
        SceneEditor::load_h3dres_from_file_qrc(".");
        h3dSetNodeParamI(m_hordeID, H3DEmitter::MatResI, m_matResource);
    }
    else if (material != QEmitterNode::material())
        m_model->undoStack()->push(new QXmlNodePropertyCommand("Set Material", this, "Material", QVariant::fromValue(material), EmitterMaterialID));
}
示例#12
0
文件: h3d.cpp 项目: cewbost/texgen
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();
}
示例#13
0
文件: h3d.cpp 项目: cewbost/texgen
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();
}
示例#14
0
void VideoComponent::closeAvi()
{
	// Stop it first as it might still be playing
	stopAvi();

	// Unload the video if there is already one
	if (m_pgf)
	{
		delete[] m_bgraData;
		m_bgraData = 0x0;
		if (m_hBitmap)
			DeleteObject(m_hBitmap);					// Delete The Device Dependant Bitmap Object
		if (m_pgf)
			AVIStreamGetFrameClose(m_pgf);				// Deallocates The GetFrame Resources
		m_pgf = 0x0;
		if (m_pavi)
			AVIStreamRelease(m_pavi);					// Release The Stream
		AVIFileExit();								// Release The File
		if (m_videoTexture)
		{
			// Remove video texture
			h3dRemoveResource(m_videoTexture);
			// And release it if unused now (should be, else we can't create the same again)
			h3dReleaseUnusedResources();		
			m_videoTexture = 0;
			m_originalSampler = 0;
			m_samplerIndex = 0;
		}
		if (m_hasAudio)
		{
			// Set an empty sound for releasing the old one
			GameEvent clearSound(GameEvent::E_SET_SOUND_FILE, &GameEventData(""), this);
			m_owner->executeEvent(&clearSound);
			m_hasAudio = false;
		}
	}
}
QModelNode::~QModelNode()
{
	if (m_resourceID != 0)
		h3dRemoveResource(m_resourceID);
}
示例#16
0
void HordeResource::free()
{
  int result = h3dRemoveResource(m_handle);
}
//  This function's code is from the RecastDemo project's main.cpp file by Mikko Mononen
void MyRecastDemo::guiRender()
{

	GLdouble proj[16];
	GLdouble model[16];
	GLint view[4];
	glGetDoublev(GL_PROJECTION_MATRIX, proj);
	glGetDoublev(GL_MODELVIEW_MATRIX, model);
	glGetIntegerv(GL_VIEWPORT, view);
		
	GLdouble x, y, z;
	gluUnProject(m_mouseX, m_mouseY, 0.0f, model, proj, view, &x, &y, &z);
	m_rays[0] = (float)x; m_rays[1] = (float)y; m_rays[2] = (float)z;
	gluUnProject(m_mouseX, m_mouseY, 1.0f, model, proj, view, &x, &y, &z);
	m_raye[0] = (float)x; m_raye[1] = (float)y; m_raye[2] = (float)z;


	glDisable(GL_DEPTH_TEST);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0, m_width, 0, m_height);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
		
	glColor4ub(255,255,255,255);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

	m_mouseOverMenu = false;
		
	imguiBeginFrame( m_mouseX,m_mouseY,m_mouseBut,m_mouseScroll );
		
	const char msg[] = "W/S/A/D: move (+ shift)  |  F1: toggle recast gui  |  F2: toggle node names  |  F12: invert mouse";
	imguiDrawText(280, m_height-20, IMGUI_ALIGN_LEFT, msg, imguiRGBA(255,255,255,200));
	
		
	if (m_showMenu)
	{
		if (m_sample)
		{
			m_sample->handleRenderOverlay((double*)proj, (double*)model, (int*)view);

		}

		if (imguiBeginScrollArea("Properties", m_width-250-10, 10, 250, m_height-20, &m_propScroll))
			m_mouseOverMenu = true;

		if (imguiCheck("Show Log", m_showLog))
			m_showLog = !m_showLog;
		if (imguiCheck("Show Tools", m_showTools))
			m_showTools = !m_showTools;

		imguiSeparator();
		imguiLabel("Sample");
		if (imguiButton(m_sampleName))
		{
			if (m_showSample)
			{
				m_showSample = false;
			}
			else
			{
				m_showSample = true;
				m_showConfig = false;
			}
		}
			
		imguiSeparator();
		imguiLabel("Config File");
		if (imguiButton(m_configName))
		{
			if (m_showConfig)
			{
				m_showConfig = false;
			}
			else
			{
				m_showSample = false;
				m_showConfig = true;
				scanDirectory("Content", ".xml", m_files);
			}
		}
		if (m_geom)
		{
			char text[64];
			snprintf(text, 64, "Verts: %.1fk  Tris: %.1fk",
						m_geom->getMesh()->getVertCount()/1000.0f,
						m_geom->getMesh()->getTriCount()/1000.0f);
			imguiValue(text);
		}
		imguiSeparator();

		if (m_geom && m_sample)
		{
			imguiSeparatorLine();
				
			m_sample->handleSettings();

			if (imguiButton("Build"))
			{
				m_ctx.resetLog();
				if (!m_sample->handleBuild())
				{
					m_showLog = true;
					m_logScroll = 0;
				}
				m_ctx.dumpLog("Build log %s:", m_configName);
			}

			imguiSeparator();
		}
			
		if (m_sample)
		{
			imguiSeparatorLine();
			m_sample->handleDebugMode();
		}

		imguiEndScrollArea();
	}
	
	
	// Sample selection dialog.
	if (m_showSample)
	{
		static int levelScroll = 0;
		if (imguiBeginScrollArea("Choose Sample", m_width-10-250-10-200, m_height-10-250, 200, 250, &levelScroll))
			m_mouseOverMenu = true;

		Sample* newSample = 0;
		for (int i = 0; i < g_nsamples; ++i)
		{
			if (imguiItem(g_samples[i].name))
			{
				newSample = g_samples[i].create();
				if (newSample)
					strcpy(m_sampleName, g_samples[i].name);
			}
		}
		if (newSample)
		{
			delete m_geom;
			m_geom = 0;
			delete m_sample;
			m_sample = newSample;
			m_sample->setContext(&m_ctx);
			if (m_geom && m_sample)
			{
				m_sample->handleMeshChanged(m_geom);
			}
			else if(!m_geom)
			{
				m_geom = new InputGeom();
				m_geom->loadMesh( &m_ctx, m_configXmlFile.c_str() );
			}
			if( m_geom && m_sample )
			{
				m_sample->handleMeshChanged(m_geom);
				m_sample->handleSettings();
			}

			m_showSample = false;
		}			
		imguiEndScrollArea();
	}

	// Config selection dialog.
	if (m_showConfig)
	{
		static int levelScroll = 0;
		if (imguiBeginScrollArea("Choose Config File", m_width-10-250-10-200, m_height-10-450, 200, 450, &levelScroll))
			m_mouseOverMenu = true;
			
		int levelToLoad = -1;
		for (int i = 0; i < m_files.size; ++i)
		{
			if (imguiItem(m_files.files[i]))
				levelToLoad = i;
		}
			
		if (levelToLoad != -1)
		{
			strncpy(m_configName, m_files.files[levelToLoad], sizeof(m_configName));
			m_configName[sizeof(m_configName)-1] = '\0';
			m_showConfig = false;
				
			delete m_geom;
			m_geom = 0;
				
			char path[256];
			strcpy(path, "Content/");
			strcat(path, m_configName);
			
			m_configXmlFile = path;

			m_geom = new InputGeom();

			if( m_loadedSceneGraphRes )
			{
				// Remove previously loaded scene .
				// Every scene.xml file loaded should group its children in a GroupNode.
				int nrFoundNodes = h3dFindNodes( H3DRootNode, "", H3DNodeTypes::Group);
				for( int i = 0; i<2; ++i )
				{
					int node = h3dGetNodeFindResult(i);
					const char* name = h3dGetNodeParamStr( node, H3DNodeParams::NameStr);
					std::string camName(name);
					// Do not delete nodes directly under the root node (e.g. the demo's camera)
					if( camName.compare("RootNode") != 0) 
					{
						h3dRemoveNode( h3dGetNodeFindResult(i) );
					}
				}
				
				int a =	h3dRemoveResource( m_loadedSceneGraphRes );
				h3dReleaseUnusedResources();
			}

			if( !loadSceneFileFromConfig( path) )
			{
				m_showLog = true;
				m_logScroll = 0;
				m_ctx.log(RC_LOG_ERROR, "Error loading resources from specified scene file.");
			}

			if (!m_geom || !m_geom->loadMesh(&m_ctx, m_configXmlFile.c_str()) )
			{
				delete m_geom;
				m_geom = 0;
					
				m_showLog = true;
				m_logScroll = 0;
				m_ctx.log(RC_LOG_ERROR, "Error loading nav mesh geometry from: \"%s\"", m_configName);
				m_ctx.dumpLog("Config: Geom load log %s:", m_configName);
			}
			if (m_sample && m_geom)
			{
				m_sample->handleMeshChanged(m_geom);
			}
		}
			
		imguiEndScrollArea();
			
	}

	// Log
	if (m_showLog && m_showMenu)
	{
		if (imguiBeginScrollArea("Log", 250+20, 10, m_width - 300 - 250, 200, &m_logScroll))
			m_mouseOverMenu = true;
		for (int i = 0; i < m_ctx.getLogCount(); ++i)
			imguiLabel(m_ctx.getLogText(i));
		imguiEndScrollArea();
	}
		
	// Tools
	if (!m_showTestCases && m_showTools && m_showMenu) // && m_geom && m_sample)
	{
		if (imguiBeginScrollArea("Tools", 10, 10, 250, m_height-20, &m_toolsScroll))
			m_mouseOverMenu = true;

		if (m_sample)
			m_sample->handleTools();
			
		imguiEndScrollArea();
	}

	m_wasMouseOverMenu = m_mouseOverMenu;
	if(!m_wasMouseOverMenu)
	{
		// In case we move a GUI slider and leave the menu area
		m_mouseBut = 0;
	}
	m_mouseScroll = 0;
	
	imguiEndFrame();
	
	imguiRenderGLDraw();

	glDisable(GL_BLEND);
	glEnable(GL_DEPTH_TEST);
}