Author Topic: Modern system native Stunts proto-engine  (Read 1758 times)

Cas

  • Joe's Friend
  • **
  • Posts: 426
  • Think different. That's OK... as long as you think
    • View Profile
    • Dimioca Labs
Modern system native Stunts proto-engine
« on: September 22, 2018, 11:27:32 PM »
Guys, I made this very, very simple proto-engine last year and left the project because of a difficulty I know I cold overcome with some hard work. Now I was thinking it's there so I can share it with you and maybe eventually give it another push. What I'm posting is the GNU/Linux 64bit compiled version. I didn't compile it for Windows because I would first have to install a 32bit Linux and then Wine on top and the compiler (I don't know why, but Wine doesn't seem to work with 64bit Linux for me), but I can later get that done and post it too.

Use the arrow keys to look around and the + and - keys to change the height of the camera. Also, < and > can be used to bank the view. The engine uses pure high-level routines, so it could be highly optimised. All calculations are made with floating point numbers so, again, this could fly if intended. You'll notice a problem when drawing very close to the camera. This is my main problem.

My intention?  To build a graphic engine that could draw any visual from Stunts at game speed with the same technology (flat triangles), but at any screen resolution. What for?  Could be used to generate high-res images of what a part of a track or replay could look like. Could also be the base for a re-creation of a full Stunts engine. If so, I'd like it to be faithful to the original, only allowing plugins easily. We don't want another Stunts-like game. We want Stunts. In any case, we want a Stunts we can more easily mod. For now, it's just a curiousity. Done the old-school way, but with modern OS and compiler support. Take a look and give any impressions or ideas. Thanks!
Earth is my country. Science is my religion.

Duplode

  • Moderator
  • Breaths Stunts
  • *****
  • Posts: 3645
  • Fear is your only god on the radio
    • View Profile
    • The Southern Cross Stunts Trophy
Re: Modern system native Stunts proto-engine
« Reply #1 on: September 23, 2018, 03:31:09 AM »
Nice work!

I didn't compile it for Windows because I would first have to install a 32bit Linux and then Wine on top and the compiler (I don't know why, but Wine doesn't seem to work with 64bit Linux for me), but I can later get that done and post it too.

You can have a 32-bit Wine prefix on a 64-bit Linux -- cf. the relevant Arch Wiki page. Below is some stuff that used to be in my .bashrc to help using multiple prefixes, which might be of some use.

Code: [Select]
# Making wine default to 32-bit.
export WINEARCH=win32

# Keeping the default wine prefix in a non-hidden directory.
export WINEPREFIX="/home/duplode/wine32"

# Simplifying the handling of Wine prefixes.
# (Adapted from http://code.google.com/p/winetricks/wiki/CommandlineTips )
# Of course we will keep some symlinks of our own at
# ~/.local/share/wineprefixes .

prefix-wine() {
    if [ -z "$1" ]; then
        echo "${WINEPREFIX}"
    else
        echo "${HOME}/.local/share/wineprefixes/$1"
    fi
}

lswine() {
    ls $* "${HOME}/.local/share/wineprefixes"
}

with-wine() {
    lswine | grep "$1" > /dev/null
    if [ "$?" -ne 0 ] || [ -z "$1" ]; then
        echo "Please select an actual wine prefix (try lswine)."
    else
        prefix=$(prefix-wine $1)
        shift 1
        echo $prefix
        env WINEPREFIX="$prefix" "$@"
    fi
}

goc() {
    lswine | grep "$1" > /dev/null
    if [ "$?" -ne 0 ]; then
        echo "Please select an actual wine prefix (try lswine)."
    elif [ -z "$1" ]; then
        cd "${WINEPREFIX}/drive_c"
    else
        cd "$(prefix-wine $1)/drive_c"
    fi
}

_lswine () {
    local cur

    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}

    if [[ $COMP_CWORD -eq 1 ]] ; then
        COMPREPLY=( $( compgen -W "$(lswine)" -- $cur ) )
        return 0
    fi
}

_with-wine () {
    local cur

    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}

    if [[ $COMP_CWORD -eq 1 ]] ; then
        COMPREPLY=( $( compgen -W "$(lswine)" -- $cur ) )
        return 0
    elif [[ $COMP_CWORD -eq 2 ]] ; then
        COMPREPLY=( $( compgen -cf -- $cur ) )
        return 0
    fi
}

complete -F _lswine prefix-wine
complete -F _lswine goc
complete -o default -F _with-wine with-wine
« Last Edit: September 23, 2018, 03:32:46 AM by Duplode »

Cas

  • Joe's Friend
  • **
  • Posts: 426
  • Think different. That's OK... as long as you think
    • View Profile
    • Dimioca Labs
Re: Modern system native Stunts proto-engine
« Reply #2 on: September 23, 2018, 03:57:19 AM »
I think my problem is more general than just with Wine. I'm having difficulty (lack of knowledge?) getting to install anything that requires 32bit architecture in my 64bit system. When I try to install Wine (which I usually do by using the software centre in Ubuntu or by sudo apt-get install), the installation fails because of dependency problems related to the architecture. Same thing was happening to me with Skype in the past. Now Skype is 64bit-only. So I don't get to the point of having it installed to be able to configure it in any way :(
Earth is my country. Science is my religion.

Duplode

  • Moderator
  • Breaths Stunts
  • *****
  • Posts: 3645
  • Fear is your only god on the radio
    • View Profile
    • The Southern Cross Stunts Trophy
Re: Modern system native Stunts proto-engine
« Reply #3 on: September 23, 2018, 06:25:34 AM »
I don't know if you have already tried it, but you apparently have to explicitly enable alternative architectures. (On Arch, you'd rather similarly have to enable a "multilib" repository.)

Cas

  • Joe's Friend
  • **
  • Posts: 426
  • Think different. That's OK... as long as you think
    • View Profile
    • Dimioca Labs
Re: Modern system native Stunts proto-engine
« Reply #4 on: September 23, 2018, 07:57:13 AM »
Looks like it's enabled 32bit, but still even the most fundamental 32bit libraries are not there, so nothing that's 32bit is running. For instance, I'm trying to run the 32bit compilation of Bliss and it just won't. I wonder what I should install next. Probably, I should check with the people at FreeBasic on how to compile 32bit on a 64bit system and that would also allow running most 32bit programs.
Earth is my country. Science is my religion.

Cas

  • Joe's Friend
  • **
  • Posts: 426
  • Think different. That's OK... as long as you think
    • View Profile
    • Dimioca Labs
Resurrecting 3D rendering. GNU and Windows executables available!
« Reply #5 on: June 23, 2020, 01:58:56 AM »
Hi!

I was exchanging a few e-mails with Overdrijf and Duplode and my 3D engine was mentioned. I've been taking a look and I found that I initially made it in 2017, but then I modified it in 2019, so I'm going to post it here, together with the 3D object editor, the newer version and with executables both for 64bit GNU/Linux and 32bit Windows/Wine.

Here's what you'll find in the package:
- engine1b is the new engine itself. Source and binaries for both platforms are included. This newer engine is able to open a track file and render the terrain and a small set of track elements. You can freely move and rotate flying on the track. Take a look
- g3dultra is the 3D object editor I used for making the objects you see. It's not super user-friendly, but it does the trick. Objects are not built in a way that's comfortable for the designer, but that makes them optimal for the renderer. More on that below

Here's how you can use engine1b:
- Left and Right arrows to rotate left (counter-clockwise over track's Z) and right (clockwise over track's Z)
- Up and Down arrows to pitch forward and backward like in an airplane
- , and . (that is, < and >) to roll (counter-clockwise and clockwise over viewer's Z axis)
- A, D, W and S to move the camera over the track
- + and - to zoom in and out. This can make things look weird if you forget you're zoomed in or out
- [ and ] to change the FOV. Again, this may make everything look really awful
- { and } to make a render-based zoom instead of a perspective-based one. The most destructive experiment :P

Here's how to use g3dultra:
- Your object is made of verteces, segments and triangles. Segments and triangles are based on the verteces you have in your object. A vertex that's not being used by any segment or triangle is called an "orphan vertex" and shows as a small cyan circle. You start with zero segments, zero triangles and eight verteces forming a box.
- Use the arrow keys to rotate the object. The three axes are always rotated in the same order, so you may experience gimbal lock. Not comfortable, but works and it's the engine that matters in the end.
- Use + and - to get nearer of farther from the object's centre
- These 3D objects are based on layers, like an onion. Higher layers are always drawn last, no matter if they're nearer or father. This allows you to control triangles drawn on top of others and prevents glitches. Use * and / to change the current editing layer. If you go to the previous layer and the layer above is empty, the number of layers in your object will fall back. You'll understand this as you use it
- Use Insert to insert a vertex. You'll have to manually provide the 3 coordinates. Again, not comfortable, but exact
- Use T to create a triangle. Before you press T, you should use the mouse left-button to click on the three verteces in order that you want your triangle to be made of, because T will take the last three selected ones. The triangle will be solid, 2-sided and made of the current colour. The main side, if I remember correctly, will be the one that sees the verteces rotating counter-clockwise
- Use S to create a segment. The same as with T, first click on the two verteces you want to use
- Use C to change the colour of a triangle or segment. You first have to select the triangle or segment. This will also change the current colour
- Use L to change the layer of a triangle or segment. You first have to select it. At the moment of creating them, triangles and segments are placed in the current layer
- Use 1 to make a triangle 1-sided. You have to select it first and if you're looking at it from the secondary side, it will become transparent. 1-sided triangles are very good. They make rendering faster and prevent glitches when it's not clear which triangle is closer to the viewer
- Use 2 to make a triangle 2-sided
- Use ` to change a triangle between solid or partially transparent (like some surfaces in Stunts)
- Use M to create a vertex that's located exactly in between the last two selected verteces
- Use X, Y and Z to split a vertex in the direction of the corresponding axis. Try it and you'll understand it
- Use DEL to delete a triangle, segment or vertex
- Use F1 to start from the beginning, F2 to save, F3 to load, F4 to "un-rotate"
- Use F5 to select a segment. Just hover it and press F5 and it will be highlighted. You can do the same with F6 to select a triangle
- Use F7 to toggle the editor's transparent mode, to see internal triangles and segments more easily
- Use , and . to go the next or previous vertex, segment or triangle
- Use ENTER to type in a command. Commands include FLIP, MOVE and SCALE. Type without parameters to see the syntax
- Use ESC to leave the program
Earth is my country. Science is my religion.

Overdrijf

  • Helen`s Lover
  • **
  • Posts: 651
  • Professional idiot
    • View Profile
Re: Modern system native Stunts proto-engine
« Reply #6 on: June 25, 2020, 10:46:15 AM »
I'ver downloaded it now that it's Windows proof. This looks cool!

I don't have anything else to say about it, but I'll try it out more over the next few weeks.

There is no way to convert 3D models from other sources (like Stunts) into the format of this engine, I assume?

Daniel3D

  • Stunts Fan
  • *
  • Posts: 17
    • View Profile
Re: Modern system native Stunts proto-engine
« Reply #7 on: June 25, 2020, 12:07:01 PM »
I've also downloaded it now that it's Windows proof.  ::)
It looks really nice. It has the right atmosphere.

I have played many stunts clones and remakes. and most go banana's with graphics but forget gameplay.
This is nice and clean. If the end result play's like the good old stunts but with better graphics i'd be happy.
other fun stuff can be added later.  (at least, that's what i think  ;) )

I'll try and figure out the object editor when i have some time..

D
« Last Edit: June 26, 2020, 07:45:11 AM by Daniel3D »

Cas

  • Joe's Friend
  • **
  • Posts: 426
  • Think different. That's OK... as long as you think
    • View Profile
    • Dimioca Labs
Re: Modern system native Stunts proto-engine
« Reply #8 on: June 25, 2020, 11:05:21 PM »
I will have to study Stunts 3D format more to answer exactly, but in my opinion, converting would be pretty hard because the strategies used by Stunts and by my engine to prevent triangle overlap are different. Still, I imagine I could make a program to transform a Stunts object in its basic form to this format and then, with some manual modifications, it could be adapted. The thing is Stunts also combines 3D objects to make the actual track objects, so it's not easy.

And yes, my idea is to make an engine that looks pretty much like Stunts. Plain triangles. But using whatever resolution one has, so stretching would be polygonal and not by pixel, as happens when you use Stunts in DOSBox. Also, I would add deeper rendering (as can already be seen in the engine), so you could see objects pretty far.
Earth is my country. Science is my religion.

Daniel3D

  • Stunts Fan
  • *
  • Posts: 17
    • View Profile
Re: Modern system native Stunts proto-engine
« Reply #9 on: June 26, 2020, 07:55:11 AM »
Expanding the current engine would be very difficult I imagine. Stunts was built for very limited hardware.
I like the idea behind ultimate stunts. But not the result.
It looks fake and drives like excrement.

But some terrain features are nice.

I'm looking forward to a driving test  ;D 

Cas

  • Joe's Friend
  • **
  • Posts: 426
  • Think different. That's OK... as long as you think
    • View Profile
    • Dimioca Labs
Re: Modern system native Stunts proto-engine
« Reply #10 on: June 26, 2020, 11:05:53 PM »
From here to a driving test, it will be long time, ha, ha. To give you an idea, the rendering you're seeing is not nearly optimal. It has to be rewritten and I have only written it this way because it's experimental. Once I get it to do what I want, I'll rewriting, this time knowing what I'm doing. Once I do that, I'll have to deal with things I have ignored for this test, such as transforming objects when they're placed on a slope or possibly allowing different height levels and tracks of other sizes, as well as a background landscape. That will make it even longer for the rendering engine.

But then, the true thing begins, because rendering is only half the work. I have to start from scratch with a physics engine. I still have no idea how I will do that. Only thing I know is what I'm looking for, which is something that feels like Stunts but can be controlled better (for example, that making a car faster doesn't mean that it will produce unpredictable magic carpets or that its gears will behave in crazy ways; that if the car will have powergear, it'll be because the designer wanted it to, not because of a combination of number of gears, grip and weigh of the car resulting in a number that adds up to, say, seven modulo twelve or something like that). Of course, starting from scratch means it's virtually impossible to make Stunts replays compatible with the new project and vice-versa, but as long as they "feel" alike, that's fine for me.
Earth is my country. Science is my religion.

Daniel3D

  • Stunts Fan
  • *
  • Posts: 17
    • View Profile
Re: Modern system native Stunts proto-engine
« Reply #11 on: June 27, 2020, 07:43:49 AM »
Is it possible to work the other way around?.
Built a solid but basic rendering engine with a test track.
Then a (modular) physics engine that rocks.
Then build on the rendering engine.
(Btw, Which language do you use?)

Because if you can't get the physics to work you'll  have an other ultimate stunts..

 :o
« Last Edit: June 27, 2020, 07:53:30 AM by Daniel3D »

Cas

  • Joe's Friend
  • **
  • Posts: 426
  • Think different. That's OK... as long as you think
    • View Profile
    • Dimioca Labs
Re: Modern system native Stunts proto-engine
« Reply #12 on: June 27, 2020, 10:12:29 PM »
Well, I think building a rendering engine is no easy task in general, so probably, the 3D rendering engine I'm making is arguably the simplest I could go for anyway. And once that works, I can start trying with physics and we'll see what happens. I have to try. And I figure I will have lots of problems, but I don't expect to end up with another Ultimate Stunts, because it seems to me that U. Stunts's physics engine on purpose. You know, we love Stunts, but many people would consider Stunts's physics engine to be very buggy and worth replacing with something more "modern". Maybe that's what the developers of Ultimate Stunts feel. I don't feel that, so my path will be different. I'm not saying I will be more successful... likely not, because it's hard work, but it will be in a different direction.

I'm currently using FreeBasic. I could use something else too. If I had to drop FreeBasic, my next bet would be pure C or perhaps, FreePascal. I don't like OOP and compilers that create huge layers of abstraction. I am also not a fan of third-party libraries. I prefer to write everything myself. I'm not doing it for money, so I like choosing how I do it. But while the compiler is relevant for the renderer (in particular, the graphics library is), for the physics engine, it's pretty much the same. On today's computers, any physics engine will fly, no matter the language. The difficulty lies in making it work well, not fast, as can happen with the graphics rendering. So I believe I'll do fine with FreeBasic :)

The problem I'm facing right now has to do with 3D clipping. I read my code and I've done everything well, only not so tidy, but then I test it and it clearly has some glitches, so I don't know... I'll rethink it and rewrite it. I have the feeling that the next try, it'll work well from the beginning. This is my first 3D renderer, after all!  And then... the physics engine :P
Earth is my country. Science is my religion.

Daniel3D

  • Stunts Fan
  • *
  • Posts: 17
    • View Profile
Re: Modern system native Stunts proto-engine
« Reply #13 on: June 29, 2020, 10:39:11 AM »
I know enough about programing to appreciate the effort, regardless the result.
And i will try to help any way i can.

I have an interesting resource you'll might find useful.
https://www.studystore.nl/p/9783662462201/handbook-of-mathematics
Quote
his guide book to mathematics contains in handbook form the fundamental working knowledge of mathematics which is needed as an everyday guide for working scientists and engineers.
Quote
emphasis was laid on those fields of mathematics that became more important for the formulation and modeling of technical and natural processes, namely Numerical Mathematics, Probability Theory and Statistics, as well as Information Processing. Besides many enhancements and new paragraphs, new sections on Geometric and Coordinate Transformations

I don't use it because i accepted that learning to program will more time and effort than i can spare.
(this book is not about programing but is part of my C++ , python and Scala book collection)

Cas

  • Joe's Friend
  • **
  • Posts: 426
  • Think different. That's OK... as long as you think
    • View Profile
    • Dimioca Labs
Re: Modern system native Stunts proto-engine
« Reply #14 on: June 30, 2020, 01:17:00 AM »
That looks like a great book. The math I'm using in the renderer is actually pretty simple. Rotations are made in the simplest way. The only thing I could do to move further mathematically speaking is go for quaternions and I have a decent idea about how to do it, but yes, I will have to read some more. Still, the hardest technical problems I'm having don't have to do with that, but with the implementation of the math in the programming. In particular, clipping the triangles with the near frustum wall is bringing me headaches and I'm not very satisfied with the horizon generation. It will become more complicated when I want to introduce landscapes, but I feel I will be able to accomplish that.

And then... the physics engine. That'll be hard. I've been thinking on which model I could use. I first considered a rectangular prism, but have since switched to four spheres where the wheels go. This makes the car unstable on its side, like in Stunts and provides some separation from the ground when on four wheels, even if upside-down. It also makes calculations a lot simpler. The prism could still have a secondary role for calculating damage to the car, but not for responding to impact with momentum. If I were to return to my career on Physics, it'd be tempting to create a thesis based on a 3D cars game, ha, ha XD
Earth is my country. Science is my religion.