Esempio n. 1
0
QString RouteMetadata::toString() const
{
	return QString("RouteMetadata %1 : %2 => %3")
					.arg(getName())
					.arg(getGUID())
					.arg(getTextureName()) ;
}
Esempio n. 2
0
/**
loads specified mesh from file. If loading of 3 uvs is selected then layer of atlas is

*/
InternalMeshInfo ModelLoader::load(const std::string &name){
	if(not scene){
		error("No scene for ModelLoader");
		hardPause();
		return {};
	}
	InternalMeshInfo info {(u32)vertex.size(), (u32)texcoord.size(), (u32)normal.size(), (u32)tangent.size(), (u32)indices.size()};

	auto meshes = find(name);
	if(meshes.empty()){
		error("no mesh:", name);
		return {};
	}
	for(auto mesh : meshes){
		InternalMeshInfo subinfo {(u32)vertex.size(), (u32)texcoord.size(), (u32)normal.size(), (u32)tangent.size(), (u32)indices.size()};
		copyIndices(mesh);
		copyVertices(mesh);
		copyTexcoords(mesh);
		copyNormals(mesh);
		copyTangents(mesh);

		info.count = indices.size() - info.iID;
		info.vertexCount = (vertex.size() - info.vID)/4;
		subinfo.count = indices.size() - subinfo.iID;
		subinfo.vertexCount = (vertex.size() - subinfo.vID)/4;
		if(getLayer) setTextureLayer(subinfo, getLayer(getTextureName(mesh)));
	}
	return info;
}
Esempio n. 3
0
HRESULT RSManager::redirectDrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
	if(hudStarted && hideHud) {
		IDirect3DBaseTexture9 *t;
		d3ddev->GetTexture(0, &t);
		bool hide = isTextureText(t);
		hide = hide || isTextureButtonsEffects(t);
		hide = hide || isTextureHudEffectIcons(t);
		t->Release();
		if(hide) return D3D_OK;
	}
	if(pausedHudRT) {
		IDirect3DBaseTexture9 *t;
		d3ddev->GetTexture(0, &t);
		bool isText = isTextureText(t);
		SDLOG(4, "On HUD, PAUSED, redirectDrawPrimitiveUP texture: %s\n", getTextureName(t));
		t->Release();
		//// Print vertices
		//SDLOG(0, "Vertices: \n");
		//INT16 *values = (INT16*)pVertexStreamZeroData;
		//for(size_t i=0; i<PrimitiveCount+2; ++i) {
		//	SDLOG(0, "%8hd, ", values[i]);
		//	if((i+1)%2 == 0) SDLOG(0, "; ");
		//	if((i+1)%8 == 0) SDLOG(0, "\n");
		//}
		if(isText && PrimitiveCount >= 12) resumeHudRendering();
	}
	bool subbed = false;
	if(onHudRT) {
		IDirect3DBaseTexture9 *t;
		d3ddev->GetTexture(0, &t);
		bool isText = isTextureText(t);
		bool isSub = isTextureText00(t);
		SDLOG(4, "On HUD, redirectDrawPrimitiveUP texture: %s\n", getTextureName(t));
		t->Release();
		//if(isText && PrimitiveCount <= 10) pauseHudRendering();
		if(isSub) {
			pauseHudRendering();
			subbed = true;
		}
	}
	HRESULT hr = d3ddev->DrawPrimitiveUP(PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
	if(subbed) resumeHudRendering();
	//if(onHudRT) {
	//	if(takeScreenshot) dumpSurface("HUD_PrimUP", rgbaBuffer1Surf);
	//}
	return hr;
}
Cursor::Cursor(ResourceManager& resourceManager, const sf::RenderWindow& screen)
    : m_screen(screen)
{
    auto sheet = resourceManager.getSpriteSheet(SHEET_NAME);
    auto iconSprite = sheet->get(SPRITE_NAME);
    m_sprite.setTexture(*resourceManager.getTexture(sheet->getTextureName()));
    m_sprite.setTextureRect(sf::IntRect(iconSprite.x, iconSprite.y, iconSprite.width, iconSprite.height));
}
Esempio n. 5
0
void Block::Draw(long posX, long posY, App &app, TextureContainer &tC, unsigned short metadata)
{
	sf::Sprite *&&tempSprite = &(tC.getTextures(getTextureName())[getTextureId(app, metadata)]);
	if (tempSprite != nullptr)
	{
		tempSprite->setPosition(posX, posY);
		app.draw(*tempSprite);
	}
}
Esempio n. 6
0
	void VertexBuffer::doRender(RenderManager* _renderManager)
	{
		if (mRenderMode == RenderModeFilterNone)
		{
			if (_renderManager->getCurrentManual())
				_renderManager->initState();

			_renderManager->setCurrentManual(true);

			_renderManager->getRenderSystem()->_setTexture(0, true, getTextureName());
			_renderManager->getRenderSystem()->_setTextureUnitFiltering(0, Ogre::FO_NONE, Ogre::FO_NONE, Ogre::FO_NONE);

			_renderManager->getRenderSystem()->_render(getRenderOperation());
		}
		else if (mRenderMode == RenderModePolygonWireframe)
		{
			if (_renderManager->getCurrentManual())
				_renderManager->initState();

			_renderManager->setCurrentManual(true);

			_renderManager->getRenderSystem()->_setTexture(0, true, getTextureName());
			_renderManager->getRenderSystem()->_setPolygonMode(Ogre::PM_WIREFRAME);
			_renderManager->getRenderSystem()->_setTextureUnitFiltering(0, Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_POINT);

			_renderManager->getRenderSystem()->_render(getRenderOperation());
		}
		else
		{
			if (_renderManager->getCurrentManual())
			{
				_renderManager->initState();
				_renderManager->setCurrentManual(false);
			}

			_renderManager->getRenderSystem()->_setTexture(0, true, getTextureName());
			_renderManager->getRenderSystem()->_setTextureUnitFiltering(0, Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_POINT);

			_renderManager->getRenderSystem()->_render(getRenderOperation());
		}
	}
Esempio n. 7
0
	bool TextureManager::_updateNormalMap(Image &Image)
	{
		if (!mCreated)
		{
			HydraxLOG("Error in TextureManager::_updateNormalMap, create() does not called.");

			return false;
		}

		if (Image.getType() != Image::TYPE_RGB)
		{
			HydraxLOG("Error in TextureManager::_updateNormalMap, Image type isn't correct.");

			return false;
		}

		Ogre::TexturePtr &Texture = getTexture(TEX_NORMAL_ID);

		Size ImageSize = Image.getSize();
		
		if (Texture->getWidth()  != ImageSize.Width ||
			Texture->getHeight() != ImageSize.Height)
		{
			HydraxLOG("Error in TextureManager::update, Update size doesn't correspond to " + getTextureName(TEX_NORMAL_ID) + " texture size");

			return false;
		}

		Ogre::HardwarePixelBufferSharedPtr pixelBuffer = Texture->getBuffer();

        pixelBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
        const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();

        Ogre::uint8* pDest = static_cast<Ogre::uint8*>(pixelBox.data);

        int x, y;

        for (x = 0; x < ImageSize.Width; x++)
        {
            for (y = 0; y < ImageSize.Height; y++)
            {
                *pDest++ =   Image.getValue(x,y,2); // B
                *pDest++ =   Image.getValue(x,y,1); // G
                *pDest++ =   Image.getValue(x,y,0); // R
				*pDest++ =   255;                   // A
            }
        }

        pixelBuffer->unlock();

		return true;
	}
Esempio n. 8
0
void GameObject::init(){
    std::ostringstream texturePath;
    texturePath << "img/" << getTextureName();

    std::cout << texturePath.str() << std::endl;

    gTexture = lTextureFactory->fetchTexture(texturePath.str(), true);

    width = gTexture->getWidth();
    height = gTexture->getHeight();
    initRectangle(clip, width, height);
    initRectangle(dyingClipRect, width, height);
}
Esempio n. 9
0
void Creature::Draw(sf::RenderWindow &app, TextureContainer &tc)
{
	sf::Sprite *sprite = &(tc.getTextures(spriteName)[spriteIndex]);
	if (sprite != NULL)
	{
		sprite->SetPosition(sf::Vector2f(x, y));
		sprite->SetRotation(angle);
		app.Draw(*sprite);
	}
	else
	{
		std::cout << "'" << getTextureName() << "' not found!" << std::endl;
	}
}
Esempio n. 10
0
void Unit::displayOnScreen(int x, int y){    
    
    CIwMaterial *mat = new CIwMaterial();
	mat->SetTexture((CIwTexture*)game->getSprites()->GetResHashed(getTextureName(), IW_GX_RESTYPE_TEXTURE));
    mat->SetModulateMode(CIwMaterial::MODULATE_NONE);
    mat->SetAlphaMode(CIwMaterial::ALPHA_DEFAULT);
    IwGxSetMaterial(mat);
    
	CIwSVec2 xy(x-45, y-45);
    CIwSVec2 duv(IW_FIXED(1.0/numFrames), IW_GEOM_ONE);
    
	static CIwSVec2 wh(90, 90);
	static CIwSVec2 uv(IW_FIXED(0), IW_FIXED(0));	
    
    IwGxSetScreenSpaceSlot(1);
    IwGxDrawRectScreenSpace(&xy, &wh, &uv, &duv);
    
    delete mat;
}
Esempio n. 11
0
    void Storage::getBlendmaps(float chunkSize, const osg::Vec2f &chunkCenter,
        bool pack, ImageVector &blendmaps, std::vector<Terrain::LayerInfo> &layerList)
    {
        // TODO - blending isn't completely right yet; the blending radius appears to be
        // different at a cell transition (2 vertices, not 4), so we may need to create a larger blendmap
        // and interpolate the rest of the cell by hand? :/

        osg::Vec2f origin = chunkCenter - osg::Vec2f(chunkSize/2.f, chunkSize/2.f);
        int cellX = static_cast<int>(origin.x());
        int cellY = static_cast<int>(origin.y());

        // Save the used texture indices so we know the total number of textures
        // and number of required blend maps
        std::set<UniqueTextureId> textureIndices;
        // Due to the way the blending works, the base layer will always shine through in between
        // blend transitions (eg halfway between two texels, both blend values will be 0.5, so 25% of base layer visible).
        // To get a consistent look, we need to make sure to use the same base layer in all cells.
        // So we're always adding _land_default.dds as the base layer here, even if it's not referenced in this cell.
        textureIndices.insert(std::make_pair(0,0));

        for (int y=0; y<ESM::Land::LAND_TEXTURE_SIZE+1; ++y)
            for (int x=0; x<ESM::Land::LAND_TEXTURE_SIZE+1; ++x)
            {
                UniqueTextureId id = getVtexIndexAt(cellX, cellY, x, y);
                textureIndices.insert(id);
            }

        // Makes sure the indices are sorted, or rather,
        // retrieved as sorted. This is important to keep the splatting order
        // consistent across cells.
        std::map<UniqueTextureId, int> textureIndicesMap;
        for (std::set<UniqueTextureId>::iterator it = textureIndices.begin(); it != textureIndices.end(); ++it)
        {
            int size = textureIndicesMap.size();
            textureIndicesMap[*it] = size;
            layerList.push_back(getLayerInfo(getTextureName(*it)));
        }

        int numTextures = textureIndices.size();
        // numTextures-1 since the base layer doesn't need blending
        int numBlendmaps = pack ? static_cast<int>(std::ceil((numTextures - 1) / 4.f)) : (numTextures - 1);

        int channels = pack ? 4 : 1;

        // Second iteration - create and fill in the blend maps
        const int blendmapSize = ESM::Land::LAND_TEXTURE_SIZE+1;

        for (int i=0; i<numBlendmaps; ++i)
        {
            GLenum format = pack ? GL_RGBA : GL_ALPHA;

            osg::ref_ptr<osg::Image> image (new osg::Image);
            image->allocateImage(blendmapSize, blendmapSize, 1, format, GL_UNSIGNED_BYTE);
            unsigned char* pData = image->data();

            for (int y=0; y<blendmapSize; ++y)
            {
                for (int x=0; x<blendmapSize; ++x)
                {
                    UniqueTextureId id = getVtexIndexAt(cellX, cellY, x, y);
                    int layerIndex = textureIndicesMap.find(id)->second;
                    int blendIndex = (pack ? static_cast<int>(std::floor((layerIndex - 1) / 4.f)) : layerIndex - 1);
                    int channel = pack ? std::max(0, (layerIndex-1) % 4) : 0;

                    if (blendIndex == i)
                        pData[y*blendmapSize*channels + x*channels + channel] = 255;
                    else
                        pData[y*blendmapSize*channels + x*channels + channel] = 0;
                }
            }

            blendmaps.push_back(image);
        }
    }
Esempio n. 12
0
HRESULT RSManager::redirectDrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
	//if(onHudRT) {
	//	SDLOG(0, "HUD render: primitive type: %d, MinIndex: %u, NumVertices: %u, PrimitiveCount: %u, IndexDataFormat: %s\n", PrimitiveType, MinIndex, NumVertices, PrimitiveCount, D3DFormatToString(IndexDataFormat));

	//	// Print vertex decl type
	//	IDirect3DVertexDeclaration9* vDecl;
	//	d3ddev->GetVertexDeclaration(&vDecl);
	//	D3DVERTEXELEMENT9 decl[MAXD3DDECLLENGTH];
	//	UINT numElements;
	//	vDecl->GetDeclaration(decl, &numElements);
	//	for(size_t i=0; i<numElements; ++i) {
	//		SDLOG(0, "element %u -- stream: %d, offset: %d, type: %s, usage: %s\n", i, decl->Stream, decl->Offset, D3DDeclTypeToString((D3DDECLTYPE)decl->Type), D3DDeclUsageToString((D3DDECLUSAGE)decl->Usage));
	//	}
	//	vDecl->Release();
	//	
	//	// Print indices
	//	//SDLOG(0, "Indices: \n");
	//	//INT16 *indices = (INT16*)pIndexData;
	//	//for(size_t i=0; i<PrimitiveCount+2; ++i) {
	//	//	SDLOG(0, "%8hd, ", indices[i]);
	//	//}
	//	//SDLOG(0, "\n");

	//	// Print vertices
	//	SDLOG(0, "Vertices: \n");
	//	INT16 *values = (INT16*)pVertexStreamZeroData;
	//	for(size_t i=0; i<NumVertices*4*2; ++i) {
	//		SDLOG(0, "%8hd, ", values[i]);
	//		if((i+1)%2 == 0) SDLOG(0, "; ");
	//		if((i+1)%8 == 0) SDLOG(0, "\n");
	//	}

	//	//return d3ddev->DrawIndexedPrimitiveUP(PrimitiveType, MinIndex, NumVertices, PrimitiveCount, pIndexData, IndexDataFormat, hudVertices, VertexStreamZeroStride);
	//}
	if(hudStarted && hideHud) {
		return D3D_OK;
	}
	bool isTargetIndicator = false;
	if(pausedHudRT) {
		IDirect3DBaseTexture9 *t;
		d3ddev->GetTexture(0, &t);
		// check for target indicator
		if(isTextureHudHealthbar(t)) {
			INT16 *vertices = (INT16*)pVertexStreamZeroData;
			if(vertices[3] > -2000) {
				resumeHudRendering();
			}
		} else {
			resumeHudRendering();
		}
		t->Release();
	}
	if(onHudRT) {
		IDirect3DBaseTexture9 *t;
		d3ddev->GetTexture(0, &t);
		SDLOG(4, "On HUD, redirectDrawIndexedPrimitiveUP texture: %s\n", getTextureName(t));
		if((hddp < 5 && isTextureHudHealthbar(t)) || (hddp >= 5 && hddp < 7 && isTextureCategoryIconsHumanityCount(t)) || (hddp>=7 && !isTextureCategoryIconsHumanityCount(t))) hddp++;
		// check for target indicator
		if(isTextureHudHealthbar(t)) {
			INT16 *vertices = (INT16*)pVertexStreamZeroData;
			if(vertices[3] < -2000) {
				isTargetIndicator = true;
				pauseHudRendering();
			}
		}
		t->Release();
		if(hddp == 8) {
			finishHudRendering();
		} else if(!isTargetIndicator) {
			//d3ddev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA);
			//d3ddev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_ADD);
			//d3ddev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
			//d3ddev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
		}
	}
	HRESULT hr = d3ddev->DrawIndexedPrimitiveUP(PrimitiveType, MinIndex, NumVertices, PrimitiveCount, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
	//if(onHudRT) {
	//	if(takeScreenshot) dumpSurface("HUD_IndexPrimUP", rgbaBuffer1Surf);
	//}
	return hr;
}
Esempio n. 13
0
	// Gets a separate texture atlas pointer
	AtlasPointer getTextureRawAP(const AtlasPointer &ap)
	{
		return getTexture(getTextureName(ap.id) + "^[forcesingle");
	}