Issue with lua hierarchy file and 3d objects positions

Issue with lua hierarchy file and 3d objects positions

Share and discuss visual creations and creation practices like texturing, modelling and musing on the meaning of life.

Moderators: MR.D, Moderators

User avatar
enetheru
Posts: 627
Joined: 11 Jun 2010, 07:32

Issue with lua hierarchy file and 3d objects positions

Post 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
User avatar
enetheru
Posts: 627
Joined: 11 Jun 2010, 07:32

Re: Issue with lua hierarchy file and 3d objects positions

Post 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!!!!???
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Re: Issue with lua hierarchy file and 3d objects positions

Post by Das Bruce »

Why is it nested like that to begin with?
User avatar
enetheru
Posts: 627
Joined: 11 Jun 2010, 07:32

Re: Issue with lua hierarchy file and 3d objects positions

Post 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.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Issue with lua hierarchy file and 3d objects positions

Post by Beherith »

aaaaaand this is why I use s3o :)
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Issue with lua hierarchy file and 3d objects positions

Post 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.
User avatar
enetheru
Posts: 627
Joined: 11 Jun 2010, 07:32

Re: Issue with lua hierarchy file and 3d objects positions

Post by enetheru »

Kloot wrote: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.
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 ;)
User avatar
enetheru
Posts: 627
Joined: 11 Jun 2010, 07:32

Re: Issue with lua hierarchy file and 3d objects positions

Post by enetheru »

Code: Select all

        globalvertexoffsets = false, -- vertices in global space?
        localpieceoffsets = true, -- offsets in local space?
this.........
Image
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Re: Issue with lua hierarchy file and 3d objects positions

Post by rattle »

^ happens all the time I try to do the most basic things in blender
User avatar
enetheru
Posts: 627
Joined: 11 Jun 2010, 07:32

Re: Issue with lua hierarchy file and 3d objects positions

Post 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
Image
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: Issue with lua hierarchy file and 3d objects positions

Post 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..
User avatar
enetheru
Posts: 627
Joined: 11 Jun 2010, 07:32

Re: Issue with lua hierarchy file and 3d objects positions

Post 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?
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Issue with lua hierarchy file and 3d objects positions

Post 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.
User avatar
enetheru
Posts: 627
Joined: 11 Jun 2010, 07:32

Re: Issue with lua hierarchy file and 3d objects positions

Post 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. :)
User avatar
enetheru
Posts: 627
Joined: 11 Jun 2010, 07:32

Re: Issue with lua hierarchy file and 3d objects positions

Post 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
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Issue with lua hierarchy file and 3d objects positions

Post by jK »

you forgot 3do ;)
Post Reply

Return to “Art & Modelling”