//----------------------------------------------------------------//
void MOAIStretchPatch2D::DrawIndex ( u32 idx, float xOff, float yOff, float zOff, float xScl, float yScl, float zScl ) {
	UNUSED ( xOff );
	UNUSED ( yOff );
	UNUSED ( zOff );
	UNUSED ( xScl );
	UNUSED ( yScl );
	UNUSED ( zScl );
	
	// TODO: make use of offset and scale
	
	MOAIGfxDevice& gfxDevice = MOAIGfxDevice::Get ();
	MOAIQuadBrush::BindVertexFormat ( gfxDevice );
	
	gfxDevice.SetVertexMtxMode ( MOAIGfxDevice::VTX_STAGE_MODEL, MOAIGfxDevice::VTX_STAGE_PROJ );
	gfxDevice.SetUVMtxMode ( MOAIGfxDevice::UV_STAGE_MODEL, MOAIGfxDevice::UV_STAGE_TEXTURE );
	
	USMatrix4x4 transform = gfxDevice.GetVertexTransform ( MOAIGfxDevice::VTX_WORLD_TRANSFORM );
	USVec3D stretch = transform.GetStretch ();
	
	USMatrix4x4 noStretch;
	noStretch.Scale ( 1.0f / stretch.mX, 1.0f / stretch.mY, 1.0f / stretch.mZ );
	noStretch.Append ( transform );
	
	gfxDevice.SetVertexTransform ( MOAIGfxDevice::VTX_WORLD_TRANSFORM, noStretch );
	
	this->UpdateParams ();
	this->DrawStretch ( idx, stretch.mX, stretch.mY );
	
	gfxDevice.SetVertexTransform ( MOAIGfxDevice::VTX_WORLD_TRANSFORM, transform );
}
Beispiel #2
0
//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetWorldToWndMtx () const {

	USMatrix4x4 worldToWnd = this->GetViewProjMtx ();
	worldToWnd.Append ( MOAIGfxDevice::GetNormToWndMtx ());
	
	return worldToWnd;
}
Beispiel #3
0
//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetWndToWorldMtx () const {

	USMatrix4x4 wndToWorld = MOAIGfxDevice::GetWndToNormMtx ();
	
	// inv viewproj
	USMatrix4x4 mtx = this->GetViewProjMtx ();
	mtx.Inverse ();
	wndToWorld.Append ( mtx );
	
	return wndToWorld;
}
Beispiel #4
0
//----------------------------------------------------------------//
USRect MOAILayoutFrame::GetScissorRect () {

	USRect scissorRect = this->GetFrame ();
	
	USMatrix4x4 mtx;
	
	mtx.Init ( this->mLocalToWorldMtx );
	mtx.Append ( MOAIGfxDevice::Get ().GetWorldToWndMtx ( 1.0f, 1.0f ));
	mtx.Transform ( scissorRect );
	
	return scissorRect;
}
Beispiel #5
0
//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetWorldToWndMtx ( float xScale, float yScale ) const {

	USMatrix4x4 worldToWnd;
	USMatrix4x4 mtx;

	USRect rect = this->GetViewRect ();
	
	float hWidth = rect.Width () * 0.5f;
	float hHeight = rect.Height () * 0.5f;

	// viewproj
	worldToWnd = this->GetViewProjMtx ();
	
	// wnd
	mtx.Scale ( hWidth * xScale, hHeight * yScale, 1.0f );
	worldToWnd.Append ( mtx );
		
	mtx.Translate ( hWidth + rect.mXMin, hHeight + rect.mYMin, 0.0f );
	worldToWnd.Append ( mtx );
	
	return worldToWnd;
}
Beispiel #6
0
//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetWndToWorldMtx () const {

	USMatrix4x4 wndToWorld;
	USMatrix4x4 mtx;

	USRect rect = this->GetViewRect ();
	
	float hWidth = rect.Width () * 0.5f;
	float hHeight = rect.Height () * 0.5f;

	// Inv Wnd
	wndToWorld.Translate ( -hWidth - rect.mXMin, -hHeight - rect.mYMin, 0.0f );
		
	mtx.Scale (( 1.0f / hWidth ), -( 1.0f / hHeight ), 1.0f );
	wndToWorld.Append ( mtx );
	
	// inv viewproj
	mtx = this->GetViewProjMtx ();
	mtx.Inverse ();
	wndToWorld.Append ( mtx );
	
	return wndToWorld;
}
Beispiel #7
0
//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetWndToNormMtx () const {

	USRect rect = this->mViewRect;

	float hWidth = rect.Width () * 0.5f;
	float hHeight = rect.Height () * 0.5f;

	// Inv Wnd
	USMatrix4x4 wndToNorm;
	wndToNorm.Translate ( -hWidth - rect.mXMin, -hHeight - rect.mYMin, 0.0f );
	
	USMatrix4x4 mtx;
	mtx.Scale (( 1.0f / hWidth ), -( 1.0f / hHeight ), 1.0f );
	wndToNorm.Append ( mtx );
	
	return wndToNorm;
}
Beispiel #8
0
//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetNormToWndMtx () const {

	USRect rect = this->mViewRect;

	float hWidth = rect.Width () * 0.5f;
	float hHeight = rect.Height () * 0.5f;

	// Wnd
	USMatrix4x4 normToWnd;
	normToWnd.Scale ( hWidth, -hHeight, 1.0f );
	
	USMatrix4x4 mtx;
	mtx.Translate ( hWidth + rect.mXMin, hHeight + rect.mYMin, 0.0f );
	normToWnd.Append ( mtx );
	
	return normToWnd;
}
Beispiel #9
0
//----------------------------------------------------------------//
USRect MOAIScissorRect::GetScissorRect ( const USMatrix4x4& worldToWndMtx ) const {

	USVec3D vtx3D [ 4 ];

	vtx3D [ 0 ].mX = this->mRect.mXMin;
	vtx3D [ 0 ].mY = this->mRect.mYMin;
	vtx3D [ 0 ].mZ = 0.0f;

	vtx3D [ 1 ].mX = this->mRect.mXMin;
	vtx3D [ 1 ].mY = this->mRect.mYMax;
	vtx3D [ 1 ].mZ = 0.0f;
	
	vtx3D [ 2 ].mX = this->mRect.mXMax;
	vtx3D [ 2 ].mY = this->mRect.mYMax;
	vtx3D [ 2 ].mZ = 0.0f;

	vtx3D [ 3 ].mX = this->mRect.mXMax;
	vtx3D [ 3 ].mY = this->mRect.mYMin;
	vtx3D [ 3 ].mZ = 0.0f;

	USMatrix4x4 mtx;
	
	mtx.Init ( this->GetLocalToWorldMtx ());
	mtx.Append ( worldToWndMtx );
	
	mtx.Project ( vtx3D [ 0 ]);
	mtx.Project ( vtx3D [ 1 ]);
	mtx.Project ( vtx3D [ 2 ]);
	mtx.Project ( vtx3D [ 3 ]);
	
	USRect scissorRect;

	scissorRect.Init ( vtx3D [ 0 ]);
	scissorRect.Grow ( vtx3D [ 1 ]);
	scissorRect.Grow ( vtx3D [ 2 ]);
	scissorRect.Grow ( vtx3D [ 3 ]);

	if ( this->mScissorRect ) {
		USRect parentRect = this->mScissorRect->GetScissorRect ( worldToWndMtx );
		parentRect.Clip ( scissorRect );
	}

	return scissorRect;
}
Beispiel #10
0
//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetViewProjMtx () const {

	USMatrix4x4 mtx = this->mVertexTransforms [ VTX_VIEW_TRANSFORM ];
	mtx.Append ( this->mVertexTransforms [ VTX_PROJ_TRANSFORM ]);
	return mtx;
}
Beispiel #11
0
//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetModelToWndMtx () const {

	USMatrix4x4 modelToWnd = this->GetModelToWorldMtx ();
	modelToWnd.Append ( this->GetWorldToWndMtx ());
	return modelToWnd;
}