Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can Curve Spline be used for an in game level editor.
#11
What does includeOnRequestProcessing do since I seem to require this to have GetModule work.

Edit* You said to modify the Destroy method in the CGMeshResourceLoader to add the custom scripts I needed. I'm having trouble allowing it to give access to my own namespace/scripts. Also if I'm to believe, I'll have to add every custom script I'd need these meshes to use into this right? Is there not an easier way to allow an entire prefab + its children to load into the Generator?
Reply
#12
(05-03-2023, 02:31 PM)Lupos Wrote: Or modify 1 spot module directly and fill that with the data I need by figuring out manually the spaces between the points I need?

To define the positions of the spots on the spline, use the CurvySpline.InterpolateByDistance and CurvySplineSegment.Length methods to build you code.

(05-03-2023, 02:31 PM)Lupos Wrote: Which would you recommend overall?

Multiple spline rasterizers is the fastest to implement. If you feel that you might need modifying the logic behind defining where to put objects, then using a custom spot module would be better I believe.

(05-03-2023, 02:31 PM)Lupos Wrote: Edit* In the createGenerator example, are the generators automatically pooled? Or is that something I'll need to take care of?

It is automatically pooled.

(05-03-2023, 02:31 PM)Lupos Wrote: Edit** When using my own prefabs with their own logic, is it possible to call specific functions on generation? Or do I move logic into OnEnable of the component?

You can use the OnBeforeRefresh and/or OnRefresh events of the modules to execute your code at each generation.

(05-03-2023, 02:31 PM)Lupos Wrote: Edit*** I keep getting a "The given key "Path" was no present in the dictionary. For the volume spots module when I try connecting the InputPath's "Path".  No matter what combination of "Path" or "Volume" I'd try would result in the error.
(Turns out you have to use "Path/Volume") The documentation made it seem like either or is fine. Or that Volume/Path would work. My bad.
 
The parameter to use is the slot's name, which can be different than the slot's display name. Example with BuildVolumeSpots.InPath:
Code:
        [InputSlotInfo(
            typeof(CGPath),
            Name = "Path/Volume",
            DisplayName = "Volume/Rasterized Path"
        )]

        public CGModuleInputSlot InPath = new CGModuleInputSlot();

(05-03-2023, 02:31 PM)Lupos Wrote: The documentation made it seem like either or is fine. Or that Volume/Path would work.
  
That was meant to mean that the type of the input can be either a path or a volume. In code world, it should be clear since the type of accepted data for that slot is CGPath, and CGVolume inherits from CGPath. But for the documentation not related to code, it has to be clarified.

(05-03-2023, 02:31 PM)Lupos Wrote: My bad.

Mine too for not making things clearer.

(05-03-2023, 02:31 PM)Lupos Wrote: Incredible support thank you so much, I'll be sure to leave a solid review.
 
Well, you jinxed me, I took longer than usual to answer you today Big Grin
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#13
(05-04-2023, 12:43 PM)Lupos Wrote: What does includeOnRequestProcessing do since I seem to require this to have GetModule work.
Here is the documentation for that method:
https://api.curvyeditor.com/860/FluffyUn...m_Boolean_
The parameter means whether the method should also return modules that implement the IOnRequestProcessing interface. These modules have their inner workings different than other modules. "Normal" modules do their computation every time (when dirty) the generator is refreshed. IOnRequestProcessing modules do their computation only when requested by other modules.
The current list of such modules is:
  • ConformPath
  • InputSplinePath
  • InputSplineShape
  • ModifierMixPaths
  • ModifierMixShapes
  • ModifierPathRelativeTranslation
  • ModifierTRSPath
  • ModifierTRSShape
  • ModifierVariableMixShapes

For simplicity sake, you can always set that parameter to true.

(05-04-2023, 12:43 PM)Lupos Wrote: Edit* You said to modify the Destroy method in the CGMeshResourceLoader to add the custom scripts I needed. I'm having trouble allowing it to give access to my own namespace/scripts.
 
It is probably because you are using Curvy Splines with amsdef files. If so, short answer would be: remove the asmdef files in the ToolBuddy folder (recursively). The long answer would be: you need reference your code in the Curvy asmdef. More information here: https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html

(05-04-2023, 12:43 PM)Lupos Wrote: Also if I'm to believe, I'll have to add every custom script I'd need these meshes to use into this right? Is there not an easier way to allow an entire prefab + its children to load into the Generator?
You can use whatever code you need in CGMeshResourceLoader.Destroy to specify what components to ignore. You can access obj.gameObject, and customize the stripping depending on the object. For example using Unity's tags.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#14
(05-04-2023, 04:26 AM)Lupos Wrote: I also had 1 follow up question regarding building in between points. I know you suggested calculating the distance but I'm having trouble knowing how I'd limit it.
I'm simply trying to make it so that for the size of my placed object (in this case its 1 unit) dont build anything at the start and end node of a segment.

I tried figuring out how to take the Distance and subtract .5f (half a unit) from it, and then converting that into a localDistance for the segments but I'm having trouble getting it correct.

It seems the generation spawns stuff starting from the first node, to the next node. Ideally I'm trying to find a way to almost essentially generate it from the center, outward to each point. However I don't really need that, I just need to make sure the start and end points don't create anything within half a unit from each point.

I provided an image below of what I'm trying to do. 

Each point is 1 unit, and then every block placed between the segment is 1 unit. I need them to fit between the points as best they can. This way the desctruction system can have towers and walls break without any intersections.

I think you should set the Range parameter (of the module that suits you) so that it sets a buffer at the beginning and end. The range is expressed as a relative distance. So if you want your range to start at 0.5u, then your range start value should be 0.5f/yourPathLength. You can access your path's length either via:
  •  CGPath.Length, if you are using the API to make your custom module, or
  • CurvySplineSegment.Length, if you are opting for using multiple Input Path modules, one for each segment.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#15
Heyo, no worries about the delay haha. Still amazing support.


(05-04-2023, 09:33 PM)_Aka_ Wrote: It is probably because you are using Curvy Splines with amsdef files. If so, short answer would be: remove the asmdef files in the ToolBuddy folder (recursively). The long answer would be: you need reference your code in the Curvy asmdef. More information here: https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html

I'm having trouble locating the assembly definition files (asdf). I actually tried to look into them before coming to you but had trouble locating them.

(05-04-2023, 09:06 PM)_Aka_ Wrote: It is automatically pooled.

I know you said the SplineGenerator was pooled in the example, but from what I saw it initialized a set amount of generators based on the segments.

For my project, I decided to attempt the approach of prefabbing the splines and generators. 
This way I could set different spline settings for my editor for different pieces. As well as customize how the generation is handled.

Currently I use two prefabs, 1 for the spline itself (with my own wrapper or facade functions), and another that generates pooled generators (also wrapped so I can spawn towers on the nodes).
I plan to use the same generator for most splines, but in cases of something different (like a railroad track) I'll have its generation be different.

Is this a recommended?

(05-04-2023, 09:33 PM)_Aka_ Wrote: Multiple spline rasterizers is the fastest to implement. If you feel that you might need modifying the logic behind defining where to put objects, then using a custom spot module would be better I believe.

And instead of having a pool generators system, would it be just better to make 1 generator handle everything I needed in 1 go? If so, where could I get started to figure this out? I simple want all the control that the standard spots volume provides, just with the ability to set padding between points based off world units.

(05-04-2023, 09:33 PM)_Aka_ Wrote: I think you should set the Range parameter (of the module that suits you) so that it sets a buffer at the beginning and end. The range is expressed as a relative distance. So if you want your range to start at 0.5u, then your range start value should be 0.5f/yourPathLength. You can access your path's length either via:

Currently I have each generator have its SplineInput range set to the points I want (always a segment). Would I still use the entire spline Length when calculating the .5 offset? Or Would I use the segment length.



Edit* Only problem I'm having with my current solution is the error StartCP/EndCP is not a part of the input spline. This is avoided if I set the Spline for the generator and then call Refresh. But it can sometimes pop up if I generate things in the editor, and then try to run the game (due to onValidate calling before) 

Is there anything I can do to avoid this? 

One possibly way is if I only needed 1 geneartor (with a custom spots), I wouldn't need to spawn the generators in anymore. And i can have 1 prefab with the spline and generator already pre-attached....  
   
Reply
#16
(05-05-2023, 03:49 AM)Lupos Wrote: I'm having trouble locating the assembly definition files (asdf). I actually tried to look into them before coming to you but had trouble locating them.

You can find them by searching for files with the asmdef extensions.

(05-05-2023, 03:49 AM)Lupos Wrote: I know you said the SplineGenerator was pooled in the example, but from what I saw it initialized a set amount of generators based on the segments.
I thought you asked if the generators used this pooling. The answer is yes.
The generators by themselves are not pooled.

(05-05-2023, 03:49 AM)Lupos Wrote: Is this a recommended?
 
I have never tried such a setting. I don't see at this moment anything that would make me say that it is not recommended.
About pooling generators, maybe you don't need that. I doubt you will have to create/destroy generators every frame (do you?), so the need for pooling is less present. I recommend to first try a naive solution without pooling, then build a pooling system only if the profiling shows a need for that.

(05-05-2023, 03:49 AM)Lupos Wrote: And instead of having a pool generators system, would it be just better to make 1 generator handle everything I needed in 1 go? If so, where could I get started to figure this out? I simple want all the control that the standard spots volume provides, just with the ability to set padding between points based off world units.

You have access to the source code of the spots producing modules (by order of complexity: InputSpots, InputTransformSpots and BuildVolumeSpots). You can skim through the code to see how things are done.


(05-05-2023, 03:49 AM)Lupos Wrote:
(05-04-2023, 09:33 PM)_Aka_ Wrote: I think you should set the Range parameter (of the module that suits you) so that it sets a buffer at the beginning and end. The range is expressed as a relative distance. So if you want your range to start at 0.5u, then your range start value should be 0.5f/yourPathLength. You can access your path's length either via:
Currently I have each generator have its SplineInput range set to the points I want (always a segment). Would I still use the entire spline Length when calculating the .5 offset? Or Would I use the segment length.

The segment's length, which is CurvySplineSegment.Length as I mentioned earlier.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#17
(05-05-2023, 03:49 AM)Lupos Wrote: I'm having with my current solution is the error StartCP/EndCP is not a part of the input spline
Are you positive that the CPs you set as the Start/End CPs are indeed part of the spline used for that module? If so, please make a small, simple, reproduction case and send it to me.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#18
(05-05-2023, 10:22 AM)_Aka_ Wrote: You can find them by searching for files with the asmdef extensions.
I tried and no files for Curvy seem to exist. I was able to find everything but curvy's asmdef.

Edit* I found the generate asmdef button in the Curvy options menu (after reading the changelog.) I'm wondering if this is an issue since without these files generated, its not possilbe to make the modifications you mentioned. 

You suggested either delete these files, or modify them to support the files I needed. Well it appears not having them just doesn't work and I'm forced to generate them and append my required data into it.

Edit** Another issue I came across was that I can't both reference the CurvySpline asdmf in my own code, and have it reference my code. (circular dependency.) I wish there was a simply way to override the parameters I need within my own code, or possibly inject what I need.


Edit*** Because I had the asset in the plugin folder, I was prevented from accessing my own namespaces without the asmdfs. (I forget if I added it to plugins myself or not)

Edit**** Even after being able to get the script I need to be referenced, it still wouldn't show up when generating. I'm not exactly sure what I need to do to get my own scripts to show on the spawned mesh.

Just to clarify, I'm convering Input GameObjects to a mesh.. oh. Create Gameobject is a thing. Aaaah thats why. Okay this makes more sense now. I'm stupid lol
   

(05-05-2023, 10:22 AM)_Aka_ Wrote: I doubt you will have to create/destroy generators every frame (do you?)


I create new generators based on the total segments. Each segment needs a generator so the longer the spline, the more I need. I'll look into a custom spots volume since I think this would def remove the need for this.

I've created a simple package with just 1 scene, 1 prefab. No scripts or anything. I didn't include Curvy either to avoid breaking the law.

You can see here that I have the generator added to the spline, rather then the spline added to the generator (like the default behavior when creating a generator and a spline input)
This is so I could share 1 spline across many generators.

Side request, is it possible to zoom in the Generator graph? And if not, is that functionality possibly able to be added?

(05-05-2023, 10:22 AM)_Aka_ Wrote: You have access to the source code of the spots producing modules (by order of complexity: InputSpots, InputTransformSpots and BuildVolumeSpots). You can skim through the code to see how things are done.

I see this, I was able to get my own custom module created, I'm just having trouble getting the right data. The VolumeSpots takes a rasterizedPath, which converts a normal path and its control points into something simpler for the actual spot generation. How would I get per segment data so I can modify the refresh. Specifically the endDistance/startDistance stuff 

   

This data is just the total length left over from the splineInput -> splineRasterizier. Which is cool, but I'd like to get the distances of each segment so I can apply that offset instead.
Maybe I need to perform the rasterization in this module per segment and have its source just be the splineInput. However that doesn't seem to fit the convention of this asset.


Attached Files
.unitypackage   Custom Spline To Generator Bug.unitypackage (Size: 14.71 KB / Downloads: 1)
Reply
#19
I've made an attempt to make my own generator. Likely due to my novice experience with this asset and its api, but I did end up needing to do a considerable amount of copying from existing modules and editors.

I was sorta able to make it work by doing the following

1) customize Spline Input to generate an array of segments (instead of an entire spline)
2) customize Spline Rasterizer to take the multiple inputs and rasterize them into the usable data
3) customize Volume Spots to take the multiple segments and generate data, then apply a custom unit offset (based off the original range param) to offset.

It sorta seems to be working however I'm having trouble getting closed to work, its likely due to how I've tried implementing this. I also still get the error in relation to StartCP/EndCP as I told you before.

If possible, would you mind taking a look? I'd love a fix to why I can't seem to make it close. It's related to try to send the end/start points as a segment (and the distance ending up calculating negative.

But I'm also just curious if this is even the best way, is there an easier way to do this without needing all these modules? Maybe a way to just modify the volume spots module to only generate within a segment (without feeding it custom new segments?)

I'm pretty stumped haha, but I'm happy I was able to get as far as I did. Learned a lot in the process.


Attached Files
.unitypackage   CustomUnitPaddingGenerator.unitypackage (Size: 444.17 KB / Downloads: 1)
Reply
#20
I just discovered I get this error if I delete a generator that is inactive. (Rather this seems to happen if I Just end the game and it tries to auto delete/cleanup)

   
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  snap to the curve created by the curvy splines segment points ShiroeYamamoto 0 0 9 hours ago
Last Post: ShiroeYamamoto
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  GO can't fit end of the spline GameDeveloperek4123 3 13 03-04-2024, 11:06 AM
Last Post: _Aka_
  Keeping a fixed spline length jh092 3 16 02-21-2024, 06:25 AM
Last Post: Primrose44

Forum Jump: