Introduction :
Today I Brought to you an Idea that may Help you Slowing down your Entire Game Scene, You might be seen such a Tutorial in The Topic area Like : Dramatic Slowmotion Which made by 'RobertooMolvadoo' , my thanks and Greetings to those whom Presented such an Idea;
but my Project we'll talk about is something Like the Same Idea but sort of advanced to support Every Possible Object in any Normal Scene to be Slowed Gradually According to Your Game Simulation
Description :
The Project Includes a Prototypes Objects to Show how to do this more Clearly with yours;
The Scene we're Talking about Contains :
- Rotated Sun with Shadows
- Rotated Sky Represents the background
- 2 Characters (yours, and CPU) SkinMehsed Supports Jumping, Running, and Other Animations
- Sound Sources , and Sound Effects
- Static ,and Dynamic RigidBodies in Order to Move Characters
Of course any Scene won't Leave the Prototypes above, and if you've Realized you would found that most of Objects in the Scene are Containing a move-able Actions;
Now Slowing Control is not according to time , but According to Press\Holding the Left Mouse Button, You can make it anything you wish by Editing the Main Script in the Project , You Can make it Slowing Down according to a Specified Time (Between : from-to) , You Can make it Even Pause by Simply Make the Simulation Value = 0.0f, and All the Scene Will Automatically be Paused (Typically) as if the Simulation Controls the Entire Scene, so in this Project I want you to Consider Simulation as the boss of the Scene
BASIC Slow Motion Script : (for Scene Including RigidBodies, SkinMehses\Characters, Sounds)
Code: [Select]
///----------------------------BASIC SLOW-MOTION SCRIPT----------------------------------\\\
float SlowMotionSpeed = 0.02; //Control SlowMotion's Speed
float NormalSimulation = 0.016666f;
float NormalFrequency = 44100;
float SimulationSpeed = SlowMotionSpeed;
float Simulation,AnimationSpeed,SoundFrequency;
void Main()
{
///Replace the OBJs and OUTs with yours as Follows to avoid errors
Character = OBJ_198;
///Defining functions to variables
// Returning the Variable Frequency Simulation to a float Variable "Simulation"
iSimulationFrqSet(Simulation);
// Gathering Animations Speeds (in order of Appearance in your scene) into a one Varaible
OUT_<<AnimationSpeed>> = OUT_<<AnimationSpeed>> = AnimationSpeed;
// Gathering Sounds' Frequencies (in order of Appearance in your scene) into a one Varaible
OUT_<<SoundFrequency>> = OUT_<<SoundFrequency>> = OUT_<<SoundFrequency>> = OUT_<<SoundFrequency>> = SoundFrequency;
// Display Simulation (erase that Group if you wish)
OUT_DisplayedValue = Simulation*60; //display Simulation with int values
OUT_DisplayedValue = Simulation; //exactly display of Simulation
///Intializing Section :
if (iInitializing())
{
Simulation = NormalSimulation;
SoundFrequency = NormalFrequency;
}
///A Small Engine for slowing-down the scene Gradually (Optional)
// if LMB pressed and held, the Scene will slow down (Gradually);
if (iMouseButtonDown(0))
{
//Gradually decreasing
Simulation = iFloatTendTo(Simulation,NormalSimulation,0,SimulationSpeed,0);
SoundFrequency = iFloatTendTo(SoundFrequency,NormalFrequency,0,SimulationSpeed,0);
}
// if LMB released, the Scene will return to its default speed (Gradually)..
//..Represents in the Variables "NormalSimulation" for Physics and "NormalFrequency" for sounds;
else
{
//Gradually increasing
Simulation = iFloatTendTo(Simulation,0,NormalSimulation,SimulationSpeed,0);
SoundFrequency = iFloatTendTo(SoundFrequency,0,NormalFrequency,SimulationSpeed,0);
}
}
Notice :
- Replace Variables in the Script with yours;
- <<AnimationSpeed>> Represents every Animation Speed Output for your SkinMeshes;
- <<SoundFrequencies>> Represents every Sound Frequency Output for your Sounds;
ADVANCED Slow Motion Script : (for Scene Including RigidBodies, SkinMehses\Characters, Sounds, Rotated Sun and Background)
Code: [Select]
///----------------------------ADVANCED SLOW-MOTION SCRIPT----------------------------------\\\
float SlowMotionSpeed = 0.02; //Control SlowMotion's Speed
float NormalSimulation = 0.016666f;
float NormalFrequency = 44100;
float MaxRotateSpeed = SlowMotionSpeed; //here where you can Return the Max Sun Rotation Speed
float SimulationSpeed = SlowMotionSpeed;
float Simulation,AnimationSpeed,SoundFrequency;
float sx,sy,sz,bx,by,bz,cx,cy,cz;
float SunRotate,BackgroundRotate;
int Sun,Background,Character;
Quaternion SunOrientation,BackgrounOrientation;
void Main()
{
///Replace the OBJs and OUTs with yours as Follows to avoid errors
Sun = OBJ_110;
Background = OBJ_176;
Character = OBJ_198;
///Defining functions to variables
// Returning the Variable Frequency Simulation to a float Variable "Simulation"
iSimulationFrqSet(Simulation);
// Gathering Animations Speeds (in order of Appearance in your scene) into a one Varaible
OUT_1 = OUT_23 = AnimationSpeed;
// Gathering Sounds' Frequencies (in order of Appearance in your scene) into a one Varaible
OUT_44 = OUT_66 = OUT_88 = OUT_352 = SoundFrequency;
// Set the Speciefied Orientation Object to a Rotate Angles
iObjectOrientationSet(Sun,SunOrientation);
iObjectOrientationSet(Background,BackgrounOrientation);
iQuaternionFromEulerAngles(SunOrientation,sx,sy,sz,"xyz");
iQuaternionFromEulerAngles(BackgrounOrientation,bx,by,bz,"xyz");
// Continues Rotate
sx += SunRotate;
by += BackgroundRotate;
// Display Simulation
OUT_220 = Simulation*60; //display Simulation with int values
OUT_264 = Simulation; //exactly display of Simulation
///Converting Variables According to Simulation
//Animations' Speed according to Simulation
AnimationSpeed = iFloatInterpolate(Simulation,0,NormalSimulation,0.0,250,true);
//Sounds' frequency according to Simulation
SoundFrequency = iFloatInterpolate(Simulation,0,NormalSimulation,0,NormalFrequency,true);
//Specified Orientation According to Simulation
BackgroundRotate = iFloatInterpolate(Simulation,0,NormalSimulation,0.0,MaxRotateSpeed,true);
SunRotate = iFloatInterpolate(Simulation,0,NormalSimulation,0.0,MaxRotateSpeed,true);
///Intializing Section :
if (iInitializing())
{
Simulation = NormalSimulation;
SoundFrequency = NormalFrequency;
//this is just an Exceptional Case for My Meshes' Orientations' Coordinates:
sx = bx = -90;
}
//Reset Sun at every 100ْ Rotation
if (sx >= 100)
{
sx = -90;
}
///A Small Engine for slowing-down the scene Gradually (Optional)
// if LMB pressed and held, the Scene will slow down (Gradually);
if (iMouseButtonDown(0))
{
//Gradually decreasing
Simulation = iFloatTendTo(Simulation,NormalSimulation,0,SimulationSpeed,0);
SoundFrequency = iFloatTendTo(SoundFrequency,NormalFrequency,0,SimulationSpeed,0);
}
// if LMB released, the Scene will return to its default speed (Gradually)..
//..Represents in the Variables "NormalSimulation" for Physics and "NormalFrequency" for sounds;
else
{
//Gradually increasing
Simulation = iFloatTendTo(Simulation,0,NormalSimulation,SimulationSpeed,0);
SoundFrequency = iFloatTendTo(SoundFrequency,0,NormalFrequency,SimulationSpeed,0);
}
}
Notice :
To See how to Create a Spin-Able Sun and Background Check this Topic out :
http://www.3drad.com/forum/index.php?topic=7409.msg58765#msg58765
I Won't Bother You with Details , Download , and See your Self .. (if you wish Edit it to fit your Project, but Becareful not to Corrupt it)
non-compiled Version : v7.22 only soon there will be for v7.12
http://www.mediafire.com/?jynxcjadwrl3e3j
Compiled Version :
in the Attachments below;