Page 1 of 2
Issue with lua hierarchy file and 3d objects positions
Posted: 03 Sep 2012, 07:29
by enetheru
hi all,
Ive been trying to sort out my exporter to handle multiple objects nicely. however i've run into an issue where the object's offsets arent working properly.
from the below lua script I would expect an object in the middle, with four objects around it. problem is that the negative values aren't being respected and there are the south and east objects OK, but the north and west objects are in the centre. its driving me bonkers thinking that there's something simple I'm missing. Using spring 89.0
- test.zip
- (168.16 KiB) Downloaded 35 times
Code: Select all
--// Object Heirarchy File
--// Generated by Enetheru's Blender Export Script
test = {
pieces = {
[1] = {
name = "ROOT",
offset = {0.0, 0.0, 0.0},
[2] = {
name = "SOUTH",
offset = {0.0, 0.0, 8.0},
[3] = {
name = "EAST",
offset = {8.0, 0.0, 0.0},
[4] = {
name = "NORTH",
offset = {0.0, 0.0, -8.0},
[5] = {
name = "WEST",
offset = {-8.0, 0.0, 0.0},
},
},
},
},
},
},
radius = 10.0,
midpos = {0.0, 0.0, 0.0},
tex1 = "test1.dds",
--tex2 = "test2.dds",
numpieces = 5,
}
return test
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 03 Sep 2012, 08:13
by enetheru
OK finally figured it out.. but seriously WTF people...
the offsets are offsets from every second level of the heirarchy.
so root = 0th level.
root = root offset
level 1 = level 1 offset
level 2 = root offset+level 2 offset
level 3 = level 1 offset+ level 3 offset
level 4 = root offset + level 2 offset + level 4 offset
why!!!!???
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 03 Sep 2012, 08:16
by enetheru
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 03 Sep 2012, 08:46
by Das Bruce
Why is it nested like that to begin with?
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 03 Sep 2012, 08:50
by enetheru
Das Bruce wrote:Why is it nested like that to begin with?
I'm testing my blender exporter. I need to take care of hierarchy and it wasn't working as I expected.
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 03 Sep 2012, 11:27
by Beherith
aaaaaand this is why I use s3o :)
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 03 Sep 2012, 11:32
by Kloot
this is also why reinventing the wheel should be avoided.
http://springrts.com/phpbb/viewtopic.php?f=9&t=22635
that script is for Blender 2.44, but the logic should transfer over to newer versions.
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 03 Sep 2012, 14:54
by enetheru
Wow I've looked at that thread lots and lots and totally glossed over the blender export script.. I guess because I ignore anything to do with 2.4x series..
Thanks I should be able to merge logic hopefully.. however 2.5x and up is very different so it will be a complete re-write anyway.
Beherith wrote:aaaaaand this is why I use s3o :)
So what your saying is that if it was easier than your current workflow you would switch

have no fear. I will make you want to switch when you see the mostly finished result.
plus, you know how to script in python anyway(obj2s3o) so you will be able to make it better and fix bugs

Re: Issue with lua hierarchy file and 3d objects positions
Posted: 03 Sep 2012, 15:42
by enetheru
Code: Select all
globalvertexoffsets = false, -- vertices in global space?
localpieceoffsets = true, -- offsets in local space?
this.........

Re: Issue with lua hierarchy file and 3d objects positions
Posted: 03 Sep 2012, 16:04
by rattle
^ happens all the time I try to do the most basic things in blender
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 03 Sep 2012, 16:17
by enetheru
rattle wrote:^ happens all the time I try to do the most basic things in blender
I seem to replying to everything with images these days... birthdays messages are especially fun

Re: Issue with lua hierarchy file and 3d objects positions
Posted: 04 Sep 2012, 07:29
by SpliFF
Your script doesn't work because it's using the format for metadata based on Kloot's OBJ script not
the metadata format used by the assimp importer.
Valid metadata looks like:
Code: Select all
model = {
radius = 25.0,
height = 40,
midpos = {0,-20,0}, -- model center offset
tex1 = "corraid1_512.dds", -- same as S3O texture 1
tex2 = "corraid2_512.dds", -- same as S3O texture 2
invertteamcolor = true, -- invert tex1 alpha channel
fliptextures = true, -- turn textures upside down
pieces = {
root = {
rotate = {-90,0,0},
offset = {10,0,0}
},
turret = {
parent = "chassis",
rotateZ = 30,
offsetY = 20,
}
}
}
return model
The thing to note is that pieces aren't nested under parent objects but are part of a flat list. Hierarchy is determined by the value of the 'parent' key. The format does this to assist tools without a real Lua interpreter since the data can be processed using regexes and simple templates rather than being required to handle arbitrarily nested data. It also means you can alter the properties of a child object without having to know how it's nested. Also note that pieces use their name for the key, not a numeric index and a "name" property..
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 04 Sep 2012, 08:28
by enetheru
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 04 Sep 2012, 08:49
by enetheru
So basically, what your saying is that I've totally wasted days of time based on assumptions made due to shitty to no documentation in the wiki....
At least I had fun :)
this should help me solve many problems I think... and get to my end goal with more clarity, even if I do have to throw out some assumptions I've made..
can you point me to where in the source the lua is parsed?
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 04 Sep 2012, 09:20
by Beherith
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 04 Sep 2012, 09:25
by enetheru
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 04 Sep 2012, 10:46
by Kloot
SpliFF wrote:Your script doesn't work because it's using the format for metadata based on Kloot's OBJ script not the metadata format used by the assimp importer.
OBJ models are not read by the assimp importer...
SpliFF wrote:Also note that pieces use their name for the key, not a numeric index and a "name" property..
Also note that this has been supported by the OBJ importer since day 1.
enetheru wrote:
what your saying is that I've totally wasted days of time
You have not.
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 04 Sep 2012, 10:51
by enetheru
Kloot wrote:SpliFF wrote:Your script doesn't work because it's using the format for metadata based on Kloot's OBJ script not the metadata format used by the assimp importer.
OBJ models are not read by the assimp importer...
enetheru wrote:
what your saying is that I've totally wasted days of time
You have not.
yeah you are right I have learned a lot of things about the internals of blender which is my secondary goal. :)
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 04 Sep 2012, 15:34
by enetheru
OK, so how many pathways are there for models to be loaded into spring?
so far i have 3 if i am reading right
* assimp
* kloot's obj
* original s3o
Re: Issue with lua hierarchy file and 3d objects positions
Posted: 04 Sep 2012, 17:25
by jK
you forgot 3do
