本文整理汇总了C++中NxActor::putToSleep方法的典型用法代码示例。如果您正苦于以下问题:C++ NxActor::putToSleep方法的具体用法?C++ NxActor::putToSleep怎么用?C++ NxActor::putToSleep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NxActor
的用法示例。
在下文中一共展示了NxActor::putToSleep方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cloneRobot
void NxRobot::cloneRobot(int indexNewScene, int indexNewRobot, NxVec3 newPosition, int indexNewTeam)
{
NxRobot* nxRobotSource = Simulation::gScenes[this->indexScene]->allRobots->getRobotByIdByTeam(this->id, this->idTeam);
NxActor* robotActor = Simulation::cloneActor(nxRobotSource->getActor(),indexNewScene);
//NxBounds3 bodyBounds;
//robotShapes[0]->getWorldBounds(bodyBounds);
NxVehicleDesc vehicleDesc;
vehicleDesc.position = NxVec3(robotActor->getGlobalPosition());
vehicleDesc.mass = robotActor->getMass();
//vehicleDesc.motorForce = 70000;
//vehicleDesc.maxVelocity = 300.f;
//vehicleDesc.cameraDistance = 8.0f;
vehicleDesc.centerOfMass.set(robotActor->getCMassLocalPosition());
//vehicleDesc.differentialRatio = 3.42f;
//vehicleDesc.transmissionEfficiency
vehicleDesc.actor = robotActor;
//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();
//.........这里部分代码省略.........
示例2: 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;
}
}