martyj Posted July 16, 2017 Share Posted July 16, 2017 How can I select items in the vegetation layer for picking? See this video for an example. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted July 16, 2017 Share Posted July 16, 2017 This makes it seem like it's currently impossible: But it's interesting to be reminded of that video. Quote Link to comment Share on other sites More sharing options...
martyj Posted July 16, 2017 Author Share Posted July 16, 2017 Well surly in that video Josh is having some sort of "Pick" option, using the Pick to figure out what position to apply a decal at. I just want to know how I can see what vegetation the user is trying to interact with at a given camera view. My ultimate goal is to then modify the vegetation layer to remove vegetation at that point, and replace it with an actual temporary entity. Use the performance of vegetation + ease of implementation along with providing dynamic content. Quote Link to comment Share on other sites More sharing options...
Rick Posted July 16, 2017 Share Posted July 16, 2017 At one point josh said this wouldn't be possible currently. Something about the vegetation not being real individual entities but combined in some way for speed purposes. So there was no way to single out an individual veg item. It was meant for visuals only not heavy interaction which does make its use limited. Or perhaps it was about the placement map couldn't be modified. Something like that. I was hoping for this back in the day too for a survival type game. Quote Link to comment Share on other sites More sharing options...
martyj Posted July 16, 2017 Author Share Posted July 16, 2017 @Rick, then how does he apply the decal in the video? You should be able to modify the placement map. It might require some OpenGL hackery. Update the texture used to show where the vegetation is, then update the GPU. Have a look at Vegetation.h in the class VegetationLayer. I think the following properties look promising. Texture* instancetexture; Texture* filtermap; Texture* variationmap; GLuint buffertexture; Also how does physics work with vegetation? ------------------ Edit: In regards to physics the Vegetation.h shows this: //---------------------------------------------------------- //Physics //---------------------------------------------------------- NewtonMesh* newtonmesh; NewtonDynamicsShape* instanceshape; Surface* collisionsurface; std::vector<int> indices; std::vector<float> facenormals; std::vector<float> vertexpositions; std::vector<int> collisionsurfaceindicecounts[32]; std::vector<int> collisionsurfaceindices[32]; std::vector<float> collisionsurfacevertices[32]; std::vector<Mat4> instances[32]; So a player can collide with up to 32 items? Quote Link to comment Share on other sites More sharing options...
Rick Posted July 16, 2017 Share Posted July 16, 2017 All a decal needs is a surface to be applied to. It doesn't mean it's an individual model. I just don't recall if they are all combined. I thought I recall a post where he mentioned a group of them are combined into 1 model. Nobody is saying it can't be done (Josh had an idea on how to do it but just didn't have the time), but Josh would be the one who knows the details. Maybe send him a private message about it. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted July 16, 2017 Share Posted July 16, 2017 Sure, but the trick is: how did he pick the rock and tree? Did he do a physics collision? 1 Quote Link to comment Share on other sites More sharing options...
Rick Posted July 16, 2017 Share Posted July 16, 2017 See Josh's response a couple posts down. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted July 16, 2017 Share Posted July 16, 2017 Right. That's what I linked above thinking that this really isn't possible, despite the video. So I guess we'll need a definite from Josh. But maybe this could still be done with some physics collision detection trickery. Quote Link to comment Share on other sites More sharing options...
Rick Posted July 16, 2017 Share Posted July 16, 2017 Martyj kind of asked 2 different questions. First it was picking only, then it was about removing individual instances. Isn't there a collision type option for trees already? I would think picking would work right now. Quote Link to comment Share on other sites More sharing options...
martyj Posted July 16, 2017 Author Share Posted July 16, 2017 1 hour ago, Rick said: See Josh's response a couple posts down. That would be a good option as well. The question is, how do we go about performing the action of "convert all instances in one section to regular models, and remove that area from the vegetation grid. " If we convert all vegetation in an area into a model, could we, for performance reasons, change it back to vegetation? Quote Link to comment Share on other sites More sharing options...
martyj Posted July 16, 2017 Author Share Posted July 16, 2017 Here is what I found so far: for (int i = 0; i < this->world->terrain->CountVegetationLayers(); i++) { VegetationLayer* layer = this->world->terrain->GetVegetationLayer(i); std::string modelPath = layer->modelpath; if (modelPath.find("oak") != std::string::npos) { layer->Hide(); layer->SetVisibility(0, 0, false); layer->viewrange = 0; Model* model = Model::Load(modelPath); AABB aabb = world->aabb; std::vector<Mat4> instances; layer->GetInstancesInAABB(aabb, instances); for (int j = 0; j < instances.size(); j++) { Mat4 instance = instances[j]; Entity* copy = model->Copy(true, true); copy->SetMatrix(instance, true); copy->SetScale(instance.GetScale()); } } } This hides the selected layer, and creates an object as expected. The problem is the scale is off. layer->viewrange = 0; is the only thing that currently hides a layer. For performance you can divide the world into different AABB regions. With a separate Entity object, you can assign a script or assign it to an Actor class. 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.