Jump to content

Camera::Pick on Vegetation


martyj
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...