AggrorJorn Posted January 20, 2010 Share Posted January 20, 2010 I got this script running last weekend but I can't seem to get it working again. I'm using a pivot point that loads all kinds of rooms from a house. The loading goes well but when I delete the house, the rooms are still there. Also, the rooms do not move when I'm moving the gizmo. house.lua: require("scripts/class") local class=CreateClass(...) function class:CreateObject(model) local object=self.super:CreateObject(model) self.basement=LoadModel("abstract::matt_house_basement.gmf") self.basement:SetParent(self.model) function object:Free(model) self.super:Free() end end basement.lua: require("scripts/class") local class=CreateClass(...) function class:CreateObject(model) local object=self.super:CreateObject(model) object.model:SetCollisionType(COLLISION_SCENE) function object:Free(model) self.super:Free() end end Quote Link to comment Share on other sites More sharing options...
gordonramp Posted January 20, 2010 Share Posted January 20, 2010 Have you updated lately? The reason I ask is because my 'change a scene' code has developed an error on exit which wasn't there a week ago. And I updated a couple of times. Quote AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64. Link to comment Share on other sites More sharing options...
AggrorJorn Posted January 20, 2010 Author Share Posted January 20, 2010 Have you updated lately? The reason I ask is because my 'change a scene' code has developed an error on exit which wasn't there a week ago. And I updated a couple of times. I've updated an hour ago. Quote Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted January 20, 2010 Share Posted January 20, 2010 I believe it should be like that. Your Parent "House" doesn't tell the child to clear, just because you remove it. You must specify.. I think. require("scripts/class") local class=CreateClass(...) function class:CreateObject(model) local object=self.super:CreateObject(model) self.basement=LoadModel("abstract::matt_house_basement.gmf") self.basement:SetParent(self.model) function object:Free(model) self.basement:Free() self.super:Free() end end Quote AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD Link to comment Share on other sites More sharing options...
macklebee Posted January 20, 2010 Share Posted January 20, 2010 try this: require("scripts/class") local class=CreateClass(...) function class:CreateObject(model) local object=self.super:CreateObject(model) object.basement=LoadModel("abstract::matt_house_basement.gmf") object.basement:SetParent(object.model,0) function object:Free(model) self.super:Free() 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...
Niosop Posted January 20, 2010 Share Posted January 20, 2010 Destroying the parent will remove the child. Try object.basement instead of self.basement and object.model instead of self.model Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
macklebee Posted January 20, 2010 Share Posted January 20, 2010 self.basement works just fine (even though self refers to class in this case)... but the parent needs to be object.model... 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...
VicToMeyeZR Posted January 20, 2010 Share Posted January 20, 2010 yeah, I was thinking it need to be Parent should be object.model I wasn't sure if the child was destroy automatically or not. Quote AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD Link to comment Share on other sites More sharing options...
macklebee Posted January 20, 2010 Share Posted January 20, 2010 for local coordinates of the parent object.basement:SetParent(object.model,0) for global coordinates: object.basement:SetParent(object.model,1) 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...
Rick Posted January 20, 2010 Share Posted January 20, 2010 I always just set the position of the loaded model to the editor model in the update method. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted January 20, 2010 Author Share Posted January 20, 2010 I'm gonna check al your suggestions tommorow. thanks for al your replies! Quote Link to comment Share on other sites More sharing options...
macklebee Posted January 20, 2010 Share Posted January 20, 2010 from what i gather he is using a common pivot point for the rooms... so just set the parent and be done with it... no reason to set a position in the update 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...
Rick Posted January 21, 2010 Share Posted January 21, 2010 If you hide a parent does the child get hidden also? If so that could be an issue. These models in the editor have a sphere mesh & body to them. I would think if you had enough of them it "could" produce a loss in fps that wouldn't be needed if you could just hide them. Hence you would need a ton of them, but not sure how many this would produce for him. That model in the editor isn't needed in game, just in the editor to place things. If I'm reading what he's doing right. Maybe not. Quote Link to comment Share on other sites More sharing options...
macklebee Posted January 21, 2010 Share Posted January 21, 2010 If you hide a parent does the child get hidden also? If so that could be an issue. These models in the editor have a sphere mesh & body to them. I would think if you had enough of them it "could" produce a loss in fps that wouldn't be needed if you could just hide them. Hence you would need a ton of them, but not sure how many this would produce for him. That model in the editor isn't needed in game, just in the editor to place things. If I'm reading what he's doing right. Maybe not. A child hides whenever the parent hides but the parent doesn't hide when the child is hidden. And this is an actual model with its own PHY body, not some primitive being constructed via code that requires a dummy mesh to be used for selection. When the parent/child is hidden so is its phy body. 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...
Rick Posted January 21, 2010 Share Posted January 21, 2010 Ah, when I saw self.basement=LoadModel("abstract::matt_house_basement.gmf") self.basement:SetParent(self.model) it looked like he was just loading one part of the room for each editor model. I'm confused as to why would he need to load the gmf in code? Why not just have the gmf be the model he drags into the editor? Quote Link to comment Share on other sites More sharing options...
macklebee Posted January 21, 2010 Share Posted January 21, 2010 ah.. ok... i was wondering what that statement was about.. at least I hope he isn't using a dummy mesh then loading the all the rooms with lua... hopefully that code is the lua script for the actual house model. actually if he is doing it the way i think he is with each model having a common pivot/origin to each other, then it would make loading the extra room models easy... perhaps you could even set up a property dialog to determine which rooms get loaded... that way you could have many different house configurations but only actually have one common script. I'm confused as to why would he need to load the gmf in code? Why not just have the gmf be the model he drags into the editor? well seems like it would be easier to just have the house and basement as one model... but if he was going to expand on that script with like i mentioned with the properties dialog, he could decide what else gets loaded with the main house model... 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...
Rick Posted January 21, 2010 Share Posted January 21, 2010 That would be pretty cool. The crappy part about it though is it's pretty static. I wish the settings were more dynamic. I also wish it had a button so we could add things on the fly. For example, if you press the "Add Room" button it adds another settings section for another room to load. I think you might be limited in the placement of the rooms though, or that property box would need to be pretty elaborate to allow to place rooms anywhere. Quote Link to comment Share on other sites More sharing options...
macklebee Posted January 21, 2010 Share Posted January 21, 2010 That would be pretty cool. The crappy part about it though is it's pretty static. I wish the settings were more dynamic. I also wish it had a button so we could add things on the fly. For example, if you press the "Add Room" button it adds another settings section for another room to load. I think you might be limited in the placement of the rooms though, or that property box would need to be pretty elaborate to allow to place rooms anywhere. yeah at some point the properties box would get a little too unwieldy with all of the options i would guess... but actually, i think there might be an issue with doing it this way... it doesn't appear that the PHY file gets loaded when you load a gmf via a script... hmmm... --EDIT-- ok it does... you just need to set the collisiontype of the child... 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...
AggrorJorn Posted January 21, 2010 Author Share Posted January 21, 2010 Ah, when I saw self.basement=LoadModel("abstract::matt_house_basement.gmf") self.basement:SetParent(self.model) it looked like he was just loading one part of the room for each editor model. I'm confused as to why would he need to load the gmf in code? Why not just have the gmf be the model he drags into the editor? I removed all the other rooms for the sake of the topic. I load around 10 rooms in total I work as follow: I have a single pivot point with no further mesh. This pivot is called 'house'. The house loads all the different room of the entire house. Because of the offset from each room, I don't need to position them. Every room can have its own code if needed. I can walk around in the house since every room has a phy file. The pivot itself doesn't have a phy file. Quote Link to comment Share on other sites More sharing options...
Rick Posted January 21, 2010 Share Posted January 21, 2010 I get it. So in your modeling program you actually modeled these rooms offset from the origin. I would think allowing to position the rooms in the editor would be more flexible. Is it that big of a pain to get them lined up correctly in the editor? (I meant that as an actual question not like a smartass like it reads ) You pivot object has a gmf though right? I was under the impression that all those objects needed a gmf even if it was the small sphere. Even the lights have a gmf associated with them. If that's the case then I think a phy file is created automatically when you run the game even if you don't want it. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted January 21, 2010 Author Share Posted January 21, 2010 I get it. So in your modeling program you actually modeled these rooms offset from the origin. I would think allowing to position the rooms in the editor would be more flexible. Is it that big of a pain to get them lined up correctly in the editor? (I meant that as an actual question not like a smartass like it reads ) You pivot object has a gmf though right? I was under the impression that all those objects needed a gmf even if it was the small sphere. Even the lights have a gmf associated with them. If that's the case then I think a phy file is created automatically when you run the game even if you don't want it. I simply copied the road object files and renamed everything. Ofcourse I cleaned the matt and lua file. I build an entire house in 3d max as I can position with very much accuracyg. When I export every single room at the time, the offset is being preserved. Ofcourse I can position every room by hand, but it never got that precise as when I used my current method (believe me: I tried a lot! The problem here is that the walls are made by flip polygons. This allows watching through one side of the wall. Therefore you can't see where the walls are intersecting. It just takes a lot more time.) I can still position every single room separate inside the editor, but because there are so many rooms I want to create some sort of prefab that places every room in correct place. Quote Link to comment Share on other sites More sharing options...
macklebee Posted January 21, 2010 Share Posted January 21, 2010 interesting aggror... but there's no reason to use an extra object file. just have your entire house model put together with all the rooms... determine where you want a common pivot/origin for all of the room models. export them individually with the offset built in... then in the main house model's script, just add code to load the extra rooms as needed. 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...
AggrorJorn Posted January 21, 2010 Author Share Posted January 21, 2010 interesting aggror... but there's no reason to use an extra object file. just have your entire house model put together with all the rooms... determine where you want a common pivot/origin for all of the room models. export them individually with the offset built in... then in the main house model's script, just add code to load the extra rooms as needed. isn't that the thing I'm already doing? Or do you mean: load for example the basement as the foundation (instead of the pivot), and it that lua file, load all the other rooms? Quote Link to comment Share on other sites More sharing options...
macklebee Posted January 21, 2010 Share Posted January 21, 2010 Or do you mean: load for example the basement as the foundation (instead of the pivot), and it that lua file, load all the other rooms? yes... thats exactly what i mean... no reason to use a dummy mesh when you already have a perfectly good model mesh.. or use the house as the foundation... makes no difference... 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...
Rick Posted January 21, 2010 Share Posted January 21, 2010 [EDIT] Nevermind I see. I guess the only reason to use the pivot object would be if you want functionality that all your rooms would share it could all be done in that object instead of each room. But yeah, either way works. 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.