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


C++ NxActor::setName方法代码示例

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


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

示例1: createBody


//.........这里部分代码省略.........
			NxMaterialDesc  *entMat  = createMaterialFromEntity(referenceObject);
			material  = world->getScene()->createMaterial(entMatNull);
			material->loadFromDesc(*entMat);
			result->setMaterial(material);
		}else{
			if (world->getDefaultMaterial())
			{
				result->setMaterial(world->getDefaultMaterial());
			}
		}
		//////////////////////////////////////////////////////////////////////////

		NxBoxShapeDesc boxShape;
		if (creationFlags & E_OFC_DIMENSION )
		{
			boxShape.dimensions = pMath::getFrom(box_s)*0.5f;
		}
		boxShape.density  = descr->density;
		boxShape.materialIndex = result->getMaterial()->getMaterialIndex();
		if (result->getSkinWidth()!=-1.0f)
			boxShape.skinWidth = result->getSkinWidth();

		actorDesc.shapes.pushBack(&boxShape);

		//////////////////////////////////////////////////////////////////////////
		//dynamic object  ? 
		if (result->getFlags() & BF_Moving){
			actorDesc.body = &bodyDesc;
		}
		else
			actorDesc.body = NULL;

		//////////////////////////////////////////////////////////////////////////
		//set transformations
		actorDesc.density  = descr->density;

		if (creationFlags & E_OFC_POSITION)
		{
			actorDesc.globalPose.t = pos;	
		}

		if (creationFlags & E_OFC_POSITION)
		{
			actorDesc.globalPose.M = rot;
		}
		
				//////////////////////////////////////////////////////////////////////////
		//create the actor

		int v = actorDesc.isValid();
		NxActor *actor  = world->getScene()->createActor(actorDesc);
		if (!actor)
		{
			xLogger::xLog(ELOGERROR,E_LI_AGEIA,"Couldn't create actor");
			delete result;
			return NULL;

		}


		//////////////////////////////////////////////////////////////////////////
		//set additional settings : 
		result->setActor(actor);
		actor->setName(referenceObject->GetName());
		actor->userData= result;

		if (result->getFlags() & BF_Moving)
		{
			VxVector massOffsetOut;referenceObject->Transform(&massOffsetOut,&result->getMassOffset());
			actor->setCMassOffsetGlobalPosition(pMath::getFrom(massOffsetOut));
		}

		if (result->getFlags() & BF_Kinematic)
		{
			actor->raiseBodyFlag(NX_BF_KINEMATIC);
		}

		result->enableCollision((result->getFlags() & BF_Collision));
		if (result->getFlags() & BF_Moving)
		{
			if (!(result->getFlags() & BF_Gravity))
			{
				actor->raiseBodyFlag(NX_BF_DISABLE_GRAVITY);
			}
		}

		NxShape *shape  = result->getShapeByIndex();
		if (shape)
		{
			pSubMeshInfo *sInfo  = new pSubMeshInfo();
			sInfo->entID = referenceObject->GetID();
			sInfo->refObject  = (CKBeObject*)referenceObject;
			shape->userData = (void*)sInfo;
			result->setMainShape(shape);
			shape->setName(referenceObject->GetName());
		}
	}
		
	return result;
}
开发者ID:gbaumgart,项目名称:vt,代码行数:101,代码来源:pFactoryBody.cpp

示例2: if


//.........这里部分代码省略.........
		}
	}

	if ( !isDeformable)
	{
		actorDesc.globalPose.t = pos;	
		actorDesc.globalPose.M = rot;
	}



	//----------------------------------------------------------------
	//
	// Create the final NxActor
	//

	if (oDescr.flags & BF_Moving)
		actorDesc.body = &bodyDesc;

	NxActor *actor  = world->getScene()->createActor(actorDesc);
	if (!actor)
	{
		xLogger::xLog(ELOGERROR,E_LI_AGEIA,"Couldn't create actor");
		delete result;
		return NULL;

	}

	//----------------------------------------------------------------
	//
	// 
	//
	result->setActor(actor);
	actor->setName(referenceObject->GetName());
	result->SetVT3DObject(referenceObject);
	actor->userData= result;


	//////////////////////////////////////////////////////////////////////////
	//Deformable : 
	if (isDeformable && cloth)
	{

		pDeformableSettings dSettings;
		dSettings.ImpulsThresold = 50.0f;
		dSettings.PenetrationDepth= 0.1f ;
		dSettings.MaxDeform = 2.0f;

		CKParameterOut *poutDS = referenceObject->GetAttributeParameter(GetPMan()->att_deformable);
		if (poutDS)
		{
			pFactory::Instance()->copyTo(dSettings,poutDS);
		}
		cloth->attachToCore(referenceObject,dSettings.ImpulsThresold,dSettings.PenetrationDepth,dSettings.MaxDeform);
		result->setCloth(cloth);
	}


	//////////////////////////////////////////////////////////////////////////
	//
	//	Extra settings : 
	//

	if (result->getFlags() & BF_Moving)
	{
		VxVector massOffsetOut;referenceObject->Transform(&massOffsetOut,&oDescr.massOffsetLinear);
开发者ID:gbaumgart,项目名称:vt,代码行数:67,代码来源:pFactoryBody.cpp

示例3: cloneRobot


//.........这里部分代码省略.........

    //Motor descricao
    //NxVehicleMotorDesc motorsDesc[4];
    //for(NxU32 i=0;i<4;i++)
    //{
    //motorsDesc[i].setToCorvette();
    //vehicleDesc.motorsDesc.push_back(&motorsDesc[i]);
    //}

    //Roda (Wheel) descricao
    int numberWheels = nxRobotSource->getNbWheels();
    NxWheelDesc* wheelDesc = new NxWheelDesc[numberWheels];
    for(NxU32 i=0; i<numberWheels; i++)
    {
        //NxActor* wheelModel = Simulation::getActorWheel(indexSourceScene,indexNewRobot,i);
        //NxActorDesc wheelActorDesc;
        //wheelModel->saveToDesc(wheelActorDesc);
        //Simulation::gScenes[0]->releaseActor(*wheelModel);

        //NxShape*const* wheelShapes = actorWheel->getShapes();
        //NxBounds3 wheelBounds;
        //wheelShapes[0]->getWorldBounds(wheelBounds);

        const NxWheel* wheel = nxRobotSource->getWheel(i);
        NxWheelShape* wheelShape = ((NxWheel2*)wheel)->getWheelShape();
        //wheelDesc[i].wheelApproximation = 10;
        wheelDesc[i].wheelOrientation = wheelShape->getGlobalOrientation();
        wheelDesc[i].position.set(wheelShape->getGlobalPosition()-robotActor->getGlobalPosition());
        //wheelDesc[i].position.z = 0;
        wheelDesc[i].id = i;
        wheelDesc[i].wheelFlags = ((NxWheel*)wheel)->getWheelFlags();
        wheelDesc[i].wheelRadius = wheel->getRadius();
        //wheelDesc[i].wheelWidth = 100;
        wheelDesc[i].wheelSuspension = wheelShape->getSuspensionTravel();
        wheelDesc[i].springRestitution = 0;
        wheelDesc[i].springDamping = 0;
        wheelDesc[i].springBias = 0.0f;
        wheelDesc[i].maxBrakeForce = 100;
        wheelDesc[i].frictionToFront = 0.1f;//0.1f;
        wheelDesc[i].frictionToSide = 0;//0.02f;//
        wheelDesc[i].inverseWheelMass = wheelShape->getInverseWheelMass(); //TODO: CONFIGURAR PARÂMETRO

        //Angulo das Rodas (Omni)
        wheelDesc[i].angWheelRelRobot = ((NxWheel2*)wheel)->angWheelRelRobot;

        vehicleDesc.robotWheels.pushBack(&wheelDesc[i]);
    }

    //Criar robot, vehicle base
    NxRobot* robot = (NxRobot*)NxRobot::createVehicle(Simulation::gScenes[indexNewScene], &vehicleDesc);
    //NxRobot* robot = (NxRobot*)NxRobot::createVehicle(gScenes[indexSourceScene], &vehicleDesc);
    robot->setId(indexNewRobot);
    robot->setIdTeam(indexNewTeam);
    robot->indexScene = indexNewScene;
    robot->bodyRadius = nxRobotSource->bodyRadius;

    //Dribbler and Kicker
    NxShape*const* robotShapes = robotActor->getShapes();
    for(int i=0; i<robotActor->getNbShapes(); i++) {
        const char* shapeName = robotShapes[i]->getName();
        if(shapeName) {
            char* dribblerName = new char[10];//"Driblador\0"
            dribblerName[9] = 0;
            memcpy(dribblerName, shapeName, strlen(dribblerName));

            if(strcmp(dribblerName, "Driblador") == 0) {
                robot->dribbler->dribblerShapes.push_back(robotShapes[i]);
            }
            delete dribblerName;
        }
    }
    robot->kicker->kickerShapeDesc = new NxBoxShapeDesc();
    NxShapeDesc* shapeDesc = nxRobotSource->kicker->kickerShapeDesc;
    robot->kicker->kickerShapeDesc->localPose = shapeDesc->localPose;
    ((NxBoxShapeDesc*)(robot->kicker->kickerShapeDesc))->dimensions = ((NxBoxShapeDesc*)shapeDesc)->dimensions;

    //Initial Pose
    robot->setInitialPose(robotActor->getGlobalPose());

    robotActor->putToSleep();

    //Transladando o robo
    robot->getActor()->setGlobalPosition(newPosition);

    string label;
    string plabel = "Robo";
    stringstream out;
    out << indexNewRobot;
    out << "-";
    out << indexNewTeam;
    //out << "-";
    //out << indexNewScene;
    label.append(plabel);
    label.append(out.str());
    char* arrayLabel = new char[label.size()+1];
    arrayLabel[label.size()]=0;
    memcpy(arrayLabel, label.c_str(), label.size());
    robotActor->setName(arrayLabel);
    //delete arrayLabel;
}
开发者ID:roboime,项目名称:legacy-roboime,代码行数:101,代码来源:NxRobot.cpp

示例4: buildModelRobot


//.........这里部分代码省略.........
        //	NxWhee
        //wheelDesc[i]
        //robot1Shapes[0]->isConvexMesh()->getConvexMesh().saveToDesc(convexMesh);
        //NxWheelShape* wheelShape = (NxWheelShape*)wheel;
        //NxTriangleMeshDesc meshDesc = *((NxTriangleMeshDesc*)(mesh->userData));
        //robot1Shapes[0]->isWheel()->

        //wheelDesc[i].wheelApproximation = 10;

        wheelDesc[i].wheelOrientation = actorWheel->getGlobalOrientation();
        wheelDesc[i].position.set(actorWheel->getGlobalPosition()-robotActor->getGlobalPosition());
        //wheelDesc[i].position.z = 0;
        wheelDesc[i].id = i;
        wheelDesc[i].wheelRadius = 27.6;
        //wheelDesc[i].wheelWidth = 100;
        wheelDesc[i].wheelSuspension = 0;
        wheelDesc[i].springRestitution = 0;
        wheelDesc[i].springDamping = 0;
        wheelDesc[i].springBias = 0.0f;
        wheelDesc[i].maxBrakeForce = 100;
        wheelDesc[i].frictionToFront = 0.1f;//0.1f;	//TODO: CONFIGURAR PARÂMETRO
        wheelDesc[i].frictionToSide = 0;//0.02f;	//TODO: CONFIGURAR PARÂMETRO
        wheelDesc[i].inverseWheelMass = 0.1;		//TODO: CONFIGURAR PARÂMETRO

        //Angulo das Rodas (Omni)
        NxVec3 wheelPosRel = actorWheel->getGlobalPosition() - robotActor->getGlobalPosition();
        wheelDesc[i].angWheelRelRobot = NxMath::atan2( wheelPosRel.y, wheelPosRel.x );

        vehicleDesc.robotWheels.pushBack(&wheelDesc[i]);
        Simulation::gScenes[indexScene]->scene->releaseActor(*actorWheel);

        //NxU32 flags = NX_WF_BUILD_LOWER_HALF;
        wheelDesc[i].wheelFlags = NX_WF_ACCELERATED | NX_WF_AFFECTED_BY_HANDBRAKE | NX_WF_USE_WHEELSHAPE | NX_WF_BUILD_LOWER_HALF;// |/*NX_WF_STEERABLE_INPUT |*/ flags;
    }

    //NxBall* teste = Simulation::gScenes[indexScene]->ball;

    //Criar robot, vehicle base
    NxRobot* robot = (NxRobot*)NxRobot::createVehicle(Simulation::gScenes[indexScene], &vehicleDesc);
    if(robot) {
        robot->setId(indexRobot);
        robot->setIdTeam(indexTeam);
        robot->indexScene = indexScene;

        //Dribbler and Kicker
        for(int i=0; i<robotActor->getNbShapes(); i++) {
            NxShape*const* robotShapes = robotActor->getShapes();
            const char* shapeName = robotShapes[i]->getName();
            if(shapeName) {
                char* dribblerName = new char[10];//"Driblador\0"
                dribblerName[9] = 0;
                memcpy(dribblerName, shapeName, strlen(dribblerName));

                char* kickerName = new char[9];//"Chutador\0"
                kickerName[8] = 0;
                memcpy(kickerName, shapeName, strlen(kickerName));

                if(strcmp(dribblerName, "Driblador") == 0) {
                    robot->dribbler->dribblerShapes.push_back(robotShapes[i]);
                }
                else if(strcmp(kickerName, "Chutador") == 0) {
                    robot->kicker->kickerShapeDesc = Simulation::copyShapeDesc(robotShapes[i]);
                    robotActor->releaseShape(*(robotShapes[i]));
                }
                delete dribblerName;
                delete kickerName;
            }
        }

        //Initial Pose
        robot->setInitialPose(robotActor->getGlobalPose());

        robotActor->putToSleep();

        //Mudar pose do robo
        //NxQuat q;
        //q.
        //q.fromAngleAxis(180.0f, NxVec3(0.0f, 1.0f, 0.0f));
        //robot->getActor()->setGlobalPose(pose);

        //Release no actor importado do 3ds Max
        //gScenes[0]->releaseActor(*robotActor);

        string label;
        string plabel = "Robo";
        stringstream out;
        out << indexRobot;
        out << "-";
        out << indexTeam;
        //out << "-";
        //out << indexScene;
        label.append(plabel);
        label.append(out.str());
        char* arrayLabel = new char[label.size()+1];
        arrayLabel[label.size()]=0;
        memcpy(arrayLabel, label.c_str(), label.size());
        robotActor->setName(arrayLabel);
        //delete arrayLabel;
    }
}
开发者ID:roboime,项目名称:legacy-roboime,代码行数:101,代码来源:NxRobot.cpp


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