Ejemplo n.º 1
0
NVECTOR2 IGraphicObject::GetBasePosOffset()
{
	IRenderer* pRenderer = GetScene()->GetRenderer();
	UINT mainWidth = pRenderer->GetMainBufferWidth();
	UINT mainHeight = pRenderer->GetMainBufferHeight();

	//Position Offset
	NVECTOR2 outBaseTopLeftPixel = *m_pBaseScreenSpacePosOffset;
	//mFunction_ConvertFloatVec2PixelVec(outBaseTopLeftPixel);
	outBaseTopLeftPixel.x = outBaseTopLeftPixel.x *float(mainWidth) / 2.0f;
	outBaseTopLeftPixel.y = - outBaseTopLeftPixel.y * float(mainHeight) / 2.0f;
	return outBaseTopLeftPixel;
}
Ejemplo n.º 2
0
inline float IGraphicObject::mFunction_ConvertPixelLength2FloatLength(float pxLen, BOOL isWidth)
{
	IRenderer* pRenderer = GetScene()->GetRenderer();
	UINT mainWidth = pRenderer->GetMainBufferWidth();
	UINT mainHeight = pRenderer->GetMainBufferHeight();

	float outLength = 0;
	//PIXEL SPACE TO [-1,1] SCR SPACE
	if (isWidth)
	{
		outLength = pxLen*2.0f / (float)mainWidth;
	}
	else
	{
		outLength = pxLen * 2.0f / (float)mainHeight;
	}
	return outLength;
}
Ejemplo n.º 3
0
void		IGraphicObject::mFunction_ConvertFloatVec2PixelVec(NVECTOR2 & in_out_vec)
{
	// --------->
	// |		
	// |	PIXEL SPACE
	// |

	//				  ^
	//				   |
	//		--------|--------->
	//				   |		SCR SPACE
	//				   |
	IRenderer* pRenderer = GetScene()->GetRenderer();
	UINT mainWidth = pRenderer->GetMainBufferWidth();
	UINT mainHeight = pRenderer->GetMainBufferHeight();

	in_out_vec.x = float(mainWidth) *((in_out_vec.x + 1.0f) / 2.0f);
	in_out_vec.y = float(mainHeight)*((1.0f - in_out_vec.y) / 2.0f);
};
Ejemplo n.º 4
0
void IGraphicObject::SetBasePosOffset(NVECTOR2 pixelOffset)
{
	// --------->
	// |		
	// |	PIXEL SPACE
	// |

	//				  ^
	//				   |
	//		--------|--------->
	//				   |		SCR SPACE
	//				   |
	
	IRenderer* pRenderer = GetScene()->GetRenderer();
	UINT mainWidth = pRenderer->GetMainBufferWidth();
	UINT mainHeight = pRenderer->GetMainBufferHeight();

	pixelOffset.x = pixelOffset.x * 2.0f / float(mainWidth);
	pixelOffset.y = -pixelOffset.y*2.0f  / float(mainHeight);

	//vector difference
	NVECTOR2 offsetV = pixelOffset - (*m_pBaseScreenSpacePosOffset);

	if (offsetV.x ==0.0f && offsetV.y == 0.0f)return;


	*m_pBaseScreenSpacePosOffset = pixelOffset;

	//update vertices, deviate with the upper difference
	for (UINT i = 0;i < NOISE_GRAPHIC_OBJECT_BUFFER_COUNT;i++)
	{
		if (i == NOISE_GRAPHIC_OBJECT_TYPE_LINE_3D || i == NOISE_GRAPHIC_OBJECT_TYPE_POINT_3D)continue;
		for (UINT j = 0;j < m_pVB_Mem[i]->size();++j)
		//for (auto &v : *m_pVB_Mem[i])
		{
			m_pVB_Mem[i]->at(j).Pos.x += offsetV.x;
			m_pVB_Mem[i]->at(j).Pos.y += offsetV.y;
		}
		mCanUpdateToGpu[i] = TRUE;
	}
}
Ejemplo n.º 5
0
inline void  IGraphicObject::mFunction_ConvertPixelVec2FloatVec(NVECTOR2& vec)
{
	// --------->
	// |		
	// |	PIXEL SPACE
	// |

	//				  ^
	//				   |
	//		--------|--------->
	//				   |		SCR SPACE
	//				   |
	IRenderer* pRenderer = GetScene()->GetRenderer();
	UINT mainWidth = pRenderer->GetMainBufferWidth();
	UINT mainHeight = pRenderer->GetMainBufferHeight();

	//PIXEL SPACE TO [-1,1] SCR SPACE
	float halfW= (float)mainWidth / 2.0f;
	float halfH = (float)mainHeight / 2.0f;
	vec.x = (vec.x / halfW)- 1.0f;	
	vec.y=1.0f - (vec.y / halfH);
	//vec -= *m_pBaseScreenSpacePosOffset;
}