Game Development Community

dev|Pro Game Development Curriculum

Triumph at last

by Thomas -elfprince13- Dickerson · 02/11/2010 (10:22 pm) · 5 comments

Paul Gyugyi generously granted me a license to adapt LDlite's lexer/parser for FreeBuild, and I've spent a dozen or so hours getting it to play nicely with TGE, and stepping through monstrous piles of switch's and goto's trying to figure out where it was getting stuck. Not an easy task for someone as new to C and C++ as I am, but finally the first fruits of my labor:
>: testLDrawParseFile("19.dat");
Remark " ~Moved to 3624" at depth 0
LDraw Write:  Part 19 moved to 3624
Remark " Minifig Police Hat" at depth 1
Remark " Name: 3624.dat" at depth 1
Remark " Author: James Jessiman" at depth 1
Remark " Original LDraw Part" at depth 1
Remark " LDRAW_ORG Part UPDATE 2003-02" at depth 1
Remark " CATEGORY Minifig Accessory" at depth 1
Remark " BFC CERTIFY CCW" at depth 1
Remark " 2003-01-30 SEB Completed header; BFC'ed; broke up non-coplanar quads" at depth 1
Remark " Stud Tube Open" at depth 2
Remark " Name: stud4.dat" at depth 2
Remark " Author: James Jessiman" at depth 2
Remark " Author: Chris Dee" at depth 2
Remark " Original LDraw Primitive" at depth 2
Remark " LDRAW_ORG Primitive UPDATE 2002-02" at depth 2
Remark " BFC CERTIFY CW" at depth 2
Remark " 2002-04-04 SEB Modified for BFC compliance" at depth 2
Remark " Circle 1" at depth 3
Remark " Name: 4-4edge.dat" at depth 3
Remark " Author: James Jessiman" at depth 3
Remark " Original LDraw Primitive" at depth 3
Remark " LDRAW_ORG Primitive UPDATE 2005-01" at depth 3
Remark "" at depth 3
Remark " Circle 1" at depth 3
Remark " Name: 4-4edge.dat" at depth 3
Remark " Author: James Jessiman" at depth 3
Remark " Original LDraw Primitive" at depth 3
Remark " LDRAW_ORG Primitive UPDATE 2005-01" at depth 3
Remark "" at depth 3
Remark " Circle 1" at depth 3
Remark " Name: 4-4edge.dat" at depth 3
Remark " Author: James Jessiman" at depth 3
Remark " Original LDraw Primitive" at depth 3
Remark " LDRAW_ORG Primitive UPDATE 2005-01" at depth 3
Remark "" at depth 3
Remark " Circle 1" at depth 3
Remark " Name: 4-4edge.dat" at depth 3
Remark " Author: James Jessiman" at depth 3
Remark " Original LDraw Primitive" at depth 3
Remark " LDRAW_ORG Primitive UPDATE 2005-01" at depth 3
Remark "" at depth 3
Remark " BFC INVERTNEXT" at depth 2
Remark " Cylinder 1" at depth 3
Remark " Name: 4-4cyli.dat" at depth 3
Remark " Author: James Jessiman" at depth 3
Remark " Original LDraw Primitive" at depth 3
Remark " LDRAW_ORG Primitive UPDATE 2005-01" at depth 3
Remark " BFC CERTIFY CCW" at depth 3
Remark " // 2002-03-23 SEB Added BFC statement; merged headers from" at depth 3
Remark " // files in distributions LDraw 0.27 and Complete." at depth 3
Remark " // 2004-12-14 GuyVivan BFC CCW" at depth 3
Remark "" at depth 3
Remark " Cylinder 1" at depth 3
Remark " Name: 4-4cyli.dat" at depth 3
Remark " Author: James Jessiman" at depth 3
Remark " Original LDraw Primitive" at depth 3
Remark " LDRAW_ORG Primitive UPDATE 2005-01" at depth 3
Remark " BFC CERTIFY CCW" at depth 3
Remark " // 2002-03-23 SEB Added BFC statement; merged headers from" at depth 3
Remark " // files in distributions LDraw 0.27 and Complete." at depth 3
Remark " // 2004-12-14 GuyVivan BFC CCW" at depth 3
Remark "" at depth 3
Remark " Ring 3 x 1" at depth 3
Remark " Name: ring3.dat" at depth 3
Remark " Author: James Jessiman" at depth 3
Remark " Original LDraw Primitive" at depth 3
Remark " LDRAW_ORG Primitive UPDATE 2002-02" at depth 3
Remark " BFC CERTIFY CW" at depth 3
Remark " 2002-4-5: TH: Added BFC statement" at depth 3
Remark "" at depth 3
Remark "" at depth 2
Remark " Circle 1" at depth 2
Remark " Name: 4-4edge.dat" at depth 2
Remark " Author: James Jessiman" at depth 2
Remark " Original LDraw Primitive" at depth 2
Remark " LDRAW_ORG Primitive UPDATE 2005-01" at depth 2
Remark "" at depth 2
Remark " Disc 1" at depth 2
Remark " Name: 4-4disc.dat" at depth 2
Remark " Author: James Jessiman" at depth 2
Remark " Original LDraw Primitive" at depth 2
Remark " LDRAW_ORG Primitive UPDATE 2002-02" at depth 2
Remark " BFC CERTIFY CCW" at depth 2
Remark " 2002-03-23 SEB Added BFC statement" at depth 2
Remark "" at depth 2
Remark "" at depth 1
Removing zcolor namelist entry Matte-Black
Removing zcolor namelist entry Tan
Removing zcolor namelist entry Orange
Removing zcolor namelist entry Mint-Green-Belville
Removing zcolor namelist entry Light-Yellow-Belville
Removing zcolor namelist entry Gold
Removing zcolor namelist entry Electrical-Contacts
Removing zcolor namelist entry Chrome
Removing zcolor namelist entry Trans-Orange
Removing zcolor namelist entry Trans-White
Removing zcolor namelist entry Trans-Yellow
Removing zcolor namelist entry Trans-Pink
Removing zcolor namelist entry Trans-Light-Red
Removing zcolor namelist entry Trans-Cyan
Removing zcolor namelist entry Trans-Light-Green
Removing zcolor namelist entry Trans-Light-Blue
Removing zcolor namelist entry Trans-Dark-Gray
Removing zcolor namelist entry Trans-Light-Gray
Removing zcolor namelist entry Trans-Brown
Removing zcolor namelist entry Trans-Magenta
Removing zcolor namelist entry Trans-Red
Removing zcolor namelist entry Trans-Dark_Cyan
Removing zcolor namelist entry Trans-Green
Removing zcolor namelist entry Trans-Blue
Removing zcolor namelist entry Trans-Black
Removing zcolor namelist entry Tan-Solid
Removing zcolor namelist entry Lime-Green
Removing zcolor namelist entry Dark-Pink
Removing zcolor namelist entry Orange-Solid
Removing zcolor namelist entry Edge-Color
Removing zcolor namelist entry Purple-Blue
Removing zcolor namelist entry Purple
Removing zcolor namelist entry Glow-In-The-Dark
Removing zcolor namelist entry Light-Purple
Removing zcolor namelist entry Tan
Removing zcolor namelist entry Light-Yellow
Removing zcolor namelist entry Pastel-Green
Removing zcolor namelist entry Main-Color
Removing zcolor namelist entry White
Removing zcolor namelist entry Yellow
Removing zcolor namelist entry Pink
Removing zcolor namelist entry Light-Red
Removing zcolor namelist entry Cyan
Removing zcolor namelist entry Light-Green
Removing zcolor namelist entry Light-Blue
Removing zcolor namelist entry Dark-Gray
Removing zcolor namelist entry Light-Gray
Removing zcolor namelist entry Brown
Removing zcolor namelist entry Magenta
Removing zcolor namelist entry Red
Removing zcolor namelist entry Dark-Cyan
Removing zcolor namelist entry Green
Removing zcolor namelist entry Blue
Removing zcolor namelist entry Black
Removing color table index 0
Profile: 0 cached, 11 uncached, 0 hits

Depressingly the caching seems to be borked, and I was concerned that it spit back a few syntax errors at me on some other test files, but 'tis a start. Now I can be content to hack away at some rendering nonsense without this looming over my head.

Also, I'm still hoping that someone with a solid grasp on the TS rendering pipeline in TGE will explain it to me.

About the author

C.S. PhD student at Brown University. Project lead for FreeBuild. Administrator, Cemetech tech community. Webmaster for the Village2Village Projects and the Vermont Sustainable Heating Initiative.


#1
02/12/2010 (10:46 am)
Congratulations on your triumph. As a non-programmer I'm baffled by what your doing.
#2
02/12/2010 (11:30 am)
Getting a lexer/parser combo (similar to the ones used to compile TorqueScript), into TGE and using it to turn the text of an LDraw model into renderable polygon data. The C code that yacc or bison generate for the parser (and lex or flex for the lexer) is pretty complex and a pain in the butt to debug, because it goto's all over the place and uses all sorts of token lookup tables. As of now, the lexer/parser that I've adapted (under license from the LDlite project), generates and understands all the necessary information to produce a renderable object in Torque, I just need to actually tell it to save that data to an object. The "code" in my post is the console spam from a test run of the parser on the LDraw minifig police hat model.
#3
02/14/2010 (3:54 pm)
Quote "a non-programmer "

I for one missed that Steve! As many bug finding posts and words of wisdom you have bestowed onto this forum I for one am surprised, and I should say with the way you seem to see, and think things through you should learn some programming skill, unless of course you are being very modest?
#4
02/15/2010 (3:27 pm)
So wait does that mean you will be having people create models in the LDraw model and then putting them into game realtime? That kind of reminds me of some other multiplayer online game. I can't remember the name right now.
#5
02/15/2010 (5:08 pm)
you'll be able to build stuff in game (as a Lego person), and then use your creations as vehicles or bases (or any other type of game object)