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


C++ TransformPtr类代码示例

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


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

示例1: paramsChanged

void kore::Camera::transformChanged(const TransformPtr& newTransform) {
  SceneNodeComponent::transformChanged(newTransform);

  _matView = glm::inverse(newTransform->getGlobal());
  _matViewInverse = newTransform->getGlobal();
  paramsChanged();
}
开发者ID:duglah,项目名称:KoRE,代码行数:7,代码来源:Camera.cpp

示例2: GetParentTransformNode

void CFlystickTranslationResetTool::OnTrackingButtonReleased(Quaternion q, Vec3f position){
	std::cout << "CFlystickTranslationResetTool::OnTrackingButtonReleased()" << std::endl;

	if (! m_bToolActive){
		std::cout << "tool is not active" << std::endl;
		return;
	}

	if (m_posgPickedObjectNode == NullFC){
		std::cout << "CFlystickTranslationResetTool: No object picked to reset translation" << std::endl;
		return;
	}

	NodePtr parentingTransformNode = GetParentTransformNode(m_posgPickedObjectNode);
	if (parentingTransformNode != NullFC){
		std::cout << "CFlystickTranslationResetTool: Resetting translation!" << std::endl;
		TransformPtr transform = TransformPtr::dcast(parentingTransformNode->getCore());
		Matrix m = transform->getMatrix();
		m.setTranslate(0.0, 0.0, 0.0);
		beginEditCP(transform, Transform::MatrixFieldMask);{
			transform->setMatrix(m);
		};endEditCP(transform, Transform::MatrixFieldMask);
	}else{
		std::cout << "CFlystickTranslationResetTool: Found no parenting transform to reset!" << std::endl;
	}

	m_bToolActive = false;
}
开发者ID:ufz-vislab,项目名称:vislab,代码行数:28,代码来源:FlystickTranslationResetTool.cpp

示例3: setCamera

void CameraController::setCamera( CameraPtr camera )
{
	m_data->camera = camera;
	m_data->camera->addStandardParameters(); // subsequent casts are safe because of this
	m_data->resolution = staticPointerCast<V2iData>( m_data->camera->parameters()["resolution"] );
	m_data->screenWindow = staticPointerCast<Box2fData>( m_data->camera->parameters()["screenWindow"] );
	m_data->clippingPlanes = staticPointerCast<V2fData>( m_data->camera->parameters()["clippingPlanes"] );
	m_data->projection = staticPointerCast<StringData>( m_data->camera->parameters()["projection"] );
	if( m_data->projection->readable()=="perspective" )
	{
		m_data->fov = staticPointerCast<FloatData>( m_data->camera->parameters()["projection:fov"] );
	}
	else
	{
		m_data->fov = 0;
	}
	
	TransformPtr transform = m_data->camera->getTransform();
	m_data->transform = runTimeCast<MatrixTransform>( transform );
	if( !m_data->transform )
	{
		m_data->transform = new MatrixTransform( transform ? transform->transform() : M44f() );
		m_data->camera->setTransform( m_data->transform );
	}

	m_data->centreOfInterest = 1;
}
开发者ID:davidsminor,项目名称:cortex,代码行数:27,代码来源:CameraController.cpp

示例4: doMovement

void  MoveManipulator::doMovement(TransformPtr t,
								  Int32 coord,
								  Real32 value,
								  const Vec3f		&translation,
								  const Quaternion	&rotation,
								  const Vec3f		&scaleFactor,
								  const Quaternion	&scaleOrientation )
{
	Vec3f trans(0.0f, 0.0f, 0.0f);
	trans[coord] = value;

	Matrix ma, mb, mc, md, me;
	
	ma.setTranslate( -translation        );
	mb.setRotate   (  rotation.inverse() );
	mc.setTransform(  trans              );
	md.setRotate   (  rotation           );
	me.setTranslate(  translation        );
	beginEditCP(t, Transform::MatrixFieldMask);
	{
		t->editMatrix().multLeft(ma);
		t->editMatrix().multLeft(mb);
		t->editMatrix().multLeft(mc);
		t->editMatrix().multLeft(md);
		t->editMatrix().multLeft(me);
	}	
	endEditCP(t, Transform::MatrixFieldMask);
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:28,代码来源:OSGMoveManipulator.cpp

示例5: display

// redraw the window
void display(void)
{
   Profiler::the().StartProfile("Frame");
   unsigned i;
   for (i=0; i<numFirst; ++i) {
     TransformPtr trf = TransformPtr::dcast(first->getChild(i)->getCore());
     beginEditCP(trf);
     trf->getMatrix()[3] += Vec4f((rand()/Real32(RAND_MAX)-0.5f),
				  (rand()/Real32(RAND_MAX)-0.5f),
				  (rand()/Real32(RAND_MAX)-0.5f), 0.0f);
     endEditCP(trf);
   }
   for (i=0; i<numSecond; ++i) {
     TransformPtr trf = TransformPtr::dcast(second->getChild(i)->getCore());
     beginEditCP(trf);
     trf->getMatrix()[3] += Vec4f((rand()/Real32(RAND_MAX)-0.5f),
				  (rand()/Real32(RAND_MAX)-0.5f),
				  (rand()/Real32(RAND_MAX)-0.5f), 0.0f);
     endEditCP(trf);
   }

   bool result = all->apply(first, second);

   OSGRAPIDCollision& col = (OSGRAPIDCollision&)all->getData();     
   SLOG << col.getNumContacts() << " contacts with " 
	<< col.getNumBVolTests() << " BVolTests/"
	<< col.getNumMixedTests() << " MixedTests/"
	<< col.getNumPrimTests() << " TriTests  " 
	<< std::endl;
   
   Profiler::the().EndProfile("Frame");
   mgr->redraw();
}
开发者ID:BackupTheBerlios,项目名称:opensgplus,代码行数:34,代码来源:testRapidCollision.cpp

示例6: SceneNode

CameraNode::CameraNode( TransformPtr pTransform, Frustum const &frustum ) 
	      : SceneNode( INVALID_ACTOR_ID, NULL, RenderPass_0, pTransform ),
	      m_Frustum( frustum ),
	      m_IsActive( true ),
	      m_IsDebugCamera( false ),
         m_pTarget( shared_ptr<SceneNode>() ),
	      m_CamOffsetVector( 0.0f, 1.0f, -10.0f, 0.0f ),
         m_View( Mat4x4::LookAt( pTransform->GetToWorldPosition(), pTransform->GetToWorldPosition() + pTransform->GetForward(), g_Up ) )
   {
   }
开发者ID:scw000000,项目名称:Engine,代码行数:10,代码来源:SceneNodes.cpp

示例7: buildBox

//////////////////////////////////////////////////////////////////////////
//! build a box
//////////////////////////////////////////////////////////////////////////
void buildBox(void)
{
    Vec3f Lengths(frand()*2.0+0.5, frand()*2.0+0.5, frand()*2.0+0.5);
    Matrix m;
    //create OpenSG mesh
    GeometryPtr box;
    NodePtr boxNode = makeBox(Lengths.x(), Lengths.y(), Lengths.z(), 1, 1, 1);
    box = GeometryPtr::dcast(boxNode->getCore());
    SimpleMaterialPtr box_mat = SimpleMaterial::create();
    beginEditCP(box_mat);
        box_mat->setAmbient(Color3f(0.0,0.0,0.0));
        box_mat->setDiffuse(Color3f(0.0,1.0 ,0.0));
    endEditCP(box_mat);
    beginEditCP(box, Geometry::MaterialFieldMask);
        box->setMaterial(box_mat);
    endEditCP(box, Geometry::MaterialFieldMask);
    TransformPtr boxTrans;
    NodePtr boxTransNode = makeCoredNode<Transform>(&boxTrans);
    m.setIdentity();
    Real32 randX = frand()*10.0-5.0;
    Real32 randY = frand()*10.0-5.0;
    m.setTranslate(randX, randY, 10.0);
    beginEditCP(boxTrans, Transform::MatrixFieldMask);
        boxTrans->setMatrix(m);
    endEditCP(boxTrans, Transform::MatrixFieldMask);

    //create ODE data
    PhysicsBodyPtr boxBody = PhysicsBody::create(physicsWorld);
    beginEditCP(boxBody, PhysicsBody::PositionFieldMask);
        boxBody->setPosition(Vec3f(randX, randY, 10.0));
    endEditCP(boxBody, PhysicsBody::PositionFieldMask);
    boxBody->setBoxMass(1.0, Lengths.x(), Lengths.y(), Lengths.z());

    PhysicsBoxGeomPtr boxGeom = PhysicsBoxGeom::create();
    beginEditCP(boxGeom, PhysicsBoxGeom::BodyFieldMask | PhysicsBoxGeom::SpaceFieldMask  | PhysicsBoxGeom::LengthsFieldMask | PhysicsBoxGeom::CategoryBitsFieldMask);
        boxGeom->setBody(boxBody);
        boxGeom->setSpace(physicsSpace);
        boxGeom->setLengths(Lengths);
        boxGeom->setCategoryBits(BoxCategory);
    endEditCP(boxGeom, PhysicsBoxGeom::BodyFieldMask | PhysicsBoxGeom::SpaceFieldMask | PhysicsBoxGeom::LengthsFieldMask | PhysicsBoxGeom::CategoryBitsFieldMask);

    //add attachments
    beginEditCP(boxNode, Node::AttachmentsFieldMask);
        boxNode->addAttachment(boxGeom);
    endEditCP(boxNode, Node::AttachmentsFieldMask);
    beginEditCP(boxTransNode, Node::AttachmentsFieldMask | Node::ChildrenFieldMask);
        boxTransNode->addAttachment(boxBody);
        boxTransNode->addChild(boxNode);
    endEditCP(boxTransNode, Node::AttachmentsFieldMask | Node::ChildrenFieldMask);

    //add to SceneGraph
    beginEditCP(spaceGroupNode, Node::ChildrenFieldMask);
        spaceGroupNode->addChild(boxTransNode);
    endEditCP(spaceGroupNode, Node::ChildrenFieldMask);
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:58,代码来源:21Collisions.cpp

示例8: buildSphere

//////////////////////////////////////////////////////////////////////////
//! build a sphere
//////////////////////////////////////////////////////////////////////////
void buildSphere(void)
{
    Real32 Radius(frand()*1.5+0.2);
    Matrix m;
    //create OpenSG mesh
    GeometryPtr sphere;
    NodePtr sphereNode = makeSphere(2, Radius);
    sphere = GeometryPtr::dcast(sphereNode->getCore());
    SimpleMaterialPtr sphere_mat = SimpleMaterial::create();
    beginEditCP(sphere_mat);
    sphere_mat->setAmbient(Color3f(0.0,0.0,0.0));
    sphere_mat->setDiffuse(Color3f(0.0,0.0,1.0));
    endEditCP(sphere_mat);
    beginEditCP(sphere, Geometry::MaterialFieldMask);
    sphere->setMaterial(sphere_mat);
    endEditCP(sphere);
    TransformPtr sphereTrans;
    NodePtr sphereTransNode = makeCoredNode<Transform>(&sphereTrans);
    m.setIdentity();
    Real32 randX = frand()*10.0-5.0;
    Real32 randY = frand()*10.0-5.0;
    m.setTranslate(randX, randY, 10.0);
    beginEditCP(sphereTrans, Transform::MatrixFieldMask);
    sphereTrans->setMatrix(m);
    endEditCP(sphereTrans);
    //create ODE data
    PhysicsBodyPtr sphereBody = PhysicsBody::create(physicsWorld);
    beginEditCP(sphereBody, PhysicsBody::PositionFieldMask | PhysicsBody::AngularDampingFieldMask);
        sphereBody->setPosition(Vec3f(randX, randY, 10.0));
        sphereBody->setAngularDamping(0.0001);
    endEditCP(sphereBody, PhysicsBody::PositionFieldMask | PhysicsBody::AngularDampingFieldMask);
    sphereBody->setSphereMass(0.4,Radius);

    PhysicsSphereGeomPtr sphereGeom = PhysicsSphereGeom::create();
    beginEditCP(sphereGeom, PhysicsSphereGeom::BodyFieldMask | PhysicsSphereGeom::SpaceFieldMask | PhysicsSphereGeom::RadiusFieldMask | PhysicsSphereGeom::CategoryBitsFieldMask);
        sphereGeom->setBody(sphereBody);
        sphereGeom->setSpace(physicsSpace);
        sphereGeom->setRadius(Radius);
        sphereGeom->setCategoryBits(SphereCategory);
    endEditCP(sphereGeom, PhysicsSphereGeom::BodyFieldMask | PhysicsSphereGeom::SpaceFieldMask | PhysicsSphereGeom::RadiusFieldMask | PhysicsSphereGeom::CategoryBitsFieldMask);
    
    //add attachments
    beginEditCP(sphereNode, Node::AttachmentsFieldMask);
    sphereNode->addAttachment(sphereGeom);
    endEditCP(sphereNode);
    beginEditCP(sphereTransNode, Node::AttachmentsFieldMask | Node::ChildrenFieldMask);
    sphereTransNode->addAttachment(sphereBody);
    sphereTransNode->addChild(sphereNode);
    endEditCP(sphereTransNode);
    //add to SceneGraph
    beginEditCP(spaceGroupNode, Node::ChildrenFieldMask);
    spaceGroupNode->addChild(sphereTransNode);
    endEditCP(spaceGroupNode);
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:57,代码来源:21Collisions.cpp

示例9: ProcessEntities

void GuiMeshRender::ProcessEntities(const EntityMap &entities) {

	if (entities.empty()) {
		//printf("Warning: GuiMeshRender: Entity list is empty\n");
		return;
	}

	EntityMap::const_iterator it, ite;

	GuiMeshPtr mesh;
	TransformPtr transform;

	mat4 model, view, projection, model_view, mvp;
	mat3 normal;

	// warning: make sure the values here are all floats
	projection = glm::ortho(0.0f, 800.0f, 600.0f, 0.0f, -1.0f, 1.0f);

	for (it = entities.begin(), ite = entities.end(); it != ite; ++it) {
		mesh = gui_mesh_mapper_(it->second);
		transform = transform_mapper_(it->second);

		model = transform->world();
		model_view = model;				// camera does not need to effect this
		mvp = projection * model_view;
		normal = inverse(transpose(mat3(model_view)));

		shared_ptr<BasicMaterial> material = boost::dynamic_pointer_cast<BasicMaterial>(mesh->material);

		vec4 light_pos = material->light_position_;

		// hack to have light move with world
		// todo: implement light as entity
		material->light_position_ = model_view * light_pos;

		// do things like setup colors and lights
		// and attach shader program
		mesh->material->PreRender();

		material->light_position_ = light_pos;

		// push matrices up
		mesh->material->PushMatrices(model_view, projection, mvp, normal);

		// call draw
		mesh->geometry->Draw();

		// let go of shader program
		mesh->material->PostRender();
	}
}
开发者ID:tylorr,项目名称:Minigolf-Engine,代码行数:51,代码来源:gui_mesh_render.cpp

示例10: ball_comp_mapper_

void PhysicsSystem::CheckCup(const TransformPtr &ball_transform){
	using glm::vec2; 

	float radius = 0.05f;

	BallComponentPtr ball_comp = ball_comp_mapper_(ball_);
	TileComponentPtr curr_tile = tile_comp_mapper_(ball_comp->current_tile);
	VolumePtr cup_vol = volume_mapper_(curr_tile->cup);
	TransformPtr cup_transform = transform_mapper_(curr_tile->cup);

	// create ball projection
	vec3 proj = Project(ball_transform->position(), cup_vol->normal, cup_vol->vertices[0]);

	// project cup vertices to xz plane
	vector<vec2> projected_vertices;
	for (int j = 0, sizej = cup_vol->vertices.size(); j < sizej; ++j) {
		vec3 v = cup_vol->vertices[j];
		vec2 p(v.x, v.z);

		projected_vertices.push_back(p);
	}

	// project ball to xz plane
	vec2 point(proj.x, proj.z);

	// check to see if ball overlaps hole
	bool inter = PointInPolygon(point, projected_vertices);

	// does ball overlap?
	if (inter) {
		float dist_from_cup = glm::length(ball_transform->position() - cup_transform->position());

		//if ball is close enough to go in hole and moving slow enough, ball went in cup (stop ball)
		if(dist_from_cup < MADE_CUP_RADIUS && glm::length(ball_comp->velocity) < MAX_CUP_ENTRY_SPEED ) {
			ball_comp->velocity = vec3();
			ball_comp->acceleration = vec3();
			ball_comp->in_cup = true;
		}
		//if ball is on lip, alter accel to go towards center
		else if(dist_from_cup > MADE_CUP_RADIUS && dist_from_cup < CUP_LIP_RADIUS) {
			ball_comp->acceleration += glm::normalize(cup_transform->position() - ball_transform->position()) * LIP_ACCEL;
		}
		else{}
	}
}
开发者ID:tylorr,项目名称:Minigolf-Engine,代码行数:45,代码来源:physics_system.cpp

示例11: cloneTree

void Particles::duplicate(Vec3f deltaPos, Quaternion deltaRot)
{
	NodePtr copyTransNode = cloneTree(particleTransNode);
	TransformPtr copyTrans = Transform::create();
	Matrix m;
	m.setIdentity();
	m.setRotate(deltaRot);
	m.setTranslate(deltaPos);
	beginEditCP(copyTrans);
		copyTrans->setMatrix(m);
	endEditCP(copyTrans);
	beginEditCP(copyTransNode);
		copyTransNode->setCore(copyTrans);
	endEditCP(copyTransNode);
	beginEditCP(particleTransNode);
		particleTransNode->addChild(copyTransNode);
	endEditCP(particleTransNode);
} // duplicate
开发者ID:flair2005,项目名称:inVRs,代码行数:18,代码来源:Particles.cpp

示例12: ResolveCollision

void PhysicsSystem::ResolveCollision(const TransformPtr &ball_transform, const vec3 &normal, const vec3 &intersection) {
	BallComponentPtr ball_comp = ball_comp_mapper_(ball_);

	ball_transform->set_position(intersection);

	vec3 direction = ball_comp->velocity;
	vec3 w = glm::dot(normal, -direction) * normal;
	vec3 result = w + (w + direction);
	ball_comp->velocity = result;
}
开发者ID:tylorr,项目名称:Minigolf-Engine,代码行数:10,代码来源:physics_system.cpp

示例13: display

void display(void)
{
    Real32 time = glutGet(GLUT_ELAPSED_TIME );
    
    //create the Quaternion the describes the rotation of
    //the planet around the sun
    Quaternion planetRot = Quaternion(Vec3f(0,1,0), time/float(1000));
    
    //now the rotation of the moon around the planet
    //the division by 12 speeds up the rotation by 12 compared to the
    //planet rotation
    Quaternion moonRot = Quaternion(Vec3f(0,1,0), time/float(1000/12));
    
    //generate the Matrices
    Matrix p,m;
    
    p.setIdentity();
    m.setIdentity();
    
    p.setRotate(planetRot);
    m.setRotate(moonRot);
    
    p.setTranslate(20,0,0);
    m.setTranslate(8,0,0);

    beginEditCP(planetTransform, Transform::MatrixFieldMask);
        planetTransform->setMatrix(p);
    endEditCP(planetTransform, Transform::MatrixFieldMask);
    
    beginEditCP(moonTransform, Transform::MatrixFieldMask);
        moonTransform->setMatrix(m);
    endEditCP(moonTransform, Transform::MatrixFieldMask);
    
    mgr->redraw();
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:35,代码来源:06solarsystem.cpp

示例14: glutGet

void 
display(void)
{
	Matrix m1, m2;

	m1.setRotate( tball.getRotation() );
	m2.setTranslate( tball.getPosition() );
	
	m1.mult( m2 );
	cam_trans->editSFMatrix()->setValue( m1 );


    // move the object
    
    float t = glutGet(GLUT_ELAPSED_TIME);
    Quaternion q;
    
    q.setValueAsAxisDeg(0, 1, 0, t / 5000);
    
    m1.setTransform(Vec3f(osgsin(t / 500.), 0, osgcos(t / 500)), q);
                    
    tr->setMatrix(m1);
    
	if ( doRender )
		win->render( ract );
	else
		win->draw( dact );
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:28,代码来源:testBillboardRender.cpp

示例15: update

    virtual void update(const UpdateEventPtr e)
    {
        Real32 RotateRate(1.0f);

        Matrix RotMat;
        RotMat.setRotate(Quaternion(Vec3f(0.0,1.0,0.0),RotateRate*e->getElapsedTime()));

        Matrix NewMat(RootTransformCore->getMatrix());
        NewMat.multLeft(RotMat);

        beginEditCP(RootTransformCore, Transform::MatrixFieldMask);
            RootTransformCore->setMatrix(NewMat);
        endEditCP(RootTransformCore, Transform::MatrixFieldMask);
    }
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:14,代码来源:04HDRFilter.cpp


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