PDA

View Full Version : Gmax to SCASM


rhumbaflappy
June 9th, 2005, 19:09
Hi all.

I'm reposting this in the new forum.

I've been discussing the use of Gmax-produced ASM files to make library objects, and damageable library objects. With the use of Arno Gerretsen's CAT2k2 program, we can even make animations of both the regular and damage models of the library object... and we can use some coding to make multiple LODs for better framerates.

But ASM is barely readable. That's why SCASM was created.

=====================

Currently, to convert gmax modeling to scasm required a decompiler. Then hacking and recompiling to BGL, and hope the model still works.

But, there is another way!

The gmax-produced asm code can be converted to a raw BGL. We can do this by compiling the *_0.asm file directly with BGLC. This data has no header info, but does contain ALL the modeling needed for displaying the object.

But how do we get scasm to display it? We need to decompile it to Dbx() code!

I'm attaching raw2sca in a zip file. It decompiles raw BGL code to SCASM Dbx() commands that can be included into scasm code:


Code:
Header( 1 N90:00:00.00 S89:60:00.00 E180:00:00.00 W179:60:00.00 )
LatRange( S89:60:00.00 N90:00:00.00 )
ObjID( 2C1D3FE1 4259FA73 4B77FAA3 D3FB5C50 )
LibObj(
PWR 0
SIZE 30
SCALE 0.5
TYPE 0
NAME "test" )
IfVarAnd( :_regular_object 0024 0040 )
Include( damage_0.sca )
:_regular_object
Include( regular_0.sca )
EndObj

This code "includes" the decompiled raw bgl data just where it's needed... without ANY hacking.


Here's the sequence:

GMAX to ASM code ( produces test.asm and test_0.asm )

ASM to raw BGL ( drag'n'drop test_0.asm onto BGLC.exe to make test_0.bgl )

raw BGL to usable SCASM ( drag'n'drop test_0.bgl onto raw2sca.exe to make test_0.sca )

Include the raw SCA code into your damagable library code.


So with a minimum of code hacking, you can use gmax-produced *_0.asm files in your SCASM code.




Dick

Bortdafarm
June 9th, 2005, 19:20
this is mystifying me i must admit fascinating as it really is (keep it coming)

now i understand that in order to generate the asm files from a g-max export i need to use the "keep files" check in middleman/makemdl etc ..but i don't get the file_0.asm just the file.asm any body help me out here?

it sounds very much like somethings amis with my g-max set up ? what are the options needed to generate the essentail file_0.asm
apologies for cutting across a little here...not intended to disrupt the flow just asking

rhumbaflappy
June 9th, 2005, 20:03
Hi Bortdafarm.

Why not attach your saved gmax file, and post it in a new thread? If you post it here, this thread will get "hijacked" by other posters commenting on your problem, and the Gmax to SCASM topic will get lost.

I'm assuming you're using the FS2002 gamepack, from the FS2002 Pro CD?

MakeMDL creates both the *.asm and *_0.asm for a valid file.

Dick

SdC
June 10th, 2005, 14:58
I ran into a compilation problem with scasm.exe on a complex building object:
Error in line 69
-> EndObj
-> destination ":_regular_object" out of range (41120), source line 64
Scasm compilation status: error(s) 1

Thanks to Martin's suggestion in another thread, I modified the code to look like this:

ObjID( 2C1D003 4352FA73 2B77FAA3 23F35C50 )

LibObj(
PWR 0
SIZE 30
SCALE 0.5
TYPE 0
NAME "Schiphol_Terminal" )

IfVarAnd( :NEXT 0024 0040 )
Jump( :MAIN )
:NEXT
Jump32( :_regular_object )
:MAIN
Include( Schiphol_Terminal_D_0.sca )
:_regular_object
Include( Schiphol_Terminal_0.sca )
EndObj


and got a working BGL!

rhumbaflappy
June 10th, 2005, 20:57
Hi SdC ( formerly known as Redwulf__53 ).

Very good solution! The use of the Jump32 assures the compilation for the included Gmax RAW code as you thought it would. :mixedsmi:

Dick

crashaz
June 15th, 2005, 01:07
Hmm well think I will stick with the ASM... my BBs are running 8-10K in polys and that will probably increase with LOD models.

SdC
June 15th, 2005, 01:59
You know, Crashaz, it is still ASM not SCASM code with this method!
The scasm we use here is just a wrapper around the original hex ASM code which was compiled in the _0.asm file. Therefore it will not impact the performance.

crashaz
June 15th, 2005, 12:11
Hmm well when I tried compiling library objects using SCASM in the past... it would fail because of the complexity of the ships... I tried increasing the Buffer but that never did work. Guess I will take a peek using this method.

rhumbaflappy
June 16th, 2005, 05:58
Hi crashaz.

The gist of raw2sca is to first use BGLC to compile just the *_0.asm file using the FS2002 gamepack. That makes a raw "image" of your Gmax object, with no header information to place it. This raw image IS your Gmaxed model...with all it's information ( LODs, animation, materials, etc... )

Then drag'n'drop the raw BGL onto raw2sca to make that BGL into a bunch of DB ( data byte ) statements. This way, nothing is lost in the original model. It's still your Gmaxed objects in it's entirety.

This pile of DB statements can now be "included" into a SCASM wrapper to easily make a library. That library can have dozens of objects, and can have damage models for each if desired, as SdC has found. His SCASM addition improves the ability of SCASM to compile longer, more complicated code... perfect for gmaxed objects using LODs.

So... you can have the best of both Gmax and SCASM to create libraries of objects.

Dick

crashaz
June 16th, 2005, 09:20
Ahhh... ok...that makes sense now. Well I will give er a shot fellas. Been working with my animations and they have been too complex as there are too many pieces for my BBs to capsize. I think I have a way around that though... attach every piece to one another... 1 giant piece and then try my animation. Right now damage does show instantly though.

SdC
June 16th, 2005, 10:08
....., as SdC has found. His SCASM addition.....
Dick
Actually, it was Martin's advice.... I'm no scasm guru at all.
Credit where credit is due ;)

crashaz
June 16th, 2005, 11:37
Hehehe in this forum the majority of the credit usually goes to Martin or Rhumba for carrying the technology to us scenery builders . ;)

We are mostly faithful followers. :jeep0a:

JP127
August 14th, 2005, 12:07
Hi,

Armed with Rhumba's gmax to scasm method and Crashaz's helpful tutoring I am able to design a gmaxed multi-lod library object for CFS2. Thanks guys.

Jeff

crashaz
August 14th, 2005, 14:24
Welcome to the club Jeff! Just helping out because guys like Rhumba, Martin,Lindsay Watt, Gary20 and Maskrider have helped me. Adding another scenery guy only helps to keep breathing life into CFS2. Add Cees, Stiz, wolfi and you... and things are looking rosy for CFS2. :) Plus the fact that people like SdC made scenery building tools like Ground2k and let them have at it. Where would CFS2 be today without people fumbling around in the dark. Hehehehe.