Beispiel #1
0
//----------------------------------------------------------------//
ZLRect MOAIQuadBrush::GetVtxBounds () {

	ZLRect rect;
	
	rect.Init ( this->mModelQuad.mV [ 0 ]);
	rect.Grow ( this->mModelQuad.mV [ 1 ]);
	rect.Grow ( this->mModelQuad.mV [ 2 ]);
	rect.Grow ( this->mModelQuad.mV [ 3 ]);
	
	return rect;
}
Beispiel #2
0
//----------------------------------------------------------------//
ZLRect MOAIScissorRect::GetScissorRect ( const ZLMatrix4x4& worldToWndMtx ) const {

	ZLVec3D 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;

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

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

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

	return scissorRect;
}
Beispiel #3
0
//----------------------------------------------------------------//
bool ZLFrustum::GetXYSectRect ( const ZLAffine3D& mtx, ZLRect& rect ) const {

	u32 nHits = 0;
	ZLVec2D hits [ 12 ];

	ZLVec3D nlt = this->mPoints [ NEAR_LT_POINT ];
	ZLVec3D nrt = this->mPoints [ NEAR_RT_POINT ];
	ZLVec3D nrb = this->mPoints [ NEAR_RB_POINT ];
	ZLVec3D nlb = this->mPoints [ NEAR_LB_POINT ];
	
	ZLVec3D flt = this->mPoints [ FAR_LT_POINT ];
	ZLVec3D frt = this->mPoints [ FAR_RT_POINT ];
	ZLVec3D frb = this->mPoints [ FAR_RB_POINT ];
	ZLVec3D flb = this->mPoints [ FAR_LB_POINT ];
	
	mtx.Transform ( nlt );
	mtx.Transform ( nrt );
	mtx.Transform ( nrb );
	mtx.Transform ( nlb );
	
	mtx.Transform ( flt );
	mtx.Transform ( frt );
	mtx.Transform ( frb );
	mtx.Transform ( flb );
	
	if ( _vecToXYPlane ( nlt, flt, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( nrt, frt, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( nrb, frb, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( nlb, flb, hits [ nHits ])) ++nHits;
	
	if ( _vecToXYPlane ( nlt, nrt, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( nrt, nrb, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( nrb, nlb, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( nlb, nlt, hits [ nHits ])) ++nHits;
	
	if ( _vecToXYPlane ( flt, frt, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( frt, frb, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( frb, flb, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( flb, flt, hits [ nHits ])) ++nHits;
	
	if ( nHits ) {
		rect.Init ( hits [ 0 ]);
		for ( u32 i = 1; i < nHits; ++i ) {
			rect.Grow ( hits [ i ]);
		}
		return true;
	}
	return false;
}