Jump to content
Sign in to follow this  
Guest

Adventures into MASM

Recommended Posts

Guest christian

It's not that complicated really. FS2K2 only reads binary data, and thats what you're producing with the dd, dw, etc.Let's dive straight into the bgl part (this is some pseudo code, not necessarily correct):the scenery engine reads '00 AA' (this is a dw number in hex code). The first number is always a so called 'opcode'. You can look those up in the Scenery SDK are in the bglmac.inc.00 AA stands for NEW_RUNWAY. So, FS2K2 knows that a runway follows. Now, FS2K2 expects some entries to follow, eg location, length, heading, etc (also explained in the Scenery SDK)... For example, something like this:dw 00AAh 'runway opcodedd 563882 'latitudedd 7668092 'longitudedd 176 'altitudedw 5673 'headingdw 765 'magnetic variationdw 1200 'lengthdw 20 'widthdw 01 'runway surface, 01 = grassThis is quite painful, so you can write a macro:macro NEW_RUNWAY lat, long, alt, heading, magvar, length, width, surfacedw 00AAh 'opcodedd latdd longdd altdw headingdw magvardw lengthdw widthdw surfaceend macroAnd then in your code you writeNEW_RUNWAY 563882,7668092,176,5673,765,1200,20,01Of course if you muck this up and write a wrong macro with an argument missing, FS2K2 will get confused and think, ok, next thing is an opcode, but it isn't and FS2K2 may either ignore whats coming or simply crash on you.So they key to remember is that everything is hardcoded, FS2K2 will read an opcode and automatically knows what follows and what to do with it. Then it expects an opcode again. Mess up the order and FS2K2 won't know what to do anymore.Cheers, Christian

Share this post


Link to post
Share on other sites
Guest

Hi Arno as most people now have cards that "do"T+L transforms (the "T" in T+L) do not have anyware near the hit that they used to.Thats why T+L is an item that is chooseable in set up. When FS 2002 "sees" ones card can perform T+L then the engine just has the card do the transforms rather than doing it in software. I hope this is of some help Dan http://members.rogers.com/klasik2/danlogo.gifhttp://members.rogers.com/eelvish/flyurl.gif

Share this post


Link to post
Share on other sites
Guest

Hi Christian good discrption of how faces (the real basic building blocks of all meshes) are handled by both the hardware and softwaredirX8 and Open G.L. as well. One thing I might add for anyone makeingmeshes is allways keep it simple stupid.(A.K.A K.I.S.S.)there are a couple of things one can do use extruded splines when ever possable all of my building are done as splines and then extruded(I.E. no sticking boxes together!) trust me just that makes a big differancein the number of pollys in a mesh and along with good texturing tricks like cramming will go a long way to keeping frame rates highso everyone can enjoy what we work so hard in creating. I hope this is of some help to everyone Danhttp://members.rogers.com/klasik2/danlogo.gifhttp://members.rogers.com/eelvish/flyurl.gif

Share this post


Link to post
Share on other sites

Thanks again learned something :), but I have turned of that feature myself as I didn't see any result of it (only a bit lower performance).ArnoMember NL2000 Teamhttp://home.wanadoo.nl/arno.gerretsen


Arno

If the world should blow itself up, the last audible voice would be that of an expert saying it can't be done.

FSDeveloper.com | Former Microsoft FS MVP | Blog

Share this post


Link to post
Share on other sites

As far as I have seen from the source code there are 3 vertices for each triangle. So that makes 9 for 3 triangles and not 5 as you say above (maybe I understood it work :)). The texture mapping is added to the vertex and that also makes that the same vertex can not be used on another polygon.ArnoMember NL2000 Teamhttp://home.wanadoo.nl/arno.gerretsen


Arno

If the world should blow itself up, the last audible voice would be that of an expert saying it can't be done.

FSDeveloper.com | Former Microsoft FS MVP | Blog

Share this post


Link to post
Share on other sites
Guest

Hi Arno what Christian is refering to is a method more or less combines faces (triangles)by "ignoring" one edge between the two faces that make up a standard polly. However I have found that the above can cause problems with things like mip mapping and it's "texels" when a lower res bit map will not line up with the higher res bit map due to the "missing" edge in the middle. That I have found is one of the causes of blury textures when extended bitmaps like dxt1 etc are used. So in short just use "standard" polly'sin fact the number of polly's with in reason is much less importantthan number and resolution of your textures as buildings are simpleobjects. You have seen pics of our scenery lots of models that lookcomplex but are not because like I said they are all done from splines (no pre-made boxes etc) and the fact that Jim and I are verycarefull when doing up textures and in how they are applied. I am sorry to say it again but forget FSDS use gmax for models.(no macros) And a face ( triangle) has three verticies not 9 in other words a face(triangle) is made up of three points and the three lines(edges)that connect the vertices say AB,BC,CA try it with a pice of paper!!. Dan again I hope this helps everyone to understand the basics of the3D worldhttp://members.rogers.com/klasik2/danlogo.gifhttp://members.rogers.com/eelvish/flyurl.gif

Share this post


Link to post
Share on other sites

I am also using only GMax for my 3D objects now. I make a library bgl from them and can then call them using a macro in GroundMaker. Works great and the framerate is very good.And the considerations you give about the complexity, etc are the same as always :), even in FSDS you had to think about things like that to keep the frames good.ArnoMember NL2000 Teamhttp://home.wanadoo.nl/arno.gerretsen


Arno

If the world should blow itself up, the last audible voice would be that of an expert saying it can't be done.

FSDeveloper.com | Former Microsoft FS MVP | Blog

Share this post


Link to post
Share on other sites
Guest

Hi there,I finally got the object optimised! Deleted all the invisible poligons (such as bottoms and tops of cylinders etc ...I can understand that defining all the vertexes and triangles in one go might be faster then using "transformcalls" to the same object!The only disadvantage is that the bgl goes from 14k to 219k!! I wonder what is the impact of this!Anyway, the same object in GMAX/MASM has very similar performance to the one produced with FSDS/SCASM. Maybe it is a bit faster in the former case. Furthermore, on the GMAX case, the autogen does not get excluded as it happen with the SCASM case.The only problem still to solve is the shadow and crash detection.Well crash detection is a problem in this case has the object is quite complex and it seems that each cm of the object is tested for this condition. This is obviously not necessary and it drops the framerate dramatically. What I would like to do is to make crash detection based on same boundaries of the object only as aircraft are supposed to land there (so no crash detection there)! Basically the equivalent to VectorJump would do the trick but I would like to include that in the MASM file to keep everything in the same bgl!The other problem is the shadow. First there is no need to have the whole object casting shadow, only the top polygon would suffice, otherwise things slows down a lot. As I said before in a different post, I am using ADDMTN to force this object to be drawn before the runway which sits on the top. This object is something like a platform with pilars and sits a few metres above sea level. Is there any alternative way of doing this as ADDMTN is being phased out? One cause of using ADDMTN is that the shadow works fine up to a altitude of approx 2500. Beyond that the shadow starts to be visible on the top of the object and runway. I will make a simple version of this object and post the code/image to illustrate the problem.Great discussion! Thanks guys!jmf

Share this post


Link to post
Share on other sites
Guest

Hello Dan,Yes I will!However, I made the surface 3 metres thick (as it is in reality I hope)! As you suggested earlier, I always prefer to draw an outline of the shape and then extrude into 3D! That seems to work OK for both FSDS and GMAX.Now the interesting part is that shadows are not supposed to be cast on other 3D objects. However, since it eventually goes on the top of the platform surface, before that it did the same on the supporting pilars (which in this case is truly realistic).I will post the code later on so that this may become THE chalenge!! ;)CheersjmfPS - if the object is not ADDMTN'ed, the shadow works fine. In this case, the runway goes under the object. Well not really has it sits on the top but the object is drawn after so it looks really strange.

Share this post


Link to post
Share on other sites
Guest

Greatings,Finally I managed to replicate the problem with a simpler model so that I could share the code here in the forum. I am enclosing the edited MASM code generated by GMAX. The change is shown and it is the only way I know to make the runway visible on top of the platform. ADDMTN instead of ADDOBJ or in SCASM terms PerspectiveCall2 instead of PerspectiveCall.I am also enclosing the SCASM code for the runway and a flatten poly.Finaly I am uploading two small pics that illustrate the problem of the shadows. Hope you enjoy the technical challenge! Another challenge is actually land a jet in the runway! But don't go on the platform as it is not hardened!! :)This is located somewhere in africa at coords N15 W0.///////////////////// SCASM FOR THE RUNWAY AND FLATTEN POLYGON //////////////////////////Header( 1 15.12500 14.87500 -0.12500 0.12500 )LatRange( 14.87500 15.12500 )set( areamx 64 )Area16N Elevation ( 297.4848 15:0.16467 -000:0.36996 ; 1 15:0.16143 000:0.43525 ; 2 14:59.85962 000:0.44249 ; 3 14:59.83479 -000:0.3839 ; 4 )End16Area( 5 15:0.0008 000:0.00165 30 ) LayerCall( :rwy 24 ) Jump( : ):rwy Smoothing ( 1 ) Runway( 15:0.0008 000:0.00165 Altitude 347.472 Heading 90 Length 3281 Width 164 Id 09 Surface 1 Markers FF THRESHOLD 0 Lights 10 ThrLightsN 00 ThrLightsF 00 ) Smoothing ( 0 ) ReturnEndA////////////////////////// MASM CODE FOR PLATFORM /////////////////////////////;compile with BGLC /BGL D:FSMASMtest.asmheader label word dw 0001 ; 00 World set number dd 000197217H ; 02 North bound dd 000196D05H ; 06 South bound dd 000000001H ; 10 East bound dd 0FFFFFFFFH ; 14 West bound dw 20 dup(0) dd (offset OBJECT_DATA) - (offset header) dw 33 dup(0) OBJECT_DATA label word db 21 ;;LATBAND_REL dw 00CB6h ;;lat min (inclusive) 512M units dw 00CBAh ;;lat max (exclusive) dd (offset OBJECT_0) - (offset OBJECT_DATA) db 0 ;;EOL OBJECT_0 label BGLCODE db 12 ; NEAR_FAR_HUGE_OBJECT_HEADER dd 000196F8Eh,000000000h ; latitude,longitude db 100 ; image power dd (offset OBJECT_0_END) - (offset OBJECT_0) OBJECT_0_START label word IFIN1 OBJECT_0_FAIL, image_complex, 2, 32767 ADDMTN OBJECT_0_SCALE 80 part= 1 prim=0 VERTEX_DEF 1211.416016, 94.000008, 245.272018, 0.000000, 1.000000, 0.000000, 0.000000,1.000000 ; 81 part= 1 prim=0 VERTEX_DEF 1211.416016, 94.000008, 238.344009, -0.654654, 0.000000,-0.755929, 0.000000,1.000000 ; 82 part= 1 prim=0 VERTEX_DEF 1211.416016, 94.000008, 238.344009, 0.000000, 1.000000, 0.000000, 0.000000,1.000000 ; 83 part= 1 prim=0 VERTEX_DEF 1213.616089, 0.000000, -274.520020, 0.000000,-1.000000, 0.000000, 0.000000,1.000000 ; 84 part= 1 prim=0 VERTEX_DEF 1213.616089, 0.000000, -274.520020, 0.327327, 0.000000, 0.944911, 0.000000,1.000000 ; 85 part= 1 prim=0 VERTEX_DEF 1213.616089, 0.000000, -281.448029, 0.000000,-1.000000, 0.000000, 0.000000,1.000000 ; 86 part= 1 prim=0 VERTEX_DEF 1213.616089, 0.000000, -281.448029, 0.654654, 0.000000,-0.755929, 0.000000,1.000000 ; 87 part= 1 prim=0 VERTEX_DEF 1213.616089, 94.000008, -274.520020, 0.000000, 1.000000, 0.000000, 0.000000,1.000000 ; 88 part= 1 prim=0 VERTEX_DEF 1213.616089, 94.000008, -274.520020, 0.654654, 0.000000, 0.755929, 0.000000,1.000000 ; 89 part= 1 prim=0 VERTEX_DEF 1213.616089, 94.000008, -281.448029, 0.000000, 1.000000, 0.000000, 0.000000,1.000000 ; 90 part= 1 prim=0 VERTEX_DEF 1213.616089, 94.000008, -281.448029, 0.327327, 0.000000,-0.944911, 0.000000,1.000000 ; 91 part= 1 prim=0 VERTEX_DEF 1215.416016, 0.000000, 245.272018, 0.000000,-1.000000, 0.000000, 0.000000,1.000000 ; 92 part= 1 prim=0 VERTEX_DEF 1215.416016, 0.000000, 245.272018, 0.327327, 0.000000, 0.944911, 0.000000,1.000000 ; 93 part= 1 prim=0 VERTEX_DEF 1215.416016, 0.000000, 238.344009, 0.000000,-1.000000, 0.000000, 0.000000,1.000000 ; 94 part= 1 prim=0 VERTEX_DEF 1215.416016, 0.000000, 238.344009, 0.654654, 0.000000,-0.755929, 0.000000,1.000000 ; 95 part= 1 prim=0 VERTEX_DEF 1215.416016, 94.000008, 245.272018, 0.000000, 1.000000, 0.000000, 0.000000,1.000000 ; 96 part= 1 prim=0 VERTEX_DEF 1215.416016, 94.000008, 245.272018, 0.654654, 0.000000, 0.755929, 0.000000,1.000000 ; 97 part= 1 prim=0 VERTEX_DEF 1215.416016, 94.000008, 238.344009, 0.000000, 1.000000, 0.000000, 0.000000,1.000000 ; 98 part= 1 prim=0 VERTEX_DEF 1215.416016, 94.000008, 238.344009, 0.327327, 0.000000,-0.944911, 0.000000,1.000000 ; 99 part= 1 prim=0 VERTEX_DEF 1215.616089, 0.000000, -277.984009, 0.000000,-1.000000, 0.000000, 0.000000,1.000000 ; 100 part= 1 prim=0 VERTEX_DEF 1215.616089, 0.000000, -277.984009, 0.981981, 0.000000, 0.188982, 0.000000,1.000000 ; 101 part= 1 prim=0 VERTEX_DEF 1215.616089, 94.000008, -277.984009, 0.000000, 1.000000, 0.000000, 0.000000,1.000000 ; 102 part= 1 prim=0 VERTEX_DEF 1215.616089, 94.000008, -277.984009, 0.981981, 0.000000,-0.188982, 0.000000,1.000000 ; 103 part= 1 prim=0 VERTEX_DEF 1217.416016, 0.000000, 241.808014, 0.000000,-1.000000, 0.000000, 0.000000,1.000000 ; 104 part= 1 prim=0 VERTEX_DEF 1217.416016, 0.000000, 241.808014, 0.981981, 0.000000, 0.188982, 0.000000,1.000000 ; 105 part= 1 prim=0 VERTEX_DEF 1217.416016, 94.000008, 241.808014, 0.000000, 1.000000, 0.000000, 0.000000,1.000000 ; 106 part= 1 prim=0 VERTEX_DEF 1217.416016, 94.000008, 241.808014, 0.981981, 0.000000,-0.188982, 0.000000,1.000000 ; 107 part= 1 prim=0 VERTEX_DEF 1258.016113, 93.960007, 282.520020, 0.000000,-1.000000, 0.000000, 0.000000,1.000000 ; 108 part= 1 prim=0 VERTEX_DEF 1258.016113, 93.960007, 282.520020, 0.000000, 0.000000, 1.000000, 0.000000,1.000000 ; 109 part= 1 prim=0 VERTEX_DEF 1258.016113, 93.960007, 282.520020, 1.000000, 0.000000, 0.000000, 0.000000,1.000000 ; 110 part= 1 prim=0 VERTEX_DEF 1258.016113, 93.960007, -318.304016, 0.000000,-1.000000, 0.000000, 0.000000,1.000000 ; 111 part= 1 prim=0 VERTEX_DEF 1258.016113, 93.960007, -318.304016, 0.000000, 0.000000,-1.000000, 0.000000,1.000000 ; 112 part= 1 prim=0 VERTEX_DEF 1258.016113, 93.960007, -318.304016, 1.000000, 0.000000, 0.000000, 0.000000,1.000000 ; 113 part= 1 prim=0 VERTEX_DEF 1258.016113, 99.960007, 282.520020, 0.000000, 0.000000, 1.000000, 0.000000,1.000000 ; 114 part= 1 prim=0 VERTEX_DEF 1258.016113, 99.960007, 282.520020, 0.000000, 1.000000, 0.000000, 0.000000,1.000000 ; 115 part= 1 prim=0 VERTEX_DEF 1258.016113, 99.960007, 282.520020, 1.000000, 0.000000, 0.000000, 0.000000,1.000000 ; 116 part= 1 prim=0 VERTEX_DEF 1258.016113, 99.960007, -318.304016, 0.000000, 0.000000,-1.000000, 0.000000,1.000000 ; 117 part= 1 prim=0 VERTEX_DEF 1258.016113, 99.960007, -318.304016, 0.000000, 1.000000, 0.000000, 0.000000,1.000000 ; 118 part= 1 prim=0 VERTEX_DEF 1258.016113, 99.960007, -318.304016, 1.000000, 0.000000, 0.000000, 0.000000,1.000000 ; 119 part= 1 prim=0 VERTEX_LIST_END; NonAlphatest_NonAlpha label BGLCODE MATERIAL 0 ; <255,255,255,255> DRAW_TRI_BEGIN 0, 120 DRAW_TRI 79, 77, 104 ; poly=47 part=1 DRAW_TRI 5, 112, 117 ; poly=2 part=1 DRAW_TRI 116, 119, 113 ; poly=3 part=1 DRAW_TRI 113, 110, 116 ; poly=4 part=1 DRAW_TRI 7, 114, 109 ; poly=5 part=1 DRAW_TRI 109, 2, 7 ; poly=6 part=1 DRAW_TRI 9, 6, 0 ; poly=7 part=1 DRAW_TRI 0, 3, 9 ; poly=8 part=1 DRAW_TRI 108, 111, 4 ; poly=9 part=1 DRAW_TRI 4, 1, 108 ; poly=10 part=1 DRAW_TRI 11, 118, 115 ; poly=11 part=1 DRAW_TRI 115, 8, 11 ; poly=12 part=1 DRAW_TRI 101, 85, 89 ; poly=13 part=1 DRAW_TRI 89, 103, 101 ; poly=14 part=1 DRAW_TRI 85, 68, 72 ; poly=15 part=1 DRAW_TRI 72, 89, 85 ; poly=16 part=1 DRAW_TRI 68, 60, 62 ; poly=17 part=1 DRAW_TRI 62, 72, 68 ; poly=18 part=1 DRAW_TRI 60, 70, 74 ; poly=19 part=1 DRAW_TRI 74, 62, 60 ; poly=20 part=1 DRAW_TRI 70, 87, 91 ; poly=21 part=1 DRAW_TRI 91, 74, 70 ; poly=22 part=1 DRAW_TRI 87, 101, 103 ; poly=23 part=1 DRAW_TRI 103, 91, 87 ; poly=24 part=1 DRAW_TRI 71, 61, 69 ; poly=25 part=1 DRAW_TRI 69, 84, 100 ; poly=26 part=1 DRAW_TRI 71, 69, 100 ; poly=27 part=1 DRAW_TRI 86, 71, 100 ; poly=28 part=1 DRAW_TRI 88, 73, 63 ; poly=29 part=1 DRAW_TRI 63, 75, 90 ; poly=30 part=1 DRAW_TRI 88, 63, 90 ; poly=31 part=1 DRAW_TRI 102, 88, 90 ; poly=32 part=1 DRAW_TRI 105, 93, 97 ; poly=33 part=1 DRAW_TRI 97, 107, 105 ; poly=34 part=1 DRAW_TRI 93, 76, 80 ; poly=35 part=1 DRAW_TRI 80, 97, 93 ; poly=36 part=1 DRAW_TRI 76, 64, 66 ; poly=37 part=1 DRAW_TRI 66, 80, 76 ; poly=38 part=1 DRAW_TRI 64, 78, 82 ; poly=39 part=1 DRAW_TRI 82, 66, 64 ; poly=40 part=1 DRAW_TRI 78, 95, 99 ; poly=41 part=1 DRAW_TRI 99, 82, 78 ; poly=42 part=1 DRAW_TRI 95, 105, 107 ; poly=43 part=1 DRAW_TRI 107, 99, 95 ; poly=44 part=1 DRAW_TRI 79, 65, 77 ; poly=45 part=1 DRAW_TRI 77, 92, 104 ; poly=46 part=1 DRAW_TRI 117, 10, 5 ; poly=1 part=1 DRAW_TRI 94, 79, 104 ; poly=48 part=1 DRAW_TRI 96, 81, 67 ; poly=49 part=1 DRAW_TRI 67, 83, 98 ; poly=50 part=1 DRAW_TRI 96, 67, 98 ; poly=51 part=1 DRAW_TRI 106, 96, 98 ; poly=52 part=1 DRAW_TRI 57, 49, 53 ; poly=53 part=1 DRAW_TRI 53, 59, 57 ; poly=54 part=1 DRAW_TRI 49, 40, 44 ; poly=55 part=1 DRAW_TRI 44, 53, 49 ; poly=56 part=1 DRAW_TRI 40, 32, 34 ; poly=57 part=1 DRAW_TRI 34, 44, 40 ; poly=58 part=1 DRAW_TRI 32, 42, 46 ; poly=59 part=1 DRAW_TRI 46, 34, 32 ; poly=60 part=1 DRAW_TRI 42, 51, 55 ; poly=61 part=1 DRAW_TRI 55, 46, 42 ; poly=62 part=1 DRAW_TRI 51, 57, 59 ; poly=63 part=1 DRAW_TRI 59, 55, 51 ; poly=64 part=1 DRAW_TRI 43, 33, 41 ; poly=65 part=1 DRAW_TRI 41, 48, 56 ; poly=66 part=1 DRAW_TRI 43, 41, 56 ; poly=67 part=1 DRAW_TRI 50, 43, 56 ; poly=68 part=1 DRAW_TRI 52, 45, 35 ; poly=69 part=1 DRAW_TRI 35, 47, 54 ; poly=70 part=1 DRAW_TRI 52, 35, 54 ; poly=71 part=1 DRAW_TRI 58, 52, 54 ; poly=72 part=1 DRAW_TRI 37, 25, 29 ; poly=73 part=1 DRAW_TRI 29, 39, 37 ; poly=74 part=1 DRAW_TRI 25, 16, 20 ; poly=75 part=1 DRAW_TRI 20, 29, 25 ; poly=76 part=1 DRAW_TRI 16, 12, 14 ; poly=77 part=1 DRAW_TRI 14, 20, 16 ; poly=78 part=1 DRAW_TRI 12, 18, 22 ; poly=79 part=1 DRAW_TRI 22, 14, 12 ; poly=80 part=1 DRAW_TRI 18, 27, 31 ; poly=81 part=1 DRAW_TRI 31, 22, 18 ; poly=82 part=1 DRAW_TRI 27, 37, 39 ; poly=83 part=1 DRAW_TRI 39, 31, 27 ; poly=84 part=1 DRAW_TRI 19, 13, 17 ; poly=85 part=1 DRAW_TRI 17, 24, 36 ; poly=86 part=1 DRAW_TRI 19, 17, 36 ; poly=87 part=1 DRAW_TRI 26, 19, 36 ; poly=88 part=1 DRAW_TRI 28, 21, 15 ; poly=89 part=1 DRAW_TRI 15, 23, 30 ; poly=90 part=1 DRAW_TRI 28, 15, 30 ; poly=91 part=1 DRAW_TRI 38, 28, 30 ; poly=92 part=1 DRAW_TRI_END BGL_END BGL_RETURN;--------- WARNING - WARNING - WARNING - WARNING - WARNING - WARNING ---------;; This file was automatically generated from D:FSMASMtest; using the MakeMDL tool. Do not edit by hand, re-run the; tool instead.;; generated on 06/01/02 01:10:36;;--------- WARNING - WARNING - WARNING - WARNING - WARNING - WARNING ---------

Share this post


Link to post
Share on other sites
Guest

Anyone had a chance to try this out? No luck so far nor devine inspiration to solve this problem. Cheersjmf

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...