Ejemplo n.º 1
0
static void PopOneTriangleList(TextureContainer * _pTex, bool clear) {
	
	ModelBatch & batch = _pTex->m_modelBatch;
	
	if(!batch.count[BatchBucket_Opaque]) {
		return;
	}

	GRenderer->SetTexture(0, _pTex);

	if(_pTex->userflags & POLY_LATE_MIP) {
		const float GLOBAL_NPC_MIPMAP_BIAS = -2.2f;
		GRenderer->GetTextureStage(0)->setMipMapLODBias(GLOBAL_NPC_MIPMAP_BIAS);
	}


	EERIEDRAWPRIM(Renderer::TriangleList, batch.list[BatchBucket_Opaque], batch.count[BatchBucket_Opaque]);
	
	if(clear) {
		batch.count[BatchBucket_Opaque] = 0;
	}

	if(_pTex->userflags & POLY_LATE_MIP) {
		float biasResetVal = 0;
		GRenderer->GetTextureStage(0)->setMipMapLODBias(biasResetVal);
	}

}
Ejemplo n.º 2
0
static void PopOneTriangleListTransparency(TextureContainer *_pTex) {

	if(!_pTex->count[TextureContainer::Blended]
	   && !_pTex->count[TextureContainer::Additive]
	   && !_pTex->count[TextureContainer::Subtractive]
	   && !_pTex->count[TextureContainer::Multiplicative]) {
		return;
	}

	GRenderer->SetTexture(0, _pTex);

	if(_pTex->count[TextureContainer::Blended]) {
		GRenderer->SetBlendFunc(Renderer::BlendDstColor, Renderer::BlendSrcColor);
		if(_pTex->count[TextureContainer::Blended]) {
			EERIEDRAWPRIM(Renderer::TriangleList, _pTex->list[TextureContainer::Blended],
						  _pTex->count[TextureContainer::Blended]);
			_pTex->count[TextureContainer::Blended]=0;
		}
	}

	if(_pTex->count[TextureContainer::Additive]) {
		GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendOne);
		if(_pTex->count[TextureContainer::Additive]) {
			EERIEDRAWPRIM(Renderer::TriangleList, _pTex->list[TextureContainer::Additive],
						  _pTex->count[TextureContainer::Additive]);
			_pTex->count[TextureContainer::Additive]=0;
		}
	}

	if(_pTex->count[TextureContainer::Subtractive]) {
		GRenderer->SetBlendFunc(Renderer::BlendZero, Renderer::BlendInvSrcColor);
		if(_pTex->count[TextureContainer::Subtractive]) {
			EERIEDRAWPRIM(Renderer::TriangleList, _pTex->list[TextureContainer::Subtractive],
						  _pTex->count[TextureContainer::Subtractive]);
			_pTex->count[TextureContainer::Subtractive]=0;
		}
	}

	if(_pTex->count[TextureContainer::Multiplicative]) {
		GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendOne);
		if(_pTex->count[TextureContainer::Multiplicative]) {
			EERIEDRAWPRIM(Renderer::TriangleList, _pTex->list[TextureContainer::Multiplicative],
						  _pTex->count[TextureContainer::Multiplicative]);
			_pTex->count[TextureContainer::Multiplicative] = 0;
		}
	}
}
Ejemplo n.º 3
0
void drawLineSphere(const Sphere & sphere, Color color) {

	if(sphere.radius <= 0)
		return;

	static const size_t sections = 64;

	size_t rings = sphere.radius / 10;
	if(rings < 7)
		rings = 7;

	std::vector<TexturedVertex> vertices;

	bool skip = false;

	for(size_t i = 1; i < rings - 1; i++) {
		float a = i * (glm::pi<float>() / (rings - 1));
		for(size_t j = 0; j <= sections; j++) {
			float b = j * ((2 * glm::pi<float>()) / sections);

			Vec3f pos;
			pos.x = glm::cos(b) * glm::sin(a);
			pos.y = glm::sin(b) * glm::sin(a);
			pos.z = glm::cos(a);

			pos *= sphere.radius;
			pos += sphere.origin;
			
			TexturedVertex out;
			Vec3f temp = EE_RT(pos);
			EE_P(temp, out);

			if(skip) {
				skip = false;
				out.color = Color(0, 0, 0, 0).toRGBA();
				vertices.push_back(out);
			}

			out.color = color.toRGBA();
			vertices.push_back(out);

			if(j == sections) {
				skip = true;
				out.color = Color(0, 0, 0, 0).toRGBA();
				vertices.push_back(out);
			}
		}
	}

	GRenderer->ResetTexture(0);
	EERIEDRAWPRIM(Renderer::LineStrip, &vertices[0], vertices.size());
}
Ejemplo n.º 4
0
void Halo_Render() {
	
	if(HALOCUR[0] == 0 && HALOCUR[1] == 0)
		return;
	
	GRenderer->ResetTexture(0);
	
	RenderState baseState = render3D().depthWrite(false);
	
	if(HALOCUR[0] > 0) {
		UseRenderState state(baseState.blend(BlendZero, BlendInvSrcColor));
		EERIEDRAWPRIM(Renderer::TriangleList, LATERDRAWHALO[0], HALOCUR[0] * 6);
		HALOCUR[0] = 0;
	}
	
	if(HALOCUR[1] > 0) {
		UseRenderState state(baseState.blend(BlendSrcColor, BlendOne));
		EERIEDRAWPRIM(Renderer::TriangleList, LATERDRAWHALO[1], HALOCUR[1] * 6);
		HALOCUR[1] = 0;
	}
	
}
Ejemplo n.º 5
0
void drawLine2D(float x0, float y0, float x1, float y1, float z, Color col) {

	TexturedVertex v[2];
	v[0].p.x = x0;
	v[0].p.y = y0;
	v[0].p.z = v[1].p.z = z;
	v[1].p.x = x1;
	v[1].p.y = y1;
	v[1].color = v[0].color = col.toRGBA();
	v[1].rhw = v[0].rhw = 1.f;

	GRenderer->ResetTexture(0);
	EERIEDRAWPRIM(Renderer::LineList, v, 2);
}
Ejemplo n.º 6
0
void CursorTrail::DrawLine2D(float _fSize, Color3f color) {
	
	if(iNbOldCoord < 2) {
		return;
	}
	
	float incSize = _fSize / iNbOldCoord;
	float currentSize = incSize;
	
	Color3f incColor = Color3f(color.r / iNbOldCoord, color.g / iNbOldCoord, color.b / iNbOldCoord);
	
	Color3f currentColor = incColor;
	
	GRenderer->SetBlendFunc(BlendDstColor, BlendInvDstColor);
	GRenderer->ResetTexture(0);
	GRenderer->SetRenderState(Renderer::AlphaBlending, true);
	
	TexturedVertex v[4];
	v[0].p.z = v[1].p.z = v[2].p.z = v[3].p.z = 0.f;
	v[0].rhw = v[1].rhw = v[2].rhw = v[3].rhw = 1.f;
	
	v[0].color = v[2].color = currentColor.toRGB();
	
	if(!ComputePer(iOldCoord[0], iOldCoord[1], &v[0], &v[2], currentSize)) {
		v[0].p.x = v[2].p.x = iOldCoord[0].x;
		v[0].p.y = v[2].p.y = iOldCoord[1].y;
	}
	
	for(int i = 1; i < iNbOldCoord - 1; i++) {
		
		currentSize += incSize;
		currentColor += incColor;
		
		if(ComputePer(iOldCoord[i], iOldCoord[i + 1], &v[1], &v[3], currentSize)) {
			
			v[1].color = v[3].color = currentColor.toRGB();
			EERIEDRAWPRIM(Renderer::TriangleStrip, v, 4);
			
			v[0].p.x = v[1].p.x;
			v[0].p.y = v[1].p.y;
			v[0].color = v[1].color;
			v[2].p.x = v[3].p.x;
			v[2].p.y = v[3].p.y;
			v[2].color = v[3].color;
		}
		
	}
	
	GRenderer->SetRenderState(Renderer::AlphaBlending, false);
}
Ejemplo n.º 7
0
void ARXDRAW_DrawAllInterTransPolyPos(LPDIRECT3DDEVICE7 pd3dDevice)
{
	SETALPHABLEND(pd3dDevice,TRUE);
	EERIEDrawnPolys+=INTERTRANSPOLYSPOS;

	for (long i=0;i<INTERTRANSPOLYSPOS;i++) 
	{
		if (!InterTransFace[i]) continue; // Object was destroyed after sending faces...

		if (InterTransFace[i]->texid<0) continue;

		if (InterTransFace[i]->facetype & POLY_DOUBLESIDED) 
				SETCULL(pd3dDevice,D3DCULL_NONE);
		else	SETCULL(pd3dDevice,D3DCULL_CW);

		SETTC(pd3dDevice,InterTransTC[i]);
		EERIE_FACE * ef=InterTransFace[i];
		float ttt=ef->transval;

		if (ttt>=2.f)  //MULTIPLICATIVE
		{
			SETBLENDMODE(pd3dDevice,D3DBLEND_ONE,D3DBLEND_ONE);
			ttt*=DIV2;
			ttt+=0.5f;
			InterTransPol[i][2].color=InterTransPol[i][1].color=InterTransPol[i][0].color=_EERIERGB(ttt);
		}
		else if (ttt>=1.f) //ADDITIVE
		{	
			ttt-=1.f;
			SETBLENDMODE(pd3dDevice,D3DBLEND_ONE,D3DBLEND_ONE);
			InterTransPol[i][2].color=InterTransPol[i][1].color=InterTransPol[i][0].color=_EERIERGB(ttt);
		}
		else if (ttt>0.f)  //NORMAL TRANS
		{
			ttt=1.f-ttt;
			SETBLENDMODE(pd3dDevice,D3DBLEND_DESTCOLOR,D3DBLEND_SRCCOLOR);
			InterTransPol[i][2].color=InterTransPol[i][1].color=InterTransPol[i][0].color=_EERIERGBA(ttt);//ttt);
		}
		else  //SUBTRACTIVE
		{
			SETBLENDMODE(pd3dDevice,D3DBLEND_ZERO,D3DBLEND_INVSRCCOLOR);
			ttt=1.f-ttt;
			InterTransPol[i][2].color=InterTransPol[i][1].color=InterTransPol[i][0].color=_EERIERGB(ttt);
		}

		EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX| D3DFVF_DIFFUSE , InterTransPol[i], 3,  0, EERIE_NOCOUNT | (bSoftRender?EERIE_USEVB:0) );
	}

	INTERTRANSPOLYSPOS=0;
}
Ejemplo n.º 8
0
void drawLine(const Vec2f & from, const Vec2f & to, float z, Color col) {
	
	TexturedVertex v[2];
	v[0].p.x = from.x;
	v[0].p.y = from.y;
	v[0].p.z = v[1].p.z = z;
	v[1].p.x = to.x;
	v[1].p.y = to.y;
	v[1].color = v[0].color = col.toRGBA();
	v[1].rhw = v[0].rhw = 1.f;

	GRenderer->ResetTexture(0);
	EERIEDRAWPRIM(Renderer::LineList, v, 2);
}
Ejemplo n.º 9
0
void drawLineRectangle(const Rectf & rect, float z, Color col) {

	TexturedVertex v[5];
	v[0].p = Vec3f(rect.bottomLeft(), z);
	v[1].p = Vec3f(rect.bottomRight(), z);
	v[2].p = Vec3f(rect.topRight(), z);
	v[3].p = Vec3f(rect.topLeft(), z);
	v[4].p = v[0].p;
	
	v[4].color = v[3].color = v[2].color = v[1].color = v[0].color = col.toRGBA();
	v[4].rhw = v[3].rhw = v[2].rhw = v[1].rhw = v[0].rhw = 1.f;

	GRenderer->ResetTexture(0);
	EERIEDRAWPRIM(Renderer::LineStrip, v, 5);
}
Ejemplo n.º 10
0
void EERIEDrawFill2DRectDegrad(Vec2f a, Vec2f b, float z, Color cold, Color cole) {

	TexturedVertex v[4];
	v[0].p.x = v[2].p.x = a.x;
	v[0].p.y = v[1].p.y = a.y;
	v[1].p.x = v[3].p.x = b.x;
	v[2].p.y = v[3].p.y = b.y;
	v[0].color = v[1].color = cold.toRGBA();
	v[2].color = v[3].color = cole.toRGBA();
	v[0].p.z = v[1].p.z = v[2].p.z = v[3].p.z = z;
	v[3].rhw = v[2].rhw = v[1].rhw = v[0].rhw = 1.f;

	GRenderer->ResetTexture(0);
	EERIEDRAWPRIM(Renderer::TriangleStrip, v, 4);
}
Ejemplo n.º 11
0
void EERIEDrawFill2DRectDegrad(float x0, float y0, float x1, float y1, float z, Color cold, Color cole) {

	TexturedVertex v[4];
	v[0].p.x = v[2].p.x = x0;
	v[0].p.y = v[1].p.y = y0;
	v[1].p.x = v[3].p.x = x1;
	v[2].p.y = v[3].p.y = y1;
	v[0].color = v[1].color = cold.toRGBA();
	v[2].color = v[3].color = cole.toRGBA();
	v[0].p.z = v[1].p.z = v[2].p.z = v[3].p.z = z;
	v[3].rhw = v[2].rhw = v[1].rhw = v[0].rhw = 1.f;

	GRenderer->ResetTexture(0);
	EERIEDRAWPRIM(Renderer::TriangleStrip, v, 4);
}
Ejemplo n.º 12
0
void MiniMap::drawPlayer(float playerSize, Vec2f playerPos, bool alphaBlending) {
	
	TexturedVertex verts[4];
	
	for(int k = 0; k < 4; k++) {
		verts[k].color = Color(255, 0, 0, 255).toRGBA();
		verts[k].rhw = 1;
		verts[k].p.z = 0.00001f;
	}
	
	Vec2f r;
	r.x = 0.f;
	r.y = -playerSize * 1.8f;
	Vec2f r2;
	r2.x = -playerSize * (1.0f / 2);
	r2.y = playerSize;
	Vec2f r3;
	r3.x = playerSize * (1.0f / 2);
	r3.y = playerSize;
	
	float angle = glm::radians(m_player->angle.getPitch());
	float ca = std::cos(angle);
	float sa = std::sin(angle);
	
	verts[0].p.x = (playerPos.x + r2.x * ca + r2.y * sa) * g_sizeRatio.x;
	verts[0].p.y = (playerPos.y + r2.y * ca - r2.x * sa) * g_sizeRatio.y;
	verts[1].p.x = (playerPos.x + r.x * ca + r.y * sa) * g_sizeRatio.x;
	verts[1].p.y = (playerPos.y + r.y * ca - r.x * sa) * g_sizeRatio.y;
	verts[2].p.x = (playerPos.x + r3.x * ca + r3.y * sa) * g_sizeRatio.x;
	verts[2].p.y = (playerPos.y + r3.y * ca - r3.x * sa) * g_sizeRatio.y;
	
	GRenderer->ResetTexture(0);
	GRenderer->SetRenderState(Renderer::AlphaBlending, alphaBlending);
	if(alphaBlending) {
		GRenderer->SetBlendFunc(BlendOne, BlendInvSrcColor);
	}
	
	EERIEDRAWPRIM(Renderer::TriangleFan, verts);
	
	GRenderer->SetRenderState(Renderer::AlphaBlending, false);
}
Ejemplo n.º 13
0
void drawLine(const Vec3f & orgn, const Vec3f & dest, Color color1, Color color2, float zbias) {
	
	TexturedVertex v[2];
	
	EE_RTP(orgn, v[0]);
	if(v[0].p.z < 0.f) {
		return;
	}
	
	EE_RTP(dest, v[1]);
	if(v[1].p.z < 0.f) {
		return;
	}
	
	v[0].p.z -= zbias, v[1].p.z -= zbias;
	
	GRenderer->ResetTexture(0);
	v[0].color = color1.toRGBA();
	v[1].color = color2.toRGBA();
	
	EERIEDRAWPRIM(Renderer::LineList, v, 2);
}
Ejemplo n.º 14
0
void MiniMap::drawPlayer(float playerSize, float playerX, float playerY, bool alphaBlending) {
	
	TexturedVertex verts[4];
	
	for(int k = 0; k < 4; k++) {
		verts[k].color = Color(255, 0, 0, 255).toRGBA();
		verts[k].rhw = 1;
		verts[k].p.z = 0.00001f;
	}
	
	float rx = 0.f;
	float ry = -playerSize * 1.8f;
	float rx2 = -playerSize * (1.0f / 2);
	float ry2 = playerSize;
	float rx3 = playerSize * (1.0f / 2);
	float ry3 = playerSize;
	
	float angle = glm::radians(m_player->angle.getPitch());
	float ca = std::cos(angle);
	float sa = std::sin(angle);
	
	verts[0].p.x = (playerX + rx2 * ca + ry2 * sa) * g_sizeRatio.x;
	verts[0].p.y = (playerY + ry2 * ca - rx2 * sa) * g_sizeRatio.y;
	verts[1].p.x = (playerX + rx * ca + ry * sa) * g_sizeRatio.x;
	verts[1].p.y = (playerY + ry * ca - rx * sa) * g_sizeRatio.y;
	verts[2].p.x = (playerX + rx3 * ca + ry3 * sa) * g_sizeRatio.x;
	verts[2].p.y = (playerY + ry3 * ca - rx3 * sa) * g_sizeRatio.y;
	
	GRenderer->ResetTexture(0);
	GRenderer->SetRenderState(Renderer::AlphaBlending, alphaBlending);
	if(alphaBlending) {
		GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendInvSrcColor);
	}
	
	EERIEDRAWPRIM(Renderer::TriangleFan, verts);
	
	GRenderer->SetRenderState(Renderer::AlphaBlending, false);
}
Ejemplo n.º 15
0
void MiniMap::drawPlayer(float playerSize, float playerX, float playerY, bool alphaBlending) {
	
	TexturedVertex verts[4];
	
	for(int k = 0; k < 4; k++) {
		verts[k].color = 0xFFFF0000; // red
		verts[k].rhw = 1;
		verts[k].p.z = 0.00001f;
	}
	
	float rx = 0.f;
	float ry = -playerSize * 1.8f;
	float rx2 = -playerSize * (1.0f / 2);
	float ry2 = playerSize;
	float rx3 = playerSize * (1.0f / 2);
	float ry3 = playerSize;
	
	float angle = radians(m_player->angle.b);
	float ca = EEcos(angle);
	float sa = EEsin(angle);
	
	verts[0].p.x = (playerX + rx2 * ca + ry2 * sa) * Xratio;
	verts[0].p.y = (playerY + ry2 * ca - rx2 * sa) * Yratio;
	verts[1].p.x = (playerX + rx * ca + ry * sa) * Xratio;
	verts[1].p.y = (playerY + ry * ca - rx * sa) * Yratio;
	verts[2].p.x = (playerX + rx3 * ca + ry3 * sa) * Xratio;
	verts[2].p.y = (playerY + ry3 * ca - rx3 * sa) * Yratio;
	
	GRenderer->ResetTexture(0);
	GRenderer->SetRenderState(Renderer::AlphaBlending, alphaBlending);
	if(alphaBlending) {
		GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendInvSrcColor);
	}
	
	EERIEDRAWPRIM(Renderer::TriangleFan, verts);
	
	GRenderer->SetRenderState(Renderer::AlphaBlending, false);
}
Ejemplo n.º 16
0
//#############################################################################################
// Render de la scene
//#############################################################################################
bool C_ARX_Carte::Render(void)
{
	if(!this->background) return false;

	GRenderer->Clear(Renderer::ColorBuffer | Renderer::DepthBuffer);

	int depx = (int)(this->posx * this->background->Xmul);

	if(depx<0) depx=0;

	int depz=(int)(this->posz*this->background->Zmul);

	if(depz<0) depz=0;

	int	endx=this->widthrender/this->nbpixels;
	int	endz=this->heightrender/this->nbpixels;
	endx+=depx;

	if(endx>this->background->Xsize) endx=this->background->Xsize;

	endz+=depz;

	if(endz>this->background->Zsize) endz=this->background->Zsize;

	float yecran=0.f;
	float zsub=((float)depz)*this->background->Zdiv;

	for(int j=depz;j<endz;j++) 
	{
		float xecran=0.f;
		float xsub=((float)depx)*this->background->Xdiv;

		for(int i=depx;i<endx;i++) 
		{
			EERIE_BKG_INFO *eg=&this->background->Backg[i+j*this->background->Xsize];

			for(int lll=0;lll<eg->nbpoly;lll++)
			{
				EERIEPOLY *ep=&eg->polydata[lll];

				if (ep)
				{
					if(ep->type&POLY_IGNORE) continue;

					if(ep->type&POLY_TRANS) continue;
					
					int nb;

					if(ep->type&POLY_QUAD) nb=4;
					else nb=3;

					for(int k=0;k<nb;k++)
					{
						ep->tv[k].p.x=xecran+(ep->v[k].p.x-xsub)*this->ecx;
						ep->tv[k].p.y=yecran+(ep->v[k].p.z-zsub)*this->ecz;
						ep->tv[k].rhw=(1.f/ep->v[k].p.y);

						if (ep->tv[k].rhw<0.f) ep->tv[k].rhw=0.f;

						if (ep->tv[k].rhw>1.f) ep->tv[k].rhw=1.f;

						ep->tv[k].p.z=1.f-ep->tv[k].rhw;

						if (ep->tv[k].p.z<0.f) ep->tv[k].p.z=0.f;

						if (ep->tv[k].p.z>1.f) ep->tv[k].p.z=1.f;

						ep->tv[k].color = 0xFFFFFFFF;
						ep->tv[k].uv = ep->v[k].uv;
					}

					if(ep->tex)
						GRenderer->SetTexture(0, ep->tex);
					else
						GRenderer->ResetTexture(0);

					EERIEDRAWPRIM(Renderer::TriangleStrip, ep->tv, nb, true);
				}

			}

			xsub+=this->background->Xdiv;
			xecran+=(float)this->nbpixels;
		}

		zsub+=this->background->Zdiv;
		yecran+=(float)this->nbpixels;
	}

	return true;
}
Ejemplo n.º 17
0
void MiniMap::showBookEntireMap(int showLevel) {
	
	// First Load Minimap TC & DATA if needed
	if(m_levels[showLevel].m_texContainer == NULL) {
		getData(showLevel);
	}
	
	if(!m_levels[showLevel].m_texContainer) {
		return;
	}
	
	GRenderer->SetRenderState(Renderer::DepthTest, false);
	
	float zoom = 250.f;
	
	Vec2f start(140.f, 120.f);
	
	Vec2f playerPos(0.f, 0.f);
	
	if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
		playerPos = computePlayerPos(zoom, showLevel);
		playerPos += start;
	}
	
	drawBackground(showLevel, Rect(0, 0, 345, 290), start, zoom);
	
	GRenderer->GetTextureStage(0)->setWrapMode(TextureStage::WrapRepeat);
	
	if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
		drawPlayer(3.f, playerPos, false);
		drawDetectedEntities(showLevel, start, zoom);
	}
	
	TexturedVertex verts[4];
	for(int k = 0; k < 4; k++) {
		verts[k].color = Color(255, 255, 255, 255).toRGBA();
		verts[k].rhw = 1;
		verts[k].p.z = 0.00001f;
	}
	
	Vec2f casePos(zoom / MINIMAP_MAX_X, zoom / MINIMAP_MAX_Z);
	float ratio = 1.f;
	
	for(size_t i = 0; i < m_mapMarkers.size(); i++) {
		
		if(m_mapMarkers[i].m_lvl != showLevel + 1) {
			continue;
		}
		
		Vec2f pos;
		pos.x = m_mapMarkers[i].m_pos.x * 8 * ratio * m_activeBkg->Xmul * casePos.x + start.x;
		pos.y = m_mapMarkers[i].m_pos.y * 8 * ratio * m_activeBkg->Zmul * casePos.y + start.y;
		
		float size = 5.f * ratio;
		verts[0].color = Color(255, 0, 0, 255).toRGBA();
		verts[1].color = Color(255, 0, 0, 255).toRGBA();
		verts[2].color = Color(255, 0, 0, 255).toRGBA();
		verts[3].color = Color(255, 0, 0, 255).toRGBA();
		verts[0].p.x = (pos.x - size) * g_sizeRatio.x;
		verts[0].p.y = (pos.y - size) * g_sizeRatio.y;
		verts[1].p.x = (pos.x + size) * g_sizeRatio.x;
		verts[1].p.y = (pos.y - size) * g_sizeRatio.y;
		verts[2].p.x = (pos.x + size) * g_sizeRatio.x;
		verts[2].p.y = (pos.y + size) * g_sizeRatio.y;
		verts[3].p.x = (pos.x - size) * g_sizeRatio.x;
		verts[3].p.y = (pos.y + size) * g_sizeRatio.y;
		verts[0].uv = Vec2f_ZERO;
		verts[1].uv = Vec2f_X_AXIS;
		verts[2].uv = Vec2f_ONE;
		verts[3].uv = Vec2f_Y_AXIS;
		
		const Rect mouseTestRect(
			verts[0].p.x,
			verts[0].p.y,
			verts[2].p.x,
			verts[2].p.y
		);
		
		if(mouseTestRect.contains(Vec2i(DANAEMouse))) {
			if(!m_mapMarkers[i].m_text.empty()) {
				
				Rect bRect(140, 295, 140 + 205, 358);
				
				Rect::Num left = checked_range_cast<Rect::Num>((bRect.left) * g_sizeRatio.x);
				Rect::Num right = checked_range_cast<Rect::Num>((bRect.right) * g_sizeRatio.x);
				Rect::Num top = checked_range_cast<Rect::Num>((bRect.top) * g_sizeRatio.y);
				Rect::Num bottom = checked_range_cast<Rect::Num>((bRect.bottom) * g_sizeRatio.y);
				Rect rRect = Rect(left, top, right, bottom);
				
				long lLengthDraw = ARX_UNICODE_ForceFormattingInRect(hFontInGameNote, m_mapMarkers[i].m_text, rRect);
				
				
				ARX_UNICODE_DrawTextInRect(hFontInGameNote,
				                           (BOOKDEC + Vec2f(bRect.topLeft())) * g_sizeRatio,
				                           (BOOKDEC.x + float(bRect.right)) * g_sizeRatio.x,
				                           m_mapMarkers[i].m_text.substr(0, lLengthDraw),
				                           Color::none);
			}
		}
		
		if(m_mapMarkerTexCont == NULL) {
			m_mapMarkerTexCont = TextureContainer::Load("graph/interface/icons/mapmarker");
		}
		
		GRenderer->SetTexture(0, m_mapMarkerTexCont);
		
		EERIEDRAWPRIM(Renderer::TriangleFan, verts, 4);
	}
}
Ejemplo n.º 18
0
void ShowFrameDurationPlot() {
	
	Vec2i windowSize = mainApp->getWindow()->getSize();
	size_t maxSamples = size_t(windowSize.x);
	
	if(maxSamples != frameDurationPlotValues.capacity()) {
		frameDurationPlotValues.set_capacity(maxSamples);
	}
	if(maxSamples != frameDurationPlotVertices.size()) {
		frameDurationPlotVertices.resize(maxSamples);
	}
	
	GRenderer->ResetTexture(0);
	
	frameDurationPlotValues.push_front(toMs(g_platformTime.lastFrameDuration()));
	
	float avg = std::accumulate(frameDurationPlotValues.begin(), frameDurationPlotValues.end(), 0.f) / frameDurationPlotValues.size();
	float worst = *std::max_element(frameDurationPlotValues.begin(), frameDurationPlotValues.end());
	
	const float OFFSET_Y = 80.f;
	const float SCALE_Y = 4.0f;

	for(size_t i = 0; i < frameDurationPlotValues.size(); ++i)
	{
		float time = frameDurationPlotValues[i];
		frameDurationPlotVertices[i].color = Color::white.toRGB();
		frameDurationPlotVertices[i].p.x = i;
		frameDurationPlotVertices[i].p.y = OFFSET_Y + (time * SCALE_Y);
		frameDurationPlotVertices[i].p.z = 1.0f;
		frameDurationPlotVertices[i].w = 1.0f;
	}

	EERIEDRAWPRIM(Renderer::LineStrip, &frameDurationPlotVertices[0], frameDurationPlotValues.size());

	Color avgColor = Color::blue * 0.5f + Color::white * 0.5f;
	float avgPos = OFFSET_Y + (avg * SCALE_Y);
	drawLine(Vec2f(0, avgPos), Vec2f(windowSize.x, avgPos), 1.0f, Color::blue);

	Color worstColor = Color::red * 0.5f + Color::white * 0.5f;
	float worstPos = OFFSET_Y + (worst * SCALE_Y);
	drawLine(Vec2f(0, worstPos), Vec2f(windowSize.x, worstPos), 1.0f, Color::red);

	Font * font = hFontDebug;
	float lineOffset = font->getLineHeight() + 2;

	std::string labels[3] = { "Average: ", "Worst: ", "Current: " };
	Color colors[3] = { avgColor, worstColor, Color::white };
	float values[3] = { avg, worst, frameDurationPlotValues[0] };

	std::string texts[3];
	float widths[3];
	static float labelWidth = 0.f;
	static float valueWidth = 0.f;
	for(size_t i = 0; i < 3; i++) {
		// Format value
		std::ostringstream oss;
		oss << std::fixed << std::setprecision(2) << values[i] << " ms ("<< 1.f / (values[i] * 0.001f) << " FPS)";
		texts[i] = oss.str();
		// Calculate widths (could be done more efficiently for monospace fonts...)
		labelWidth = std::max(labelWidth, float(font->getTextSize(labels[i]).width()));
		widths[i] = font->getTextSize(texts[i]).width();
		valueWidth = std::max(valueWidth, widths[i]);
	}

	float x = 10;
	float y = 10;
	float xend = x + labelWidth + 10 + valueWidth;
	for(size_t i = 0; i < 3; i++) {
		font->draw(Vec2i(x, y), labels[i], Color::gray(0.8f));
		font->draw(Vec2i(xend - widths[i], y), texts[i], colors[i]);
		y += lineOffset;
	}

}
Ejemplo n.º 19
0
void ShowFpsGraph() {
	
	ARX_PROFILE_FUNC();

	GRenderer->ResetTexture(0);

	static std::deque<float> lastFPSArray;
	lastFPSArray.push_front(1000 / arxtime.get_frame_delay());

	Vec2i windowSize = mainApp->getWindow()->getSize();
	if(lastFPSArray.size() == size_t(windowSize.x))
	{
		lastFPSArray.pop_back();
	}

	float avg = 0;
	float worst = lastFPSArray[0];

	std::vector<TexturedVertex> vertices;
	vertices.resize(lastFPSArray.size());

	const float SCALE_Y = 2.0f;

	for(size_t i = 0; i < lastFPSArray.size(); ++i)
	{
		float time = lastFPSArray[i];

		avg += lastFPSArray[i];
		worst = std::min(worst, lastFPSArray[i]);

		vertices[i].color = Color(255, 255, 255, 255).toRGBA();
		vertices[i].p.x = i;
		vertices[i].p.y = windowSize.y - (time * SCALE_Y);
		vertices[i].p.z = 1.0f;
		vertices[i].rhw = 1.0f;
	}
	avg /= lastFPSArray.size();

	EERIEDRAWPRIM(Renderer::LineStrip, &vertices[0], vertices.size());

	Color avgColor = Color::blue * 0.5f + Color::white * 0.5f;
	float avgPos = windowSize.y - (avg * SCALE_Y);
	drawLine2D(0, avgPos,  windowSize.x, avgPos, 1.0f, Color::blue);

	Color worstColor = Color::red * 0.5f + Color::white * 0.5f;
	float worstPos = windowSize.y - (worst * SCALE_Y);
	drawLine2D(0, worstPos,  windowSize.x, worstPos, 1.0f, Color::red);

	Font * font = hFontDebug;
	float lineOffset = font->getLineHeight() + 2;

	std::string labels[3] = { "Average: ", "Worst: ", "Current: " };
	Color colors[3] = { avgColor, worstColor, Color::white };
	float values[3] = { avg, worst, lastFPSArray[0] };

	std::string texts[3];
	float widths[3];
	static float labelWidth = 0.f;
	static float valueWidth = 0.f;
	for(size_t i = 0; i < 3; i++) {
		// Format value
		std::ostringstream oss;
		oss << std::fixed << std::setprecision(2) << values[i] << " FPS";
		texts[i] = oss.str();
		// Calculate widths (could be done more efficiently for monospace fonts...)
		labelWidth = std::max(labelWidth, float(font->getTextSize(labels[i]).x));
		widths[i] = font->getTextSize(texts[i]).x;
		valueWidth = std::max(valueWidth, widths[i]);
	}

	float x = 10;
	float y = 10;
	float xend = x + labelWidth + 10 + valueWidth;
	for(size_t i = 0; i < 3; i++) {
		font->draw(Vec2i(x, y), labels[i], Color::gray(0.8f));
		font->draw(Vec2i(xend - widths[i], y), texts[i], colors[i]);
		y += lineOffset;
	}

}
Ejemplo n.º 20
0
void MiniMap::drawBackground(int showLevel, Rect boundaries, Vec2f start, float zoom, float fadeBorder, Vec2f decal, bool invColor, float alpha) {
	
	m_mapVertices.clear();
	
	Vec2f cas;
	cas.x = zoom / MINIMAP_MAX_X;
	cas.y = zoom / MINIMAP_MAX_Z;
	
	GRenderer->SetTexture(0, m_levels[showLevel].m_texContainer);
	
	float div = (1.0f / 25);
	TextureContainer * tc = m_levels[showLevel].m_texContainer;
	Vec2f d;
	d.x = 1.f / tc->m_pTexture->getStoredSize().x;
	d.y = 1.f / tc->m_pTexture->getStoredSize().y;
	
	Vec2f v2;
	v2.x = 4.f * d.x * m_mod.x;
	v2.y = 4.f * d.y * m_mod.y;
	
	float fadeDiv = 0.f;
	Rect fadeBounds(0, 0, 0, 0);
	
	if(fadeBorder > 0.f) {
		fadeDiv = 1.f/fadeBorder;
		fadeBounds.left = checked_range_cast<Rect::Num>((boundaries.left + fadeBorder) * g_sizeRatio.x);
		fadeBounds.right = checked_range_cast<Rect::Num>((boundaries.right - fadeBorder) * g_sizeRatio.x);
		fadeBounds.top = checked_range_cast<Rect::Num>((boundaries.top + fadeBorder) * g_sizeRatio.y);
		fadeBounds.bottom = checked_range_cast<Rect::Num>((boundaries.bottom - fadeBorder) * g_sizeRatio.y);
	}
	
	GRenderer->SetRenderState(Renderer::AlphaBlending, true);
	if(invColor) {
		GRenderer->SetBlendFunc(BlendOne, BlendInvSrcColor);
	} else {
		GRenderer->SetBlendFunc(BlendZero, BlendInvSrcColor);
	}
	GRenderer->GetTextureStage(0)->setWrapMode(TextureStage::WrapClamp);
	GRenderer->GetTextureStage(0)->setMinFilter(TextureStage::FilterLinear);
	GRenderer->GetTextureStage(0)->setMagFilter(TextureStage::FilterLinear);

	for(int z = -2; z < int(MINIMAP_MAX_Z) + 2; z++) {
	for(int x = -2; x < int(MINIMAP_MAX_X) + 2; x++) {
		
		Vec2f v3;
		v3.x = float(x) * float(m_activeBkg->Xdiv) * m_mod.x;
		v3.y = float(z) * float(m_activeBkg->Zdiv) * m_mod.y;
		
		Vec2f v4;
		v4.x = (v3.x * div) * d.x;
		v4.y = (v3.y * div) * d.y;
		
		Vec2f pos;
		pos.x = (start.x + x * cas.x) * g_sizeRatio.x;
		pos.y = (start.y + z * cas.y) * g_sizeRatio.y;
		
		if((pos.x < boundaries.left * g_sizeRatio.x)
		   || (pos.x > boundaries.right * g_sizeRatio.x)
		   || (pos.y < boundaries.top * g_sizeRatio.y)
		   || (pos.y > boundaries.bottom * g_sizeRatio.y)) {
			continue; // out of bounds
		}
		
		TexturedVertex verts[4];
		
		verts[3].p.x = verts[0].p.x = pos.x;
		verts[1].p.y = verts[0].p.y = pos.y;
		verts[2].p.x = verts[1].p.x = pos.x + (cas.x * g_sizeRatio.x);
		verts[3].p.y = verts[2].p.y = pos.y + (cas.y * g_sizeRatio.y);
		
		verts[3].uv.x = verts[0].uv.x = v4.x;
		verts[1].uv.y = verts[0].uv.y = v4.y;
		verts[2].uv.x = verts[1].uv.x = v4.x + v2.x;
		verts[3].uv.y = verts[2].uv.y = v4.y + v2.y;
		
		float v;
		float oo = 0.f;
		
		for(int vert = 0; vert < 4; vert++) {
			verts[vert].color = Color(255, 255, 255, 255).toRGBA();
			verts[vert].rhw = 1;
			verts[vert].p.z = 0.00001f;

			// Array offset according to "vert"
			int iOffset = 0;
			int jOffset = 0;
			
			if(vert == 1 || vert == 2)
				iOffset = 1;
			if(vert == 2 || vert == 3)
				jOffset = 1;
			
			if((x + iOffset < 0) || (x + iOffset >= int(MINIMAP_MAX_X)) || (z + jOffset < 0) || (z + jOffset >= int(MINIMAP_MAX_Z))) {
				v = 0;
			} else {
				int minx = std::min(x + iOffset, int(MINIMAP_MAX_X) - iOffset);
				int minz = std::min(z + jOffset, int(MINIMAP_MAX_Z) - jOffset);
				v = float(m_levels[showLevel].m_revealed[minx][minz]) * (1.0f / 255);
			}
			
			if(fadeBorder > 0.f) {
				
				float _px = verts[vert].p.x - fadeBounds.left;
				
				if(_px < 0.f) {
					v = 0.f;
				} else if(_px < fadeBorder) {
					v *= _px * fadeDiv;
				}
				
				_px = fadeBounds.right - verts[vert].p.x;
				
				if(_px < 0.f) {
					v = 0.f;
				} else if(_px < fadeBorder) {
					v *= _px * fadeDiv;
				}
				
				_px = verts[vert].p.y - fadeBounds.top;
				
				if(_px < 0.f) {
					v = 0.f;
				} else if(_px < fadeBorder) {
					v *= _px * fadeDiv;
				}
				
				_px = fadeBounds.bottom - verts[vert].p.y;
				
				if(_px < 0.f) {
					v = 0.f;
				} else if(_px < fadeBorder) {
					v *= _px * fadeDiv;
				}
			}
			
			verts[vert].color = Color::gray(v * alpha).toRGB();
			
			oo += v;
		}
		
		if(oo > 0.f) {
			
			verts[0].p.x += decal.x * g_sizeRatio.x;
			verts[0].p.y += decal.y * g_sizeRatio.y;
			verts[1].p.x += decal.x * g_sizeRatio.x;
			verts[1].p.y += decal.y * g_sizeRatio.y;
			verts[2].p.x += decal.x * g_sizeRatio.x;
			verts[2].p.y += decal.y * g_sizeRatio.y;
			verts[3].p.x += decal.x * g_sizeRatio.x;
			verts[3].p.y += decal.y * g_sizeRatio.y;
			
			m_mapVertices.push_back(verts[0]);
			m_mapVertices.push_back(verts[1]);
			m_mapVertices.push_back(verts[2]);
			
			m_mapVertices.push_back(verts[0]);
			m_mapVertices.push_back(verts[2]);
			m_mapVertices.push_back(verts[3]);
		}
	}
	}

	if(!m_mapVertices.empty()) {
		EERIEDRAWPRIM(Renderer::TriangleList, &m_mapVertices[0], m_mapVertices.size());
	}
	
	GRenderer->SetRenderState(Renderer::AlphaBlending, false);
}
Ejemplo n.º 21
0
void MiniMap::drawBackground(int showLevel, Rect boundaries, float startX, float startY, float zoom, float fadeBorder, float decalX, float decalY, bool invColor, float alpha) {
	
    m_mapVertices.resize(0);

	float caseX = zoom / ((float)MINIMAP_MAX_X);
	float caseY = zoom / ((float)MINIMAP_MAX_Z);
	
	GRenderer->SetTexture(0, m_levels[showLevel].m_texContainer);
	
	float div = (1.0f / 25);
	TextureContainer * tc = m_levels[showLevel].m_texContainer;
	float dw = 1.f / tc->m_pTexture->getStoredSize().x; 
	float dh = 1.f / tc->m_pTexture->getStoredSize().y;
	
	float vx2 = 4.f * dw * m_modX;
	float vy2 = 4.f * dh * m_modZ;
	
	float fadeDiv = 0.f;
	Rect fadeBounds(0, 0, 0, 0);
	
	if(fadeBorder > 0.f) {
		fadeDiv = 1.f/fadeBorder;
		fadeBounds.left = checked_range_cast<Rect::Num>((boundaries.left + fadeBorder) * Xratio);
		fadeBounds.right = checked_range_cast<Rect::Num>((boundaries.right - fadeBorder) * Xratio);
		fadeBounds.top = checked_range_cast<Rect::Num>((boundaries.top + fadeBorder) * Yratio);
		fadeBounds.bottom = checked_range_cast<Rect::Num>((boundaries.bottom - fadeBorder) * Yratio);
	}
	
	GRenderer->SetRenderState(Renderer::AlphaBlending, true);
	if(invColor) {
		GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendInvSrcColor);
	} else {
		GRenderer->SetBlendFunc(Renderer::BlendZero, Renderer::BlendInvSrcColor);
	}
	GRenderer->GetTextureStage(0)->setWrapMode(TextureStage::WrapClamp);

	for(int j = -2; j < MINIMAP_MAX_Z + 2; j++) {
		for(int i = -2; i < MINIMAP_MAX_X + 2; i++) {
			
			float vx, vy, vxx, vyy;
			vxx = ((float)i * (float)m_activeBkg->Xdiv * m_modX);
			vyy = ((float)j * (float)m_activeBkg->Zdiv * m_modZ);
			vx = (vxx * div) * dw;
			vy = (vyy * div) * dh;
			
			float posx = (startX + i * caseX) * Xratio;
			float posy = (startY + j * caseY) * Yratio;
			
			if((posx < boundaries.left * Xratio)
			   || (posx > boundaries.right * Xratio)
			   || (posy < boundaries.top * Yratio)
			   || (posy > boundaries.bottom * Yratio)) {
				continue; // out of bounds
			}

			TexturedVertex verts[4];
			
			verts[3].p.x = verts[0].p.x = (posx);
			verts[1].p.y = verts[0].p.y = (posy);
			verts[2].p.x = verts[1].p.x = posx + (caseX * Xratio);
			verts[3].p.y = verts[2].p.y = posy + (caseY * Yratio);
			
			verts[3].uv.x = verts[0].uv.x = vx;
			verts[1].uv.y = verts[0].uv.y = vy;
			verts[2].uv.x = verts[1].uv.x = vx + vx2;
			verts[3].uv.y = verts[2].uv.y = vy + vy2;
			
			float v;
			float oo = 0.f;
			
			for(int vert = 0; vert < 4; vert++) {
				verts[vert].color = 0xFFFFFFFF;
				verts[vert].rhw = 1;
				verts[vert].p.z = 0.00001f;

				// Array offset according to "vert"
				int iOffset = 0;
				int jOffset = 0;
				
				if(vert == 1 || vert == 2)
					iOffset = 1;
				if(vert == 2 || vert == 3)
					jOffset = 1;
				
				if((i + iOffset < 0) || (i + iOffset >= MINIMAP_MAX_X) || (j + jOffset < 0) || (j + jOffset >= MINIMAP_MAX_Z)) {
					v = 0;
				} else {
					v = ((float)m_levels[showLevel].m_revealed[min(i+iOffset, MINIMAP_MAX_X-iOffset)][min(j+jOffset, MINIMAP_MAX_Z-jOffset)]) * (1.0f / 255);
				}
				
				if(fadeBorder > 0.f) {
					
					float _px = verts[vert].p.x - fadeBounds.left;
					
					if(_px < 0.f) {
						v = 0.f;
					} else if(_px < fadeBorder) {
						v *= _px * fadeDiv;
					}
					
					_px = fadeBounds.right - verts[vert].p.x;
					
					if(_px < 0.f) {
						v = 0.f;
					} else if(_px < fadeBorder) {
						v *= _px * fadeDiv;
					}
					
					_px = verts[vert].p.y - fadeBounds.top;
					
					if(_px < 0.f) {
						v = 0.f;
					} else if(_px < fadeBorder) {
						v *= _px * fadeDiv;
					}
					
					_px = fadeBounds.bottom - verts[vert].p.y;
					
					if(_px < 0.f) {
						v = 0.f;
					} else if(_px < fadeBorder) {
						v *= _px * fadeDiv;
					}
				}
				
				verts[vert].color = Color::gray(v * alpha).toBGR();
				
				oo += v;
			}
			
			if(oo > 0.f) {
				
				verts[0].p.x += decalX * Xratio;
				verts[0].p.y += decalY * Yratio;
				verts[1].p.x += decalX * Xratio;
				verts[1].p.y += decalY * Yratio;
				verts[2].p.x += decalX * Xratio;
				verts[2].p.y += decalY * Yratio;
				verts[3].p.x += decalX * Xratio;
				verts[3].p.y += decalY * Yratio;
				
				m_mapVertices.push_back(verts[0]);
				m_mapVertices.push_back(verts[1]);
				m_mapVertices.push_back(verts[2]);

				m_mapVertices.push_back(verts[0]);
				m_mapVertices.push_back(verts[2]);
				m_mapVertices.push_back(verts[3]);
			}
		}
	}

    EERIEDRAWPRIM(Renderer::TriangleList, m_mapVertices.data(), m_mapVertices.size());
	
	GRenderer->SetRenderState(Renderer::AlphaBlending, false);
}
Ejemplo n.º 22
0
void MiniMap::showBookEntireMap(int showLevel) {
	
	// First Load Minimap TC & DATA if needed
	if(m_levels[showLevel].m_texContainer == NULL) {
		getData(showLevel);
	}
	
	if(!m_levels[showLevel].m_texContainer) {
		return;
	}
	
	GRenderer->SetRenderState(Renderer::DepthTest, false);
	
	float zoom = 250.f;
	float startX = 140.f;
	float startY = 120.f;
	
	Vec2f playerPos(0.f, 0.f);
	
	if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
		playerPos = computePlayerPos(zoom, showLevel);
		playerPos.x += startX;
		playerPos.y += startY;
	}
	
	drawBackground(showLevel, Rect(0, 0, 345, 290), startX, startY, zoom);
	
	GRenderer->GetTextureStage(0)->setWrapMode(TextureStage::WrapRepeat);
	
	if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
		drawPlayer(3.f, playerPos.x, playerPos.y);
		drawDetectedEntities(showLevel, startX, startY, zoom);
	}
	
	TexturedVertex verts[4];
	for(int k = 0; k < 4; k++) {
		verts[k].color = 0xFFFFFFFF;
		verts[k].rhw = 1;
		verts[k].p.z = 0.00001f;
	}
	
	float caseX = zoom / ((float)MINIMAP_MAX_X);
	float caseY = zoom / ((float)MINIMAP_MAX_Z);
	float ratio = 1.f;
	
	for(size_t i = 0; i < m_mapMarkers.size(); i++) {
		
		if(m_mapMarkers[i].m_lvl != showLevel + 1) {
			continue;
		}
		
		float pos_x = m_mapMarkers[i].m_x * 8 * ratio * m_activeBkg->Xmul * caseX + startX;
		float pos_y = m_mapMarkers[i].m_y * 8 * ratio * m_activeBkg->Zmul * caseY + startY;
		float size = 5.f * ratio;
		verts[0].color = 0xFFFF0000;
		verts[1].color = 0xFFFF0000;
		verts[2].color = 0xFFFF0000;
		verts[3].color = 0xFFFF0000;
		verts[0].p.x = (pos_x - size) * Xratio;
		verts[0].p.y = (pos_y - size) * Yratio;
		verts[1].p.x = (pos_x + size) * Xratio;
		verts[1].p.y = (pos_y - size) * Yratio;
		verts[2].p.x = (pos_x + size) * Xratio;
		verts[2].p.y = (pos_y + size) * Yratio;
		verts[3].p.x = (pos_x - size) * Xratio;
		verts[3].p.y = (pos_y + size) * Yratio;
		verts[0].uv = Vec2f::ZERO;
		verts[1].uv = Vec2f::X_AXIS;
		verts[2].uv = Vec2f::ONE;
		verts[3].uv = Vec2f::Y_AXIS;
		
		if(MouseInRect(verts[0].p.x, verts[0].p.y, verts[2].p.x, verts[2].p.y)) {
			if(!m_mapMarkers[i].m_text.empty()) {
				
				Rect bRect(140, 290, 140 + 205, 358);
				
				Rect::Num left = checked_range_cast<Rect::Num>((bRect.left) * Xratio);
				Rect::Num right = checked_range_cast<Rect::Num>((bRect.right) * Xratio);
				Rect::Num top = checked_range_cast<Rect::Num>((bRect.top) * Yratio);
				Rect::Num bottom = checked_range_cast<Rect::Num>((bRect.bottom) * Yratio);
				Rect rRect = Rect(left, top, right, bottom);
				
				long lLengthDraw = ARX_UNICODE_ForceFormattingInRect(hFontInGameNote, m_mapMarkers[i].m_text, rRect);
				
				DrawBookTextInRect(hFontInGameNote, float(bRect.left), float(bRect.top), float(bRect.right), m_mapMarkers[i].m_text.substr(0, lLengthDraw), Color::none);
			}
		}
		
		if(m_mapMarkerTexCont == NULL) {
			m_mapMarkerTexCont = TextureContainer::Load("graph/interface/icons/mapmarker");
		}
		
		GRenderer->SetTexture(0, m_mapMarkerTexCont);
		
		EERIEDRAWPRIM(Renderer::TriangleFan, verts, 4);
	}
}
Ejemplo n.º 23
0
void SetTextureDrawPrim(TextureContainer* tex, TexturedVertex* v, Renderer::Primitive prim) {
	GRenderer->SetTexture(0, tex);
	EERIEDRAWPRIM(prim, v, 4);
}
Ejemplo n.º 24
0
void ARXDRAW_DrawAllTransPolysPos( LPDIRECT3DDEVICE7 pd3dDevice, long MODIF )
{
	int flg_NOCOUNT_USEVB = EERIE_NOCOUNT | (bSoftRender?EERIE_USEVB:0);
	SetZBias( pd3dDevice, 1 );

	SETALPHABLEND( pd3dDevice, TRUE );

	long i, to = 0; 

	register EERIEPOLY * ep;

	for ( i = 0 ; i < TRANSPOLYSPOS ; i++ ) 
	{
		ep = TransPol[i];

		if ( ( !( Project.hide & HIDE_BACKGROUND ) ) )
		{
			if ( ep->type & POLY_DOUBLESIDED ) SETCULL( pd3dDevice, D3DCULL_NONE );
			else SETCULL( pd3dDevice, D3DCULL_CW );
		
			if ( ViewMode & VIEWMODE_FLAT ) SETTC( pd3dDevice, NULL );
			else	SETTC( pd3dDevice, ep->tex );

			if ( ep->type & POLY_QUAD ) to = 4;
			else to = 3;

			float ttt = ep->transval;

			if ( ttt >= 2.f )  //MULTIPLICATIVE
			{
				SETBLENDMODE( pd3dDevice, D3DBLEND_ONE, D3DBLEND_ONE );
				ttt	*= DIV2;
				ttt	+= 0.5f;
				ep->tv[3].color = ep->tv[2].color = ep->tv[1].color = ep->tv[0].color = _EERIERGB( ttt );
			}
			else if ( ttt >= 1.f ) //ADDITIVE
			{	
				ttt -= 1.f;
				SETBLENDMODE( pd3dDevice, D3DBLEND_ONE, D3DBLEND_ONE );
				ep->tv[3].color = ep->tv[2].color = ep->tv[1].color = ep->tv[0].color = _EERIERGB( ttt );
			}
			else if ( ttt > 0.f )  //NORMAL TRANS
			{
				ttt = 1.f - ttt;
				SETBLENDMODE( pd3dDevice, D3DBLEND_DESTCOLOR, D3DBLEND_SRCCOLOR );
				ep->tv[3].color = ep->tv[2].color = ep->tv[1].color = ep->tv[0].color = _EERIERGBA(ttt);  
			}
			else  //SUBTRACTIVE
			{
				SETBLENDMODE( pd3dDevice, D3DBLEND_ZERO, D3DBLEND_INVSRCCOLOR );
				ttt = 1.f - ttt;
				ep->tv[3].color = ep->tv[2].color = ep->tv[1].color = ep->tv[0].color = _EERIERGB( ttt );
			}

			EERIEDRAWPRIM( pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE , ep->tv, to,  0, bSoftRender?EERIE_USEVB:0  );

				if (ep->type & POLY_LAVA)
				{
					pd3dDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND,  D3DBLEND_DESTCOLOR );
					pd3dDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE );	
					SETALPHABLEND( pd3dDevice, TRUE );	
					D3DTLVERTEX verts[4];
					SETTC( pd3dDevice, enviro );

				ARX_CHECK(to > 0);

					for ( long j = 0 ; j < to ; j++ )
					{
						verts[j].sx		= ep->tv[j].sx;
						verts[j].sy		= ep->tv[j].sy;
						verts[j].sz		= ep->tv[j].sz;
						verts[j].rhw	= ep->tv[j].rhw;
						verts[j].color	= 0xFFFFFFFF;
						verts[j].tu		= ep->v[j].sx * DIV1000 + EEsin( ( ep->v[j].sx ) * DIV200 + (float) FrameTime * DIV2000 ) * DIV20;
						verts[j].tv		= ep->v[j].sz * DIV1000 + EEcos( (ep->v[j].sz) * DIV200 + (float) FrameTime * DIV2000 ) * DIV20;
					}	

					EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, to, 0, flg_NOCOUNT_USEVB );

					for ( i = 0 ; i < to ; i++ )
					{
						verts[i].tu = ep->v[i].sx * DIV1000 + EEsin( ( ep->v[i].sx ) * DIV100 + (float)FrameTime * DIV2000 ) * DIV10;
						verts[i].tv = ep->v[i].sz * DIV1000 + EEcos( ( ep->v[i].sz ) * DIV100 + (float)FrameTime * DIV2000 ) * DIV10;
					}	
					EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, to, 0, flg_NOCOUNT_USEVB );
					
					for ( i = 0 ; i < to ; i++ )
					{
							verts[i].tu		= ep->v[i].sx * DIV600 + EEsin ( ( ep->v[i].sx ) * DIV160 + (float)FrameTime * DIV2000 ) * DIV11;
							verts[i].tv		= ep->v[i].sz * DIV600 + EEcos ( ( ep->v[i].sz ) * DIV160 + (float)FrameTime * DIV2000 ) * DIV11;
							verts[i].color	= 0xFF666666;
					}	

					pd3dDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND,  D3DBLEND_ZERO );
					pd3dDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCCOLOR );
					EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, to, 0, flg_NOCOUNT_USEVB );
				}
			}


		if ( ep->type & POLY_WATER )
		{
				pd3dDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND,  D3DBLEND_DESTCOLOR );
				pd3dDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE );	

				SETALPHABLEND( pd3dDevice, TRUE );	
				
				D3DTLVERTEX verts[4];

				SETTC( pd3dDevice, enviro );

			ARX_CHECK(to > 0);

				for ( long j = 0 ; j < to ; j++ )
				{
					verts[j].sx		= ep->tv[j].sx;
					verts[j].sy		= ep->tv[j].sy;
					verts[j].sz		= ep->tv[j].sz;
					verts[j].rhw	= ep->tv[j].rhw;
					verts[j].color	= 0xFF505050;
					verts[j].tu		= ep->v[j].sx * DIV1000 + EEsin( ( ep->v[j].sx ) * DIV200 + (float)FrameTime * DIV1000 ) * DIV32;
					verts[j].tv		= ep->v[j].sz * DIV1000 + EEcos( ( ep->v[j].sz ) * DIV200 + (float)FrameTime * DIV1000 ) * DIV32;

					if ( ep->type & POLY_FALL ) verts[j].tv += (float)FrameTime * DIV4000;
				}

				EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, to, 0, flg_NOCOUNT_USEVB );

				for ( i = 0 ; i < to ; i++ )
				{
					verts[i].tu = ( ep->v[i].sx + 30.f ) * DIV1000 + EEsin( ( ep->v[i].sx + 30 ) * DIV200 + (float)FrameTime * DIV1000 ) * DIV28;
					verts[i].tv = ( ep->v[i].sz + 30.f ) * DIV1000 - EEcos( ( ep->v[i].sz + 30 ) * DIV200 + (float)FrameTime * DIV1000 ) * DIV28;

					if ( ep->type & POLY_FALL ) verts[i].tv += (float)FrameTime * DIV4000;
				}

				EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, to, 0, flg_NOCOUNT_USEVB );

				for ( i = 0 ; i < to ; i++ )
				{
					verts[i].tu = ( ep->v[i].sx + 60.f ) * DIV1000 - EEsin( ( ep->v[i].sx + 60 ) * DIV200 + (float)FrameTime * DIV1000 ) * DIV40;
					verts[i].tv = ( ep->v[i].sz + 60.f ) * DIV1000 - EEcos( ( ep->v[i].sz + 60 ) * DIV200 + (float)FrameTime * DIV1000 ) * DIV40;

					if ( ep->type & POLY_FALL ) verts[i].tv += (float)FrameTime * DIV4000;
				}	
				EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, to, 0, flg_NOCOUNT_USEVB );
		}
	}

	SetZBias( pd3dDevice, 0 );
}
Ejemplo n.º 25
0
//#############################################################################################
// Render de la scene
//#############################################################################################
BOOL C_ARX_Carte::Render(void)
{
	if((!this->device)||(!this->background)) return E_FAIL;

	CalcFPS();
	device->Clear(0,NULL,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,0x00000000,1.0f,0L);

	if(!danaeApp.DANAEStartRender()) return E_FAIL;

	int depx = (int)(this->posx * this->background->Xmul);

	if(depx<0) depx=0;

	int depz=(int)(this->posz*this->background->Zmul);

	if(depz<0) depz=0;

	int	endx=this->widthrender/this->nbpixels;
	int	endz=this->heightrender/this->nbpixels;
	endx+=depx;

	if(endx>this->background->Xsize) endx=this->background->Xsize;

	endz+=depz;

	if(endz>this->background->Zsize) endz=this->background->Zsize;

	float yecran=0.f;
	float zsub=((float)depz)*this->background->Zdiv;

	for(int j=depz;j<endz;j++) 
	{
		float xecran=0.f;
		float xsub=((float)depx)*this->background->Xdiv;

		for(int i=depx;i<endx;i++) 
		{
			EERIE_BKG_INFO *eg=&this->background->Backg[i+j*this->background->Xsize];

			for(int lll=0;lll<eg->nbpoly;lll++)
			{
				EERIEPOLY *ep=&eg->polydata[lll];

				if (ep)
				{
					if(ep->type&POLY_IGNORE) continue;

					if(ep->type&POLY_TRANS) continue;
					
					int nb;

					if(ep->type&POLY_QUAD) nb=4;
					else nb=3;

					for(int k=0;k<nb;k++)
					{
						ep->tv[k].sx=xecran+(ep->v[k].sx-xsub)*this->ecx;
						ep->tv[k].sy=yecran+(ep->v[k].sz-zsub)*this->ecz;
						ep->tv[k].rhw=(1.f/ep->v[k].sy);

						if (ep->tv[k].rhw<0.f) ep->tv[k].rhw=0.f;

						if (ep->tv[k].rhw>1.f) ep->tv[k].rhw=1.f;

						ep->tv[k].sz=1.f-ep->tv[k].rhw;

						if (ep->tv[k].sz<0.f) ep->tv[k].sz=0.f;

						if (ep->tv[k].sz>1.f) ep->tv[k].sz=1.f;

						ep->tv[k].color=0xFFFFFFFF;
						ep->tv[k].tu=ep->v[k].tu;
						ep->tv[k].tv=ep->v[k].tv;
					}

					if(ep->tex)
						device->SetTexture(0,ep->tex->m_pddsSurface);
					else
						device->SetTexture(0,NULL);

					EERIEDRAWPRIM( device,	D3DPT_TRIANGLESTRIP,
											D3DFVF_TLVERTEX|D3DFVF_DIFFUSE,
											ep->tv,
											nb,
											0, EERIE_NOCOUNT );
				}

			}

			xsub+=this->background->Xdiv;
			xecran+=(float)this->nbpixels;
		}

		zsub+=this->background->Zdiv;
		yecran+=(float)this->nbpixels;
	}

	return S_OK;
}
Ejemplo n.º 26
0
void ARXDRAW_DrawInterShadows() {
	
	ARX_PROFILE_FUNC();
	
	g_shadowBatch.clear();
	
	GRenderer->SetFogColor(Color::none);
	GRenderer->SetDepthBias(1);
	
	for(long i=0; i<TREATZONE_CUR; i++) {
		if(treatio[i].show != 1 || !treatio[i].io)
			continue;
		
		Entity *io = treatio[i].io;
		
		if(   !io->obj
		   || (io->ioflags & IO_JUST_COLLIDE)
		   || (io->ioflags & IO_NOSHADOW)
		   || (io->ioflags & IO_GOLD)
		   || !(io->show == SHOW_FLAG_IN_SCENE)
		) {
			continue;
		}
		
		
		EERIE_BKG_INFO * bkgData = getFastBackgroundData(io->pos.x, io->pos.z);
		if(bkgData && !bkgData->treat) { //TODO is that correct ?
			continue;
		}
		
		TexturedVertex ltv[4];
		ltv[0] = TexturedVertex(Vec3f(0, 0, 0.001f), 1.f, ColorRGBA(0), Vec2f(0.3f, 0.3f));
		ltv[1] = TexturedVertex(Vec3f(0, 0, 0.001f), 1.f, ColorRGBA(0), Vec2f(0.7f, 0.3f));
		ltv[2] = TexturedVertex(Vec3f(0, 0, 0.001f), 1.f, ColorRGBA(0), Vec2f(0.7f, 0.7f));
		ltv[3] = TexturedVertex(Vec3f(0, 0, 0.001f), 1.f, ColorRGBA(0), Vec2f(0.3f, 0.7f));
		
		if(io->obj->grouplist.size() <= 1) {
			for(size_t k = 0; k < io->obj->vertexlist.size(); k += 9) {
				EERIEPOLY *ep = CheckInPoly(io->obj->vertexlist3[k].v);
				
				if(!ep)
					continue;
				
				Vec3f in;
				in.y = ep->min.y - 3.f;
				float r = 0.5f - ((float)glm::abs(io->obj->vertexlist3[k].v.y - in.y)) * (1.f/500);
				r -= io->invisibility;
				r *= io->scale;
				
				if(r <= 0.f)
					continue;
				
				float s1 = 16.f * io->scale;
				float s2 = s1 * (1.f/2);
				in.x = io->obj->vertexlist3[k].v.x - s2;
				in.z = io->obj->vertexlist3[k].v.z - s2;
				
				r *= 255.f;
				long lv = r;
				ltv[0].color = ltv[1].color = ltv[2].color = ltv[3].color = Color(lv, lv, lv, 255).toRGBA();
				
				ltv[0].p = EE_RT(in);
				in.x += s1;
				ltv[1].p = EE_RT(in);
				in.z += s1;
				ltv[2].p = EE_RT(in);
				in.x -= s1;
				ltv[3].p = EE_RT(in);
				
				if(ltv[0].p.z > 0.f && ltv[1].p.z > 0.f && ltv[2].p.z > 0.f) {
					AddToShadowBatch(&ltv[0], &ltv[1], &ltv[2]);
					AddToShadowBatch(&ltv[0], &ltv[2], &ltv[3]);
				}
			}
		} else {
			for(size_t k = 0; k < io->obj->grouplist.size(); k++) {
				long origin = io->obj->grouplist[k].origin;
				EERIEPOLY *ep = CheckInPoly(io->obj->vertexlist3[origin].v);
				
				if(!ep)
					continue;
				
				Vec3f in;
				in.y = ep->min.y - 3.f;
				float r = 0.8f - ((float)glm::abs(io->obj->vertexlist3[origin].v.y - in.y)) * (1.f/500);
				r *= io->obj->grouplist[k].siz;
				r -= io->invisibility;
				
				if(r <= 0.f)
					continue;
				
				float s1 = io->obj->grouplist[k].siz * 44.f;
				float s2 = s1 * (1.f/2);
				in.x = io->obj->vertexlist3[origin].v.x - s2;
				in.z = io->obj->vertexlist3[origin].v.z - s2;
				
				r *= 255.f;
				long lv = r;
				ltv[0].color = ltv[1].color = ltv[2].color = ltv[3].color = Color(lv, lv, lv, 255).toRGBA();
				
				ltv[0].p = EE_RT(in);
				in.x += s1;
				ltv[1].p = EE_RT(in);
				in.z += s1;
				ltv[2].p = EE_RT(in);
				in.x -= s1;
				ltv[3].p = EE_RT(in);
				
				AddToShadowBatch(&ltv[0], &ltv[1], &ltv[2]);
				AddToShadowBatch(&ltv[0], &ltv[2], &ltv[3]);
			}
		}
	}
	
	if(g_shadowBatch.size() > 0)
	{
		GRenderer->SetRenderState(Renderer::DepthWrite, false);
		GRenderer->SetBlendFunc(Renderer::BlendZero, Renderer::BlendInvSrcColor);
		GRenderer->SetRenderState(Renderer::AlphaBlending, true);
		GRenderer->SetTexture(0, Boom);
		
		EERIEDRAWPRIM(Renderer::TriangleList, &g_shadowBatch[0], g_shadowBatch.size());
		
		GRenderer->SetRenderState(Renderer::AlphaBlending, false);
		GRenderer->SetRenderState(Renderer::DepthWrite, true);
		GRenderer->SetDepthBias(0);
		GRenderer->SetFogColor(ulBKGColor);
	}
}
Ejemplo n.º 27
0
//-----------------------------------------------------------------------------
void ARX_MINIMAP_Show(LPDIRECT3DDEVICE7 m_pd3dDevice, long SHOWLEVEL, long flag, long fl2)
{
	float sstartx, sstarty;

	if (!pTexDetect)
	{
		GetTextureFile("Graph\\particles\\flare.bmp");
		char temp[256];
		MakeDir(temp, "Graph\\particles\\flare.bmp");
		pTexDetect = D3DTextr_GetSurfaceContainer(temp);
	}

	//	SHOWLEVEL=8;
	// First Load Minimap TC & DATA if needed
	if (minimap[SHOWLEVEL].tc == NULL)
	{
		ARX_MINIMAP_GetData(SHOWLEVEL);
	}

	if ((minimap[SHOWLEVEL].tc) && (minimap[SHOWLEVEL].tc->m_pddsSurface))
	{
		float startx, starty, casex, casey, ratiooo;
		float mod_x = (float)MAX_BKGX / (float)MINIMAP_MAX_X;
		float mod_z = (float)MAX_BKGZ / (float)MINIMAP_MAX_Z;

		if (flag == 1)
		{


			startx = 0;
			starty = 0;
			casex = (900) / ((float)MINIMAP_MAX_X);
			casey = (900) / ((float)MINIMAP_MAX_Z);
			ratiooo = 900.f / 250.f;

			if (fl2)
			{
				casex = (600) / ((float)MINIMAP_MAX_X);
				casey = (600) / ((float)MINIMAP_MAX_Z);
				ratiooo = 600.f / 250.f;
			}

		}
		else
		{
			startx = (140); 
			starty = (120);
			casex = (250) / ((float)MINIMAP_MAX_X);
			casey = (250) / ((float)MINIMAP_MAX_Z);
			ratiooo = 1.f;
		}

		sstartx = startx;
		sstarty = starty;


		float ofx, ofx2, ofy, ofy2, px, py;
		px = py = 0.f;

		ofx		= mini_offset_x[CURRENTLEVEL];
		ofx2	= minimap[SHOWLEVEL].xratio;
		ofy		= mini_offset_y[CURRENTLEVEL];
		ofy2	= minimap[SHOWLEVEL].yratio;

		if ((SHOWLEVEL == ARX_LEVELS_GetRealNum(CURRENTLEVEL)) || (flag == 2))
		{
			// Computes playerpos
			ofx = mini_offset_x[CURRENTLEVEL];
			ofx2 = minimap[SHOWLEVEL].xratio;
			ofy = mini_offset_y[CURRENTLEVEL];
			ofy2 = minimap[SHOWLEVEL].yratio;
		
			px = startx + ((player.pos.x + ofx - ofx2) * DIV100 * casex
			               + mini_offset_x[CURRENTLEVEL] * ratiooo * mod_x) / mod_x ; //DIV100*2;
			py = starty + ((mapmaxy[SHOWLEVEL] - ofy - ofy2) * DIV100 * casey
			               - (player.pos.z + ofy - ofy2) * DIV100 * casey + mini_offset_y[CURRENTLEVEL] * ratiooo * mod_z) / mod_z ;    //DIV100*2;

			if (flag == 1)
			{
				sstartx = startx;
				sstarty = starty;

				startx = 490.f - px;
				starty = 220.f - py;
				px += startx;
				py += starty;
			}
		}


		D3DTLVERTEX verts[4];
		SETTC(m_pd3dDevice, minimap[SHOWLEVEL].tc);

		for (long k = 0; k < 4; k++)
		{
			verts[k].color = 0xFFFFFFFF;
			verts[k].rhw = 1;
			verts[k].sz = 0.00001f;
		}

		float div = DIV25;
		TextureContainer * tc = minimap[SHOWLEVEL].tc;
		float dw = 1.f / (float)max(tc->m_dwDeviceWidth, tc->m_dwOriginalWidth); 
		float dh = 1.f / (float)max(tc->m_dwDeviceHeight, tc->m_dwOriginalHeight);
		
		float vx2 = 4.f * dw * mod_x;
		float vy2 = 4.f * dh * mod_z;

		float _px;
		RECT boundaries;
		float MOD20, MOD20DIV, divXratio, divYratio;

		boundaries.bottom = boundaries.left = boundaries.right = boundaries.top = 0;
		MOD20 = MOD20DIV = divXratio = divYratio = 0.f;

		if (flag != 2)
		{

			if (flag == 1)
			{
				MOD20 = 20.f * Xratio;
				MOD20DIV = 1.f / (MOD20);
				//@PERF do if(fl2){}else{} to make 4 and not 8 flot op if fl2.

				ARX_CHECK_LONG((360 + MOD20)*Xratio);
				ARX_CHECK_LONG((555 - MOD20)*Xratio);
				ARX_CHECK_LONG((85 + MOD20)*Yratio);
				ARX_CHECK_LONG((355 - MOD20)*Yratio);

				//CAST
				boundaries.left		=	ARX_CLEAN_WARN_CAST_LONG((360 + MOD20) * Xratio);
				boundaries.right	=	ARX_CLEAN_WARN_CAST_LONG((555 - MOD20) * Xratio);
				boundaries.top		=	ARX_CLEAN_WARN_CAST_LONG((85 + MOD20) * Yratio);
				boundaries.bottom	=	ARX_CLEAN_WARN_CAST_LONG((355 - MOD20) * Yratio);

				if (fl2)
				{
					//CHECK (DEBUG)
					ARX_CHECK_LONG((390 + MOD20)*Xratio);
					ARX_CHECK_LONG((590 - MOD20)*Xratio);
					ARX_CHECK_LONG((135 + MOD20)*Yratio);
					ARX_CHECK_LONG((295 - MOD20)*Yratio);

					//CAST
					boundaries.left		=	ARX_CLEAN_WARN_CAST_LONG((390 + MOD20) * Xratio);
					boundaries.right	=	ARX_CLEAN_WARN_CAST_LONG((590 - MOD20) * Xratio);
					boundaries.top		=	ARX_CLEAN_WARN_CAST_LONG((135 + MOD20) * Yratio);
					boundaries.bottom	=	ARX_CLEAN_WARN_CAST_LONG((295 - MOD20) * Yratio);
				}
			}

			SETALPHABLEND(m_pd3dDevice, TRUE);
			m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,  D3DBLEND_ZERO);
			m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCCOLOR);
			m_pd3dDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS);
			SETTEXTUREWRAPMODE(m_pd3dDevice, D3DTADDRESS_CLAMP);

			if (fl2)
			{
				m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,  D3DBLEND_ONE);
				m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCCOLOR);
			}
		}
		else
		{
			divXratio = 1.f / Xratio;
			divYratio = 1.f / Yratio;
		}

		for (long j = -2; j < MINIMAP_MAX_Z + 2; j++)
		{
			for (long i = -2; i < MINIMAP_MAX_X + 2; i++)
			{
				float vx, vy, vxx, vyy;
				vxx = ((float)i * (float)ACTIVEBKG->Xdiv * mod_x);
				vyy = ((float)j * (float)ACTIVEBKG->Zdiv * mod_z);
				vx = (vxx * div) * dw;
				vy = (vyy * div) * dh;

				long okay = 1;
				float posx = (startx + i * casex) * Xratio;
				float posy = (starty + j * casey) * Yratio;

				if (flag == 1)
				{

					if	((posx < 360 * Xratio)
					        ||	(posx > 555 * Xratio)
					        ||	(posy < 85 * Yratio)
					        ||	(posy > 355 * Yratio))
						okay = 0;

					if (fl2)
					{
						okay = 1;

						if	((posx < 390 * Xratio)
						        ||	(posx > 590 * Xratio)
						        ||	(posy < 135 * Yratio)
						        ||	(posy > 295 * Yratio))
							okay = 0;
					}

				}
				else
				{
					if ((posx > 345 * Xratio)
					        ||	(posy > 290 * Yratio))
						okay = 0;
				}

				if (okay)
				{
					if ((flag == 2)
					        && (i >= 0) && (i < MINIMAP_MAX_X)
					        && (j >= 0) && (j < MINIMAP_MAX_Z))
					{
						float d = Distance2D(posx * divXratio + casex * DIV2, posy * divYratio /*-casey * 2 * Yratio*/, px, py);

						if (d <= 6.f)
						{
							long r;
							float vv = (6 - d) * DIV6;

							if (vv >= 0.5f)
								vv = 1.f;
							else if (vv > 0.f)
								vv = vv * 2.f;
							else
								vv = 0.f;

							F2L((float)(vv * 255.f), &r);


							long ucLevel =  __max(r, minimap[SHOWLEVEL].revealed[i][j]);
							ARX_CHECK_UCHAR(ucLevel);

							minimap[SHOWLEVEL].revealed[i][j] = ARX_CLEAN_WARN_CAST_UCHAR(ucLevel);


						}
					}

					if (!FOR_EXTERNAL_PEOPLE)
					{
						if ((i >= 0) && (i < MINIMAP_MAX_X)
						        &&	(j >= 0) && (j < MINIMAP_MAX_Z))
						{
							minimap[SHOWLEVEL].revealed[i][j] = 255;
						}
					}

					verts[3].sx = verts[0].sx = (posx);
					verts[1].sy = verts[0].sy = (posy);
					verts[2].sx = verts[1].sx = posx + (casex * Xratio);
					verts[3].sy = verts[2].sy = posy + (casey * Yratio);

					verts[3].tu = verts[0].tu = vx;
					verts[1].tv = verts[0].tv = vy;
					verts[2].tu = verts[1].tu = vx + vx2;
					verts[3].tv = verts[2].tv = vy + vy2;

					if (flag != 2)
					{
						float v;
						float oo = 0.f;

						if ((i < 0) || (i >= MINIMAP_MAX_X) || (j < 0) || (j >= MINIMAP_MAX_Z)) v = 0;
						else v = ((float)minimap[SHOWLEVEL].revealed[i][j]) * DIV255;

						if (flag == 1)
						{
							long vert = 0;
							_px = verts[vert].sx - boundaries.left;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.right - verts[vert].sx;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = verts[vert].sy - boundaries.top;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.bottom - verts[vert].sy;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;
						}

						if (fl2) verts[0].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2);
						else
							verts[0].color = D3DRGB(v, v, v);

						oo += v;

						if ((i + 1 < 0) || (i + 1 >= MINIMAP_MAX_X) || (j < 0) || (j >= MINIMAP_MAX_Z)) v = 0;
						else v = ((float)minimap[SHOWLEVEL].revealed[__min(i+1, MINIMAP_MAX_X-1)][j]) * DIV255;

						if (flag == 1)
						{
							long vert = 1;
							_px = verts[vert].sx - boundaries.left;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.right - verts[vert].sx;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = verts[vert].sy - boundaries.top;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.bottom - verts[vert].sy;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;
						}

						if (fl2) verts[1].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2);
						else
							verts[1].color = D3DRGB(v, v, v);

						oo += v;

						if ((i + 1 < 0) || (i + 1 >= MINIMAP_MAX_X) || (j + 1 < 0) || (j + 1 >= MINIMAP_MAX_Z)) v = 0;
						else v = ((float)minimap[SHOWLEVEL].revealed[__min(i+1, MINIMAP_MAX_X-1)][__min(j+1, MINIMAP_MAX_Z-1)]) * DIV255;

						if (flag == 1)
						{
							long vert = 2;
							_px = verts[vert].sx - boundaries.left;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.right - verts[vert].sx;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = verts[vert].sy - boundaries.top;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.bottom - verts[vert].sy;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;
						}
						

						if (fl2) verts[2].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2);
						else
							verts[2].color = D3DRGB(v, v, v);

						oo += v;

						if ((i < 0) || (i >= MINIMAP_MAX_X) || (j + 1 < 0) || (j + 1 >= MINIMAP_MAX_Z)) v = 0;
						else v = ((float)minimap[SHOWLEVEL].revealed[i][__min(j+1, MINIMAP_MAX_Z-1)]) * DIV255;

						if (flag == 1)
						{
							long vert = 3;
							_px = verts[vert].sx - boundaries.left;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.right - verts[vert].sx;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = verts[vert].sy - boundaries.top;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;

							_px = boundaries.bottom - verts[vert].sy;

							if (_px < 0.f) v = 0.f;
							else if (_px < MOD20) v *= _px * MOD20DIV;
						}

						if (fl2) verts[3].color = D3DRGB(v * DIV2, v * DIV2, v * DIV2);
						else
							verts[3].color = D3DRGB(v, v, v);

						oo += v;

						if (oo > 0.f)
						{
							if (fl2)
							{
								verts[0].sx += DECALX * Xratio;
								verts[0].sy += DECALY * Yratio;
								verts[1].sx += DECALX * Xratio;
								verts[1].sy += DECALY * Yratio;
								verts[2].sx += DECALX * Xratio;
								verts[2].sy += DECALY * Yratio;
								verts[3].sx += DECALX * Xratio;
								verts[3].sy += DECALY * Yratio;
							}

							EERIEDRAWPRIM(GDevice, D3DPT_TRIANGLEFAN, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, 4, 0);
						}
					}
				}
			}
		}

		if (flag != 2)
		{
			m_pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESS , D3DTADDRESS_WRAP);
			m_pd3dDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESSEQUAL);

			SETALPHABLEND(m_pd3dDevice, FALSE);

			if ((SHOWLEVEL == ARX_LEVELS_GetRealNum(CURRENTLEVEL)))
			{
				// Now Draws Playerpos/angle
				verts[0].color = 0xFFFF0000;
				verts[1].color = 0xFFFF0000;
				verts[2].color = 0xFFFF0000;
				float val;

				if (flag == 1) val = 6.f;
				else val = 3.f;

				float rx = 0.f;
				float ry = -val * 1.8f;
				float rx2 = -val * DIV2;
				float ry2 = val;
				float rx3 = val * DIV2;
				float ry3 = val;

				float angle = DEG2RAD(player.angle.b);
				float ca = EEcos(angle);
				float sa = EEsin(angle);

				verts[0].sx = (px + rx2 * ca + ry2 * sa) * Xratio;
				verts[0].sy = (py + ry2 * ca - rx2 * sa) * Yratio;
				verts[1].sx = (px + rx * ca + ry * sa) * Xratio;
				verts[1].sy = (py + ry * ca - rx * sa) * Yratio;
				verts[2].sx = (px + rx3 * ca + ry3 * sa) * Xratio;
				verts[2].sy = (py + ry3 * ca - rx3 * sa) * Yratio;

				SETTC(GDevice, NULL);

				if (fl2)
				{
					SETALPHABLEND(m_pd3dDevice, TRUE);
					verts[0].sx += DECALX * Xratio;
					verts[0].sy += DECALY * Yratio;
					verts[1].sx += DECALX * Xratio;
					verts[1].sy += DECALY * Yratio;
					verts[2].sx += DECALX * Xratio;
					verts[2].sy += DECALY * Yratio;
				}

				EERIEDRAWPRIM(GDevice, D3DPT_TRIANGLEFAN, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, 3, 0);

				if (fl2) SETALPHABLEND(m_pd3dDevice, FALSE);
			}
		}

		// tsu
		for (long lnpc = 1; lnpc < inter.nbmax; lnpc++)
		{
			if ((inter.iobj[lnpc] != NULL) && (inter.iobj[lnpc]->ioflags & IO_NPC))
			{
				if (inter.iobj[lnpc]->_npcdata->life > 0.f)
					if (!((inter.iobj[lnpc]->GameFlags & GFLAG_MEGAHIDE) ||
					        (inter.iobj[lnpc]->show == SHOW_FLAG_MEGAHIDE))
					        && (inter.iobj[lnpc]->show == SHOW_FLAG_IN_SCENE))
						if (!(inter.iobj[lnpc]->show == SHOW_FLAG_HIDDEN))
							if (inter.iobj[lnpc]->_npcdata->fDetect >= 0)
							{
								if (player.Full_Skill_Etheral_Link >= inter.iobj[lnpc]->_npcdata->fDetect)
								{
									float fpx;
									float fpy;
								
									fpx = sstartx + ((inter.iobj[lnpc]->pos.x - 100 + ofx - ofx2) * DIV100 * casex
									                 + mini_offset_x[CURRENTLEVEL] * ratiooo * mod_x) / mod_x; 
									fpy = sstarty + ((mapmaxy[SHOWLEVEL] - ofy - ofy2) * DIV100 * casey
									                 - (inter.iobj[lnpc]->pos.z + 200 + ofy - ofy2) * DIV100 * casey + mini_offset_y[CURRENTLEVEL] * ratiooo * mod_z) / mod_z; 

									if (flag == 1)
									{

										fpx = startx + ((inter.iobj[lnpc]->pos.x - 100 + ofx - ofx2) * DIV100 * casex
										                + mini_offset_x[CURRENTLEVEL] * ratiooo * mod_x) / mod_x; 
										fpy = starty + ((mapmaxy[SHOWLEVEL] - ofy - ofy2) * DIV100 * casey
										                - (inter.iobj[lnpc]->pos.z + 200 + ofy - ofy2) * DIV100 * casey + mini_offset_y[CURRENTLEVEL] * ratiooo * mod_z) / mod_z; 


									}

									float d = Distance2D(player.pos.x, player.pos.z, inter.iobj[lnpc]->pos.x, inter.iobj[lnpc]->pos.z);

		
									if ((d <= 800) && (fabs(inter.iobj[0]->pos.y - inter.iobj[lnpc]->pos.y) < 250.f))
									{
										float col = 1.f;

										if (d > 600.f)
										{
											col = 1.f - (d - 600.f) * DIV200;
										}

										if (!fl2)
										{
											SETALPHABLEND(m_pd3dDevice, true);
											m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,  D3DBLEND_ONE);
											m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
										}
										else
											SETALPHABLEND(m_pd3dDevice, true);

										if (fl2)
										{
											fpx += DECALX * Xratio;
											fpy += (DECALY + 15) * Yratio;
										}

										fpx *= Xratio;
										fpy *= Yratio;
										EERIEDrawBitmap(GDevice, fpx, fpy,
										                5.f * ratiooo, 5.f * ratiooo, 0, pTexDetect, D3DRGB(col, 0, 0));

										if (!fl2)
											SETALPHABLEND(m_pd3dDevice, false);
									}
								}
							}
			}
		}

		if (flag == 0)
			for (long i = 0; i < Nb_Mapmarkers; i++)
			{
				if (Mapmarkers[i].lvl == SHOWLEVEL + 1)
				{
					float pos_x = Mapmarkers[i].x * 8 * ratiooo * ACTIVEBKG->Xmul * casex + startx;
					float pos_y = Mapmarkers[i].y * 8 * ratiooo * ACTIVEBKG->Zmul * casey + starty;
					float size = 5.f * ratiooo;
					verts[0].color = 0xFFFF0000;
					verts[1].color = 0xFFFF0000;
					verts[2].color = 0xFFFF0000;
					verts[3].color = 0xFFFF0000;
					verts[0].sx = (pos_x - size) * Xratio;
					verts[0].sy = (pos_y - size) * Yratio;
					verts[1].sx = (pos_x + size) * Xratio;
					verts[1].sy = (pos_y - size) * Yratio;
					verts[2].sx = (pos_x + size) * Xratio;
					verts[2].sy = (pos_y + size) * Yratio;
					verts[3].sx = (pos_x - size) * Xratio;
					verts[3].sy = (pos_y + size) * Yratio;
					verts[0].tu = 0.f;
					verts[0].tv = 0.f;
					verts[1].tu = 1.f;
					verts[1].tv = 0.f;
					verts[2].tu = 1.f;
					verts[2].tv = 1.f;
					verts[3].tu = 0.f;
					verts[3].tv = 1.f;

					if ((!fl2)
					        && (MouseInRect(verts[0].sx, verts[0].sy, verts[2].sx, verts[2].sy)))
					{
						if (!Mapmarkers[i].tstring)
						{
							_TCHAR output[4096];
							MakeLocalised(Mapmarkers[i].string, output, 4096, 0);
							Mapmarkers[i].tstring = (_TCHAR *)malloc((_tcslen(output) + 1) * sizeof(_TCHAR));
							ZeroMemory(Mapmarkers[i].tstring, (_tcslen(output) + 1)*sizeof(_TCHAR));
							_tcscpy(Mapmarkers[i].tstring, output);
						}

						if (Mapmarkers[i].tstring)
						{
							RECT rRect, bRect;
							SetRect(&bRect	, (140),	(290)
							        , (140 + 205),	(358));

							float fLeft		= (bRect.left) * Xratio ;
							float fRight	= (bRect.right) * Xratio ;
							float fTop		= (bRect.top) * Yratio ;
							float fBottom	= (bRect.bottom) * Yratio ;
							ARX_CHECK_INT(fLeft);
							ARX_CHECK_INT(fRight);
							ARX_CHECK_INT(fTop);
							ARX_CHECK_INT(fBottom);

							SetRect(&rRect
							        , ARX_CLEAN_WARN_CAST_INT(fLeft)
							        , ARX_CLEAN_WARN_CAST_INT(fTop)
							        , ARX_CLEAN_WARN_CAST_INT(fRight)
							        , ARX_CLEAN_WARN_CAST_INT(fBottom));


							long lLengthDraw = ARX_UNICODE_ForceFormattingInRect(
							                       hFontInGameNote, Mapmarkers[i].tstring, 0, rRect);

							danaeApp.DANAEEndRender();
							_TCHAR	Page_Buffer[256];
							_tcsncpy(Page_Buffer, Mapmarkers[i].tstring, lLengthDraw);
							Page_Buffer[lLengthDraw] = _T('\0');

							DrawBookTextInRect(ARX_CLEAN_WARN_CAST_FLOAT(bRect.left), ARX_CLEAN_WARN_CAST_FLOAT(bRect.top),
							                   ARX_CLEAN_WARN_CAST_FLOAT(bRect.right), ARX_CLEAN_WARN_CAST_FLOAT(bRect.bottom),
							                   Page_Buffer, 0, 0x00FF00FF,
							                   hFontInGameNote);


							danaeApp.DANAEStartRender();
						}
					}

					if (MapMarkerTc == NULL)
					{
						MapMarkerTc = MakeTCFromFile("Graph\\interface\\icons\\mapmarker.bmp");
					}

					SETTC(GDevice, MapMarkerTc);

					if (fl2)
					{
						verts[0].sx += DECALX * Xratio;
						verts[0].sy += DECALY * Yratio;
						verts[1].sx += DECALX * Xratio;
						verts[1].sy += DECALY * Yratio;
						verts[2].sx += DECALX * Xratio;
						verts[2].sy += DECALY * Yratio;
						verts[3].sx += DECALX * Xratio;
						verts[3].sy += DECALY * Yratio;
					}

					EERIEDRAWPRIM(GDevice, D3DPT_TRIANGLEFAN, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, 4, 0);
				}
			}

	}
}