Search Unity

PrimitivesPro [RELEASED]

Discussion in 'Assets and Asset Store' started by reindeer-games, Mar 11, 2013.

  1. Polygans

    Polygans

    Joined:
    Apr 19, 2009
    Posts:
    79
    Hi Reindeer,

    I'm trying to use the mesh slicer for real time slicing of gameobjects. I want to put it on a sword so you can slice trough stuff. The slice code isn't documented. Could you provide me with some starters on how to go about this?
     
  2. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    sorry about the documentation. The public interface is well commented, just look into the

    MeshCutting/MeshCutter.cs

    Also you can look into the cutter demo:

    Assets/PrimitivesPro/Scrips/Demo/CutterDemo.cs (function Cut())

    You only have to do something like this:

    Code (csharp):
    1.  
    2. var cutter = new MeshCutter();
    3. cutter.Cut(GameObject, cuttingPlane, triangulate, deleteOriginal, out cut0, out cut1, out contour);
    4.  
    Regards.
     
  3. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, can you please be more specific? What kind of scene view handles for what parameters? I know that there are only scene view handles for moving, rotating and scaling, in what way you would like to use it?

    This sounds good, I can do this.

    Ok, this is easy.

    Thanks!
     
  4. vidjo

    vidjo

    Joined:
    Sep 8, 2013
    Posts:
    97
    Heres a link to Unity's Handle reference page: https://docs.unity3d.com/Documentation/ScriptReference/Handles.html

    Take a default capsule collider and hold shift in the scene view, you will notice that handles appear to make it easier to manipulate the capsule collider. You can drag the handles to manipulate the capsule's height and radius. It would be nice PrimitivesPro had similar handles for its primitives. I only need it for spheres, boxes and capsules, but I'm sure others would like handles for other primitives types. Notice these handles do NOT affect the objects transform component in any way. They just affect the properties of the collider component. This is what I would like for PrimitivesPro objects.

    I would also prefer not to have to hold shift to make them appear. I'd either have a checkbox in the inspector to turn them on/off, or just only display when the object is selected.

    Does this make more sense? Let me know if I should explain more.
     
  5. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    I see, I didn't know about this editor API, we can do interesting with these tools. Sounds like a good idea.
     
  6. vidjo

    vidjo

    Joined:
    Sep 8, 2013
    Posts:
    97
    Oh, and a a function that takes two positions parameters and creates a capsule that is stretched with one end point on each of the position arguments. Maybe you could have this for a box type as well.
     
  7. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hey guys,

    I just made a hollow cone, I will add it to next update...

    $hollow_cone.jpg
     
    Last edited: Mar 19, 2014
  8. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    Thanks for updates...
    6R
     
  9. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, I just submitted all the changes as you requested, handles for all primitives, colliders options and additional functions, the asset should be ready for download in few working days.

    $handles.jpg

    Regards,
    RG
     
  10. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    Great !!!
    Could you add a "rounded" option for all primitives like the rounded cube !?!

    6R
     
  11. vidjo

    vidjo

    Joined:
    Sep 8, 2013
    Posts:
    97
    Wow! Thank you very much!! You know I accidentally bought Primitives Pro twice, but with support like this, I'm happy to have spent a little extra! Thanks again :)


    Is there any chance that the handles support undo functionality?
     
    Last edited: Mar 29, 2014
  12. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Sorry, that's not possible, "roundness" is a property only of "rounded cube" and "superellipsoid". Only way how to round/smooth objects is to apply one of the subdivision/refinement algorithms, and that's not in the plan for now.
     
  13. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, I will look into that!
     
  14. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Last edited: Apr 5, 2014
  15. iamsam

    iamsam

    Joined:
    Dec 22, 2013
    Posts:
    233
    Hi, excellent product. It has helped me a lot with my workflow. I had a question regarding Boolean operations. I read a few posts back that there was a problem, did you remove that option as I cannot find it in the list? I tried using the Boolean Op script but it does not seem to work, can you please guide me as to how I can use boolean operations since it very important for my current project. Thanks.
     
  16. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi rocki,

    I just downloaded version 1.8 to a new project (Unity 4.3) and everything is correct, documentation 1.8, cone has hollow option and handles are visible by default, please try again.
     
  17. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hello, thanks for using my package, I am glad you like it!

    Boolean operations are still there but disabled (commented out), you can enable it back by uncommenting

    Code (csharp):
    1. #define BOOLEAN_EXPERIMENTAL
    in PrimitivesPro/Editor/CreateBooleanOp.cs.

    The algorithm is not very stable, it can work well with simple meshes but there are edge cases with bad results.
     
  18. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Yes, you are right, I tried it again now and I have 1.8, the handles are really cool.
    Also the hollow cone is very nice.

    Great work.

    P.S. the arc is still a bit funky.
     
  19. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    I will check the arc, thank you for feedback.
     
  20. vidjo

    vidjo

    Joined:
    Sep 8, 2013
    Posts:
    97
    The capsule is a bit funky too. I expect preserve height checkbox to just change the way the "height" and "radius" attributes are affected when dragging a handle. But it actually completely changes the size of a capsule when toggled on and off. Try playing with a capsule a bit, then toggle preserve height on and off, the entire capsule changes on toggle.
     
  21. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    I see, I will make you patch and post it here, the asset store approval process takes a whole week now.
     
  22. iamsam

    iamsam

    Joined:
    Dec 22, 2013
    Posts:
    233
    Thank you very much for the quick feedback, for my purposes it seems to work well. Thanks again.
     
  23. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, I just made a fix for capsule preserve height toggle; replace method OnInspectorGUI() in Editor/CreateCapsule.cs with this. Let me know if it works for you, I put it to next update.

    Code (csharp):
    1.  
    2.     public override void  OnInspectorGUI()
    3.     {
    4.         var obj = Selection.activeGameObject.GetComponent<PrimitivesPro.GameObjects.Capsule>();
    5.  
    6.         if (target != obj)
    7.         {
    8.             return;
    9.         }
    10.  
    11.         Utils.Toggle("Show scene handles", ref obj.showSceneHandles);
    12.         bool colliderChange = Utils.MeshColliderSelection(obj);
    13.  
    14.         EditorGUILayout.Separator();
    15.  
    16.         useFlipNormals = obj.flipNormals;
    17.         bool uiChange = false;
    18.  
    19.         uiChange |= Utils.SliderEdit("Radius", 0, 100, ref obj.radius);
    20.         uiChange |= Utils.SliderEdit("Height", 0, 100, ref obj.height);
    21.         var preserveHeightToggle = Utils.Toggle("Preserve Height", ref obj.preserveHeight);
    22.         uiChange |= preserveHeightToggle;
    23.  
    24.         EditorGUILayout.Separator();
    25.  
    26.         uiChange |= Utils.SliderEdit("Sides", 4, 100, ref obj.sides);
    27.         uiChange |= Utils.SliderEdit("Height segments", 1, 100, ref obj.heightSegments);
    28.  
    29.         EditorGUILayout.Separator();
    30.  
    31.         uiChange |= Utils.NormalsType(ref obj.normalsType);
    32.         uiChange |= Utils.PivotPosition(ref obj.pivotPosition);
    33.  
    34.         uiChange |= Utils.Toggle("Flip normals", ref useFlipNormals);
    35.         uiChange |= Utils.Toggle("Share material", ref obj.shareMaterial);
    36.         uiChange |= Utils.Toggle("Fit collider", ref obj.fitColliderOnChange);
    37.  
    38.         if (preserveHeightToggle)
    39.         {
    40.             if (obj.preserveHeight)
    41.             {
    42.                 obj.height = obj.height + obj.radius * 2;
    43.             }
    44.             else
    45.             {
    46.                 obj.height = obj.height - obj.radius * 2;
    47.             }
    48.         }
    49.  
    50.         Utils.StatWindow(Selection.activeGameObject);
    51.  
    52.         Utils.ShowButtons<PrimitivesPro.GameObjects.Capsule>(this);
    53.  
    54.         if (uiChange || colliderChange)
    55.         {
    56.             if (obj.generationMode == 0  !colliderChange)
    57.             {
    58.                 obj.GenerateGeometry();
    59.  
    60.                 if (useFlipNormals)
    61.                 {
    62.                     obj.FlipNormals();
    63.                 }
    64.             }
    65.             else
    66.             {
    67.                 obj.GenerateColliderGeometry();
    68.             }
    69.         }
    70.     }
    71.  
     
  24. vidjo

    vidjo

    Joined:
    Sep 8, 2013
    Posts:
    97
    Hello, is it possible for you to add functionality to the Capsule.FitBetweenPoints function so that the capsule stretches past the two points by the radius amount? Or perhaps a simple offset parameter would work, you can calculate the angle and I can pass in if I want the edge of the capsule to be at the point, or if i want the center of the sphere on each end of the capsule to be on the points I pass to FitBetweenPoints, or maybe even a another offset altogether.
     
  25. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, yes I will update it, I think the most universal solution is to add an offset (float) parameter and option (enum) parameter offset_point0/offset_point1/offset_both.
     
  26. vidjo

    vidjo

    Joined:
    Sep 8, 2013
    Posts:
    97
    That sounds great! I agree :)
     
  27. DevoMage

    DevoMage

    Joined:
    Dec 19, 2012
    Posts:
    16
    Any chance we could get a "slant" primitive? basicially, a 3d triangle... specify the length, width, (length and width form a 90) depth and the angle is automatically generated accordingly.

    i really like primitives pro and do not want to buy the "other" primitives package. but need this slant soon...

    thanks for the consideration!
     
  28. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    the package 1.8.1 with the offset feature is already on the store.
     
  29. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hello,

    you mean something like this:

    http://www.sgwoodworksllc.com/Incline_Board.JPG

    Like a box cut in diagonal, I will add it, it should be easy.
     
  30. DevoMage

    DevoMage

    Joined:
    Dec 19, 2012
    Posts:
    16
    yea a box cut diagonally. controlled by the height and width of the perpendicular angle planes... your example would be width of 2 and height of 1. and of course, depth of 2.

    thanks!
     
  31. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    If you are adding this specific case. Please add a more general Ramp that can be used for much more applications (other procedural primitive packages have this shape). Picture frames, Stairs, Ramps, etc.


    The angles on both ends of the rectangle can be adjusted.

    Here is a better image:

    $ProceduralRamp.jpg


    P.S. I made a request for this a few months back.

    http://forum.unity3d.com/threads/173575-PrimitivesPro-RELEASED/page10
     
  32. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Alright :).
     
  33. DevoMage

    DevoMage

    Joined:
    Dec 19, 2012
    Posts:
    16
    for a box - i need the 4 side faces to be one material, the top another material and the bottom another. i have an asset prefab that does this - i was wondering how to recreate it. the renderer has an array of 3 materials.

    how can i do this with the box primitive? i also need it for the arc pro primitive...
     
  34. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    I've been running into a very similar use case,

    It would make life so much easier if there were a way to be able to customize the UV-material mapping on the Primitive Pro objects. For example, an boolean in the inspector that allows the user to turn the object into a multi-mesh, which then allows the assignment of separate materials.

    Edit: Even better, to be able to visually in the editor, select the face of the object to assign a new material. If the material is the same for say 3 of the faces, then it's smart enough to make those three faces one mesh instead of 3 separate meshes.

    So something like: Shift select the 3 faces, right mouse click to choose the material.
     
    Last edited: May 4, 2014
  35. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    I was thinking similar way, to have some universal tool for picking/selecting faces which can be used for creating submeshes and/or for other features like extrusion etc.
     
  36. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    I just submitted modification of box primitive to asset store, there are few more parameters for adjusting box edges:

    $ramp.jpg

    Should be for download in few working days, version 1.8.3.
     
  37. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Nice one. That was speedy Gonzales.
     
  38. vidjo

    vidjo

    Joined:
    Sep 8, 2013
    Posts:
    97
    Just wanted to thank you for the updates, they have been very helpful :)
     
  39. dl_studios

    dl_studios

    Joined:
    Oct 14, 2012
    Posts:
    76
    Hi Reindeer,

    I'm loving PrimativesPro awesome asset. I love all the shapes that can be created with a single object.

    I've run into a little snag. I'd like to use PrimitavesPro gameObjects as triggers for OnTriggerEnter() OnTriggerExit() unity events. So when you've entered a primativepro OnTriggerEnter will fire and when you leave the bounds OnTriggerExit() will fire. However I've just discovered that both OnTriggerEnter and OnTriggerExit events fire one after another when running through the wall of a primativespro gameObject mesh.

    The objects I've tested so far are box and sphere. My guess is that the other will be the same.

    Do you know why this happens and do you have any suggestions on how I could accomplish what I'm after?

    Thank you
     
  40. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, thank you for using PrimitivesPro!

    Which type of colliders are you using - mesh colliders or default (box/sphere/capsule)?
     
  41. dl_studios

    dl_studios

    Joined:
    Oct 14, 2012
    Posts:
    76
    It happens with both mesh and default.

    I've attached a script to reproduce. Attach this to a regular unity cube primitive and set it to Trigger, and then do the same with a PrimitivesPro box and PrimitivesPro sphere also set to Trigger. Then in scene view, drag any collider with a rigidbody attached in and out of the cube, PrimitivesPro box, and PrimitivesPro sphere and it should reproduce the issue. Just make sure that Error Pause is marked off, or it might be hard to see it.
     

    Attached Files:

  42. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hello,

    I just tested the colliders and the script and I don't see any problems, I found only few errors when you create a CubePro object but triggers on/off are just fine. I think the problem is in the errors you see in the console, as you wrote "Error Pause should be marked off" - it means that you see errors during triggering? You shouldn't see any errors at all, otherwise it will raise an exception and the rest of the code will be skipped - not executed - not triggered. Are the errors related to PrimitivesPro? I fixed the BoxPro creation error, I attached the file so you can use it. Anyway try to fix all those errors first and then test the triggers again when the console is clean.
     

    Attached Files:

  43. dl_studios

    dl_studios

    Joined:
    Oct 14, 2012
    Posts:
    76
    So sorry, I attached the wrong script. That must have been confusing.

    If I had attached the correct script, what it would have demonstrated was that OnTriggerEnter() AND OnTriggerExit are firing when a rigidbody simply enters a primitivepro, which isn't the desired result. When a rigidbody enters, OnTriggerExit() should never fire. OnTriggerExit should only fire when a rigidbody exits a collider.

    Here's a video demonstrating the issue. Green objects are PrimitivesPro. The Red cube is Unity's standard cube. The unity standard cube gives the correct result. When I drag the orange cube into the red unity cube, OnTriggerEnter() fires. When I drag the orange cube out of the red cube, OnTriggerExit() fires. However on both the PrimitivesPro sphere and box objects when I drag the orange cube into either of them both OnTriggerEnter() and OnTriggerExit fire. Not the desired result. When I drag the orange cube out of a PrimitivesPro object both OnTriggerEnter() and OnTriggerExit fire. Not the desired result.

    Below the video is the code which I attached to all of the demo trigger objects in the video. So all of the red and green objects had the script attached. The orange cube with the rigidbody did not use that code. It was simply a unity cube with a rigidbody attached.

    Thanks for taking a look at this.




    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class TestTrigger : MonoBehaviour {
    5.  
    6.  
    7.  
    8.    
    9.     void OnTriggerEnter(){
    10.        
    11.        
    12.        
    13.         Debug.Log("ENTERED!!!");
    14.        
    15.        
    16.        
    17.     }
    18.    
    19.     void OnTriggerExit(){
    20.        
    21.         Debug.Log("EXITED!!!");
    22.        
    23.        
    24.        
    25.        
    26.     }
    27.  
    28.  
    29. }
    30.  
     
  44. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Thanks for explanation, I will look at it and let you know.
     
  45. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    I was playing with colliders and I found the problem. It doesn't work correctly with mesh colliders. When you use mesh colliders with BoxPro or SpherePro Unity does not detect the trigger correctly, probably because of the vertices ordering. I am not sure if I can fix it easily, but good news is that the box or sphere colliders are working correctly.

    This is a screenshot of my PrimitivesPro cube with box colliders:
    colliders.png

    This settings (Box Collider) is working correctly with the trigger. Can you use it instead of the mesh collider? I try to fix the problem, but it looks I will have to change the mesh vertices order.

    Regards,
    RG
     
  46. dl_studios

    dl_studios

    Joined:
    Oct 14, 2012
    Posts:
    76
    Thanks for taking a look at that.

    No. It would make collisions too inaccurate. For example if I used a box with an Edgeoffset, the OnTriggerEnter() on some edges would fire when the player hadn't actually entered the mesh. On small scale objects this might not be a huge deal, unfortunately I'd like to be using them for very large scale triggers like oddly shaped rooms and the like. The cool thing about primitives pro is the odd shapes that are available and modifiable at run time. Not having correct onTrigger enter adds difficulty not only to my project but also will throw off other users. It took me a couple hours to figure out that it wasn't my code but rather how Primitive Pros was reacting to OnTriggerEnter/Exit events. I'm surprised I'm the first to run across this issue. However, I'm sure that other developers will stumble across it and experience the same frustration.

    Does this mean that you will try to fix the problem but you suspect that this may a fundamental flaw and unfixable, or take a long while to fix?

    I just want to make sure that I understand the status on this, so I know how to proceed.

    Thank you.
     
    Last edited: Jul 10, 2014
  47. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    my apologies for late reply, I just returned from vacation. It is fixable, I just need to play with the triangles order and figure out the right way, I am working on it this week and put the fix here.

    Yes, you are the first developer who encountered this problem, but it could be also because I changed the box generation code recently (I added the edge offsets and not much people use this feature).

    Regards.
     
  48. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Is it possible to use Primitive Pro objects in ProBuilder from ProCore?
     
  49. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi Rocki,

    as far as I know, ProBuilder or Prototype from ProCore is using own internal data structures for creating/modifying meshes and it is not possible to use them with PrimitivesPro. Off course you can use PrimitivesPro objects in the scene but you will not be able to change them with ProBuilder tools.
     
  50. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Actually I found the answer:
    Under the Tools > Probuilder > Actions > ProBuilderize Selection

    This makes a primitive pro prefab object into an editable Probuilder mesh. Very cool.
     
    karl_ likes this.