Jump to content

Rough Terrain (Smooth ?)


Dad72
 Share

Recommended Posts

Hi,

 

That is why I talked about the feature 'smooth' on the ground. I wanted to flatten parts of ground and the edges are in saw tooth. With a brush smooth, this lisserais the edges.

 

You can see on my screen copy :

 

 

This project shalt distribute freely in the future.

 

Thanks

Link to comment
Share on other sites

That is what AFAC ?

 

Yes, agreed. But it would be interesting to complement this demo technic to make a small product more finished.

This would help me to understand how to make that my project leads to something presentable. Without this, my project will not see the day and this shalt be 1 years of lost work for me, because my project canst not be circulated to the public without its features that I do not feel capable of achieving: "smooth", "paint texture", "radius brush visible". That is all that is missing to worldmonger.

Thank you for your attention.
 

Link to comment
Share on other sites

Thank you Wingnut. It is a pleasure to have opinions.
I hope the distribute a day and be of benefit to the community. Unfortunately, I have not yet integrated into the English language in it, but the system multi-language is present.


 

 
Link to comment
Share on other sites

I used the demo WorldMonger. I think that is in _elevateFaces which elevate vertices.

WORLDMONGER.ElevationControl.prototype._elevateFaces = function (pickInfo, radius, height)    {        this._prepareDataModelForElevation();        this._selectedVertices = [];        // Impact zone        var sphereCenter = pickInfo.pickedPoint, index;                sphereCenter.y = 0;        // Determine list of vertices        for (var subIndex = 0; subIndex < this._ground.subMeshes.length; subIndex++)        {            var subMesh = this._ground.subMeshes[subIndex];            if (!this._isBoxSphereIntersected(subMesh.getBoundingInfo().boundingBox, sphereCenter, radius)) continue;                        for (index = subMesh.verticesStart; index < subMesh.verticesStart + subMesh.verticesCount; index++) {                var position = this._groundPositions[index];                sphereCenter.y = position.y;                var distance = BABYLON.Vector3.Distance(position, sphereCenter);                if (distance < radius) {                    this._selectedVertices[index] = distance;                                    }            }        }        // Elevate vertices            for (var selectedVertice in this._selectedVertices)            {                var position = this._groundPositions[selectedVertice];                var distance = this._selectedVertices[selectedVertice];                var fullHeight = height * this.direction * this._invertDirection;                if (distance < radius * 0.3) position.y += fullHeight;                else { position.y += fullHeight * (1.0 - (distance - radius * 0.3) / (radius * 0.7)); }                           if (position.y > this.heightMax) position.y = this.heightMax;                else if (position.y < this.heightMin) position.y = this.heightMin;                this._groundVerticesPositions[selectedVertice * 3 + 1] = position.y;                this._updateSubdivisions(selectedVertice);            }                        // Normals        this._reComputeNormals();        // Update vertex buffer        this._ground.updateVerticesData(BABYLON.VertexBuffer.PositionKind, this._groundVerticesPositions);        this._ground.updateVerticesData(BABYLON.VertexBuffer.NormalKind,this._groundVerticesNormals);            };
Link to comment
Share on other sites

This line is the key:

if (distance < radius * 0.3) position.y += fullHeight;
                else { position.y += fullHeight * (1.0 - (distance - radius * 0.3) / (radius * 0.7)); }

 

if you need to smooth things up, just add a small variable there:

if (distance < radius * 0.1) position.y += fullHeight * 0.5;

                else { position.y += 0.5 * fullHeight * (1.0 - (distance - radius * 0.1) / (radius * 0.9)); }

Link to comment
Share on other sites

I cannot do the loading of the field. Because I saved in a json file any change of vertices and when i reloaded, it is the file that is read to generate the ground. If I added a subdivision, the file no longer corresponds to the number of vertices. I would like the users of my editor can have a smoothing tool while he edited the ground.

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.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...