the Magicball Network Forums

the Magicball Network Forums (https://forum.magicball.net/index.php)
-   LBA Modifications - General (https://forum.magicball.net/forumdisplay.php?f=37)
-   -   I've Been Learning C! (https://forum.magicball.net/showthread.php?t=18052)

MrQuetch 2017-01-02 21:06

I've Been Learning C!
 
I just thought I'd let you guys know, especially since it's a new year! So, one of my new years resolutions goals is to make more programs in C!

There are a couple things I have in mind right now that I'm going to try and get working and hopefully have ready for everyone to download in the future!

1.) LBA2 Color Changer
2.) LBA2 Surface Creator

Although they aren't necessarily exciting or fun, it will definitely be awesome to have more programs to modify / alter the game!

I already know where the color information's are stored for all models from LBA2, and I already know how the surface information's are stored for the height maps. Now that I've got this much going, it's just a matter of learning more C, and getting the program to produce an output.lun file that can replace an entry in the already existing LBAPackageEditor! I know where the information's are stored because I've hexed the files to see where what is located.

I'll keep you guys posted, and hopefully I'll have something soon! I said that I was going on a mission soon, but there is a nine month waiting list for the mission I plan to go to, so I should be here for another while...

MrQuetch 2017-01-04 02:00

I've also discovered more of the file structure for the terrain's, including the background texture and sea informations. Unfortunately, the sea informations in the entire game are misleading - the person who typed "sea" should have typed "terrain type", because in the sea, are located the type of floors and colors / textures of the floor.

Knowing this knowledge, I could make a program that randomly generates colors / textures for the floor, and could do the same for whether Twinsen will drown, burn, or blow-up on a surface. Just letting you guys know, the possibilities are becoming bigger.

Maybe someday it'd be possible to create an entire game out of the engine. ;)

Right now I have terrain generations working slightly - you can input a number and the terrain will generate accordingly, using that value as a height for every single vertex in the grid.

Polaris 2017-01-07 12:41

Sounds like you're having fun :)

MrQuetch 2017-01-07 20:16

Quote:

Originally Posted by Polaris (Post 455276)
Sounds like you're having fun :)

Yup! I still have lots to learn, but I can already write to a file in binary, so that's helping a lot! The way in which the surfaces work are at 0 by default, and if you increase that value, it literally raises that vertex. The matter is just making an efficient program - hopefully one that's user friendly. But, by the looks of it right now, it's going to be easiest for me to do it in just using a command prompt - which sucks without the user interface, but I'll see what I can do. I'm not giving up easily.

xesf 2017-01-07 20:24

Good luck on learning.
C is a great programming language as a starting point. It can be both easy and complex to master it, but it will teach you loads of important subjects - special the lower level ones.

LBA will be a great way to practice that, even if you're doing something that already exists. Just do it! The more you do, the more you learn.

As an advice, start with simple stuffs and don't go over optimist for the initial programs. As you build your knowledge pick more and more challenging tasks. It will help you keep motivated and see small progresses in every step.

MrQuetch 2017-01-12 03:51

Quote:

Originally Posted by xesf (Post 455288)
Good luck on learning.
C is a great programming language as a starting point. It can be both easy and complex to master it, but it will teach you loads of important subjects - special the lower level ones.

LBA will be a great way to practice that, even if you're doing something that already exists. Just do it! The more you do, the more you learn.

As an advice, start with simple stuffs and don't go over optimist for the initial programs. As you build your knowledge pick more and more challenging tasks. It will help you keep motivated and see small progresses in every step.

Thanks, Xesf.

Yup, definitely a lot of learning - but it'll be worth it. The interface is already coming along quite nicely. I still have yet to save and load the algorithms, but saving in binary is working so far! That being said, (if I haven't said it already) you should be able to load already existing surfaces from the game as well.

I plan on posting screen shots of the program at some point. ;)

MrQuetch 2017-01-12 05:41

Figured I better post something for now.

A sample with the terrain, as you can see, it's clear that the terrain follows the height values.

The algorithm is as follows:
------------------------------

1.) Vertex 1 Height
2.) Vertex 1 (Extra) Height
3.) Vertex 2 Height
4.) Vertex 2 (Extra) Height
5.) Repeat for all vertices leading up to the end of the map from top-left to bottom-right.

------------------------------

So, in hexadecimal binary notation, values can go as far as 255. With the additional height for the vertices, the heights can go as high as 510! In that notation, 255 = FF. 0 is just simply 0. It's interesting the way in which hex is stored.

http://i.imgur.com/GIMbF1v.png

The mountains have been squashed, and everything is quite bumpy. The palm trees are even floating in the back. Some line segments are connected in different ways, so that's why there is some randomization in the pattern. As you can see to our left (Twinsen's right) that line segment is clearly perpendicular in relation to our point of view while most are facing our direction.

gravel22 2017-01-15 01:22

Lsba

MevX 2017-01-15 05:47

Quote:

Originally Posted by gravel22 (Post 455335)
Lsba

asödhjs

MrQuetch 2017-01-15 20:50

Quote:

Originally Posted by gravel22 (Post 455335)
Lsba

Little 'Surface' Big Adventure? Or did you have something else in mind, Gravel?

MrQuetch 2017-01-15 20:51

Quote:

Originally Posted by MevX (Post 455337)
asödhjs

Is this an inside joke? Anyways, the program is coming close to working properly. I should have a download up in the future. I can't say exactly when it'll be up. But, I'll keep you guys posted. ;)

I've managed to get colors working as well, so I'm going to make that possible in the program.

MevX 2017-01-15 22:30

i thought he mashed random letters, so i did aswell

MrQuetch 2017-01-16 19:54

Quote:

Originally Posted by MevX (Post 455347)
i thought he mashed random letters, so i did aswell

Hmm... Possibly. Anyways, I've managed to save terrain with my own heights! :D

That one was a bit tricky, so now it shouldn't be too difficult to load them and color in the vertices appropriately. Xesf would be so proud right now! :)

The program still needs some touching up, but I'll try and get an example posted. :cool:

MrQuetch 2017-01-16 20:05

Alright, so here's how the program looks so far. The interface, such as icons are still cruddy, but things should be looking better soon. Believe me, this is more user friendly than it was before.

So, the vertices change the height that you have selected. The dark blue is at value 0, and the lighter blue is at value 32. So, although it's not a smooth transition in height, it really works in the game.

http://i.imgur.com/Fkg7jxb.png

MrQuetch 2017-01-16 20:20

Alright, guys. Here is the example from the program to the game! As you can see, the example shown here was put together rather quickly, but it just goes to show that it works! The different locations have been drawn in different colors corresponding to the height. Just start looking, and it will all make sense.

http://i.imgur.com/zhvXXux.png

This is so awesome! The possibilities are growing! |)

MrQuetch 2017-01-16 22:41

I'm also trying to see if I can make a static model editor at some point. I'm currently looking at simple lm2 formats (practically boxes), trying to decipher the algorithm. It's a bit tricky right now, but hopefully it will make more sense in the future.

Looks like the animated models are going to be a nightmare to figure out though. :(

Polaris 2017-01-17 12:27

Whoa, looks nice !

Lupin 2017-01-17 14:52

Nice work so far MrQuetch!

MrQuetch 2017-01-17 18:45

Quote:

Originally Posted by Polaris (Post 455363)
Whoa, looks nice !

Thanks, Polaris. Finally getting some success. ;)

MrQuetch 2017-01-17 18:48

Quote:

Originally Posted by Lupin (Post 455364)
Nice work so far MrQuetch!

Thanks, Lupin. :) I'll be pushing limits to see what else I'm capable of. I'll try to get a program (or maybe part of the same one) for editing the terrain colors and textures, as well as floor types (like Twinsen drowning, burning, etc.).

MrQuetch 2017-01-18 08:03

I'm understanding how the models in the game (static ones anyways) are stored now. There's still much that I don't understand, but I've managed to add an extra quad on a model. It only works in the LBA Model Viewer right now, and for some reason when I try it in the game, it crashes... :-/

I'm just glad I've managed to add a vertex and some triangles. :)

MrQuetch 2017-01-19 04:59

I for some reason cannot remember for my own life where the heck the army green colors of terrain are seen in LBA2! Anyways, they're there.

Here's a sample of color changing the terrain in LBA2. I currently do not have a program for coloring the terrain yet, but have managed to (using for loops) get all triangles in the grid to contain a single color.

Here's some samples showing: Gray, Yellow, Army Green, and Emerald Blue.

http://i.imgur.com/55FhGbJ.png

We continue to march forward. ;)

Unfortunately, I still have yet to learn about how the models in the game are stored. I quickly drew this up in Photoshop, and this is what I discovered using the LBA Model Viewer.
The model seen here is one of the couple poles from the Desert Island Raceway that hold up the black & white checkered board.

http://i.imgur.com/sNqbG0M.png

Of course, much of it is possibly wrong. I may go back and change what I wrote down. It seems like the Viewer takes content less seriously, whereas in the actual game, it strictly takes everything seriously. So much as offsetting a single byte can make the game overload in memory and result in a crash. This one is going to take awhile, and it makes sense that nobody's made a model creator yet. But, I'm going to make the creator one of my goals.

The image only had so much space, so after the materials, comes the polygons' colors, their numbers, and their data sizes. Apparently, there is some weird formula for getting the right data sizes, resulting in subtracting the data by 8 and then multiplying by the amount of polygons.

Lupin 2017-01-19 11:23

You may want to check this thread: [Max/Blender models] and the follow-up thread here: LBA2 3D Chat.
You'll find a lot of information about the island file format there. It's not 100% complete, but it should give you a good overview.

MrQuetch 2017-01-19 22:14

Quote:

Originally Posted by Lupin (Post 455382)
You may want to check this thread: [Max/Blender models] and the follow-up thread here: LBA2 3D Chat.
You'll find a lot of information about the island file format there. It's not 100% complete, but it should give you a good overview.

Holy crap! Nice thread. Thanks, Lupin. Hopefully I can have something up and running soon. Last night I managed to create another section in my terrain program that enables the user to draw colors on the surface. When I get home from work, I'll try to post some images.

As far as the LBA2 model structures are concerned, I'll try to look at that thread more when I have the chance. I generally have an hour or so for lunch break.

May I ask what the '#h:'s mean? I know the S's are signed integers and the U's are unsigned integers. Does the 'h' just mean header?

Lupin 2017-01-20 01:59

It means it's an hexadecimal (base 16) number.


All times are GMT +2. The time now is 10:29.

Powered by vBulletin®
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright ©2000 - 2019, the Magicball Network