Comments (1)
Hey! Thanks for the suggestion.
If I understand your suggestion correctly, these sub-shapes would not change the outline of the rooms, so they would not change the behaviour of the layouting algorithm. If this is the case, it's probably not a good idea to add these sub-shapes to the algorithm itself because it would slow it down.
It would be probably better to implement this as a postprocessing step on the output of the algorithm. I added (release 1.0.6, master branch) a simple extension method to the IRoom interface that should help you do this. It could be done as follows:
- Create classic room descriptions for room types
- Define your slots for each room type e.g. as lists of
IntVector2
and create a mapping from room types to these lists of slots - Run the algorithm, it produces a position and a room shape for each node in the input graph
- Take the generated layout, go through each room
- find associated slots
- the room may have been transformed (e.g. rotated and moved) - so you have to transform all the slots - there is a
TransformPointToNewPosition
extension method on theIRoom
interface and you should use it on all your slots - now you have the slot positions of a given room in the final layout
I also implemented an integration test that should demonstrate how it could be done (here):
// Create a rectangular room shape
// Move it away from (0, 0) so that we can properly test the functionality
var rectangleShape = GridPolygon.GetRectangle(10, 4) + new IntVector2(10, 10);
// Create points to be transformed
// These could be for example traps, spawn points, etc.
// We use points of the rectangle here because it is easy to check that the transformation is correct.
var pointsToTransform = rectangleShape.GetPoints();
var mapDescription = new MapDescription<int>();
// Create simple graph with 2 vertices and 1 edge
mapDescription.AddRoom(0);
mapDescription.AddRoom(1);
mapDescription.AddPassage(0, 1);
// Add the rectangle shape
mapDescription.AddRoomShapes(new RoomDescription(rectangleShape, new OverlapMode(1, 0)));
var layoutGenerator = LayoutGeneratorFactory.GetDefaultChainBasedGenerator<int>();
var layout = layoutGenerator.GetLayouts(mapDescription, 1)[0];
foreach (var room in layout.Rooms)
{
// The points were chosen to be the points of the polygon, so after transforming them, they should
// be equal to the room.Shape + room.Position points
var transformedPoints = pointsToTransform.Select(x => room.TransformPointToNewPosition(x));
var expectedPoints = (room.Shape + room.Position).GetPoints();
Assert.That(transformedPoints, Is.EquivalentTo(expectedPoints));
}
Is this a solution to your problem/suggestion?
from edgar-dotnet.
Related Issues (20)
- Performance: simulated annealing parameters
- Chain decomposition: faces connected by chains
- Improve exception messages
- Allow doors with zero length HOT 1
- Update config format to reflect new transformations
- Refactor configuration spaces generator
- .NET Standard
- Throwing exceptions when trying to get layouts. HOT 5
- Add possibility to choose that no two neighbouring rooms should be same
- Two-stage generation
- Output 'points' or json structure to determine position of the rooms on output images? HOT 2
- A doorway to the outside? HOT 2
- Room shape smoothing
- Algorithm simplification
- Performance optimization - evolving generator configurations
- Roadmap
- Notes on performance
- Get json HOT 2
- Memory leak
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edgar-dotnet.