SPE update prearrangement: from 1.7 to 1.8 - an introduction

All sub-forums of the SoftPixel Engine, HLC Games' 3d engine.
2D- and 3D-graphics, project-feedback etc.

SPE update prearrangement: from 1.7 to 1.8 - an introduction

Postby LukasBanana » Mon Sep 28, 2009 2:02 pm

In this thread I want to give you an introduction to prepare you for the update of the SoftPixel Engine from 1.7 to 1.8 which is going to be released in the next month (perhaps three or four weeks).

I think this prearrangement is not insignificant because in the new version a lot has been changed, added, removed or integrated into an other part.
So I will list the important changes and describe it:

General news:

- Code::Blocks project support:
With immediate effect the SDK will include a Code::Blocks project file "SoftPixelEngine.cbp" additionally to the DevC++ project file "SoftPixelEngine.dev".

- GNU/Linux support:
The engine supports GNU/Linux and needs running an X server which shouldn't be a proble, because the most Linux platforms are using the X Window System.
Currently there are some incomplete parts but it is usable as well as the Shader effects using GLSL for high-performance graphics on Linux.
Fore the status of development take a look at Development progress.

- Two new dimension classes:
the template "dim::aabbox3d" is the AxisAlingedBoundingBox and the "dim::obbox3d" is the OriantatedBoundingBox.
In some math functions the "dim::line3d" class was used and replaced by these classes.

- Three new classes for tree hierarchy has been added:
"scene::TreeNodeQuad", "scene::TreeNodeOct" and "scene::TreeNodeBSP" (BSP trees under progress).

- New standard primitive again:
Torusknot (scene::ENTITY_TORUSKNOT)

to be continued ...

Movie management:

There is no longer the "movie" namespace and its MovieManager. The MovieManager has been integrated into the VideoDriver because there are only the functions "loadMovie" and "deleteMovie".
The functions of the Movie objects has been added to the "video::Movie" class. Thus the functions names has been changed.
For the next release the API doxygen documentation will be updated too at SPE API docu.
As well in other classes like these for mesh animating and the new redesigned sound system the functions names and its simplicity became more easier.
In the old version you had the function "video::movie::MovieManager::playMovie(Movie* hMovie, bool isLoop = true)".
Now you have the Function "video::Movie::play(bool Looped = true)"; "video::Movie::pause(bool Paused = true)"; "video::Movie::stop()".

Here is a short example of the new version for managing movies:

Code: Select all
video::Movie* MyMovieObject = spDriver->loadMovie("MyMovieFile.avi");

if (!MyMovieObject->valid())
    io::printError("The movie could not be loaded");

MyMovieObject->play();
MyMovieObject->setSeek(0.5); // To the middle of the movie
MyMovieObject->setSpeed(1.5); // Play with 1.5 times the speed, negative values are also possible but much slower!

MyMovieObject->renderTexture(MyTextureObject);

MyMovieObject->reload("MyMovieField2.avi"); // You can also reload an other movie file using the same movie object handle

Furthermore some bugs of loading AVI files has been fixed. Now it should be possible to load each AVI file you can load with the Windows Media Player (an additional factor is, if you have DivX installed to play special AVI movies).

to be continued ...

SensitiveSoundSystem v.3.0:

The sound system - so called "SensitiveSoundSystem" version 3.0 - has been completly redesigned.
The main reason why I did so was, that I could not use the WinMM (WindowsMultiMedia sound API) of Windows
under Linux. So I had to make it like with VideoDriber, using different devices including a "Dummy" (in other engines called "Null device") for the first time on Linux.

The whole time you had to use the "sound::createListener(f32, f32, f32, f32)" function.
Now you have to use "sound::createSoundDevice(ESoundDevices SoundDeviceType = SOUNDDEVICE_AUTODETECT)"

Here is a list of all the current supported sound devices:

  • SOUNDDEVICE_AUTODETECT // Determines which device is the best and can be used for the current platform
  • SOUNDDEVICE_WINMM // Only for Windows
  • SOUNDDEVICE_DUMMY // Dummy/ Null device (for the first time, testing and using the engine on Linux)

    The following devices are planed for the furture and maybe for the 'second next' version (1.9 or so):
  • SOUNDDEVICE_OPENAL // OpenAL audio API for Windows and Linux
  • SOUNDDEVICE_DIRECTSOUND8 // DirectSound8 from DirectX only for Windows
  • SOUNDDEVICE_XAUDIO2 // XAudio2 from the XBox360 and comming to Windows (XBox and XBox360 are not supported for the SPE)

OpenAL is the most wanted sound API for the furture!

By the way: the "Record" class has been integrated into the "Sound" class.

Here is a short example of using the new sound system:

Code: Select all
sound::SensitiveSoundDevice* spListener = sound::createSoundDevice();

sound::Sound* MySoundObject = spListener->loadSound("MySoundFile.wav");

if (!MySoundObject->valid())
    io::printError("The sound could not be loaded");

MySoundObject->play(); // Remember to the "Movie" class with its simple functions: "play", "pause", "stop"
MySoundObject->setVolume(0.5); // 50% volume
MySoundObject->setSeek(0.1);
MySoundObject->setSpeed(1.5); // 1.5 times the speed, 1.0 is default (in the old version 0.0 was normal, -1.0 was slow, 1.0 was fast)

while (!MySoundObject->playing()) // Check if the sound is currently playing
    if (MySoundObject->finish()) // Stupid request within the above code, but just an example :)
        io::printMessage("The sound has been finished");


As well the "updateSounds" and "updateSound3D" functions has been removed because the sounds will be updated automatically.

to be continued ...

SoftNetworkSystem v.2.0:

The new network system and the first one which is really usable uses just one thread - but only if used.
It is using UDP internet protocoll. To use it for internet games has never be tested but quite possible.
Besides it is designed for network games.
You have the class "network::NetworkSystem" and "network::NetworkClient". For the engien there is one server and an amount of clients.
But internal it sending, receiving and connecting direct to each of the network members.
That is to say that sending and receiving messages is very fast :) .

Here is a short example:

Code: Select all
network::NetworkSystem* spNetwork = new network::NetworkSystem(); // (going to be changed in "spDevice->getNetworkSystem()")

if (I_Am_The_Server)
{
    if (!spNetwork->openServer(Port)) // Default port number is 10000
        io::printError("The server could not be opened");
}
else
{
    // Useful function is "std::vector<io::stringc> spNetwork->getIPAddressesByName("HostName")" to each IP address of the host by its name
    if (!spNetwork->joinServer("192.168.0.1", Port)) // The IP address of the host
        io::printError("The server could not be opened");
}

spNetwork->sendPacket("MyMessage", 0); // instead of 0 you can use an "network::NetworkClient" pointer for a special Acceptor, otherwise (0) the message will be send to all in the network (which joined the SPE server)

network::SNetworkPacket MyPacket;

if (spNetwork->pickPacket(MyPacket))
    io::printMessage(io::stringc("I've got a network message: ") + MyPacket.Message); // Received a message from "MyPacket.Sender"

spNetwork->disconnect(); // Disconnect from the server or the server self

to be continued ...

FileSystem:

The functions for reading/ writing in/ out files has been transfered from the "io::FileSystem" class (earlier "io::FileLoader") for the "io::File" class.
There are currently only three types to open a file: "FILE_READWRITE", "FILE_READ", "FILE_WRITE".
Planed is to split the "io::File" class into two additional child classes "FileHDD" (HadDiskDrive operations) and "FileRAM" (virtual files, e.g. as temporary storage).
The function "io::FileLoader::doesFileExist" has been changed to "io::FileSystem::findFile".

Here is a short example:

Code: Select all
io::FileSystem* spFileSys = spDevice->getFileSystem(); // alternativly "new io::FileSystem();"
io::File* MyFileObject = spFileSys->openFile("MyFile.dat");

if (!MyFileObject) // In this case no object will be created when the file could not be opened (e.g. because of missing file)!
    io::printError("The file could not be opened");

MyFileObject->writeString("MyTextField"); // Writes just a string
MyFileObject->writeStringN("MyTextField"); // Writes a string and a new line character (on Windows: char(13) & char(10), on Linux: char(10))
MyFileObject->writeStringC("MyTextField"); // Writes an ANSI C string, terminated by 0
MyFileObject->writeStringData("MyTextField"); // Writes an interger value with the string length and the string self

MyFileObject->writeValue<s32>(math::Random(100)); // Writes a random integer: "s32", 32 bit value

while (!MyFileObject->isEOF()) // Check "EndOfFile"
    io::printMessage(MyFileObject->readString()); // Reads a string until the line ends (description see "writeStringN")

MyFileObject->readValue<s32>(); // Reads an interger value

FILE* AnsiCFileHandle = MyFileObject->getHandle(); // Old name "getID", return the ANSI C "FILE" pointer/ handle to proceed own ANSI C file operations.
s32 FileSizeInBytes = MyFileObject->getSize(); // Old name "getLength"

spFileSys->closeFile(MyFileObject);

to be continued ...

Mesh/ Entities/ Models/ Scene Nodes:

There is only one function to create standard primitives, now using a structure for all the model architecture data:
"createModel(EEntityModels Type, SModelConstruct BuildConstruct = SModelConstruct());"
How this case shows - using EEntityModels - the engine is more expecting enumerations instead of simple integers to clarify which values are allowed.

Here are multiple ways to create a standard primitive:

Code: Select all
scene::Entity* MyMeshObjectA = spSmngr->createModel(scene::ENTITY_TEAPOT);
scene::Entity* MyMeshObjectB = spSmngr->createModel(scene::ENTITY_TORUS, 15); // 15 is the count of segments, allowed because first parameter of "SModelConstruct" structure is the segmentation, all parameters have default values.

scene::SModelConstruct MyConstruct;
MyConstruct.Segments = 10; // Segmentation
MyConstruct.DegreeLength = 360.0f * 2; // two rotations for the spiral
MyConstruct.Size = 1.0f; // Distance between the ring of the spiral in one rotation
scene::Entity* MyMeshObjectA = spSmngr->createModel(scene::ENTITY_SPIRAL, MyConstruct);

The cube (ENTITY_CUBE) can get a segmentation too, e.g. so you can create an Rubik's Cube :D .

An other thing is a change in function names again. These are the following functions:

  • Node::doTranslate -> Node::translate
  • Node::doTransform -> Node::transform
  • Node::doTurn -> Node::turn
  • Node::doMove -> Node::move
  • Entity::doTextureTranslate -> Entity::textureTranslate
  • Entity::doTextureTransform -> Entity::textureTransform
  • Entity::doTextureTurn -> Entity::textureTurn
  • Entity::doMeshTranslate-> Entity::meshTranslate
  • Entity::doMeshTransform -> Entity::meshTranslate
  • Entity::doMeshTurn-> Entity::meshTurn

The matrix transformations are now like in Blitz3D. One thing which looks different is when using "Node::turn", the scene node will turn not wobble like before.
The function "setAutoMatrix" has been deleded because now you can set the position, rotation and scale by a matrix. So you have already more control of the object transformation. By the way: the matrices have with immediate effect loaded the identity - you do not need call "matrixReset" to load the identity at the beginning.
The new functions are: "setPositionMatrix", "setRotationMatrix", "setScaleMatrix" and each of these with "get...". The old functions "setPosition" using a vector do exist furthermore.

The enumeration "ERenderFaceTypes" has been replaced be the enumeration "EFaceTypes". Because both enumerations exist the first one is redundant. Now using "Entity->setRenderFace(video::FACE_FRONT);" and no longer "video::RENDER_FRONT" (with the two other attributes "FACE_BACK" and "FACE_BOTH" it's the same).

to be continued ...

Animation management:

The Animation system is also a party which that has changed greatly.
There is no longer the "anim" namespace. The Animation class has been splitted into each Animation method class:

  • AnimationNode // Node animations
  • AnimationMorphTarget // MorphTarget/ keyframe animations
  • AnimationSkeletal // Skeletal animations
  • (AnimationFacial) // Facial animations (planed but not supported yet, one reason to partition the class)

This class has in part equal functions like the "Sound" and "Movie" class. You can possibly imagine already ;)
"play" (afore: "doAnimate"), "pause", "stop", "setSpeed", "setSeek".

All in all is this combination of animation system much more conceptional and clearly arranged :ugeek:

to be continued ...

Mesh Buffer Objects:

There is a new structure called "scene::SMeshSurface" which represents and holds the hardware accelerated MeshBufferObjects.
With the four functions "createMeshBuffer", "deleteMeshBuffer", "updateMeshBuffer" and "renderMeshBuffer" you can handle the meshes for your own Entity/ Model/ Mesh class.

to be continued ...

UserControl:

Almost all functions has changed the name because of more simplicity: "UserControl::isKeyPressed" has changed to "UserControl::keyDown", these names are similiar to the input-control of the Blitz3D programming language.

Here is an overview of the new UserControl functions:

Code: Select all
// Each of these functions must called with an UserControl pointer object: e.g. "spControl->..."

// Keyboard
bool& keyDown(const EKeyCodes KeyCode);     // Key pressed
bool& keyHit(const EKeyCodes KeyCode);      // Key hit
bool& keyReleased(const EKeyCodes KeyCode); // Key released

void keyDownSimulation(const EKeyCodes KeyCode) const;
void keyReleasedSimulation(const EKeyCodes KeyCode) const;

bool keyDownEx(const EKeyCodes KeyCode) const;  // Extendet key pressed method (e.g. for LShift/ RShift)

// Mouse control
bool& mouseDown(const EMouseKeyCodes KeyCode);      // Mouse button pressed
bool& mouseHit(const EMouseKeyCodes KeyCode);       // Mouse button hit
bool& mouseReleased(const EMouseKeyCodes KeyCode);  // Mouse button released

void mouseDownSimulation(const EMouseKeyCodes KeyCode) const;
void mouseReleasedSimulation(const EMouseKeyCodes KeyCode) const;

s16 getMouseWheel() const;
void setMouseWheel(s16 Value); // Simulates a mouse wheel movement

void setCursorVisible(bool Visible);

// Joystick
bool joystickDown(const EJoystickKeyCodes KeyCode) const; // Joystick button pressed
dim::vector3df getJoystickPosition() const;


to be continued ...
User avatar
LukasBanana
Site Admin
 
Posts: 35
Joined: Thu Aug 27, 2009 5:33 pm
Location: Germany

Return to SoftPixel Engine

Who is online

Users browsing this forum: No registered users and 1 guest

cron