Some script updates, fixed windows build script (not tested)

git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@65 ea6a568a-9f4f-0410-981a-c910a81bb256
pull/7/head
nkorslund 16 years ago
parent 54f598d2e7
commit 7de25b0dee

@ -8,4 +8,4 @@ g++ -c ogre\cpp_ogre.cpp -I.\includes\ogre\
g++ -c bullet\cpp_bullet.cpp -I.\includes\bullet\
echo Compiling main program (openmw.exe)
gdc -Wall -g openmw.d bsa\*.d core\*.d esm\*.d input\*.d nif\*.d ogre\*.d scene\*.d sound\*.d util\*.d bullet\*.d cpp_ogre.o cpp_avcodec.o cpp_bullet.o libbulletdynamics.a libbulletcollision.a libbulletmath.a monster\util\*.d avcodec-51.dll avformat-52.dll avdevice-52.dll avutil-49.dll openal32.dll ogremain_d.dll OIS_d.dll -lstdc++ -o openmw.exe
gdc -Wall -g openmw.d bsa\*.d core\*.d esm\*.d input\*.d nif\*.d ogre\*.d scene\*.d sound\*.d util\*.d bullet\*.d cpp_ogre.o cpp_avcodec.o cpp_bullet.o libbulletdynamics.a libbulletcollision.a libbulletmath.a mscripts\object.d monster\compiler\*.d monster\vm\*.d monster\util\*.d avcodec-51.dll avformat-52.dll avdevice-52.dll avutil-49.dll openal32.dll ogremain_d.dll OIS_d.dll -lstdc++ -o openmw.exe

@ -404,10 +404,38 @@ extern "C" void bullet_insertStatic(btConcaveShape *shape,
// FIXME: Scaling does NOT work.
// Are we scaled?
if(scale != 1.0) {}
// Wrap the shape in a class that scales it. TODO: Try this on
// ALL shapes, just to test the slowdown.
//shape = new ScaleShape(shape, scale);
if(scale != 1.0)
{
cout << "Scaling shape " << shape << " by " << scale << endl;
// Not quite sure how to handle local scaling yet. Our initial
// attempt was to create a wrapper that showed a scale mesh to
// the "outside world" while referencing the original, but I
// suspect it ended up altering the original data. At least it
// doesn't work the way it is now, and only crashes.
// The alternative is to create a new copy of the shape for each
// scaled version we insert. This is wasteful, but might be
// acceptable.
// It's also possible we can achieve this effect by changing
// larger parts of the Bullet library - but I hope I don't have
// to create my own dispatcher and such. Finally, even if the
// transformations given to objects are supposed to be uniform
// in length, maybe we can cheat the system and scale the
// transformation instead. Try it just for kicks, and go through
// the system to see what parts of Bullet it would break.
// In any case, when we find a solution we should apply it to
// all shapes (not just scale!=1.0) to get a better impression
// of any performance and memory overhead.
// Also, as an optimization, it looks like multiple instances of
// the same shape are often inserted with the same scale
// factor. We could easily cache this. The scale-recreation of
// meshes (in necessary) could be done as a separate function,
// and the caching could be done in D code.
}
btTransform trafo;
trafo.setIdentity();

@ -32,8 +32,8 @@ class Jukebox : Object;
float fadeLevel = 0.0;
// How much to fade in and out each second
float fadeInRate = 0.10;
float fadeOutRate = 0.25;
float fadeInRate = 0.14;
float fadeOutRate = 0.30;
// Time between each fade step
float fadeInterval = 0.2;
@ -50,12 +50,7 @@ int index;
float musVolume;
bool isPlaying; // Is a song currently playing?
// TODO: Make "isPaused" instead, makes more sense
bool hasSong; // Is a song currently selected (playing or paused)
// TODO: Move to Object for now
native int randInt(int a, int b);
bool isPaused; // Is the song currently paused?
// Native functions to control music
native setSound(char[] filename);
@ -66,12 +61,18 @@ idle waitUntilFinished();
// Fade out and then stop the music. TODO: Rename these to resume()
// etc and use super.resume, when this is possible.
pause() { state = fadeOut; }
pause()
{
isPaused = true;
state = fadeOut;
}
resume()
{
if(!hasSong) next();
else playSound();
if(isPaused) playSound();
else next();
isPaused = false;
state = fadeIn;
}
@ -81,7 +82,6 @@ stop()
{
stopSound();
hasSong = false;
isPlaying = false;
fadeLevel = 0.0;
state = null;
@ -96,7 +96,9 @@ play()
playSound();
isPlaying = true;
hasSong = true;
isPaused = false;
state = playing;
}
// Play the next song in the playlist
@ -159,7 +161,6 @@ randomize()
state fadeIn
{
begin:
setVolume(musVolume*fadeLevel);
sleep(fadeInterval);
@ -179,7 +180,6 @@ state fadeIn
state fadeOut
{
begin:
sleep(fadeInterval);
fadeLevel -= fadeInterval*fadeOutRate;
@ -187,7 +187,6 @@ state fadeOut
if(fadeLevel <= 0.0)
{
fadeLevel = 0.0;
stopSound();
isPlaying = false;
@ -201,12 +200,16 @@ state fadeOut
state playing
{
begin:
// Wait for the song to play. Will return imediately if the song has
// already stopped or if no song is playing
waitUntilFinished();
setVolume(musVolume);
fadeLevel = 1.0;
// Start playing the next song
next();
while(true)
{
// Wait for the song to play. Will return imediately if the song has
// already stopped or if no song is playing
waitUntilFinished();
goto begin;
// Start playing the next song
next();
}
}

@ -26,6 +26,7 @@ module mscripts.object;
import monster.monster;
import std.stdio;
import std.date;
import core.resource : rnd;
// Set up the base Monster classes we need in OpenMW
void initMonsterScripts()
@ -38,6 +39,9 @@ void initMonsterScripts()
// Bind various functions
mc.bind("print", { print(); });
mc.bind("randInt",
{ stack.pushInt(rnd.randInt
(stack.popInt,stack.popInt));});
mc.bind("sleep", new IdleSleep);
// Load and run the test script

@ -29,3 +29,6 @@ idle sleep(float seconds);
// Print a message to screen
native print(char[][] msg...);
// Get a random number between a and b (inclusive)
native int randInt(int a, int b);

@ -10,7 +10,7 @@ state printMessage
{
// This state code will run as long as the object is in this state.
begin:
sleep(10);
sleep(15);
print("Howdy from the world of Monster scripts!");
print("This script is located in mscripts/test.mn. Check it out!");
goto begin;

@ -90,9 +90,6 @@ struct MusicManager
{
assert(mc is null);
mc = new MonsterClass("Jukebox", "jukebox.mn");
mc.bind("randInt",
{ stack.pushInt(rnd.randInt
(stack.popInt,stack.popInt));});
mc.bind("waitUntilFinished",
new Idle_waitUntilFinished);

Loading…
Cancel
Save