Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Scaling/Modify a CSG Polygon in PathFollow when PathNode is drawing the mesh #1062

Open
stebulba opened this issue Jun 15, 2020 · 10 comments

Comments

@stebulba
Copy link

stebulba commented Jun 15, 2020

Describe the project you are working on:
I am making a 3d map editor. I am using Path and CSG Polygon (path fallow) to make slides and tracks.

Describe the problem or limitation you are having in your project:
That's work, but it's missing one option. I would like modify the PoolVector2Array polygon on any steep when drawing the path. I want extrude my polygon from a array A and scaling/moving/midify to the end of the path until a got the new polygon from array B.
bezier

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
They have the option for tween animation : tween_step where on any step of the animation we can do someting. But it's probably not a good way.

Can be possible to add on last points of the curve (path node) a different PoolVector2Array polygon and leave the path calculate the size of the csg polygon between those points when is drawing? On that way, Why not to include a TransitionType, like trans linear on the csg polygon between the first and the last point of the curve.

When Godot is drawing the mesh of the csg polygon from on the path, that should be easy for Godot to calculate the interpolation between the first csg polygon array and the second array.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
curve_image

Each CSG polygon should have if Path fallow is activate :

  • two polygon pool array, one for beginning (the original one) and the second for the end.
  • option to activate the interpolation from the both array.
  • option if activate to choose a TransitionType, (trans linear etc)

That don't look difficult to include in Godot. Something in this file.
https://github.com/godotengine/godot/blob/master/modules/csg/csg_shape.cpp#L2087
If I am not in error at the line 2087 the final_polygon array (with a different name of var) should be updated to the new polygon size and position depending of the transitionType between beginning and the end.
2087: new_polygon = polygon_from_slip_already_interpolate_earlier_arround_line_1815[i];
That's right ?

just for link :
https://github.com/godotengine/godot/blob/master/scene/3d/path_3d.cpp

That limitation will miss me the AAA on map Editor.
I hope you understand what a mind, what I am proposing.

This small option will give us a lot of opportunities.

@stebulba stebulba changed the title Scaling or Modify a CSG Polygon in PathFallow when PathNode is drawing the mesh Add Scaling/Modify a CSG Polygon in PathFallow when PathNode is drawing the mesh Jun 17, 2020
@stebulba
Copy link
Author

stebulba commented Jun 17, 2020

Options that I need when "Path" in Path_Node is selected.
csgpolygon_options
-Should work on any path_rotation option. Myself, I only need the pathFallow.
-Adding small code for the path_joined.
-If polygon2.size is different of the polygon.size that feature will be inactive. (message error on execution)

The most difficult thing should add the vertex positions in the editor. (confusion between both polygons)
points
But if I doing the code by myself, I will not touch that because I don't need it.

I don't have any experience on C++ but if they don't have contributor on that, I will compile my home Godot. I absolutely need this powerful feature.
But that should be include in the first version of Godot 4 to avoid any trouble with CSGPolygon if people downgrade godot version.

@Calinou Calinou changed the title Add Scaling/Modify a CSG Polygon in PathFallow when PathNode is drawing the mesh Add Scaling/Modify a CSG Polygon in PathFollow when PathNode is drawing the mesh Jun 19, 2020
@faculezcano
Copy link

Hi! im working on a forest/tree generation module and i was using CSGPolygon for trunk and branches and i figured out that i can make the mesh to start on a scale and finish on other, so i made my modifications to engine core and managed that functionality. That would work for your needs? Im willing to make a PR for this.

@faculezcano
Copy link

This is what i've achieved, i added a CurveTexture to CSGPolygon to choose the curve describing the scale towards the path, the problem is CurveTexture is aimed to generate a texture (used in Particle node) so i think is not the best approach.

2020-07-23_15-21
Here you can see a path that start at scale 0.0 through 1.0 with a in-out-ease function (Curve editor on the right bottom corner)

I need more research on the iu widget to manipulate the curve as CurveTexture does.

@faculezcano
Copy link

Here you can see it in action.
vlc-record-2020-07-23-15h38m01s-csgpolygon-2020-07-23_15 29 31 mp4-

@stebulba
Copy link
Author

Interesting, I am curious to know how you add the TextureCurve. Directly in the core of csg_shape.cpp ?
I think that should be include in godot. Il will use it for sure.
But, It's not what I need. You are adding a TexCurve for scaling,
and me I what to use a second PoolArray for scaling/modify and apply the CurveTexture on the interpolation between the first and second array. For exemple if the Y-axis don't have difference between both array the CurveTexture will be 0 for all Y-axis (no interpolation)

CurveTexture is aimed to generate a texture (used in Particle node) so i think is not the best approach.

I don't know how work particule, but for my self I want to use the interpolation of the curve that you made to apply (multiply) on any extrusion slice.
At that line https://github.com/godotengine/godot/blob/master/modules/csg/csg_shape.cpp#L2087 I have to update the array in the loop by the new extrusion slice with the new size/modify poolArray already affected by the curve.
On my way, I don't think you will (using in Particle node) because you will drawing the mesh like normal way. The only difference will be that the extrudes slides will be all different together. I am maybe wrong, because I don't know how is "generate a texture (used in Particle node)".

A picture is worth a thousand words, on that way I can draw a Babylon Tour as this picture :
baby

I am thinking to copy the csg_shape.cpp and make a new plugins call as a different CSGPolygon. But I still thinking that the best way should be to modify the core in csg_shape.cpp If the them don't want include all my feature in csg_shape.cpp, maybe we can make a new module csg_shapeB.cpp [csgpolygon2] with my version.

For now I cannont work on i because a got trouble to compile Godot on my Desktop. I have to work on that issue.

@faculezcano
Copy link

Oh now i understand! I think my approach can work for you if somehow we can have a curve for each Vec2 component (a separate curve for x and y), so you can separate the "floor" of your spiral using a scale curve for x and use a separate CSGPolygon for "wall" with no scale curve.
CurveTexture is a object that with a curve can generate a texture (i think they encode the point of the curve in a Texture so it can be uploaded to GPU and use a compute shader for GPU particles), i only use the curve part and the fancy ui. So since TextureCurve is not made for that purpose, core devs are not going to merge a PR like this.

https://github.com/godotengine/godot/blob/master/modules/csg/csg_shape.cpp#L2087
Exactly there i multiply first 2 components with previous scale and actual scale from curve.

@stebulba
Copy link
Author

stebulba commented Jul 24, 2020

Yes you understand want I want. We almost doing the same ting. But in your scaling you have limitation. If you just add a new array at the end you can modify the form of your branch at the end. And for what I want, I can move my left wall and my two left left vertex without changing anything of the right wall. On that way I just make bigger the width of my road. It's possible to do some rotation on the second array and make for exemple a curving turn for car. They have no limitation.
Your ways is more simple, not bad and you are wright, can work for me.
BUT to work for me I have to make a personal CORE for one specific thing. If I want modify the wall for exemple, I have to modify the core again.
My proposal will not make sense if it's for a personal thing. It's why I propose two differents poolArray. Make a tools who everybody with imagination can use it with no limitation.

In my proposal, I can do the same thing that you. Except your scaling of your curve at [1] will be already calculate in the second array push by godot (gdscript) to the core.

It'is why a am thinking to include your feature on a normal CSGPolygon. And add a new CSG, the CSGComplexPolygon with my feature. Because we don't want include to mush condition in the drawing path loop.

Why are you not using a Normal Curve? I don't think you need to use CurveTexture.
curve

Also I suppose I can use those function (easing_equations.cpp) directly from (csg_shape.cpp) to get the curve that I want.
https://github.com/godotengine/godot/blob/master/thirdparty/misc/easing_equations.cpp
Or to do exactly what you did to adding the curve with editor in CSGPolygon property as name "Path Interpolate Curve".
I will try add the curve Editor and a curve selector from easing_equations.cpp

Anyway, thank to participate, you help me to focus on that and I progress a lot today on that :)

@stebulba
Copy link
Author

stebulba commented Aug 18, 2020

Hi am working on it. My Feature is working. I can scale, modify, moving by interpolation from array(polygon) 1 to array(polygon) 2.
I can do exactly what faculezcano demo show us. If the polygon1 (position 0 on curve) = polygon2 (position 1 on curve), we can only set point in the curve at 2 to double size.

I made I small exemple of what we can do. Make lake with path for the beach and a path for the cliff / grass. On Gdscript we can make easily random procedural lake of different form and size.
curve2_lake

I want to make a animation like Tacoma bridge collapse as demo how to use Gdscript with my feature.
I still working on the core, I am not completely done to show you my code.
I am thinking about to add more feature later. A polygon Editor for exemple.

@faculezcano
Copy link

Hi am working on it. My Feature is working. I can scale, modify, moving by interpolation from array(polygon) 1 to array(polygon) 2.
I can do exactly what faculezcano demo show us. If the polygon1 (position 0 on curve) = polygon2 (position 1 on curve), we can only set point in the curve at 2 to double size.

I made I small exemple of what we can do. Make lake with path for the beach and a path for the cliff / grass. On Gdscript we can make easily random procedural lake of different form and size.
curve2_lake

I want to make a animation like Tacoma bridge collapse as demo how to use Gdscript with my feature.
I still working on the core, I am not completely done to show you my code.
I am thinking about to add more feature later. A polygon Editor for exemple.

Nice work! if you like to this get merge, mention a core dev so them can advice you or tell you if the approach is ok. There is a doc where talk about the procedure to pull request.

@stebulba
Copy link
Author

stebulba commented Aug 22, 2020

I made it. I just fixed a stupid bug who crash Godot. A loop for "<=" when suppose to be "<".

My last demo, I modelized that in few minutes with only a polygon with 4 points. I used un CSGCombiner to made the door and the windows. I small ruin house
curve_ruin_house_demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants