feature pics & error

feature pics & error

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

Moderator: Moderators

Post Reply
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

feature pics & error

Post by gajop »

How can I get/generate a picture of a feature? F.e, much like (most) of the units have a build picture, is there a way to get a picture of a feature, or generate it in a way - by rendering a picture of the model, f.e?
I recall seeing something about taking a snapshot of units... or something, is it possible to do that for features?

Also, when trying to draw a feature using the gl.FeatureShape, I sometimes get errors, and nothing gets drawn:

Code: Select all

Error: could not find a parser for model "" (unknown format?)
However, once I actually create that model it gets displayed just fine.
Example youtube video posted, it seems to be the case for all tree features in BA f.e.
http://www.youtube.com/watch?v=o6y-YhLuD6o
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: feature pics & error

Post by knorke »

There is an icon generator by jK, it makes these images like in avatar.
It is in toolbox:
http://springrts.com/phpbb/viewtopic.php?t=27268
At top of file are the commands to start it. (it can take VERY long to generate all images)

To make buildpics of features, I would just create a fake unit in _post file of every feature. I do similiar for features that can have animations when they get crushed:

Code: Select all

--create a "death animation unit" for every feature
for name, fd in pairs(FeatureDefs) do
--	Spring.Echo ("feature: " .. ud.name or "nil")
	local u = {}
	for key,value in pairs(fd) do
		u[key]=value
	end
	--u.filename = "xxx"
	u.name = "unit" .. name
	u.script = "shatter.lua"
	u.objectname = fd.object
	u.maxDamage = 1
	u.hideDamage = true
	u.levelGround=false
	UnitDefs [u.name] = u
end
For each feature named "tree" this will give you a unit "unit_tree"
However, once I actually create that model it gets displayed just fine.
Example youtube video posted, it seems to be the case for all tree features in BA f.e.
You mean the engine trees?
It might be that object3d is nil for them, iirc they use drawType = some number.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: feature pics & error

Post by Forboding Angel »

It's also very picky and likes to break at the drop of a hat, but it's pretty much the only recourse. Cozy up to infolog.

Have you checked the buildpics in spring features? Chances are, I've probably already generated them.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: feature pics & error

Post by gajop »

knorke wrote:There is an icon generator by jK, it makes these images like in avatar.
It is in toolbox:
http://springrts.com/phpbb/viewtopic.php?t=27268
At top of file are the commands to start it. (it can take VERY long to generate all images)
oww, it was here all along!
great, that'll be useful - already added pictures of units that lacked buildicons, such as chickens
knorke wrote: To make buildpics of features, I would just create a fake unit in _post file of every feature. I do similiar for features that can have animations when they get crushed:

Code: Select all

--create a "death animation unit" for every feature
for name, fd in pairs(FeatureDefs) do
--	Spring.Echo ("feature: " .. ud.name or "nil")
	local u = {}
	for key,value in pairs(fd) do
		u[key]=value
	end
	--u.filename = "xxx"
	u.name = "unit" .. name
	u.script = "shatter.lua"
	u.objectname = fd.object
	u.maxDamage = 1
	u.hideDamage = true
	u.levelGround=false
	UnitDefs [u.name] = u
end
For each feature named "tree" this will give you a unit "unit_tree"
I tried adding a "featuredefs_post.lua" file in the Gamedata folder. However that would just crash telling me that UnitDefs table doesn't exist.
If I put it in the "unitdefs_post.lua" file it would tell me that there is no FeatureDefs table.
I'm trying to put this in the toolboxes Gamedata folder so i don't have to copy/paste it for every mod out there. I did check and it seems that dependencies' gamedata folder gets loaded before toolboxes, so that should be ok. What am I missing here?
knorke wrote:
However, once I actually create that model it gets displayed just fine.
Example youtube video posted, it seems to be the case for all tree features in BA f.e.
You mean the engine trees?
It might be that object3d is nil for them, iirc they use drawType = some number.
Yeah, they seem to have drawType from -1 to #somepositivenumber (exlcluding 0). No idea what to do with that though...
Forboding Angel wrote:It's also very picky and likes to break at the drop of a hat, but it's pretty much the only recourse. Cozy up to infolog.

Have you checked the buildpics in spring features? Chances are, I've probably already generated them.
$ ls
features modinfo.lua objects3d unittextures
I don't see any pictures. I also won't need it if I figure out how to generate units from features as knorke suggested. Also, it's quite an impressive feature pack. I'm thinking of adding it as a default dependency for the scenario editor.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: feature pics & error

Post by knorke »

I tried adding a "featuredefs_post.lua" file in the Gamedata folder. However that would just crash telling me that UnitDefs table doesn't exist.
If I put it in the "unitdefs_post.lua" file it would tell me that there is no FeatureDefs table.
oh.
i have it in anydefs_post.lua, dont know if you need to have something special in defs.lua or something. (i just stole from zwszg iirc)
that is also in springtanks, so maybe check it out there. (mod is broken atm but just look at those files)
pastebin of defs.lua for quicker looking:
http://pastebin.com/WfgFKMCG

btw, not sure why i commented out the ud.filename, some time ago it was needed. http://springrts.com/phpbb/viewtopic.ph ... me#p487647
maybe commented out because was no longer needed or i was testing and forgot :roll:

The default trees are generated somewhere in engine..
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: feature pics & error

Post by gajop »

Well, I managed to populate it as instructed but I'm getting this when running it with BAR.

Code: Select all

[f=0000036] Error: error = 2, LuaRules/draw.lua, error = 2, luagadgets/gadgets.lua, error = 2, LuaRules/Configs/UnitMaterials/1_normalmapping.lua, [string "LuaRules/Configs/
UnitMaterials/1_normalmapp..."]:108: attempt to index local 'rawstr' (a nil value)
I tried adding some values from a random UnitDef, but wasn't sure what's needed, so that didn't work out (adding all the values resulted in really nasty stuff http://i.imgur.com/CcWrs.jpg)
It seems to be working with BA though, at least that didn't crash (I've set it to generate stuff, will take a while).
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: feature pics & error

Post by smoth »

What do you need the pictures of? how many?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: feature pics & error

Post by gajop »

smoth wrote:What do you need the pictures of? how many?
I need one picture (similar to the build icon) of every unit and feature for any mod :).[/quote]
Realistically however, I plan to generate those icons for some of the top mods/games/feature packs that will work with toolbox, using the existing icon generator.
It works OK-ish, although it can crash (and take spring with it).
An example crash has been posted below (happens for Spring Features, for metal.s3o, which is referenced in the /features/smoth/metal.lua ;)).
http://pastebin.ca/2173440 @ line 455.
Only problem is I can't currently see what is missing (can't really thus figure out a way on which features to ignore as invalid... and it takes time to run it all), as f.e metal.s3o exists.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: feature pics & error

Post by FLOZi »

:? why on earth?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: feature pics & error

Post by gajop »

FLOZi wrote::? why on earth?
why what?
If you're asking why I need an icon, well, so I can have an icon by which users can recognize units & features http://www.youtube.com/watch?v=4q-V6ODj7z0, instead of having some placeholder icons like in http://www.youtube.com/watch?v=4q-V6ODj7z0#t=43s.
Images are just processed faster than text (even in this case when they don't exactly render the object).
If you're asking why stuff's crashing, dunno :)
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: feature pics & error

Post by FLOZi »

http://springrts.com/wiki/Lua_OpenGL_Api#Textures

Though I see the issue with features. :|

Still trying to build some 'collection' of common features just seems like it is doomed to always be out of date. If your editor is built on toolbox, and toolbox is generally run on top of a real game, and contains the icon generator code, maybe some button 'rebuild feature icons for current game' (could even have an option to only build icons that are missing?)

edit: Going back to the original post - your problem is only with the engine generated trees (feature name 'treetype1' etc).
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: feature pics & error

Post by knorke »

It works OK-ish, although it can crash (and take spring with it).
An example crash has been posted below (happens for Spring Features, for metal.s3o, which is referenced in the /features/smoth/metal.lua ;)).
http://pastebin.ca/2173440 @ line 455.
fault of the featuredefs from the springfeatures archive.
spring crashs even if you spawn that feature normally.

in metal.lua it says
object="metal.s3o",
needs to be
object="features/smoth/metal.s3o",

Same with neutralhlvlanding_dead.lua
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: feature pics & error

Post by gajop »

ok i'll fix them and check if the rest are fine...
but is there any way to programmatically check if paths are proper without crashing spring?
VFS.FileExists(u.objectname) would return true for the metal one, and false for many others that actually had proper paths
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: feature pics & error

Post by Beherith »

gajop wrote:Well, I managed to populate it as instructed but I'm getting this when running it with BAR.

Code: Select all

[f=0000036] Error: error = 2, LuaRules/draw.lua, error = 2, luagadgets/gadgets.lua, error = 2, LuaRules/Configs/UnitMaterials/1_normalmapping.lua, [string "LuaRules/Configs/
UnitMaterials/1_normalmapp..."]:108: attempt to index local 'rawstr' (a nil value)
I tried adding some values from a random UnitDef, but wasn't sure what's needed, so that didn't work out (adding all the values resulted in really nasty stuff http://i.imgur.com/CcWrs.jpg)
It seems to be working with BA though, at least that didn't crash (I've set it to generate stuff, will take a while).
Relevant code from 1_normalmapping.lua:

Code: Select all

elseif (udef.model.type == "s3o") then
103	    local modelpath = udef.model.path
104	    if (modelpath) then
105	      --// udef.model.textures is empty at gamestart, so read the texture filenames from the s3o directly
106	
107	      local rawstr = VFS.LoadFile(modelpath)
108	      local header = rawstr:sub(1,60) 
Seems like the modelpath isn't read correctly, and the VFS.LoadFile fails.
Can you tell me more info as to what you were adding to BAR?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: feature pics & error

Post by gajop »

Beherith wrote:
gajop wrote:Well, I managed to populate it as instructed but I'm getting this when running it with BAR.

Code: Select all

[f=0000036] Error: error = 2, LuaRules/draw.lua, error = 2, luagadgets/gadgets.lua, error = 2, LuaRules/Configs/UnitMaterials/1_normalmapping.lua, [string "LuaRules/Configs/
UnitMaterials/1_normalmapp..."]:108: attempt to index local 'rawstr' (a nil value)
I tried adding some values from a random UnitDef, but wasn't sure what's needed, so that didn't work out (adding all the values resulted in really nasty stuff http://i.imgur.com/CcWrs.jpg)
It seems to be working with BA though, at least that didn't crash (I've set it to generate stuff, will take a while).
Relevant code from 1_normalmapping.lua:

Code: Select all

elseif (udef.model.type == "s3o") then
103	    local modelpath = udef.model.path
104	    if (modelpath) then
105	      --// udef.model.textures is empty at gamestart, so read the texture filenames from the s3o directly
106	
107	      local rawstr = VFS.LoadFile(modelpath)
108	      local header = rawstr:sub(1,60) 
Seems like the modelpath isn't read correctly, and the VFS.LoadFile fails.
Can you tell me more info as to what you were adding to BAR?
I was trying to add Spring Features and generate units from features so I could render those build icons, as instructed in this thread. Doesn't really matter anymore as I managed to generate them in BA, so I should be able to use them in BAR.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: feature pics & error

Post by Beherith »

Is there any specific reason you wish to generate units from features? Also, did you notice any issue with the 1-bit alpha on trees and such when generating icons?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: feature pics & error

Post by gajop »

these are some of those features build icons:
http://dl.dropbox.com/u/29384665/buildicons.7z
so there are some obvious problems with them, jk told me it could be fixed by adding some lines;
same thing happens when drawing those features with just gl.FeatureShape (without any texture binding and what not)
[23:18:03] <[LCC]jK> <[dere]gajop> they seem to have textures.. but also those weird rectangles/triangles > cause iconbuilder doesn't handle alpha channel iirc
[23:18:17] <[LCC]jK> but that's a 3liner in the shader
[23:18:29] <[LCC]jK> + a 3 liner in texture binding
The reason I did it was because I wanted to generate build pics from those features, so I can have that thing on the right (helps when you can visually browse features): http://i.imgur.com/QJpkH.jpg. It's not really a "BAR" thing, I've just been testing my scenario editor with BA/BAR (the latest version of BAR has some issues with attack orders so will probably have to revert to using BA instead, I was mainly using BAR since it was pretty).
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: feature pics & error

Post by Beherith »

The attack orders bug with BAR was fixed yesterday.
Post Reply

Return to “Lua Scripts”