Beispiel #1
0
//Loads a model with a given file name and texture.
void cModelLoader::loadModel(const char* mdlFilename, cTexture mdlTexture)
{
	m_model = glmReadOBJ(mdlFilename);
	glmUnitize(m_model);
	glmFacetNormals(m_model);
	glmVertexNormals(m_model, 180.0f,false);
	m_TextureID = mdlTexture.getTexture();

	m_model->textures[m_model->numtextures - 1].id = m_TextureID;
	m_model->textures[m_model->numtextures - 1].width = mdlTexture.getTWidth();
	m_model->textures[m_model->numtextures - 1].height = mdlTexture.getTHeight();
}
Beispiel #2
0
void cSphere::initialise(cTexture theTexture)
{
	quad = gluNewQuadric();

	gluQuadricDrawStyle(quad, GLU_FILL);
	gluQuadricNormals(quad, GLU_SMOOTH);
	gluQuadricTexture(quad, GL_TRUE);

	glBindTexture(GL_TEXTURE_2D, theTexture.getTexture());

}
Beispiel #3
0
void ovlFLICManager::AddTexture(const cTexture& item) {
    Check("ovlFLICManager::AddTexture");
    item.Check();

    unsigned long index;
    if (m_btbl) {
        index = m_btbl->AddTexture(item);
    } else {
        index = m_items.size();
    }
    m_items[index] = item;
    m_itemmap[item.name] = index;

    // FlicStruct and a pointer. Rest goes to extradata
    m_size += sizeof(Flic); //sizeof(FlicStruct) + 4;

    //GetLSRManager()->AddLoader(OVLT_COMMON);
	cLoader& loader = GetLSRManager()->reserveIndexElement(OVLT_COMMON, ovlFLICManager::TAG);
	loader.identify(item.name);
}
Beispiel #4
0
HRESULT cMyHost::InitDeviceObjects()
{
	cGameHost::InitDeviceObjects();

	// generate a random height map
	m_pHeightMap = 
		displayManager()
		.texturePool()
		.createResource(cString("height map"));
	m_pHeightMap->createTexture(
		256, 256, 
		1, 0, 
		D3DFMT_A8R8G8B8, 
		D3DPOOL_MANAGED);
	m_pHeightMap->generatePerlinNoise(
		0.03f, 5, 0.6f);

	// create a terrain from this map
	m_terrainSystem.create(
		&rootNode(), 
		m_pHeightMap, 
		worldExtents(), 
		3);

	// load our render method
	m_pRenderMethod = 
		TheGameHost
		.displayManager()
		.renderMethodPool()
		.createResource("terrain method");
	m_pRenderMethod->loadEffect(
		0, "media\\shaders\\simple_terrain.fx");
	m_pRenderMethod->loadEffect(
		1, "media\\shaders\\simple_terrain_ambient.fx");
	m_pRenderMethod->loadEffect(
		2, "media\\shaders\\simple_terrain_bump.fx");
	m_pRenderMethod->loadEffect(
		3, "media\\shaders\\simple_terrain_sunlight.fx");

	// generate three elevation structures
    cTerrain::elevationData elevation[3];

	// grass (all elevations and slopes)
	elevation[0].minElevation = -500;
	elevation[0].maxElevation = 1000;
	elevation[0].minNormalZ = -1.0f;
	elevation[0].maxNormalZ = 1.0f;
	elevation[0].strength = 1.0f;

	// rock (all elevations, steep slopes)
	elevation[1].minElevation = 0;
	elevation[1].maxElevation = 1500;
	elevation[1].minNormalZ = 0.0f;
	elevation[1].maxNormalZ = 0.85f;
	elevation[1].strength = 10.0f;

	// dirt (high elevation, flat slope)
	elevation[2].minElevation = 800;
	elevation[2].maxElevation = 1500;
	elevation[2].minNormalZ = 0.75f;
	elevation[2].maxNormalZ = 1.0f;
	elevation[2].strength = 20.0f;

	// generate the blend image
	cImage* pBlendImage;
	pBlendImage = 
		displayManager()
		.imagePool()
		.createResource(cString("image map 3"));
	pBlendImage->create(
		256, 
		256, 
		cImage::k_32bit);

	m_terrainSystem.generateBlendImage(
		pBlendImage, 
		elevation, 3);

	pBlendImage->randomChannelNoise(3, 200, 255);

	// upload the blend image to a texture
	m_pBlendMap = 
		displayManager()
		.texturePool()
		.createResource(cString("image map"));
	
	m_pBlendMap->createTexture(
		256, 256, 
		1, 0, 
		D3DFMT_A8R8G8B8, 
		D3DPOOL_MANAGED);

	m_pBlendMap->uploadImage(pBlendImage);

	// now convert the blend image to
	// a mask for bump-mapping. First, clear
	// the alpha channel back to zero
	pBlendImage->setChannel(3,0);
	pBlendImage->convertToBumpMask();

	// create the bump mask 
	// texture and upload
	m_pBumpMask = 
		displayManager()
		.texturePool()
		.createResource(cString("image mask"));
	
	m_pBumpMask->createTexture(
		256, 256, 
		1, 0, 
		D3DFMT_A8R8G8B8, 
		D3DPOOL_MANAGED);

	m_pBumpMask->uploadImage(pBlendImage);

	// we are now done with the blend image
	safe_release(pBlendImage);

	// load the ground surface materials

	// create a surface material
	// and load our textures into it
	m_pColorMaterial = 
		displayManager()
		.surfaceMaterialPool()
		.loadResource("media\\materials\\terrain.mat");
	m_pColorMaterial->setTexture(0, m_pBlendMap);

	m_pBumpMaterial = 
		displayManager()
		.surfaceMaterialPool()
		.loadResource("media\\materials\\terrain_bump.mat");
	m_pBumpMaterial->setTexture(0, m_pBumpMask);

	m_pRenderMethod->setMaterial(
		0, m_pColorMaterial);
	m_pRenderMethod->setMaterial(
		1, m_pColorMaterial);
	m_pRenderMethod->setMaterial(
		2, m_pBumpMaterial);
	m_pRenderMethod->setMaterial(
		3, m_pColorMaterial);

	// give the final render method to the terrain
	m_terrainSystem.setRenderMethod(m_pRenderMethod);

	// generate the sky box
	m_skyDome.create(cSkyModel::k_hemisphere);
	m_cloudLayer.create(cSkyModel::k_dome);

	m_pSkyMethod = 
		TheGameHost
		.displayManager()
		.renderMethodPool()
		.createResource("sky box method");
	m_pSkyMethod->loadEffect(
		cRenderMethod::k_defaultMethod,
		"media\\shaders\\sunlit_skydome.fx");

	
	m_pCloudMethod = 
		TheGameHost
		.displayManager()
		.renderMethodPool()
		.createResource("sky cloud method");
	m_pCloudMethod->loadEffect(
		cRenderMethod::k_defaultMethod,
		"media\\shaders\\animated_clouds.fx");

	m_pSkyClouds = 
		TheGameHost
		.displayManager()
		.texturePool()
		.createResource("sky cloud texture");
	m_pSkyClouds->loadResource("media\\textures\\clouds.dds");

	m_pSkyMaterial = 
		TheGameHost
		.displayManager()
		.surfaceMaterialPool()
		.createResource("sky box material");
	m_pSkyMaterial->setTexture(0, m_pSkyClouds);

	m_pCloudMethod->setMaterial(
		0, m_pSkyMaterial);
	
	m_skyDome.setRenderMethod(m_pSkyMethod);
	m_cloudLayer.setRenderMethod(m_pCloudMethod);

	// force-update the camera to make sure
	// we start above the terrain
	defaultCamera().update();
	updateCamera(
		10.0f, 
		0.1f, 
		&m_terrainSystem,
		75.0f, 
		true); //<- true forces an update


	m_lensFlare.create();

	return S_OK;
}
void cStarfield::initialise(cTexture theTexture)
{
	srand((unsigned)time(NULL));
	glBindTexture(GL_TEXTURE_2D, theTexture.getTexture());
}
Beispiel #6
0
HRESULT cMyHost::InitDeviceObjects()
{
	cGameHost::InitDeviceObjects();

	// generate a random height map
	m_pHeightMap = 
		displayManager()
		.texturePool()
		.createResource(cString("height map"));
	m_pHeightMap->createTexture(
		128, 128, 
		1, 0, 
		D3DFMT_A8R8G8B8, 
		D3DPOOL_MANAGED);
	m_pHeightMap->generatePerlinNoise(
		0.01f, 5, 0.6f);

	// create a terrain from this map
	m_terrainSystem.create(
		&rootNode(), 
		m_pHeightMap, 
		worldExtents(), 
		3);

	// load our render method
	m_pRenderMethod = 
		TheGameHost
		.displayManager()
		.renderMethodPool()
		.createResource("terrain method");
	m_pRenderMethod->loadEffect(
		cRenderMethod::k_defaultMethod,
		"media\\shaders\\simple_terrain.fx");

	// generate three elevation structures
    cTerrain::elevationData elevation[3];

	// grass (all elevations and slopes)
	elevation[0].minElevation = 0;
	elevation[0].maxElevation = 500;
	elevation[0].minNormalZ = -1.0f;
	elevation[0].maxNormalZ = 1.0f;
	elevation[0].strength = 1.0f;

	// rock (all elevations, steep slopes)
	elevation[1].minElevation = 0;
	elevation[1].maxElevation = 500;
	elevation[1].minNormalZ = 0.0f;
	elevation[1].maxNormalZ = 0.85f;
	elevation[1].strength = 10.0f;

	// dirt (high elevation, flat slope)
	elevation[2].minElevation = 300;
	elevation[2].maxElevation = 500;
	elevation[2].minNormalZ = 0.75f;
	elevation[2].maxNormalZ = 1.0f;
	elevation[2].strength = 20.0f;

	// generate the blend image
	cImage* pBlendImage;
	pBlendImage = 
		displayManager()
		.imagePool()
		.createResource(cString("image map 3"));
	pBlendImage->create(
		256, 
		256, 
		cImage::k_32bit);

	m_terrainSystem.generateBlendImage(
		pBlendImage, 
		elevation, 3);

	pBlendImage->randomChannelNoise(3, 200, 255);

	// upload the blend image to a texture
	m_pBlendMap = 
		displayManager()
		.texturePool()
		.createResource(cString("image map"));
	
	m_pBlendMap->createTexture(
		256, 256, 
		1, 0, 
		D3DFMT_A8R8G8B8, 
		D3DPOOL_MANAGED);

	m_pBlendMap->uploadImage(pBlendImage);
	safe_release(pBlendImage);

	// load the ground surface textures
	m_pGrass = 
		displayManager()
		.texturePool()
		.createResource(cString("grass"));
	m_pRock = 
		displayManager()
		.texturePool()
		.createResource(cString("rock"));
	m_pDirt = 
		displayManager()
		.texturePool()
		.createResource(cString("dirt"));

	m_pGrass->loadResource(
		"media\\textures\\grass.dds");
	m_pRock->loadResource(
		"media\\textures\\rock.dds");
	m_pDirt->loadResource(
		"media\\textures\\dirt.dds");

	// create a surface material
	// and load our textures into it
	m_pSurfaceMaterial = 
		displayManager()
		.surfaceMaterialPool()
		.createResource(cString("ground material"));
	m_pSurfaceMaterial->setTexture(0, m_pBlendMap);
	m_pSurfaceMaterial->setTexture(1, m_pGrass);
	m_pSurfaceMaterial->setTexture(2, m_pRock);
	m_pSurfaceMaterial->setTexture(3, m_pDirt);

	// give the render method and material to the terrain
	m_pRenderMethod->setMaterial(0, m_pSurfaceMaterial);
	m_terrainSystem.setRenderMethod(m_pRenderMethod);

	// force-update the camera to make sure
	// we start above the terrain
	defaultCamera().update();
	updateCamera(
		10.0f, 
		0.1f, 
		&m_terrainSystem,
		30.0f, 
		true); //<- true forces an update

	return S_OK;
}