Open tehKaiN opened 6 years ago
So I needed to display some 3D stuff on map, which GeoJSON extrusion can't do (e.g. flying saucers on their proper altitude ;) ). Since tangram-es doesn't have any means to use that, I've hacked my way through by adding two simple helper functions to Map:
void Map::lngLatToGlPosition(double _lng, double _lat, double *_x, double *_y) { auto posMeters = impl->view.getMapProjection().LonLatToMeters({_lng, _lat}); auto viewPos = impl->view.getPosition(); *_x = posMeters.x - viewPos.x; *_y = posMeters.y - viewPos.y; } glm::mat4 Map::getViewProjectionMatrix(void) { return impl->view.getViewProjectionMatrix(); }
I'm just starting my journey into OGL so I'm no expert and can't really tell how much complete this solution is, but it suffices for displaying basic shapes - you basically only need pos in meters to construct model matrix (also, adding custom height in meters works) and V*P matrix to generate MVP.
So I'm wondering, perhaps it would be okay to add such methods before project gets better means to display custom objects on map. In the long run, it would be cool to also expose complex mesh code which is used privately in code and which I don't comprehend completely yet.
have you completed this feature yet?
I still use same code, so I guess that's good enough. It's nothing fancy but it suffices for my needs. You can try it in action on my fork.
I still use same code, so I guess that's good enough. It's nothing fancy but it suffices for my needs. You can try it in action on my fork.
I can`t find this functions in your fork. Please tehKaiN help me! How i can put 3d object on map? I have 3d Max file with model
@tehKaiN I can`t find this functions in your fork. Please tehKaiN help me! How i can put 3d object on map? I have 3d Max file with model
There's a lot of reading and trial & error before you, I think.
What I implemented are just two very low-level functions which allow you to put stuff on map using your own OpenGL commands. You still need to read model by yourself (I used OBJ, I think that file format is better documented than 3ds files), put it into vertex/index buffers, write basic shaders and draw all that via OpenGL functions using MVP matrices. My helpers just give you V*P matrix and allow to translate lng/lat to scene coords so that you can calculate M matrix.
I've touched that code years ago, so I don't remember it too well, and I also can't share it since it was written as part of my job. But it's not that complicated, if you read some OpenGL tutorials you can recreate all those steps quite easily. Just start with something simple, like cube, then draw it on an empty OpenGL context, then try drawing it on map context, then try to draw it on given lng/lat, etc.
@tehKaiN I have the problem is that I do not know OpenGL at All for me it will be extremely difficult (((I beg you to help, if you can not throw off the functions of the whole, please throw off some hints of the name of the functions, where to insert, and what the function should do
So I needed to display some 3D stuff on map, which GeoJSON extrusion can't do (e.g. flying saucers on their proper altitude ;) ). Since tangram-es doesn't have any means to use that, I've hacked my way through by adding two simple helper functions to Map:
I'm just starting my journey into OGL so I'm no expert and can't really tell how much complete this solution is, but it suffices for displaying basic shapes - you basically only need pos in meters to construct model matrix (also, adding custom height in meters works) and V*P matrix to generate MVP.
So I'm wondering, perhaps it would be okay to add such methods before project gets better means to display custom objects on map. In the long run, it would be cool to also expose complex mesh code which is used privately in code and which I don't comprehend completely yet.