amit Posted July 27, 2012 Share Posted July 27, 2012 Hi, As far as i understand there is only one type of PropertyDialog for all objects if we use, require("scripts/myclass") local class=CreateClass(...) in the class lua script. But now I want to read the model while the creation of UI < class:InitDialog(grid) >, which seems to be not possible in current setting as model is created only when we create an instance of it, Right? < class:CreateObject() > q1) Is it possible to get and use model class, while ui creation? q2) Is it possible to create ui for each instance, and also created in CreateObject code, so ui can be customized as required! Also, all this had to be figured out, so any link to details of editor working would be great help. If any trouble understanding what I wrote, please let me know, I'll try to detail it more. Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 29, 2012 Share Posted July 29, 2012 if you are talking about adding custom properties in the ui for your model, then yes that is possible... look at the scripted objects that come with SDK as well as the numerous examples in the forum... as for making custom properties for each individual instance of an object, just set the options in the ui and control how that instance should behave by programming the rest of the script to respond to whatever settings you pick in the properties ui... maybe if you are more specific on what you are trying to do someone will be nice enough to help... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
amit Posted August 1, 2012 Author Share Posted August 1, 2012 Hi, Thanks, looked at few scripts in editor for various objects, The function InitDialog(grid), is the one which is responsible for the property ui, but the only connection i can see to the model is via, SetKey() function, which is like a callback to AddProperty(). What I want to do is to check the no of children for model, and its assigned materials and list them in the ui, so it can be edited as required. somehow I would like to access the model instance in InitDialog function, but was not able to do so. Any suggestions? Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 1, 2012 Share Posted August 1, 2012 you can change the material for the model and its corresponding LODs with the normal properties dialog - but it makes the change the same to all of them - Or are you asking how to set different materials to the different LODs? which is doable... just as long as you remember the current version of LE will apply the same material to all instances of a particular GMF. As for accessing the object model in the InitDialog function, you just need to put that function inside the CreateObject function. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
amit Posted August 1, 2012 Author Share Posted August 1, 2012 As for accessing the object model in the InitDialog function, you just need to put that function inside the CreateObject function. I didn't get it, ( not a lua programmer ), but InitDialog and CreateObject are both defined in class, <class>. Can you guide me with some code? Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 1, 2012 Share Posted August 1, 2012 are you trying to give each LOD a separate material? or are you just trying to change the material to one thing for every model instance and their LOD? Can you guide me with some code? how about you post what you have? Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
amit Posted August 2, 2012 Author Share Posted August 2, 2012 Please see the commented lines for my problem. require("scripts/class") local class=CreateClass(...) local gridme; function class:InitDialog(grid) local group gridme = grid self.super:InitDialog(grid) group=grid:AddGroup( "Abc" ) group:AddProperty("aaaa",PROPERTY_CHOICE,"") -- here i want to access the object/model instance but in all tried cases, -- I get error like "attempt to index field 'object' (a nil value)" -- local mymesh = class.super.object.model:GetChild(1) end function class:CreateObject(model) local object=self.super:CreateObject(model) function object:Init() -- This also does not, work. My guess is that this is not the place to code UI! --group=gridme:FindGroup( "Appearance" ) --group:AddProperty("aaaa",PROPERTY_CHOICE,"") end function object:SetKey(key,value) return self.super:SetKey(model,key,value) end function object:GetKey(key,value) return self.super:GetKey(key,value) end object:Init() end Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 3, 2012 Share Posted August 3, 2012 did you try to put the InitDialog() inside the CreateObject() function like I suggested? And since you never answered the question that I have asked twice now, I am going to assume you are trying to set the material for each stage of an LOD and show you how i would do it. require("scripts/class") local class=CreateClass(...) function class:CreateObject(model) local object=self.super:CreateObject(model) function class:InitDialog(grid) self.super:InitDialog(grid) group=grid:AddGroup("LOD Materials") local n for n = 0,CountModelLODEntities(object.model)-1 do group:AddProperty( "mat"..n, PROPERTY_FILE, "Material Files (*.mat):mat" ) end group:Expand(1) end function object:UnlockKeys() local m for m = 0,CountModelLODEntities(self.model)-1 do if self.model:GetKey("mat"..m)~=("" or nil) then GetModelLODEntity(self.model,m):Paint(LoadMaterial("abstract::"..self.model:GetKey("mat"..m))) end end end end Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
amit Posted August 4, 2012 Author Share Posted August 4, 2012 sorry for late reply, was trying to test the code you gave (modified to my requirement), but wasn't working for me, here it is: require("scripts/class") local class=CreateClass(...) function class:CreateObject(model) local object=self.super:CreateObject(model) function class:InitDialog(grid) local group, meshx, childrencount gridme = grid self.super:InitDialog(grid) meshx=object.model:GetChild(1) --return meshx:CountSurfaces() childrencount = meshx:CountChildren() group=grid:AddGroup( "Abc" ) group:AddProperty("aaaa",PROPERTY_INTEGER ,childrencount) end function object:Init() --group=gridme:FindGroup( "Xyz" ) --group:AddProperty("test",PROPERTY_CHOICE,"") end function object:SetKey(key,value) return self.super:SetKey(model,key,value) end function object:GetKey(key,value) --if key=="surfacecount" then -- abc=object.model:GetChild(1) -- --return abc:CountSurfaces() -- return abc:CountChildren() --else return self.super:GetKey(key,value) --end end object:Init() end the value of "aaaa" in group Abc is 0. If I uncomment all the code lines in GetKey() function, then the value comes to be 169 (which is right for my model). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.