Widget request: Extract model data - Page 2

Widget request: Extract model data

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Widget request: Extract model data

Post by zwzsg »

I'm not bright enough to see what difference it makes to wireframes, please enlighten me.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Widget request: Extract model data

Post by Argh »

Check what a 3DO wireframe looks like, and then view a S3O one in Spring. Return enlightened.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Widget request: Extract model data

Post by zwzsg »

Ah, I guess you mean the diagonals, thanks.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Widget request: Extract model data

Post by Argh »

And that's just the tip of the iceberg. Having a S3O parser, either engine-side or Lua, is a Big Deal.
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: Widget request: Extract model data

Post by Tribulex »

@det

How am I insulting people by calling 1 person "not so incredibly dense"? Thats actually what I would consider a compliment. Im pointing out something good about him.

@others:

You guys really dont get it. Ill use big text so you can read it better:

I dont care about drawing. I dont want to know how to draw a wireframe. I dont want to know how to do what you want to know how to do. I dont want to convert to quads. I dont want to do anything except for this: Extract a list of vertices from a model, and extract a list of lines I could use to connect those vertices.

I have learned from Argh, who is a really great guy (no really), that this can only be done right now by parsing the s3o file. Has anyone done anything on this?


Aside from this, does anyone have a way of extracting this data from a file outside of spring? I dont care about the 3d model format or the programming language or what. I need a list of points and lines that form a model. If i have to calculate it outside of spring, then thats what I will do.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Widget request: Extract model data

Post by hoijui »

best would have been/would be, if you had outlined what yo uare trying to do in general, as in:
i want to do a programm/mod/widget that does X and Y, and to do this i need to do Z, and therefore ... i have to get the points and vertices.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Widget request: Extract model data

Post by lurker »

I'm going to put this as gently and non-insulting as I can.

If you ask about a widget rendering wireframes, you get told how to render wireframes from a widget.

If you ask about extracting model data with a valid reason, despite the difficulties involved, you will get an answer about that.

Don't insult other people when you came in with a two sentence post expecting it to be easy to get complex 3d model data and failed to clarify why you wanted it, instead repeating your original request.
d_b wrote:@det
How am I insulting people by calling 1 person "not so incredibly dense"? Thats actually what I would consider a compliment. Im pointing out something good about him.
This is either trolling or you're posting at 4am high on cough syrup. Either way, stop it.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Widget request: Extract model data

Post by Kloot »

d_b wrote:Basically, i need the coordinates so that I can draw a wireframe.
d_b wrote:I dont care about drawing.
Maybe get your story straight before asking people to "right" you any code, CMU's finest.

d_b wrote:this can only be done right now by parsing the s3o file. Has anyone done anything on this?
Yes.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Widget request: Extract model data

Post by Forboding Angel »

det wrote:Way to insult the people who are trying to help you.
The way he was being "answered" and spoken to was insulting. I would have had the same reaction.
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: Widget request: Extract model data

Post by Tribulex »

Kloot wrote:
d_b wrote:this can only be done right now by parsing the s3o file. Has anyone done anything on this?
Yes.
What? w2dl?

At others: >:( Meanface
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Widget request: Extract model data

Post by AF »

Where would I find the details on parsing and extracting all the data in an s3o?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Widget request: Extract model data

Post by jK »

Spring is what? O p e n S o u r c e :p
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: Widget request: Extract model data

Post by Tribulex »

jK wrote:jK is what? L u a / S p r i n g W i z a r d :p
Please bless me with your powers.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Widget request: Extract model data

Post by Argh »

He can't, that involves answering questions, and he doesn't do that until you're semi-competent.

OK...

1. Kloot, do you have any source you'd be willing to share? All I want, personally, is to be able to read a single-object S3O (i.e., it's 'base'). That would be fine, for the things I want to do (read model data for Lua rendering, instead of having to build the display lists in Lua, or porting said objects to OBJ and manually parsing their points, blech).

2. If no... here's what we need to read:

http://github.com/spring/spring/blob/a2 ... Parser.cpp

I'm stuck at step 1 of the process: how do we convert the header and the rest of the hex back into a format we can use?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Widget request: Extract model data

Post by Argh »

OK... how's about an easier idea: an OBJ parser? I might be able to do that, it's a non-hex format. Let me look at some stuff.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Widget request: Extract model data

Post by Argh »

OK, so an OBJ is pretty close to being a display list already. The data we need is:

For each vertex:

Vertex Coordinates:
v 5.956962 0.000000 -14.999999

Vertex Normal:
vn 0.000000 0.242536 -0.970142

Texture coordinates (?)
vt 0.109027 0.142404 0.0

Triangles are defined by specifying the entry X of the vertex coodinates, the vertex normal coordinates, and the texture coordinates:
f 1/1/1 2/2/2 3/3/3

Where 1,2,3 are entries with vertex positions, normals, texture coordinates. Texture coordinates are in order- 1 would use the first entry, 2 would use the second entry, 3 would use the third (I assume that the 0.0 third entry is there for either material support or for 3D textures- not that important either way).

So... basically, we need to read the OBJ file, parse it into lists according to type, and use the "f" lists to build our display list.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Widget request: Extract model data

Post by aegis »

Argh wrote:I'm stuck at step 1 of the process: how do we convert the header and the rest of the hex back into a format we can use?
http://www.inf.puc-rio.br/~roberto/struct/
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Widget request: Extract model data

Post by Argh »

That's a C file, intended to add that functionality. Question then is: does our Lua allow for struct atm? If not, that would need to be added to the engine.

That said, if the struct is already a complete display list, it'd sure save some time. I suck at parsing / sorting, and the OBJ loader is basically all about that.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Widget request: Extract model data

Post by aegis »

routines to unpack C structs are for parsing binary data.
it would merely help you implement spring's parser.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Widget request: Extract model data

Post by Argh »

Right, you're unpacking the data, so that Lua can read it, then we'd have to go through the same routine as here:

http://github.com/spring/spring/blob/a2 ... Parser.cpp

To arrive at final TRIANGLE_STRIP display lists, more or less. The problem I have with attacking the problem that way is that, very simply, IDK if I can read that well enough to convert it, and it assumes a lot of utility / math functions are present (although some of that is available in LUPS, IIRC, such as cross).
Post Reply

Return to “Lua Scripts”