当前位置: 首页>>代码示例>>C++>>正文


C++ Vector2D::Base方法代码示例

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


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

示例1: SetFixedFunctionTextureScale

void CBaseShader::SetFixedFunctionTextureScale( MaterialMatrixMode_t textureTransform, int scaleVar )
{
	Assert( !IsSnapshotting() );

	// handle scrolling of base texture
	Vector2D vScale;
	s_ppParams[scaleVar]->GetVecValue( vScale.Base(), 2 );
	if( vScale[0] != 0.0f || vScale[1] != 0.0f )
	{
		s_pShaderAPI->MatrixMode( textureTransform );

		// only do the upper 3x3 since this is a 2D matrix
		float mat[16];
		mat[0] = vScale[0];	mat[1] = 0.0f;		mat[2] = 0.0f;
		mat[4] = 0.0f;		mat[5] = vScale[1];	mat[6] = 0.0f;
		mat[8] = 0.0f;		mat[9] = 0.0f;		mat[10] = 1.0f;

		// Better set the stuff we don't set with some sort of value!
		mat[3] = mat[7] = mat[11] = 0;
		mat[12] = mat[13] = mat[14] = 0;
		mat[15] = 1;

		s_pShaderAPI->LoadMatrix( mat );
	}
	else
	{
		LoadIdentity( textureTransform );
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:29,代码来源:BaseShader.cpp

示例2: Serialize

//-----------------------------------------------------------------------------
// Attribute types related to vector math
//-----------------------------------------------------------------------------
bool Serialize( CUtlBuffer &buf, const Vector2D &src )
{
	if ( buf.IsText() )
	{
		SerializeFloats( buf, 2, src.Base() );
	}
	else
	{
		buf.PutFloat( src.x );
		buf.PutFloat( src.y );
	}
	return buf.IsValid();
}
开发者ID:Cre3per,项目名称:hl2sdk-csgo,代码行数:16,代码来源:utlbufferutil.cpp

示例3: OnBind

void CTextureTransformProxy::OnBind( void *pC_BaseEntity )
{
    Vector2D center( 0.5, 0.5 );
    Vector2D translation( 0, 0 );

    VMatrix mat, temp;

    if (m_pCenterVar)
    {
        m_pCenterVar->GetVecValue( center.Base(), 2 );
    }
    MatrixBuildTranslation( mat, -center.x, -center.y, 0.0f );

    if (m_pScaleVar)
    {
        Vector2D scale;
        m_pScaleVar->GetVecValue( scale.Base(), 2 );
        MatrixBuildScale( temp, scale.x, scale.y, 1.0f );
        MatrixMultiply( temp, mat, mat );
    }

    if (m_pRotateVar)
    {
        float angle = m_pRotateVar->GetFloatValue( );
        MatrixBuildRotateZ( temp, angle );
        MatrixMultiply( temp, mat, mat );
    }
    MatrixBuildTranslation( temp, center.x, center.y, 0.0f );
    MatrixMultiply( temp, mat, mat );

    if (m_pTranslateVar)
    {
        m_pTranslateVar->GetVecValue( translation.Base(), 2 );
        MatrixBuildTranslation( temp, translation.x, translation.y, 0.0f );
        MatrixMultiply( temp, mat, mat );
    }

    m_pResult->SetMatrixValue( mat );

    if ( ToolsEnabled() )
    {
        ToolFramework_RecordMaterialParams( GetMaterial() );
    }
}
开发者ID:GOGIBERRY,项目名称:source-sdk-2013,代码行数:44,代码来源:matrixproxy.cpp

示例4: CreateCylinder

void CHLSL_Mesh::CreateCylinder( float size, int subdiv )
{
	subdiv /= 2;

	delete [] m_Vertices;
	delete [] m_Triangles;

	int num_verts_u = subdiv + 1;
	int num_verts_v = subdiv + 1;
	int num_verts_side = num_verts_u * num_verts_v;
	int num_verts_top = 1 + num_verts_u - 1;
	m_iNumVertices = num_verts_side + num_verts_top * 2;

	int num_tris_u = (num_verts_u-1);
	int num_tris_v = (num_verts_v-1);
	int num_tris_side = num_tris_u * num_tris_v * 2;
	int num_tris_top = num_tris_u;
	m_iNumTriangles = num_tris_side + num_tris_top * 2;

	m_Vertices = new CHLSL_Vertex[ m_iNumVertices ];
	m_Triangles = new CHLSL_Triangle[ m_iNumTriangles ];

	QAngle rotate( 0, 0, 0 );

	float yaw_step = 360.0f / (num_verts_u-1);
	float up_step = size * 2.0f / (num_verts_v-1);
	float size_radius = size * 0.5f;

	Vector fwd, right, up, pos;

/// verts for side
	for ( int vert_u = 0; vert_u < num_verts_u; vert_u++ )
	{
		AngleVectors( rotate, &fwd, &right, &up );

		pos = up * size + fwd * size_radius;

		for ( int vert_v = 0; vert_v < num_verts_v; vert_v++ )
		{
			int vindex = vert_u * num_verts_v +
				vert_v;

			Assert( vindex < m_iNumVertices );

			CHLSL_Vertex &vert = m_Vertices[ vindex ];

			Q_memcpy( vert.normal, fwd.Base(), sizeof( float ) * 3 );
			Q_memcpy( vert.pos, pos.Base(), sizeof( float ) * 3 );

			vert.uv[0][0] = vert_u / (float)( num_verts_u - 1 );
			vert.uv[0][1] = vert_v / (float)( num_verts_v - 1 );

			pos -= up * up_step;
		}

		rotate.y += yaw_step;
	}

/// verts for top/bottom
	for ( int v_side = 0; v_side < 2; v_side++ )
	{
		rotate.y = 0;
		float sign = (v_side==1) ? -1.0f : 1.0f;

		up.Init( 0, 0, sign );
		Vector height = up * size;

		for ( int v_u = 0; v_u < num_verts_top; v_u++ )
		{
			int vindex = num_verts_side +
				v_side * num_verts_top +
				v_u;

			Assert( vindex < m_iNumVertices );

			CHLSL_Vertex &vert = m_Vertices[ vindex ];

			Vector2D uv;
			Vector pos = height;

			if ( v_u > 0 )
			{
				AngleVectors( rotate, &fwd, NULL, NULL );
				pos += fwd * size_radius;
				uv.x = -sign * fwd.x * 0.5f + 0.5f;
				uv.y = fwd.y * 0.5f + 0.5f;
				rotate.y += yaw_step * sign;
			}
			else
				uv.Init( 0.5f, 0.5f );

			Q_memcpy( vert.pos, pos.Base(), sizeof( float ) * 3 );
			Q_memcpy( vert.normal, up.Base(), sizeof( float ) * 3 );
			Q_memcpy( vert.uv, uv.Base(), sizeof( float ) * 2 );
		}
	}

/// tris for side
	for ( int tri_u = 0; tri_u < num_tris_u; tri_u++ )
	{
//.........这里部分代码省略.........
开发者ID:BSVino,项目名称:source-shader-editor,代码行数:101,代码来源:chlsl_mesh.cpp


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