If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
04May2012, 01:16  #1 
Registered
Join Date: May 2012
Posts: 1

How to make a 3d object relationship script?
I'm a complete programming newbie so hate me if you want to.
Here's what I need to do: Make a 3D object, label/class it as Fire Sprinkler Make another set of 3D Objects  walls, obviously classed as walls. Make a set of intrinsic rules such as Fire Sprinkler objects must be at least 1 foot away from wall objects. Define a rule that says Fire Sprinkler objects must be at least 4 feet away from each other, but cannot be more than 15 feet away from each other.. Have a routine automatically space Fire Sprinkler objects within the walls, while trying to space sprinkler objects as far apart as is possible while still keeping within the rules. I don't care how long it takes to learn this, I will devote as much time as needed. I understand I need to read books on java/c++ etc. I just can't get a grasp on what the total plan to accomplish this would look like. What comes after learning to code? Is there not some easier way than by starting from absolute scratch? Is there opensource software out there that could be used as a starting point? Is what I'm trying to do even possible with current technology? And I guess this is a long shot, but is there any software out there that lets you input the types of parameters I just listed and do this already? 
04May2012, 10:47  #2  
Regular
Join Date: Jun 2004
Posts: 11,088

Quote:
Fire Sprinkler objects must be at least 4 feet away from each other udk would let you do this just create a appropriate size bounding box around it http://udk.com/ Have a routine automatically space Fire Sprinkler objects within the walls, while trying to space sprinkler objects as far apart as is possible while still keeping within the rules. cant imagine udk supporting that.
__________________
Guardian of the Bodacious Three Terabytes of Gaming Goodness™ 

04May2012, 12:48  #3 
Member
Join Date: Oct 2008
Posts: 139

Sounds more like 2D problem to me.
If you don't worry too much with piping efficiency and obstructions like concrete beams. Maybe you can start by studying circle packing algorithm. And look at processing as a medium to play with your algorithm. 
04May2012, 13:23  #4 
Regular
Join Date: Jun 2004
Posts: 11,088

one thing that I imagine would let you define rules on object spacing is speedtree
you'd need to tell it to place hydrant models instead of trees, No idea if there is a demo version available
__________________
Guardian of the Bodacious Three Terabytes of Gaming Goodness™ 
04May2012, 14:03  #5 
Member
Join Date: May 2010
Location: Kings Langley
Posts: 122

If you're just worried about placing the sprinklers on a roof (i.e. not varying their heights within the building) then it's really a 2D problem and doesn't require 3D objects, classes or labels, You are finding points on a 2D shape.
You can also ignore the rule about staying a foot away from a wall as you just make the surface you're finding points on a foot smaller than your roof. Maximal Poisson Disk Sampling (MPDS) would take a surface and spread a set of points as widely as possible. An inefficient way of solving your problem would be to run MPDS with N points. If it spreads the points out too much so that there's a point more than your maximum distance then add more points and run it again. If all the points are within your maximum limit then reduce the number of points until they're not  that's the point where they're at maximum spread within your rules. Note: there's probably much more efficient ways of doing it and having a good first guess of the number of points you need would save time but it'd work. 
04May2012, 14:47  #6 
Member
Join Date: Mar 2010
Posts: 145

I'm wondering whether the 'not more than 15ft from each other' is actually meant to be 'no point on the roof more than 7.5ft from a sprinkler' (i.e. the roof must be entirely covered). If this is a case you wouldn't be able to assume this.

04May2012, 14:53  #7 
Member
Join Date: May 2010
Location: Kings Langley
Posts: 122

true but I read not more than 15ft from one another to mean not more than 15ft from one another ;P

05May2012, 05:44  #8 
Senior Member
Join Date: Mar 2006
Posts: 2,337

There must be many different ways to solve this, but fundamentally this is going to be problem for which it is hard, if not impossible, to prove that you have an optimal solution.
My way to tackle this would be something along the lines of a simulated annealing algorithm (google it) where you start with a bunch of randomly chosen sprinklers and then iteratively move them around until you have a solution with the lowest cost function. Now how to do this when you don't know to program? I suggest having a look at Matlab and its Global Optimization Toolbox. It will take the low level implementation details out of the picture and leave only leaves the part of modeling the cost function. That is: assign mathematical equations to the constraints you want to see validated. Last edited by silent_guy; 05May2012 at 05:50. 
05May2012, 06:07  #9 
Regular
Join Date: Jun 2004
Posts: 11,088

Lets say he actually wants to model a large building and have something that would auto decide sprinkler locations would matlab do that ?
__________________
Guardian of the Bodacious Three Terabytes of Gaming Goodness™ 
05May2012, 08:47  #10  
Senior Member
Join Date: Mar 2006
Posts: 2,337

Quote:
The typical way to get going with these kinds of things is to model it first with some highlevel language for basic problems and iterate quickly to find something that works. Start with a room with 4 walls, see how that works. Then add a separator wall and see if your algorithm still works. Until you're satisfied that you've covered all the corner cases etc. Later, if you're really still into it, you can start thinking about writing something that automatically converts your Sketchup or CAD model into your mathematical model. But most people will have given up by that time. And if you make it past that stage and you get into performance problems, you could start to consider learning C/C++/Java and convert your Matlab script into a compiled language. As for autodeciding the sprinkler position: it's not about deciding anything, it's stating the problem as problem of (#sp * 3) variables and defining a cost function that includes the distance to the wall and distance of the sprinklers to each other etc. You give the sprinkler positions some random initial position. Then you throw your optimizer at it. Since the cost function is going to be one with a lot of nonoptimal local minima and a ton of variables, you'll need something like simulated annealing to first explore a lot of options and slow down to converge to the local minimum of the best solution up to then. That said, I'm sure that there will be other algorithms that work as well or much better. 

Thread Tools  
Display Modes  

