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


C++ GLC_Matrix4x4::setMatTranslate方法代码示例

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


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

示例1: gluPickMatrix

void glc::gluPickMatrix(GLdouble x, GLdouble y, GLdouble deltax, GLdouble deltay,
		  GLint viewport[4])
{
    if (deltax <= 0 || deltay <= 0) { 
	return;
    }

    /* Translate and scale the picked region to the entire window */
    GLC_Matrix4x4 translate;
    translate.setMatTranslate((viewport[2] - 2 * (x - viewport[0])) / deltax, (viewport[3] - 2 * (y - viewport[1])) / deltay, 0.0);

    GLC_Matrix4x4 scaling;
    scaling.setMatScaling(viewport[2] / deltax, viewport[3] / deltay, 0.0);
    GLC_ContextManager::instance()->currentContext()->glcMultMatrix(translate * scaling);
}
开发者ID:JasonWinston,项目名称:GLC_lib,代码行数:15,代码来源:glc_project.cpp

示例2: gluLookAt

void glc::gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx,
	  GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy,
	  GLdouble upz)
{
    float forward[3], side[3], up[3];
    GLfloat m[4][4];

    forward[0] = centerx - eyex;
    forward[1] = centery - eyey;
    forward[2] = centerz - eyez;

    up[0] = upx;
    up[1] = upy;
    up[2] = upz;

    normalize(forward);

    /* Side = forward x up */
    cross(forward, up, side);
    normalize(side);

    /* Recompute up as: up = side x forward */
    cross(side, forward, up);

    __gluMakeIdentityf(&m[0][0]);
    m[0][0] = side[0];
    m[1][0] = side[1];
    m[2][0] = side[2];

    m[0][1] = up[0];
    m[1][1] = up[1];
    m[2][1] = up[2];

    m[0][2] = -forward[0];
    m[1][2] = -forward[1];
    m[2][2] = -forward[2];

    GLC_Matrix4x4 translate;
    translate.setMatTranslate(-eyex, -eyey, -eyez);
    GLC_Matrix4x4 result= GLC_Matrix4x4(&m[0][0]) * translate;
    GLC_ContextManager::instance()->currentContext()->glcMultMatrix(result);
}
开发者ID:JasonWinston,项目名称:GLC_lib,代码行数:42,代码来源:glc_project.cpp

示例3: createCrossInstance

//////////////////////////////////////////////////////////////////////
// Private services Functions
//////////////////////////////////////////////////////////////////////
GLC_3DViewInstance GLC_RepCrossMover::createCrossInstance()
{
	GLC_Polylines* pCross= new GLC_Polylines();

	int nLgAxe;
	const int winHSize= m_pViewport->viewHSize();
	const int winVSize= m_pViewport->viewVSize();
	if (winHSize > winVSize)
	{
		nLgAxe = static_cast<int>(static_cast<double>(winVSize) / 2.0);
	}
	else
	{
		nLgAxe = static_cast<int>(static_cast<double>(winHSize) / 2.0);
	}

	// Compute the length of camera's field of view
	const double ChampsVision = 2 * (m_pViewport->cameraHandle()->distEyeTarget()) *  tan((m_pViewport->viewAngle() * glc::PI / 180.0) / 2.0);

	// the side of camera's square is mapped on Vertical length of window
	// Axis length in OpenGL unit = length(Pixel) * (dimend GL / dimens Pixel)
	const double dLgAxe= ((double)nLgAxe * ChampsVision / (double)winVSize) / 7;
	const double dDecAxe= dLgAxe / 3;

	//X axis
	{
		GLC_Point3d p1(-dLgAxe, 0, 0);
		GLC_Point3d p2(-dDecAxe, 0, 0);
		GLC_Point3d p3(dDecAxe, 0, 0);
		GLC_Point3d p4(dLgAxe, 0, 0);
		QList<GLC_Point3d> points;
		points << p1 << p2 << p3 << p4;
		pCross->addPolyline(points);
	}

	//Y axis
	{
		GLC_Point3d p1(0, -dLgAxe, 0);
		GLC_Point3d p2(0, -dDecAxe, 0);
		GLC_Point3d p3(0, dDecAxe, 0);
		GLC_Point3d p4(0, dLgAxe, 0);
		QList<GLC_Point3d> points;
		points << p1 << p2 << p3 << p4;
		pCross->addPolyline(points);
	}

	//Z axis
	{
		GLC_Point3d p1(0, 0, -dLgAxe);
		GLC_Point3d p2(0, 0, -dDecAxe);
		GLC_Point3d p3(0, 0, dDecAxe);
		GLC_Point3d p4(0, 0, dLgAxe);
		QList<GLC_Point3d> points;
		points << p1 << p2 << p3 << p4;
		pCross->addPolyline(points);
	}

	pCross->setWireColor(m_MainColor);
	GLC_3DViewInstance crossInstance(pCross);

	GLC_Matrix4x4 translation;
	translation.setMatTranslate(m_pViewport->cameraHandle()->target());

	crossInstance.setMatrix(translation);

	return crossInstance;
}
开发者ID:Alex-Rongzhen-Huang,项目名称:OpenPilot,代码行数:70,代码来源:glc_repcrossmover.cpp


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