//----------------------------------------------------------------------------- // // VSpawnSphereSpawnTargetTrack::spawnTarget( pTime, pForward ); // // Spawn an Object. // //----------------------------------------------------------------------------- void VSpawnSphereSpawnTargetTrack::spawnTarget( void ) { VTorque::SpawnSphereType *object; if ( !getSceneObject( object ) ) { return; } // Spawn the Object. SimObject *spawnedObject = object->spawnObject(); // Scene Object? VTorque::SceneObjectType *sceneObject = dynamic_cast<VTorque::SceneObjectType*>( spawnedObject ); if ( sceneObject ) { sceneObject->setPosition( object->getPosition() ); } // Valid? if ( spawnedObject ) { // Add Reference. mSpawnList.addObject( spawnedObject ); } }
std::shared_ptr<const CollisionShape3D> BodyConvexHullShapeWidget::createBodyShape() const { try { LabelStyleHelper::applyNormalStyle(pointsLabel); auto scaledShape = std::make_shared<const CollisionConvexHullShape>(getPoints()); //test construction of original shape because can throw an exception due to imprecision of float float invScale = 1.0 / getSceneObject()->getModel()->getTransform().getScale(); scaledShape->scale(invScale); return scaledShape; }catch(std::invalid_argument &e) { LabelStyleHelper::applyErrorStyle(pointsLabel, std::string(e.what())); return DefaultBodyShapeCreator(getSceneObject()).createDefaultBodyShape(CollisionShape3D::ShapeType::CONVEX_HULL_SHAPE, true); } }
//----------------------------------------------------------------------------- // // VLightObjectAnimationEvent::onComplete( pTime, pDelta ); // // The current animation played by the light object will be paused when this // Event completes its updates. // //----------------------------------------------------------------------------- void VLightObjectAnimationEvent::onComplete( const S32 &pTime, const S32 &pDelta ) { Parent::onTrigger( pTime, pDelta ); // Fetch the Light Object. VTorque::LightObjectType *lightObject; if ( getSceneObject( lightObject ) ) { // Pause the Animation. VTorque::pauseAnimation( lightObject ); } }
//----------------------------------------------------------------------------- // // VLightObjectAnimationEvent::onTrigger( pTime, pDelta ); // // When this Event is triggered the light object will begin to play the target // animation. // //----------------------------------------------------------------------------- void VLightObjectAnimationEvent::onTrigger( const S32 &pTime, const S32 &pDelta ) { Parent::onTrigger( pTime, pDelta ); // Fetch the Light Object. VTorque::LightObjectType *lightObject; if ( getSceneObject( lightObject ) ) { // Play the Animation. VTorque::playAnimation( lightObject, mAnimationData ); } }
//----------------------------------------------------------------------------- // // VLightObjectAnimationTrack::onControllerReset( pTime, pForward ); // // // //----------------------------------------------------------------------------- void VLightObjectAnimationTrack::onControllerReset( const S32 &pTime, const bool &pForward ) { // Default Reset. Parent::onControllerReset( pTime, pForward ); // Fetch the Light Object. VTorque::LightObjectType *lightObject; if ( getSceneObject( lightObject ) ) { // Stop the Animation. VTorque::pauseAnimation( lightObject ); } }
//----------------------------------------------------------------------------- // // VLightObjectAnimationTrack::onControllerEvent( pEvent ); // // // //----------------------------------------------------------------------------- bool VLightObjectAnimationTrack::onControllerEvent( VController::eControllerEventType pEvent ) { if ( !Parent::onControllerEvent( pEvent ) ) { // Skip. return false; } // Enabled? if ( !isEnabled() ) { // Continue Processing Events. return true; } // Fetch the Light Object. VTorque::LightObjectType *lightObject; if ( !getSceneObject( lightObject ) ) { // Skip. return true; } switch ( pEvent ) { case VController::k_EventPlay : { // Play Animation? VLightObjectAnimationEvent *event; if ( getCurrentEvent( event ) ) { // Play. VTorque::playAnimation( lightObject ); } } break; case VController::k_EventPause : case VController::k_EventStop : { // Stop the Animation. VTorque::pauseAnimation( lightObject ); } break; } return true; }
//----------------------------------------------------------------------------- // // VParticleEffectToggleTrack::onControllerReset( pTime, pForward ); // // Enable or Disable the particle effect after a reset. // //----------------------------------------------------------------------------- void VParticleEffectToggleTrack::onControllerReset( const S32 &pTime, const bool &pForward ) { // Default Reset. Parent::onControllerReset( pTime, pForward ); VParticleEffectToggleEvent *event; VTorque::ParticleEffectType *particleEffect; if ( getSceneObject( particleEffect ) && getPreviousEvent( event ) ) { // Turn On? const bool turnOn = ( event->mEventType == VSharedEnum::k_ActionTurnOn ); // Toggle the Particle Effect. VTorque::setParticleEffectOn( particleEffect, turnOn ); } }
//----------------------------------------------------------------------------- // // VMotionEvent::onTrigger( pDelta, pDelta ); // // The path object is told to move to the next node. If this event corresponds // to Node 0, the object will move to Node 1. If the object reaches the node // before the next event is triggered, then the object will stop moving. // // The object's position is only reset when the track is reset and not when an // event is triggered. // //----------------------------------------------------------------------------- void VMotionEvent::onTrigger( const S32 &pTime, const S32 &pDelta ) { Parent::onTrigger( pTime, pDelta ); // Fetch Parent Track. VMotionTrack *track; if ( !getTrack( track ) ) { // Invalid Track. return; } // Fetch Path & Reference Object. VTorque::PathObjectType *path = track->getPath(); VTorque::SceneObjectType *object = getSceneObject(); if ( !path || !object ) { // Invalid. return; } // Valid Destination Node? if ( !isControllerLooping() && !getNextEvent() ) { // Clear Active. VTorque::setPathObjectActive( path, object, false ); // Quit. return; } // Set Active. VTorque::setPathObjectActive( path, object, true ); // Apply Speed. VTorque::setPathObjectSpeed( path, object, getObjectSpeed() ); }
//----------------------------------------------------------------------------- // // VMotionTrack::getObjectSpeed(); // // Determine the Speed that an object must move at to travel over the segment // length of the Path. // //----------------------------------------------------------------------------- F32 VMotionEvent::getObjectSpeed( void ) { // Fetch Parent Track. VMotionTrack *track; if ( !getTrack( track ) ) { // Invalid Track. return 0.f; } // Fetch Path & Reference Object. VTorque::PathObjectType *path = track->getPath(); VTorque::SceneObjectType *object = getSceneObject(); if ( !path || !object ) { // Invalid Object(s). return 0.f; } // Fetch Node Index. const S32 &srcNodeIndex = getNodeIndex( ( isControllerPlayingForward() ) ? 0 : -1 ); // Fetch the Next Event. VEvent *nextEvent = getNextEvent(); // Valid Destination Node? if ( !isControllerLooping() && !nextEvent ) { // No Next Node. return 0.f; } // Valid Next Node? if ( nextEvent ) { // Fetch Segment Length & Duration. const F32 &length = VTorque::getPathNodeLength( path, srcNodeIndex ); const F32 &duration = mAbs( getTriggerTime() - nextEvent->getTriggerTime() ); // Speed = Distance / Duration. return ( length / ( duration / 1000.f ) ); } // Playing Forwards? if ( isControllerPlayingForward() ) { // Fetch the First Event. VEvent *firstEvent = dynamic_cast<VEvent*>( track->getChild() ); // Fetch Segment Length & Duration. const F32 &length = VTorque::getPathNodeLength( path, srcNodeIndex ); const F32 &duration = ( getControllerDuration() - getTriggerTime() ) + firstEvent->getTriggerTime(); // Speed = Distance / Duration. return ( length / ( duration / 1000.f ) ); } // Fetch the Last Event. VEvent *lastEvent = dynamic_cast<VEvent*>( track->getLastChild() ); // Fetch Segment Length & Duration. const F32 &length = VTorque::getPathNodeLength( path, srcNodeIndex ); const F32 &duration = ( getControllerDuration() - lastEvent->getTriggerTime() ) + getTriggerTime(); // Speed = Distance / Duration. return ( length / ( duration / 1000.f ) ); }