Esempio n. 1
0
File: Ase.cpp Progetto: RinM/CGA
void CLoadASE::GetTextureInfo (tMaterialInfo *pTexture, int desiredMaterial)
{
	char strWord[255] = {0};
	int materialCount= 0;
	
	rewind(m_FilePointer);

	while (!feof(m_FilePointer))
	{
		fscanf(m_FilePointer, "%s", &strWord);

		if (!strcmp(strWord, MATERIAL))
		{
			materialCount++;

			if(materialCount == desiredMaterial)
				break;
		}
		else
		{
			fgets(strWord, 100, m_FilePointer);
		}
	}

	while (!feof(m_FilePointer))
	{
		fscanf(m_FilePointer, "%s", &strWord);

		if (!strcmp (strWord, MATERIAL))
		{
			return;
		}
		else if (!strcmp(strWord, MATERIAL_COLOR))
		{
			fscanf(m_FilePointer, " %f %f %f", &(pTexture->fColor[0]), 
											   &(pTexture->fColor[1]), 
											   &(pTexture->fColor[2]));
		}
		else if (!strcmp(strWord, TEXTURE))
		{
			GetTextureName(pTexture);
		}
		else if (!strcmp(strWord, MATERIAL_NAME))
		{
			GetMaterialName(pTexture);
		}
		else if(!strcmp(strWord, UTILE))
		{
			pTexture->uTile = ReadFloat();
		}
		else if(!strcmp(strWord, VTILE))
		{
			pTexture->vTile = ReadFloat();
		}
		else
		{
			fgets (strWord, 100, m_FilePointer);
		}
	}
}
Esempio n. 2
0
//
// D3DSkyNode11::VRender						- Chapter 16, page 559
//
HRESULT D3DSkyNode11::VRender(Scene *pScene)
{
	HRESULT hr;

	V_RETURN (m_D3D11VertexShader.SetupRender(pScene, this));
	V_RETURN (m_D3D11PixelShader.SetupRender(this));
	V_RETURN (m_D3D11VertexBuffer.SetupRender());

    // Set primitive topology
    g_pDX11W->GetD3D11DeviceContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

	for (DWORD side = 0; side < m_sides; side++)
	{
		// FUTURTE WORK: A good optimization would be to transform the camera's
		// world look vector into local space, and do a dot product. If the
		// result is positive, we shouldn't draw the side since it has to be
		// behind the camera!

		// Sky boxes aren't culled by the normal mechanism

		/***
		// [mrmike] - This was slightly changed post press, look at the lines below this commented out code
		const char *suffix[] = { "_n.jpg", "_e.jpg",  "_s.jpg",  "_w.jpg",  "_u.jpg" };
		name += suffix[side];
		****/

		std::string name = GetTextureName(side);
		m_D3D11PixelShader.SetTexture(name.c_str());

		g_pDX11W->GetD3D11DeviceContext()->DrawIndexed(6, side * 6, 0);
	}
	return S_OK;
}
Esempio n. 3
0
static int WriteSIDEDEFS (FILE *file)
{
	mapsidedef_t msd;

	for (int i = 0; i < numsides; ++i)
	{
		msd.textureoffset = LittleShort(short(sides[i].GetTextureXOffset(side_t::mid) >> FRACBITS));
		msd.rowoffset = LittleShort(short(sides[i].GetTextureYOffset(side_t::mid) >> FRACBITS));
		msd.sector = LittleShort(short(sides[i].sector - sectors));
		uppercopy (msd.toptexture, GetTextureName (sides[i].GetTexture(side_t::top)));
		uppercopy (msd.bottomtexture, GetTextureName (sides[i].GetTexture(side_t::bottom)));
		uppercopy (msd.midtexture, GetTextureName (sides[i].GetTexture(side_t::mid)));
		fwrite (&msd, sizeof(msd), 1, file);
	}
	return numsides * sizeof(msd);
}
HRESULT D3DSkyNode9::Render(Scene* pScene)
{
	// blend the texture with the color of the vertices

	DXUTGetD3D9Device()->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
	DXUTGetD3D9Device()->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
	DXUTGetD3D9Device()->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);

	DXUTGetD3D9Device()->SetStreamSource(0, m_pVerts, 0, sizeof(D3D9Vertex_ColoredTextured));
	DXUTGetD3D9Device()->SetFVF(D3D9Vertex_ColoredTextured::FVF);

	for (DWORD side = 0; side < m_Sides; side++)
	{
		std::string name = GetTextureName(side);

		Resource resource(name);
		shared_ptr<ResHandle> texture = g_pApp->m_ResCache->GetHandle(&resource);
		shared_ptr<D3DTextureResourceExtraData9> extra = static_pointer_cast<D3DTextureResourceExtraData9>(texture->GetExtra());
		
		DXUTGetD3D9Device()->SetTexture(0, extra->GetTexture());
		DXUTGetD3D9Device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 4 * side, 2);
	}

	DXUTGetD3D9Device()->SetTexture(0, NULL);
	return S_OK;
}
Esempio n. 5
0
static int WriteSECTORS (FILE *file)
{
	mapsector_t ms;

	for (int i = 0; i < numsectors; ++i)
	{
		ms.floorheight = LittleShort(short(sectors[i].GetPlaneTexZF(sector_t::floor)));
		ms.ceilingheight = LittleShort(short(sectors[i].GetPlaneTexZF(sector_t::ceiling)));
		uppercopy (ms.floorpic, GetTextureName (sectors[i].GetTexture(sector_t::floor)));
		uppercopy (ms.ceilingpic, GetTextureName (sectors[i].GetTexture(sector_t::ceiling)));
		ms.lightlevel = LittleShort((short)sectors[i].lightlevel);
		ms.special = LittleShort(sectors[i].special);
		ms.tag = LittleShort(tagManager.GetFirstSectorTag(&sectors[i]));
		fwrite (&ms, sizeof(ms), 1, file);
	}
	return numsectors * sizeof(ms);
}
Esempio n. 6
0
iTextureWrapper* Lightmap::GetTexture()
{
    if (texture == 0)
    {
        texture = globalLighter->engine->CreateBlackTexture (
                      GetTextureName(), 1, 1, 0, CS_TEXTURE_3D);
    }
    return texture;
}
Esempio n. 7
0
void CSkyClouds::Prep ()
{

	//
	// Load the texture
	//

	const char *pszTexture = GetTextureName ();
	SetTextureIndex (g_sTextureManager .FindNormalN (pszTexture));
}
Esempio n. 8
0
//
// D3DSkyNode9::VRender				- Chapter 14, page 502
//
HRESULT D3DSkyNode9::VRender(Scene *pScene)
{

	// Setup our texture. Using textures introduces the texture stage states,
    // which govern how textures get blended together (in the case of multiple
    // textures) and lighting information. In this case, we are modulating
    // (blending) our texture with the diffuse color of the vertices.

    DXUTGetD3D9Device()->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
    DXUTGetD3D9Device()->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
    DXUTGetD3D9Device()->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );

	DXUTGetD3D9Device()->SetStreamSource( 0, m_pVerts, 0, sizeof(D3D9Vertex_ColoredTextured) );
	DXUTGetD3D9Device()->SetFVF( D3D9Vertex_ColoredTextured::FVF );

	for (DWORD side = 0; side < m_sides; side++)
	{
		// FUTURE WORK: A good optimization would be to transform the camera's
		// world look vector into local space, and do a dot product. If the
		// result is positive, we shouldn't draw the side since it has to be
		// behind the camera!

		// Sky boxes aren't culled by the normal mechanism

		std::string name = GetTextureName(side);

		/***
		// [mrmike] - This was slightly changed post press, look at the lines below this commented out code
		const char *suffix[] = { "_n.jpg", "_e.jpg",  "_s.jpg",  "_w.jpg",  "_u.jpg" };
		name += suffix[side];
		****/
		
		Resource resource(name);
		shared_ptr<ResHandle> texture = g_pApp->m_ResCache->GetHandle(&resource);
		shared_ptr<D3DTextureResourceExtraData9> extra = static_pointer_cast<D3DTextureResourceExtraData9>(texture->GetExtra());

		DXUTGetD3D9Device()->SetTexture( 0, extra->GetTexture() );
		DXUTGetD3D9Device()->DrawPrimitive( D3DPT_TRIANGLESTRIP , 4 * side, 2);
	}

	DXUTGetD3D9Device()->SetTexture (0, NULL);
	return S_OK;
}