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


C++ Matrix4::CreateRotation方法代码示例

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


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

示例1: ApplyTransform

void EditorBodyControl::ApplyTransform(float32 x, float32 y, float32 z)
{
	if (!InModificationMode())
		return;

    Entity *selectedNode = scene->GetProxy();
    if(selectedNode)
	{
		Matrix4 modification;
		modification.Identity();

		Matrix4 t1, t2;
		t1.CreateTranslation(-selectedNode->GetWorldTransform().GetTranslationVector());
		t2.CreateTranslation(selectedNode->GetWorldTransform().GetTranslationVector());

		switch (GetModificationMode())
		{
			case ResourceEditor::MODIFY_MOVE:
				modification.CreateTranslation(Vector3(x, y, z));
				break;

			case ResourceEditor::MODIFY_ROTATE:
				modification.CreateRotation(Vector3(1, 0, 0), DegToRad(x));
				modification *= Matrix4::MakeRotation(Vector3(0, 1, 0), DegToRad(y));
				modification *= Matrix4::MakeRotation(Vector3(0, 0, 1), DegToRad(z));

				modification = (t1 * modification) * t2;
				break;

			case ResourceEditor::MODIFY_SCALE:
				modification.CreateScale(Vector3(1, 1, 1) + Vector3(x + y + z, x + y + z, x + y + z) / 100.f);
				modification = (t1 * modification) * t2;
				break;

			default:
				break;
		}

		Matrix4 originalTransform = selectedNode->GetLocalTransform();
		modification = originalTransform * modification;

		if (IsLandscapeRelative())
		{
			modification = modification * GetLandscapeOffset(modification);
		}

		CommandsManager::Instance()->ExecuteAndRelease(new CommandTransformObject(selectedNode,
																				  originalTransform,
																				  modification),
													   scene);
	}
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:52,代码来源:EditorBodyControl.cpp

示例2: _up

void ParticleLayer3D::Draw(Camera * camera)
{
    if(!sprite)
        return;

    Matrix4 rotationMatrix = Matrix4::IDENTITY;
    switch(RenderManager::Instance()->GetRenderOrientation())
    {
    case Core::SCREEN_ORIENTATION_LANDSCAPE_LEFT:
        //glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
        rotationMatrix.CreateRotation(Vector3(0.0f, 0.0f, 1.0f), DegToRad(90.0f));
        break;
    case Core::SCREEN_ORIENTATION_LANDSCAPE_RIGHT:
        //glRotatef(-90.0f, 0.0f, 0.0f, 1.0f);
        rotationMatrix.CreateRotation(Vector3(0.0f, 0.0f, 1.0f), DegToRad(-90.0f));
        break;
    }

    Matrix4 mv = RenderManager::Instance()->GetMatrix(RenderManager::MATRIX_MODELVIEW)*rotationMatrix;

    Vector3 _up(mv._01, mv._11, mv._21);
    Vector3 _left(mv._00, mv._10, mv._20);

    verts.clear();
    textures.clear();
    colors.clear();
    int32 totalCount = 0;

    Particle * current = head;
    if(current)
    {
        renderBatch->GetMaterial()->GetRenderState()->SetTexture(sprite->GetTexture(current->frame));
    }

    while(current != 0)
    {
        Vector3 dx(_left);
        Vector3 dy(_up);

        //dx *= sqrt(2.f);
        //dy *= sqrt(2.f);

        float32 sine;
        float32 cosine;
        SinCosFast(current->angle, sine, cosine);

        float32 pivotRight = ((sprite->GetWidth()-pivotPoint.x)*current->size.x*current->sizeOverLife)/2.f;
        float32 pivotLeft = (pivotPoint.x*current->size.x*current->sizeOverLife)/2.f;
        float32 pivotUp = (pivotPoint.y*current->size.y*current->sizeOverLife)/2.f;
        float32 pivotDown = ((sprite->GetHeight()-pivotPoint.y)*current->size.y*current->sizeOverLife)/2.f;

        Vector3 dxc = dx*cosine;
        Vector3 dxs = dx*sine;
        Vector3 dyc = dy*cosine;
        Vector3 dys = dy*sine;

        Vector3 topLeft = current->position+(-dxc+dys)*pivotUp + (dxs+dyc)*pivotLeft;
        Vector3 topRight = current->position+(-dxs-dyc)*pivotRight + (-dxc+dys)*pivotUp;
        Vector3 botLeft = current->position+(dxs+dyc)*pivotLeft + (dxc-dys)*pivotDown;
        Vector3 botRight = current->position+(dxc-dys)*pivotDown + (-dxs-dyc)*pivotRight;

        verts.push_back(topLeft.x);//0
        verts.push_back(topLeft.y);
        verts.push_back(topLeft.z);

        verts.push_back(topRight.x);//1
        verts.push_back(topRight.y);
        verts.push_back(topRight.z);

        verts.push_back(botLeft.x);//2
        verts.push_back(botLeft.y);
        verts.push_back(botLeft.z);

        verts.push_back(botLeft.x);//2
        verts.push_back(botLeft.y);
        verts.push_back(botLeft.z);

        verts.push_back(topRight.x);//1
        verts.push_back(topRight.y);
        verts.push_back(topRight.z);

        verts.push_back(botRight.x);//3
        verts.push_back(botRight.y);
        verts.push_back(botRight.z);

        float32 *pT = sprite->GetTextureVerts(current->frame);

        textures.push_back(pT[0]);
        textures.push_back(pT[1]);

        textures.push_back(pT[2]);
        textures.push_back(pT[3]);

        textures.push_back(pT[4]);
        textures.push_back(pT[5]);

        textures.push_back(pT[4]);
        textures.push_back(pT[5]);

        textures.push_back(pT[2]);
//.........这里部分代码省略.........
开发者ID:vilonosec,项目名称:dava.framework,代码行数:101,代码来源:ParticleLayer3D.cpp

示例3: PrepareModMatrix

void EditorBodyControl::PrepareModMatrix(const Vector2 & point)
{
	float32 winx = point.x - touchStart.x;
	float32 winy = point.y - touchStart.y;
	
	Matrix4 modification;
	modification.Identity();

	ArrowsNode* arrowsNode = GetArrowsNode(false);
	if (!arrowsNode)
		return;

	if (GetModificationMode() == ResourceEditor::MODIFY_MOVE)
	{
		Vector3 from, dir;
		GetCursorVectors(&from, &dir, point);
		
		Vector3 currPoint;
		bool result = GetIntersectionVectorWithPlane(from, dir, planeNormal, rotationCenter, currPoint);
		
		if (result)
		{
			
			if (arrowsNode)
			{
				switch (arrowsNode->GetModAxis())
				{
					case ArrowsNode::AXIS_X:
						currPoint.y = startDragPoint.y;
						currPoint.z = startDragPoint.z;
						break;
					case ArrowsNode::AXIS_Y:
						currPoint.x = startDragPoint.x;
						currPoint.z = startDragPoint.z;
						break;
					case ArrowsNode::AXIS_Z:
						currPoint.x = startDragPoint.x;
						currPoint.y = startDragPoint.y;
						break;
                    
					default:
						break;
				}
				modification.CreateTranslation(currPoint - startDragPoint);
			}
		}
	}
	else if (GetModificationMode() == ResourceEditor::MODIFY_ROTATE)
	{
		Matrix4 d;
		switch (arrowsNode->GetModAxis())
		{
			case ArrowsNode::AXIS_X:
			case ArrowsNode::AXIS_Y:
				modification.CreateRotation(vect[arrowsNode->GetModAxis()], winy / 100.0f);
				break;
			case ArrowsNode::AXIS_Z:
				modification.CreateRotation(vect[arrowsNode->GetModAxis()], winx / 100.0f);
				break;
			case ArrowsNode::AXIS_XY:
				modification.CreateRotation(vect[ArrowsNode::AXIS_X], winx / 100.0f);
				d.CreateRotation(vect[ArrowsNode::AXIS_Y], winy / 100.0f);
				modification *= d;
				break;
			case ArrowsNode::AXIS_YZ:
				modification.CreateRotation(vect[ArrowsNode::AXIS_Y], winx / 100.0f);
				d.CreateRotation(vect[ArrowsNode::AXIS_Z], winy / 100.0f);
				modification *= d;
				break;
			case ArrowsNode::AXIS_XZ:
				modification.CreateRotation(vect[ArrowsNode::AXIS_X], winx / 100.0f);
				d.CreateRotation(vect[ArrowsNode::AXIS_Z], winy / 100.0f);
				modification *= d;
				break;
			default:
				break;
		}
		modification = (translate1 * modification) * translate2;
		
	}
	else if (GetModificationMode() == ResourceEditor::MODIFY_SCALE)
	{
		float kf = winx / 100.0f;
		if (kf < -1.0)
			kf = - kf - 2.0;
		modification.CreateScale(Vector3(1,1,1) + Vector3(1,1,1) * kf);
		modification = (translate1 * modification) * translate2;
	}
	currTransform = startTransform * modification;
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:90,代码来源:EditorBodyControl.cpp


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