• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ USMatrix4x4类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中USMatrix4x4的典型用法代码示例。如果您正苦于以下问题:C++ USMatrix4x4类的具体用法?C++ USMatrix4x4怎么用?C++ USMatrix4x4使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了USMatrix4x4类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GetWorldToWndMtx

//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetWorldToWndMtx () const {

	USMatrix4x4 worldToWnd = this->GetViewProjMtx ();
	worldToWnd.Append ( MOAIGfxDevice::GetNormToWndMtx ());
	
	return worldToWnd;
}
开发者ID:LOFI,项目名称:moai-dev,代码行数:8,代码来源:MOAIGfxDevice.cpp


示例2: Transform

//----------------------------------------------------------------//
void USPrism::Transform ( const USMatrix4x4& mtx ) {

	mtx.Transform ( mLoc );
	mtx.TransformVec ( mXAxis );
	mtx.TransformVec ( mYAxis );
	mtx.TransformVec ( mZAxis );
}
开发者ID:Odie,项目名称:moai-beta,代码行数:8,代码来源:USPrism.cpp


示例3: UNUSED

//----------------------------------------------------------------//
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 );
}
开发者ID:Inzaghi2012,项目名称:moai-dev,代码行数:31,代码来源:MOAIStretchPatch2D.cpp


示例4: GetWndToWorldMtx

//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetWndToWorldMtx () const {

	USMatrix4x4 wndToWorld = MOAIGfxDevice::GetWndToNormMtx ();
	
	// inv viewproj
	USMatrix4x4 mtx = this->GetViewProjMtx ();
	mtx.Inverse ();
	wndToWorld.Append ( mtx );
	
	return wndToWorld;
}
开发者ID:LOFI,项目名称:moai-dev,代码行数:12,代码来源:MOAIGfxDevice.cpp


示例5: GetScissorRect

//----------------------------------------------------------------//
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;
}
开发者ID:,项目名称:,代码行数:13,代码来源:


示例6: GetViewQuad

//----------------------------------------------------------------//
USQuad MOAIGfxDevice::GetViewQuad () const {

	USQuad quad;

	USMatrix4x4 invMtx;
	invMtx.Inverse ( this->GetViewProjMtx ());
	
	quad.mV [ 0 ].Init ( -1.0f, 1.0f );
	quad.mV [ 1 ].Init ( 1.0f, 1.0f );
	quad.mV [ 2 ].Init ( 1.0f, -1.0f );
	quad.mV [ 3 ].Init ( -1.0f, -1.0f );
	
	invMtx.TransformQuad ( quad.mV );
	return quad;
}
开发者ID:,项目名称:,代码行数:16,代码来源:


示例7: BeginLayer

//----------------------------------------------------------------//
void MOAIGfxDevice::BeginLayer () {

	float width = ( float )this->mWidth;
	float height = ( float )this->mHeight;
	
	MOAIViewport viewport;
	viewport.Init ( 0.0f, 0.0f, width, height );
	viewport.SetScale ( width, -height );
	viewport.SetOffset ( -1.0f, 1.0f );
	
	this->SetViewport ( viewport );

	for ( u32 i = 0; i < TOTAL_VTX_TRANSFORMS; ++i ) {
		this->mVertexTransforms [ i ].Ident ();
	}
	this->mUVTransform.Ident ();
	this->mCpuVertexTransformMtx.Ident ();
	
	this->mVertexMtxInput = VTX_STAGE_MODEL;
	this->mVertexMtxOutput = VTX_STAGE_MODEL;
	
	USMatrix4x4 projMtx;
	projMtx.Init ( viewport.GetProjMtx ());
	this->mVertexTransforms [ VTX_PROJ_TRANSFORM ] = projMtx;
	
	// fixed function reset
#if USE_OPENGLES1
	if ( !this->IsProgrammable ()) {
		
		// load identity matrix
		glMatrixMode ( GL_MODELVIEW );
		glLoadIdentity ();
		
		glMatrixMode ( GL_PROJECTION );
		this->GpuLoadMatrix ( projMtx );
		
		glMatrixMode ( GL_TEXTURE );
		glLoadIdentity ();
		
		// reset the current vertex color
		glColor4f ( 1.0f, 1.0f, 1.0f, 1.0f );
		
		// reset the point size
		glPointSize (( GLfloat )this->mPointSize );
	}
#endif
}
开发者ID:joarb,项目名称:moai-beta,代码行数:48,代码来源:MOAIGfxDevice.cpp


示例8: GetWndToNormMtx

//----------------------------------------------------------------//
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;
}
开发者ID:LOFI,项目名称:moai-dev,代码行数:18,代码来源:MOAIGfxDevice.cpp


示例9: GetNormToWndMtx

//----------------------------------------------------------------//
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;
}
开发者ID:LOFI,项目名称:moai-dev,代码行数:18,代码来源:MOAIGfxDevice.cpp


示例10: GetScissorRect

//----------------------------------------------------------------//
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;
}
开发者ID:isovector,项目名称:moai-dev,代码行数:45,代码来源:MOAIScissorRect.cpp


示例11: GetWndToWorldMtx

//----------------------------------------------------------------//
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;
}
开发者ID:,项目名称:,代码行数:24,代码来源:


示例12: GetWorldToWndMtx

//----------------------------------------------------------------//
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;
}
开发者ID:,项目名称:,代码行数:23,代码来源:


示例13: loc

//----------------------------------------------------------------//
void MOAIDraw::DrawRay ( float x, float y, float dx, float dy ) {
	
	USVec2D loc ( x, y );
	USVec2D vec ( dx, dy );
	
	USMatrix4x4 mtx = MOAIGfxDevice::Get ().GetViewProjMtx ();
	
	USMatrix4x4 invMtx;
	invMtx.Inverse ( mtx );
	
	mtx.Transform ( loc );
	mtx.TransformVec ( vec );
	
	USRect viewRect;
	viewRect.Init ( -1.0f, -1.0f, 1.0f, 1.0f );
	
	USVec2D p0;
	USVec2D p1;
	
	if ( viewRect.GetIntersection ( loc, vec, p0, p1 )) {
		
		invMtx.Transform ( p0 );
		invMtx.Transform ( p1 );
		
		MOAIGfxDevice& gfxDevice = MOAIGfxDevice::Get ();
		
		gfxDevice.BeginPrim ( GL_LINES );
		
			gfxDevice.WriteVtx ( p0.mX, p0.mY, 0.0f );
			gfxDevice.WriteFinalColor4b ();
			
			gfxDevice.WriteVtx ( p1.mX, p1.mY, 0.0f );
			gfxDevice.WriteFinalColor4b ();

		gfxDevice.EndPrim ();
	}
}
开发者ID:LOFI,项目名称:moai-dev,代码行数:38,代码来源:MOAIDraw.cpp


示例14: DrawAxisGrid

//----------------------------------------------------------------//
void MOAIDraw::DrawAxisGrid ( USVec2D loc, USVec2D vec, float size ) {

	USMatrix4x4 mtx = MOAIGfxDevice::Get ().GetViewProjMtx ();
	
	USMatrix4x4 invMtx;
	invMtx.Inverse ( mtx );
	
	// Set the axis to the grid length so we can get the length back post-transform
	vec.SetLength ( size );
	
	mtx.Transform ( loc );
	mtx.TransformVec ( vec );

	// Get the axis unit vector
	USVec2D norm = vec;
	size = norm.NormSafe ();
	
	// Get the axis normal
	USVec2D perpNorm ( norm.mY, -norm.mX );
	
	// Project the corners of the viewport onto the axis to get the mix/max bounds
	float dot;
	float min;
	float max;
	
	USVec2D corner;
	
	// left, top
	corner.Init ( -1.0f, 1.0f );
	corner.Sub ( loc );
	dot = norm.Dot ( corner );
	
	min = dot;
	max = dot;
	
	// right, top
	corner.Init ( 1.0f, 1.0f );
	corner.Sub ( loc );
	dot = norm.Dot ( corner );
	
	min = ( dot < min ) ? dot : min;
	max = ( dot > max ) ? dot : max;
	
	// right, bottom
	corner.Init ( 1.0f, -1.0f );
	corner.Sub ( loc );
	dot = norm.Dot ( corner );
	
	min = ( dot < min ) ? dot : min;
	max = ( dot > max ) ? dot : max;
	
	// left, bottom
	corner.Init ( -1.0f, -1.0f );
	corner.Sub ( loc );
	dot = norm.Dot ( corner );
	
	min = ( dot < min ) ? dot : min;
	max = ( dot > max ) ? dot : max;
	
	// Get the start andstop grids
	s32 start = ( s32 )( min / size ) - 1;
	s32 stop = ( s32 )( max / size ) + 1;
	
	// Set the pen to the first...
	USVec2D pen = norm;
	pen.Scale (( float )start * size );
	pen.Add ( loc );
	
	// Step along the axis to draw perpendicular grid lines
	USRect viewRect;
	viewRect.Init ( -1.0f, -1.0f, 1.0f, 1.0f );
	
	for ( ; start < stop; ++start ) {
		
		USVec2D p0;
		USVec2D p1;
		
		if ( viewRect.GetIntersection ( pen, perpNorm, p0, p1 )) {
			
			invMtx.Transform ( p0 );
			invMtx.Transform ( p1 );
			
			MOAIDraw::DrawLine ( p0, p1 );
		}
		
		pen.Add ( vec );
	}
}
开发者ID:LOFI,项目名称:moai-dev,代码行数:89,代码来源:MOAIDraw.cpp


示例15: GetViewProjMtx

//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetViewProjMtx () const {

	USMatrix4x4 mtx = this->mVertexTransforms [ VTX_VIEW_TRANSFORM ];
	mtx.Append ( this->mVertexTransforms [ VTX_PROJ_TRANSFORM ]);
	return mtx;
}
开发者ID:joarb,项目名称:moai-beta,代码行数:7,代码来源:MOAIGfxDevice.cpp


示例16: UpdateViewVolume

//----------------------------------------------------------------//
void MOAIGfxDevice::UpdateViewVolume () {

	USMatrix4x4 invViewProj;
	invViewProj.Inverse ( this->GetViewProjMtx ());
	this->mViewVolume.Init ( invViewProj );
}
开发者ID:joarb,项目名称:moai-beta,代码行数:7,代码来源:MOAIGfxDevice.cpp


示例17: SetVertexTransform

//----------------------------------------------------------------//
void MOAIGfxDevice::SetVertexTransform ( u32 id, const USAffine3D& transform ) {

	USMatrix4x4 mtx;
	mtx.Init ( transform );
	this->SetVertexTransform ( id, mtx );
}
开发者ID:joarb,项目名称:moai-beta,代码行数:7,代码来源:MOAIGfxDevice.cpp


示例18: SetUVTransform

//----------------------------------------------------------------//
void MOAIGfxDevice::SetUVTransform ( const USAffine3D& transform ) {

	USMatrix4x4 mtx;
	mtx.Init ( transform );
	this->SetUVTransform ( mtx );
}
开发者ID:joarb,项目名称:moai-beta,代码行数:7,代码来源:MOAIGfxDevice.cpp


示例19: Init

//----------------------------------------------------------------//
void USFrustum::Init ( const USMatrix4x4& mtx ) {

	// set up the homogenous coordinates of the canonical view volume
	USVec3D nlt ( -1.0f, 1.0f, -1.0f );
	USVec3D nrt ( 1.0f, 1.0f, -1.0f );
	USVec3D nrb ( 1.0f, -1.0f, -1.0f );
	USVec3D nlb ( -1.0f, -1.0f, -1.0f );

	USVec3D flt ( -1.0f, 1.0f, 1.0f );
	USVec3D frt ( 1.0f, 1.0f, 1.0f );
	USVec3D frb ( 1.0f, -1.0f, 1.0f );
	USVec3D flb ( -1.0f, -1.0f, 1.0f );

	// compute the corners of the frustum
	mtx.Project ( nlt );
	mtx.Project ( nrt );
	mtx.Project ( nrb );
	mtx.Project ( nlb );
	
	mtx.Project ( flt );
	mtx.Project ( frt );
	mtx.Project ( frb );
	mtx.Project ( flb );

	this->mPoints [ NEAR_LT_POINT ].Init ( nlt.mX, nlt.mY, nlt.mZ );
	this->mPoints [ NEAR_RT_POINT ].Init ( nrt.mX, nrt.mY, nrt.mZ );
	this->mPoints [ NEAR_RB_POINT ].Init ( nrb.mX, nrb.mY, nrb.mZ );
	this->mPoints [ NEAR_LB_POINT ].Init ( nlb.mX, nlb.mY, nlb.mZ );
	
	this->mPoints [ FAR_LT_POINT ].Init ( flt.mX, flt.mY, flt.mZ );
	this->mPoints [ FAR_RT_POINT ].Init ( frt.mX, frt.mY, frt.mZ );
	this->mPoints [ FAR_RB_POINT ].Init ( frb.mX, frb.mY, frb.mZ );
	this->mPoints [ FAR_LB_POINT ].Init ( flb.mX, flb.mY, flb.mZ );

	// Compute the frustum's axis-aligned bounding box
	this->mAABB.Init ( nlt );
	this->mAABB.Grow ( nrt );
	this->mAABB.Grow ( nrb );
	this->mAABB.Grow ( nlb );
	
	this->mAABB.Grow ( flt );
	this->mAABB.Grow ( frt );
	this->mAABB.Grow ( frb );
	this->mAABB.Grow ( flb );
	
	// intialize the planes
	this->mPlanes [ LEFT_PLANE ].Init ( nlt, flt, flb );
	this->mPlanes [ RIGHT_PLANE ].Init ( nrb, frb, frt );
	
	this->mPlanes [ TOP_PLANE ].Init ( nrt, frt, flt );
	this->mPlanes [ BOTTOM_PLANE ].Init ( nlb, flb, frb );
	
	this->mPlanes [ NEAR_PLANE ].Init ( nrt, nlt, nlb );
	this->mPlanes [ FAR_PLANE ].Init ( flt, frt, frb );
	
	USVec3D center;
	mtx.GetTranslation ( center );
	
	for ( u32 i = 0; i < TOTAL_PLANES; ++i ) {
		if ( USDist::VecToPlane ( center, this->mPlanes [ i ]) > 0.0f ) {
			this->mPlanes [ i ].Flip ();
		}
	}
	
	double frustArea = _frustArea ( *this );
	double boxArea = this->mAABB.Area ();
	
	this->mUsePlanes = (( float )( frustArea / boxArea )) < MIN_FILL_RATIO;
}
开发者ID:Inzaghi2012,项目名称:moai-dev,代码行数:70,代码来源:USFrustum.cpp


示例20: GetModelToWndMtx

//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetModelToWndMtx () const {

	USMatrix4x4 modelToWnd = this->GetModelToWorldMtx ();
	modelToWnd.Append ( this->GetWorldToWndMtx ());
	return modelToWnd;
}
开发者ID:,项目名称:,代码行数:7,代码来源:



注:本文中的USMatrix4x4类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ USRGenerator类代码示例发布时间:2022-05-31
下一篇:
C++ USLuaState类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap