Widget request: Extract model data

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
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Widget request: Extract model data

Post by Tribulex »

Can someone right me some code to extract all the vertex and edge data, or just give me the coordinates of all the polys. Basically, i need the coordinates so that I can draw a wireframe.


Cookies, Cake, and Win,
The Management
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Widget request: Extract model data

Post by Google_Frog »

Look at how Ghost Radar did it.
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 »

This is not what i need. Reread the post. I dont want to draw it, i want to get the coordinates of the vertices, edges, and/or faces. I want to use this data to produce a 3d line drawing, but im not asking HOW to draw it. Im asking HOW to get the data.

Edit: Sorry, if i misunderstand something, please explain further. Thanks.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Widget request: Extract model data

Post by knorke »

ghost radar draws transparent units iirc.
and other widgets can draw the units in certain ways, for example the outline widget, the xray widget, the highlight unit thing.
so maybe its possible to modify this shaders to make a wireframe drawing?
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 »

hmmmm, how to clarify.....


[quote="d_b"]im not asking HOW to draw it. Im asking HOW to get the data.[/quote][/color]
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Widget request: Extract model data

Post by jK »

AND STILL YOU DO NOT NEED THE DATA FOR DRAWING A WIREFRAME
User avatar
Peet
Malcontent
Posts: 4384
Joined: 27 Feb 2006, 22:04

Re: Widget request: Extract model data

Post by Peet »

You don't need the model data to draw a wireframe, you leave a shader under your pillow and the arghfairy comes in the night.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Widget request: Extract model data

Post by jK »

Code: Select all

gl.PolygonMode(GL.FRONT_AND_BACK,GL.LINE);
gl.Unit(unitId, true);
gl.PolygonMode(GL.FRONT_AND_BACK,GL.FILL);
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Widget request: Extract model data

Post by Argh »

Also, you can use a shader pass when running the gl.Unit() and do further manipulation of the data. So you can give that wireframe depth via color or color-cycle it or whatever you want really easily.

Spring won't currently just give us a vert list for a given Piece, so far as I know, but you can certainly do post-processing on the geometry, including vertex manipulation in GLSL.

That said, I don't think it's currently satisfactory. It should be possible to just request the raw Piece display list by Piece name, so that we can write specific shaders that don't require re-rendering the entire Unit, amongst other issues.
Satirik
Lobby Developer
Posts: 1688
Joined: 16 Mar 2007, 18:27

Re: Widget request: Extract model data

Post by Satirik »

you could also answer his question instead of thinking ahead of what he really needs
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: Widget request: Extract model data

Post by SpliFF »

Well the answer is simple. He can't. The only exposed interfaces I can see return piece transforms, not vertices. This probably belongs in feature requests. Given the feedback here you'd probably want to provide better justification for needing them since as others have pointed out you can do wireframes more efficiently using the existing drawing interfaces.

On the other hand if it's that important to you, you could read the vertex data out of the s3o file via VFS and do your own transforms.
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 »

Satirik wrote:you could also answer his question instead of thinking ahead of what he really needs
THANK YOU SATIRIK FOR NOT BEING SO INCREDIBLY DENSE

K thx spliff ill just parse the s3o
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Widget request: Extract model data

Post by Google_Frog »

Look at how Ghost Radar did it.
Did you look at how ghost radar did it? For all I know it extracts the vertexes then draws them.
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 »

Google_Frog wrote:
Look at how Ghost Radar did it.
Did you look at how ghost radar did it? For all I know it extracts the vertexes then draws them.

Code: Select all

function DrawGhosts()
  glColor(1.0, 1.0, 1.0, 0.35 )
  glDepthTest(true)

  for unitID, dot in pairs( dots ) do
		local x, y, z = spGetUnitPosition(unitID)
		local udef = udefTab[ dot["unitDefId"] ]
		local radius = max( udef["xsize"], udef["zsize"] ) * 0.5
		
		if ( dot["radar"] == true ) and ( dot["los"] == false ) and ( dot["unitDefId"] ~= nil ) and ( x ~= nil ) then		
		--	printDebug("DRAW udef: " .. dot["unitDefId"] .. " x: " .. x .. " y: " .. y .. " z:" .. z )
			if ( spIsSphereInView( x, y, z, radius ) ) then
				glPushMatrix()
				glTranslate( x, y + 5 , z)
				glUnitShape( dot["unitDefId"], dot["teamId"] )					      
				glPopMatrix()
			end
		end
	end

	glDepthTest(false)
 -- glBlending(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA); 
 -- glBlending(false)
 	glColor(1, 1, 1, 1)
end
So, where/how do i get this data from this code?
User avatar
det
Moderator
Posts: 737
Joined: 26 Nov 2005, 11:22

Re: Widget request: Extract model data

Post by det »

d_b wrote:
Satirik wrote:you could also answer his question instead of thinking ahead of what he really needs
THANK YOU SATIRIK FOR NOT BEING SO INCREDIBLY DENSE

K thx spliff ill just parse the s3o
Way to insult the people who are trying to help you.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Widget request: Extract model data

Post by Argh »

So, where/how do i get this data from this code?
You don't. gl.UnitShape is just sending you a display list, IIRC, just like gl.Unit does.

Anyhow, please let me know if you write a S3O parser that works, that would be wonderful- I've been wanting to load single meshes and stick them in display lists for some time now, but the code doesn't exist and I suck at writing such things.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Widget request: Extract model data

Post by zwzsg »

d_b wrote:So, where/how do i get this data from this code?

Code: Select all

glUnitShape( dot["unitDefId"], dot["teamId"] )
If you claim to need doing over-complex stuff like extracting the raw vertices data, then you need to lern2read code, or you risk losing all credibility.

Hint: It doesn't do what you ask for, but what you've been told to.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Widget request: Extract model data

Post by Argh »

Please understand that his question had two parts:

1. "How do I draw a wireframe?" That's easy, jK's example provides instructions, and it works.

2. "I want the raw data of the triangle strips, can I get that from Spring?" The answer, so far as I know, is "no, you can't", and while that's a Feature Request, it may be faster to just write a S3O parser that will provide that data from any given S3O and allow us to store that data for future use in a display list. I, for one, really want that, and would use it extensively.

At any rate, that's how I am reading what he's saying. So, maybe a bit less flaming, and a little bit clearer communication might be helpful here. Perhaps I'm wrong, and he just wants a bloody wireframe and that's all, but that's not what I am seeing, and a S3O parser would be *very* useful.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Widget request: Extract model data

Post by zwzsg »

And the original post show us what relationship connects 1 to 2 in the mind of the original poster:
d_b wrote:Basically, i need the coordinates so that I can draw a wireframe.
Hencefoth, the incredibly dense answere were actually hitting home.
Last edited by zwzsg on 29 Oct 2009, 21:28, edited 1 time in total.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Widget request: Extract model data

Post by Argh »

OK... but what if he wants to convert it to quads, instead of triangles, so that it looks professional?
Post Reply

Return to “Lua Scripts”