reinterpretcat / utymap

Highly customizable library for procedural world generation based on real map data
Apache License 2.0
958 stars 151 forks source link

Building new objects with Flexible extension #129

Open chinnuGarg opened 5 years ago

chinnuGarg commented 5 years ago

Hello reinterpret cat, great library.

I am colliding Ethan 3D model to the building and trying to get latlong of the corners for the same building. If Ethan 3D model has already collided with the building, I will add a 3D cube on top of that building (as in https://github.com/reinterpretcat/utymap#flexible-extension) indicating the building’s location is already found.

On Collision of Ethan to the building, I am just getting the id of the building nothing more than that. And we need a node to use flexible extension. So is it possible to do this?

reinterpretcat commented 5 years ago

You could try to add your collision detection script via https://github.com/reinterpretcat/utymap/blob/master/unity/demo/Assets/Scripts/Core/Plugins/GameObjectBuilder.cs::BuildFromMesh Buildings are built in core library and they are materialized using BuildFromMesh method.

Another way is just to search for building's GameObject in scene using its id and knowing how are building names are generated.

Another way might involve search api implemented in core lib

chinnuGarg commented 5 years ago

I did try adding collision detection but it is just giving me building ID rather than latlongs.

reinterpretcat commented 5 years ago

Have you tried to store lat/lon in your custom MonoBehaviour when you're attaching it to gameobject?

chinnuGarg commented 5 years ago

What is the way to get the latlon for the buildings? Can I get it while i build the mesh in GameObjectBuilder css?

reinterpretcat commented 5 years ago

No, mesh geometry is already mapped to unity coordinates. Here you have raw geometry: https://github.com/reinterpretcat/utymap/blob/master/unity/demo/Assets/Scripts/Core/Interop/MapDataAdapter.cs

chinnuGarg commented 5 years ago

Thank you.

Also isn't it possible to get all building objects in ThirdPersonBehaviour script? Normally we should be able to get gameobject as GameObject.Find() right?

reinterpretcat commented 5 years ago

It is not responsibility of ThirdPersonBehaviour class to handle logic with buildings. Yes, you can search for GO using unity API

chinnuGarg commented 5 years ago

Is it possible to create custom shaped building rather than rectangular buildings with the current raw data that OSM provides??

reinterpretcat commented 5 years ago

You can change or add new implementation for that based on current building builder implementation: https://github.com/reinterpretcat/utymap/tree/master/core/src/builders/buildings

chinnuGarg commented 5 years ago

Does UtyMap provides any kind of latlong bounds to determine the centre of polygon or a building?

reinterpretcat commented 5 years ago

There is getCentroid function in https://github.com/reinterpretcat/utymap/blob/master/core/src/utils/GeometryUtils.hpp

However, there is two things to be aware: