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

C++ ogre::Matrix4类代码示例

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

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



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

示例1: SetPosition

//设置位置 (游戏世界坐标)
VOID CEffectObject::SetPosition(const fVector3& vPos)
{
	//坐标转换
	fVector3 fvGfx;
	CRenderSystem::GetMe()->Axis_Trans(CRenderSystem::AX_GAME, vPos, CRenderSystem::AX_GFX, fvGfx);

	std::list< std::pair< Fairy::Effect*, Ogre::SceneNode* > >::iterator it;
	for(it=m_listEffectImpl.begin(); it!=m_listEffectImpl.end(); it++)
	{
		it->second->setPosition(Ogre::Vector3(fvGfx.x, fvGfx.y, fvGfx.z));
	}

#if 0
	Ogre::Matrix4 mxPosition = Ogre::Matrix4::IDENTITY;
	mxPosition.makeTrans(fvGfx.x, fvGfx.y, fvGfx.z);

	Ogre::MatrixList vMatrix;
	vMatrix.push_back(mxPosition);

	std::list< Ogre::Effect* >::iterator it;
	for(it=m_listEffectImpl.begin(); it!=m_listEffectImpl.end(); it++)
	{
		(*it)->execute(0, vMatrix);
	}
#endif
}
开发者ID:brock7,项目名称:TianLong,代码行数:27,代码来源:EffectObj.cpp


示例2:

//------------------------------------------------------------------------------
void
Background2D::renderQueueEnded( Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation )
{
    if( cv_show_background2d.GetB() == false )
    {
        return;
    }



    if( queueGroupId == Ogre::RENDER_QUEUE_MAIN )
    {
        m_RenderSystem->_setWorldMatrix( Ogre::Matrix4::IDENTITY );
        m_RenderSystem->_setProjectionMatrix( Ogre::Matrix4::IDENTITY );

        Ogre::Viewport *viewport( CameraManager::getSingleton().getViewport() );
        float width = viewport->getActualWidth();
        float height = viewport->getActualHeight();
        Ogre::Matrix4 view;
        view.makeTrans( Ogre::Vector3( m_PositionReal.x * 2 / width, -m_PositionReal.y * 2 / height, 0 ) );
        m_RenderSystem->_setViewMatrix( view );

        if( m_AlphaRenderOp.vertexData->vertexCount != 0 )
        {
            m_SceneManager->_setPass( m_AlphaMaterial->getTechnique( 0 )->getPass( 0 ), true, false );
            m_RenderSystem->_render( m_AlphaRenderOp );
        }

        if( m_AddRenderOp.vertexData->vertexCount != 0 )
        {
            m_SceneManager->_setPass( m_AddMaterial->getTechnique( 0 )->getPass( 0 ), true, false );
            m_RenderSystem->_render( m_AddRenderOp );
        }
    }
}
开发者ID:DeejStar,项目名称:q-gears,代码行数:36,代码来源:Background2D.cpp


示例3:

	const Ogre::Vector3 Mesh::getWorldSpacePosition(const Ogre::Vector3& ObjectSpacePosition) const
	{
		Ogre::Matrix4 mWorldMatrix;

		if (mCreated)
		{
	#if OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 7
			 mWorldMatrix = mEntity->getParentSceneNode()->_getFullTransform();
	#else
			 mEntity->getParentSceneNode()->getWorldTransforms(&mWorldMatrix);
	#endif
		}
		else
		{
			Ogre::SceneNode *mTmpSN = new Ogre::SceneNode(0);
		    mTmpSN->setPosition(mHydrax->getPosition());

	#if OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 7
			 mWorldMatrix = mTmpSN->_getFullTransform();
	#else
			 mTmpSN->getWorldTransforms(&mWorldMatrix);
	#endif

		    delete mTmpSN;
		}

		return mWorldMatrix.transformAffine(ObjectSpacePosition);
	}
开发者ID:heropunch,项目名称:cyberdeck,代码行数:28,代码来源:Mesh.cpp


示例4: injectMouseMoved

bool Panel::injectMouseMoved(const Ogre::Ray& ray)
{
    Ogre::Matrix4 transform;
    transform.makeTransform(mNode->getPosition(), mNode->getScale(), mNode->getOrientation());
   
    Ogre::AxisAlignedBox aabb = mScreenRenderable->getBoundingBox();
    aabb.transform(transform);
    pair<bool, Ogre::Real> result = Ogre::Math::intersects(ray, aabb);

    if (result.first == false)
    {
        unOverAllElements();
        return false;
    }

    Ogre::Vector3 a,b,c,d;
    Ogre::Vector2 halfSize = (mSize/100) * 0.5f;
    a = transform * Ogre::Vector3(-halfSize.x,-halfSize.y,0);
    b = transform * Ogre::Vector3( halfSize.x,-halfSize.y,0);
    c = transform * Ogre::Vector3(-halfSize.x, halfSize.y,0);
    d = transform * Ogre::Vector3( halfSize.x, halfSize.y,0);
    
    result = Ogre::Math::intersects(ray, c, b, a);
    if (result.first == false)
        result = Ogre::Math::intersects(ray, c, d, b);
    if (result.first == false)
    {
        unOverAllElements();
        return false;
    }
    if (result.second > mDistanceFromPanelToInteractWith)
    {
        unOverAllElements();
        return false;
    }

    Ogre::Vector3 hitPos = (ray.getOrigin() + (ray.getDirection() * result.second));
    Ogre::Vector3 localPos = transform.inverse() * hitPos;
    localPos.x += halfSize.x;
    localPos.y -= halfSize.y;
    localPos.x *= 100;
    localPos.y *= 100;
   
    // Cursor clip
    localPos.x = Ogre::Math::Clamp<Ogre::Real>(localPos.x, 0, mSize.x - 10);
    localPos.y = Ogre::Math::Clamp<Ogre::Real>(-localPos.y, 0, mSize.y - 18);

    mInternalMousePos = Ogre::Vector2(localPos.x, localPos.y);
    mMousePointer->position(mInternalMousePos);

    // Let's actualize the "over" for each elements
    for (size_t i=0; i < mPanelElements.size(); i++)
        mPanelElements[i]->isOver(mInternalMousePos);

    return true;
}
开发者ID:Valentin33,项目名称:Gui3D,代码行数:56,代码来源:Gui3DPanel.cpp


示例5:

// ----------------------------------------------------------------
// gets the location of the specified eye
// ----------------------------------------------------------------
Ogre::Matrix4 OgreOpenVR::getHMDMatrixPoseEye(vr::Hmd_Eye nEye)
{
    if (!m_pHMD)
        return Ogre::Matrix4();

    vr::HmdMatrix34_t matEye = m_pHMD->GetEyeToHeadTransform(nEye);    
    Ogre::Matrix4 eyeTransform = convertSteamVRMatrixToOgreMatrix4(matEye);

    return eyeTransform.inverse();
}
开发者ID:noirb,项目名称:SIGViewer,代码行数:13,代码来源:OgreOpenVR.cpp


示例6: addToVertices

int IcoSphere::addToVertices(std::list<VertexPair> *target, const Ogre::Vector3 &position, const Ogre::ColourValue &colour, float scale)
{
	Ogre::Matrix4 transform = Ogre::Matrix4::IDENTITY;
	transform.setTrans(position);
	transform.setScale(Ogre::Vector3(scale, scale, scale));
 
	for (int i = 0; i < (int)vertices.size(); i++)
		target->push_back(VertexPair(transform * vertices[i], colour));

	return vertices.size();
}
开发者ID:hasyimibhar,项目名称:ogre-debug-drawing-utility,代码行数:11,代码来源:DebugDrawer.cpp


示例7: check

  Button* check(const Ogre::Ray& ray, bool& isOver)
  {
   
   isOver = false;
   
   Ogre::Matrix4 transform;
   transform.makeTransform(mNode->getPosition(), mNode->getScale(), mNode->getOrientation());
   
   Ogre::AxisAlignedBox aabb = mScreen->getBoundingBox();
   aabb.transform(transform);
   std::pair<bool, Ogre::Real> result = Ogre::Math::intersects(ray, aabb);

   if (result.first == false)
     return 0;
   
   Ogre::Vector3 a,b,c,d;
   Ogre::Vector2 halfSize = mSize * 0.5f;
   a = transform * Ogre::Vector3(-halfSize.x,-halfSize.y,0);
   b = transform * Ogre::Vector3( halfSize.x,-halfSize.y,0);
   c = transform * Ogre::Vector3(-halfSize.x, halfSize.y,0);
   d = transform * Ogre::Vector3( halfSize.x, halfSize.y,0);
    
   result = Ogre::Math::intersects(ray, c, b, a);
   if (result.first == false)
    result = Ogre::Math::intersects(ray, c, d, b);
   if (result.first == false)
    return 0;
   
   if (result.second > 6.0f)
    return 0;
   
   isOver = true;
   
   Ogre::Vector3 hitPos = ( ray.getOrigin() + (ray.getDirection() * result.second) );
   Ogre::Vector3 localPos = transform.inverse() * hitPos;
   localPos.x += halfSize.x;
   localPos.y -= halfSize.y;
   localPos.x *= 100;
   localPos.y *= 100;
   
   // Cursor clip
   localPos.x = Ogre::Math::Clamp<Ogre::Real>(localPos.x, 0, (mSize.x * 100) - 10);
   localPos.y = Ogre::Math::Clamp<Ogre::Real>(-localPos.y, 0, (mSize.y * 100) - 18);
   
   mMousePointer->position(localPos.x, localPos.y);

   for (size_t i=0;i < mButtons.size();i++)
   {
    if (mButtons[i]->isOver(mMousePointer->position()))
     return mButtons[i];
   }
   
   return 0;
  }
开发者ID:ViteFalcon,项目名称:gorilla,代码行数:54,代码来源:gorilla_3d.cpp


示例8: GetBoundingBox

Ogre::AxisAlignedBox AACamera::GetBoundingBox(bool transformed) const
{	
	Ogre::AxisAlignedBox box = Box;
	if (!transformed)
		return box;

	Ogre::Matrix4 transforms;
	//Node->getWorldTransforms(&transforms);
	transforms.makeTransform(Node->getPosition(),Node->getScale(),Node->getOrientation());
	box.transform(transforms);
	return box;
}
开发者ID:beorc,项目名称:flare_star,代码行数:12,代码来源:AACamera.cpp


示例9:

    void
    BoxCenterMovable::getBoundingBoxCenter()
    {
        if(object.lock()->hasProperty("bounding box") && object.lock()->hasProperty("position"))
        {
            Ogre::AxisAlignedBox aabb = VariantCast<Ogre::AxisAlignedBox>(object.lock()->getProperty("bounding box"));
            /*Ogre::Vector3 position = VariantCast<Ogre::Vector3>(object.lock()->getProperty("position"));
            Ogre::Matrix4 matTrans;
            matTrans.makeTrans( position );
            aabb.transformAffine(matTrans);*/

			Ogre::Matrix4 transform = Ogre::Matrix4::IDENTITY;

			Ogre::Matrix3 rot3x3;
			if (object.lock()->hasProperty("orientation"))
			{
				Ogre::Quaternion orientation = VariantCast<Ogre::Quaternion>(object.lock()->getProperty("orientation"));
				orientation.ToRotationMatrix(rot3x3);
			}
			else
			{
				rot3x3 = Ogre::Matrix3::IDENTITY;
			}

			Ogre::Matrix3 scale3x3;
			if (object.lock()->hasProperty("scale"))
			{
				Ogre::Vector3 scale = VariantCast<Ogre::Vector3>(object.lock()->getProperty("scale"));
				scale3x3 = Ogre::Matrix3::ZERO;
				scale3x3[0][0] = scale.x;
				scale3x3[1][1] = scale.y;
				scale3x3[2][2] = scale.z;
			}
			else
			{
				scale3x3 = Ogre::Matrix3::IDENTITY;
			}

			transform = rot3x3 * scale3x3;

			if (object.lock()->hasProperty("position"))
			{
				Ogre::Vector3 position = VariantCast<Ogre::Vector3>(object.lock()->getProperty("position"));
				transform.setTrans(position);
			}
			aabb.transformAffine(transform);

            mCenterPosWC = aabb.getCenter();
        }
    }
开发者ID:gitrider,项目名称:wxsj2,代码行数:50,代码来源:WXBoxCenterMovable.cpp


示例10: onRightButtonPressed

void PlayerCameraOgre::onRightButtonPressed()
{
	if (!mRightButtonPressedLastFrame)
		mMousePosLastFrame = mMouse->getPosition();

	mp::Vector2i diff = mMouse->getPosition() - mMousePosLastFrame;
	const mp::Vector3f &playerPos = mPlayer->model()->getPosition();
	Ogre::Vector3 pivotPoint(playerPos.getX(), playerPos.getY() + mPivotHeight, playerPos.getZ());
	float yaw = (float)diff.getX() * CAMERA_SPEED;
	float pitch = (float)-diff.getY() * CAMERA_SPEED;

	Ogre::Quaternion yawQuat;
	yawQuat.FromAngleAxis(Ogre::Radian(yaw), Ogre::Vector3::UNIT_Y);
	Ogre::Matrix3 yawMat;
	yawQuat.ToRotationMatrix(yawMat);

	Ogre::Vector3 pivotToPos = Ogre::Vector3(mRealPosition.getX(), mRealPosition.getY(), mRealPosition.getZ()) - pivotPoint;
	Ogre::Matrix4 pos(1, 0, 0, pivotToPos.x,
		0, 1, 0, pivotToPos.y,
		0, 0, 1, pivotToPos.z,
		0, 0, 0, 1);

	Ogre::Vector3 xz(pivotToPos.x, 0, pivotToPos.z);
	Ogre::Vector3 norm(-xz.z, 0, xz.x);
	Ogre::Quaternion pitchQuat;
	pitchQuat.FromAngleAxis(Ogre::Radian(pitch), norm);
	Ogre::Matrix3 pitchMat;
	pitchQuat.ToRotationMatrix(pitchMat);

	Ogre::Matrix4 toPivot(1, 0, 0, pivotPoint.x,
		0, 1, 0, pivotPoint.y,
		0, 0, 1, pivotPoint.z,
		0, 0, 0, 1);

	Ogre::Matrix4 newPosMat = pos * pitchMat * yawMat * toPivot;
	newPosMat = newPosMat.inverse();
	Ogre::Vector3 newPos = newPosMat.getTrans();
	mRealPosition.set(-newPos.x, -newPos.y, -newPos.z);
	setPosition(mRealPosition);
	lookAt(pivotPoint.x, pivotPoint.y, pivotPoint.z);

	adjustDistance();

	mMousePosLastFrame = mMouse->getPosition();
	mRightButtonPressedLastFrame = true;
}
开发者ID:Tyrame,项目名称:ethnosonline,代码行数:46,代码来源:PlayerCameraOgre.cpp


示例11: createSceneDFS

void OgreCollada::MeshWriter::pass1Finish() {
  // build scene graph and record transformations for each geometry instantiation

  // determine initial transformation
  Ogre::Matrix4 xform;
  xform.makeTransform(Ogre::Vector3::ZERO,    // no translation
                      Ogre::Vector3(m_ColladaScale.x, m_ColladaScale.y, m_ColladaScale.z),
                      Ogre::Quaternion(m_ColladaRotation.w, m_ColladaRotation.x, m_ColladaRotation.y, m_ColladaRotation.z));

  // recursively find geometry instances and their transforms
  for (size_t i = 0; i < m_vsRootNodes.size(); ++i) {
    createSceneDFS(m_vsRootNodes[i], xform);
  }

  // create manualobject for use by pass2 writeGeometry calls
  m_manobj = new Ogre::ManualObject(m_vsRootNodes[0]->getName() + "_mobj");
}
开发者ID:jefftrull,项目名称:ColladaOgreImporter,代码行数:17,代码来源:OgreMeshWriter.cpp


示例12: setTransform

void EditorNode::setTransform(Ogre::Matrix4 transform) {
	Ogre::Vector3 position, scale;
	Ogre::Quaternion orientation;
	transform.decomposition(position, scale, orientation);
	scene_node->setPosition(position);
	scene_node->setScale(scale);
	scene_node->setOrientation(orientation);
}
开发者ID:BestWanted,项目名称:libgens-sonicglvl,代码行数:8,代码来源:EditorNode.cpp


示例13: BuildTransformMatrix

//
// 根据输入的平移, 旋转, 缩放分量创建出位置变换矩阵.
//
void FairyEditorFrame::BuildTransformMatrix(Ogre::Matrix4& Matrix,  const Ogre::Vector3& position, const Ogre::Quaternion rotate, const Ogre::Vector3 scale)
{

	Ogre::Matrix4 posMatrix;
	Ogre::Matrix4 scaleMatrix;
	Ogre::Matrix4 rotateMatrix(rotate);

	posMatrix = Ogre::Matrix4::IDENTITY;
	posMatrix.setTrans(position);

	scaleMatrix = Ogre::Matrix4::IDENTITY;
	scaleMatrix.setScale(scale);

	// 最终的变换矩阵.	
	Matrix = posMatrix * rotateMatrix * scaleMatrix;


}
开发者ID:gitrider,项目名称:wxsj2,代码行数:21,代码来源:WXEditorFrame_BuildingCollision.cpp


示例14:

	const Ogre::Vector3 Mesh::getWorldSpacePosition(const Ogre::Vector3& ObjectSpacePosition) const
	{
		Ogre::Matrix4 mWorldMatrix;

		if (mCreated)
		{
			mWorldMatrix = mEntity->getParentSceneNode()->_getFullTransform();
		}
		else
		{
			Ogre::SceneNode *mTmpSN = new Ogre::SceneNode(0);
		    mTmpSN->setPosition(mHydrax->getPosition());

			mWorldMatrix = mTmpSN->_getFullTransform();

		    delete mTmpSN;
		}

		return mWorldMatrix.transformAffine(ObjectSpacePosition);
	}
开发者ID:lockie,项目名称:Landscape,代码行数:20,代码来源:Mesh.cpp


示例15: GetPointOnPlane

float3 EC_WaterPlane::GetPointOnPlane(const float3 &point) const 
{
    if (node_ == 0)
        return float3::nan;

    Ogre::Quaternion rot = node_->_getDerivedOrientation();
    Ogre::Vector3 trans = node_->_getDerivedPosition();
    Ogre::Vector3 scale = node_->_getDerivedScale();

    Ogre::Matrix4 worldTM;
    worldTM.makeTransform(trans, scale, rot);

    // In Ogre 1.7.1 we could simply use the following line, but since we're also supporting Ogre 1.6.4 for now, the above
    // lines are used instead, which work in both.
    // Ogre::Matrix4 worldTM = node_->_getFullTransform(); // local->world. 

    Ogre::Matrix4 inv = worldTM.inverse(); // world->local
    Ogre::Vector4 local = inv * Ogre::Vector4(point.x, point.y, point.z, 1.f);
 
    local.y = 0;
    Ogre::Vector4 world = worldTM * local;
    return float3(world.x, world.y, world.z);
}
开发者ID:Ilikia,项目名称:naali,代码行数:23,代码来源:EC_WaterPlane.cpp


示例16:

// Called by Rocket when it wants to render application-compiled geometry.
void RenderInterfaceOgre3D::RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rocket::Core::Vector2f& translation)
{
	Ogre::Matrix4 transform;
	transform.makeTrans(translation.x, translation.y, 0);
	render_system->_setWorldMatrix(transform);

	render_system = Ogre::Root::getSingleton().getRenderSystem();
	RocketOgre3DCompiledGeometry* ogre3d_geometry = (RocketOgre3DCompiledGeometry*) geometry;

	if (ogre3d_geometry->texture != NULL)
	{
		render_system->_setTexture(0, true, ogre3d_geometry->texture->texture);

		// Ogre can change the blending modes when textures are disabled - so in case the last render had no texture,
		// we need to re-specify them.
		render_system->_setTextureBlendMode(0, colour_blend_mode);
		render_system->_setTextureBlendMode(0, alpha_blend_mode);
	}
	else
		render_system->_disableTextureUnit(0);

	render_system->_render(ogre3d_geometry->render_operation);
}
开发者ID:Draion,项目名称:Gamekit,代码行数:24,代码来源:RenderInterfaceOgre3D.cpp


示例17: RenderCompiledGeometry

void RocketInterface::RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometryHandle,
                                             const Rocket::Core::Vector2f& translation)
{
    RocketOgreGeometry* geometry = reinterpret_cast<RocketOgreGeometry*>(geometryHandle);

    // Build world matrix
    Ogre::Matrix4 world;
    world.makeTrans(translation.x, translation.y, 0);

    // Draw UI element
    Ogre::Pass* pass;
    if (geometry->texture)
    {
        pass = mUIMaterial->getTechnique("Texture")->getPass(0);
        pass->getTextureUnitState(0)->setTexture(geometry->texture->texture);
    }
    else
    {
        pass = mUIMaterial->getTechnique("NoTexture")->getPass(0);
    }
    mSceneMgr->manualRender(&geometry->renderOp, pass, nullptr,
                            world, Ogre::Matrix4::IDENTITY, mProjection);
}
开发者ID:JamesLinus,项目名称:dawnengine,代码行数:23,代码来源:RocketInterface.cpp


示例18:

HavokNode::HavokNode(string name, hkGeometry *geometry, LibGens::Matrix4 transform, Ogre::SceneManager *scene_manager) {
	type = EDITOR_NODE_HAVOK;

	scene_node = scene_manager->getRootSceneNode()->createChildSceneNode();
	havok_name = name;

	buildHavokMesh(scene_node, havok_name, geometry, scene_manager, EDITOR_NODE_QUERY_HAVOK, GENERAL_MESH_GROUP);

	Ogre::Matrix4 matrix = Ogre::Matrix4(transform.m[0][0], transform.m[0][1], transform.m[0][2], transform.m[0][3],
		                                 transform.m[1][0], transform.m[1][1], transform.m[1][2], transform.m[1][3],
									     transform.m[2][0], transform.m[2][1], transform.m[2][2], transform.m[2][3],
										 transform.m[3][0], transform.m[3][1], transform.m[3][2], transform.m[3][3]);


	matrix.decomposition(position, scale, rotation);
	scene_node->setPosition(position);
	scene_node->setScale(scale);
	scene_node->setOrientation(rotation);

	scene_node->getUserObjectBindings().setUserAny(EDITOR_NODE_BINDING, Ogre::Any((EditorNode *)this));
		
	selected = false;
}
开发者ID:Radfordhound,项目名称:libgens-sonicglvl,代码行数:23,代码来源:HavokNode.cpp


示例19: processIndexData

namespace Nx {

bool mFlipVertexWinding = false;
Ogre::Matrix4 mTransform ;
AxisAlignedBox mBoundingBox;
bool mNormaliseNormals = false;
bool mUpdateBoundingBox = true;

void processIndexData(IndexData* indexData)
{
	if (!mFlipVertexWinding)
	{
		// Nothing to do.
		return;
	}

	if (indexData->indexCount % 3 != 0)
	{
        printf("Index number is not a multiple of 3, no vertex winding flipping possible. Skipped.");
        return;
	}

	//print("Flipping index order for vertex winding flipping.", V_HIGH);
	Ogre::HardwareIndexBufferSharedPtr buffer = indexData->indexBuffer;
	unsigned char* data = static_cast<unsigned char*>(buffer->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));

	if(buffer->getType() == Ogre::HardwareIndexBuffer::IT_16BIT)
	{
		// 16 bit
		//print("using 16bit indices", V_HIGH);

		for (size_t i = 0; i < indexData->indexCount; i+=3)
		{
			Ogre::uint16 * i0 = (Ogre::uint16*)(data+0 * buffer->getIndexSize());
			Ogre::uint16* i2 = (Ogre::uint16*)(data+2 * buffer->getIndexSize());

			// flip
			Ogre::uint16 tmp = *i0;
			*i0 = *i2;
			*i2 = tmp;

			data += 3 * buffer->getIndexSize();
		}
	}
	else
	{
		// 32 bit
		//print("using 32bit indices", V_HIGH);

		for (size_t i = 0; i < indexData->indexCount; i+=3)
		{
			Ogre::uint32* i0 = (Ogre::uint32*)(data+0 * buffer->getIndexSize());
			Ogre::uint32* i2 = (Ogre::uint32*)(data+2 * buffer->getIndexSize());

			// flip
			Ogre::uint32 tmp = *i0;
			*i0 = *i2;
			*i2 = tmp;

			data += 3 * buffer->getIndexSize();
		}
	}

	buffer->unlock();
}

void processPositionElement( VertexData* vertexData, const VertexElement* vertexElem )
{
	int nMaxVert= vertexData->vertexCount ;
	//const Ogre::VertexElement* VertexEle_POS = vertexData->vertexDeclaration->findElementBySemantic( Ogre::VES_POSITION );
 
	// get vertex buffer info via the input element
	Ogre::HardwareVertexBufferSharedPtr VertexBufPOS = vertexData->vertexBufferBinding->getBuffer( vertexElem->getSource() );
 
	//LOCK BUFFER
	unsigned char* VertexPtrPOS = static_cast<unsigned char*>( VertexBufPOS->lock( Ogre::HardwareBuffer::HBL_NORMAL)   );
	int VertSizePOS=VertexBufPOS->getVertexSize();

	float * pElementPOS=NULL;
   
	//A vector of every vertices position
	std::vector<Ogre::Vector3> positions(nMaxVert);
	//Copy each position into position vector
	for(int nVert=0 ; nVert<nMaxVert ; nVert++)
	{
		vertexElem->baseVertexPointerToElement( VertexPtrPOS, &pElementPOS );
		Ogre::Vector3 vertex(pElementPOS);
		vertex = mTransform * vertex;
		pElementPOS[0] = vertex.x;
		pElementPOS[1] = vertex.y;
		pElementPOS[2] = vertex.z;
		mBoundingBox.merge(vertex);
		VertexPtrPOS+=VertSizePOS ;
	}
	//UNLOCK BUFFER
	if(VertexBufPOS->isLocked()){VertexBufPOS->unlock();}
}

void processDirectionElement(VertexData* vertexData, const VertexElement* vertexElem )
{
//.........这里部分代码省略.........
开发者ID:nxgraphics,项目名称:NxGraphics,代码行数:101,代码来源:NxMeshManagerUtils.cpp


示例20: SetPivotTransform

void NxMeshManager::SetPivotTransform( Ogre::MeshPtr mesh, const Nx::Vector3 & Position, const Nx::Quaternion & Rotation, const Nx::Vector3 & Scale )
{
	//from mesh magick / mit licence
	 Nx::Matrix4 transform = Nx::Matrix4::IDENTITY;
	 Nx::Vector3 translate =  Nx::Vector3::ZERO;
	// Apply current transform to the mesh, to get the bounding box to
	// base te translation on.
	AxisAlignedBox aabb = getMeshAabb( mesh, transform);
	//if (alignment == "left")
	//{
	// 	translate = Vector3(-aabb.getMinimum().x, 0, 0);
	//}
	//else if (alignment == "center")
	//{
	//	translate = Vector3(-aabb.getCenter().x, 0, 0);
	//}
	//else if (alignment == "right")
	//{
	//	translate = Vector3(-aabb.getMaximum().x, 0, 0);
	//}

	//Position .. only support pivot down / centered
	//translate = Vector3(0, -aabb.getMinimum().y, 0);// pivot down

	translate = Position;
	 
	transform = Nx::Matrix4::getTrans(translate) * transform;

	//rotation
	transform = Nx::Matrix4(Rotation) * transform;

	//scale
	transform = Nx::Matrix4::getScale(Scale) * transform;

    // Check whether we have to flip vertex winding.
    // We do have to, if we changed our right hand base.
    // We can test it by using the cross product from X and Y and see, if it is a non-negative
    // projection on Z. Actually it should be exactly Z, as we don't do non-uniform scaling yet,
    // but the test is cheap either way.
    Nx::Matrix3 m3;
    transform.extract3x3Matrix(m3);

    if (m3.GetColumn(0).crossProduct(m3.GetColumn(1)).dotProduct(m3.GetColumn(2)) < 0)
    {
		LogMsg("SetPivotPosition : Flipping vertex winding ... "   );
    	mFlipVertexWinding = true;
    }

	//mTransform = transform;

	NxMat4toOgre( mTransform, transform ) ;


	mBoundingBox.setNull();

    if( mesh->sharedVertexData != NULL)
    {
        processVertexData( mesh->sharedVertexData);
	}else
	{
		LogMsg("mesh->sharedVertexData NULL");
	}

    for( int i = 0; i < mesh->getNumSubMeshes(); i++ )
    {
        SubMesh* submesh = mesh->getSubMesh(i);
        if( submesh->vertexData != NULL )
        {
			LogMsg("SetPivotPosition : Processing vertex data ... "   );
            processVertexData(submesh->vertexData);
		}else
		{
			LogMsg("submesh->vertexData NULL");
		}

        if (submesh->indexData != NULL)
        {
			LogMsg("SetPivotPosition : Processing Index data .."   );
        	processIndexData(submesh->indexData);
		}else
		{
			LogMsg("submesh->indexData NULL");
		}
    }

	//process pose
    for( unsigned short i = 0; i < mesh->getPoseCount(); ++i )
    {
		Ogre::Pose * pose =  mesh->getPose(i);
		Ogre::Matrix3 m3x3;
		mTransform.extract3x3Matrix(m3x3);

		Pose::VertexOffsetIterator it = pose->getVertexOffsetIterator();
		while (it.hasMoreElements()) {
			Ogre::Vector3 offset = it.peekNextValue();
			Ogre::Vector3 newOffset = m3x3 * offset;
			*it.peekNextValuePtr() = newOffset;
			it.moveNext();
		}
    }
//.........这里部分代码省略.........
开发者ID:nxgraphics,项目名称:NxGraphics,代码行数:101,代码来源:NxMeshManagerUtils.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ ogre::MeshPtr类代码示例发布时间:2022-05-31
下一篇:
C++ ogre::Matrix3类代码示例发布时间: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