Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

PrimitivesPro [RELEASED]

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

  1. brianbraatz

    brianbraatz

    Joined:
    Apr 21, 2013
    Posts:
    17
    Question- because you are searching by NAME for the object- how do you handle multiple objects of the same type in the scene?

    I am not in front of unity right now- and I have NOT tried to add multiple objects of the same type yet- but curious if this is supported..

    thanks

    Brian
     
  2. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    editing of multiple selected primitives of the same type is not supported.
     
  3. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,317
    There is a bug when a primitivespro object is renamed in the inspector then changing the parameters in the inspector has no effect on the object. Have to change the name back to default then it works.

    For example:
    1. Create new "BoxPro" , able to change params in inspector
    2. Change name to "BoxPro1", doesn't work
    3. Change back to "BoxPro", works.

    Edit:

    In the CreateBox.cs line 106

    if (Selection.activeGameObject Selection.activeGameObject.name == "BoxPro")

    var box = Selection.activeGameObject.GetComponent<PrimitivesPro.GameObjects.Box>();

    if (box)
    {

    It's looking for "BoxPro" so no other names will work. This hard-coded naming situation is the same for other primitivesPro objects that's created.

    For now I'm doing this:
    if (Selection.activeGameObject)

    to make it work.

    because the next two lines make sure that the selected object is a primitivesPro Box object anyway.
     
    Last edited: Apr 29, 2013
  4. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,317
    PrimitivesPro is amazing and I am really having lots of fun trying to incorporating it into an existing project.

    Because I'm using it extensively, it's inevitable that minor bugs are popping up.

    Here is a small one but quite a show stopper.

    Copies of "BoxPro" do not act independently.

    Test:
    1. Create 2 BoxPro objects in Editor
    2. Each BoxPro can be independently controlled via the sliders.
    3. Copy or Duplicate one of the BoxPro objects
    4. Adjusting the slider on the original or copy will affect both.
    5. Adjusting unity's transforms Pos,Rot,Scale still works independently for each object.
     
  5. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Thank you for all your bug reports. This week should be out a new version with fixes and with a new big feature :).
     
  6. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,317
    Super Cool. Good on Ya.

    Edit:

    Just updated to the new version. Holy Cow - or Horse. This new Cutting Feature is Wicked ! Nothing less than Magic. Really enjoyed running the demo and watching it randomly cutting shapes.

    This Package is Blossoming big time. Anyone who is interested should buy it right away.

    It looks this cutting technology has laid a solid foundation for Boolean Awesomeness.

    Big Thumbs Up.
     
    Last edited: May 2, 2013
  7. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    New version 1.3 is already on Asset Store.

    Features:

    * mesh cutter - can cut any mesh or game object, simple interface is provided, supports mesh with holes (Tube)
    * duplicating of game object - new button for duplicating a primitive
    * fixed renaming of a primitive object
    * few minor fixes

    $13a.jpg

    [video=youtube_share;tccSMB87SG0]http://youtu.be/tccSMB87SG0


    Cutter Demo


    Link to Asset Store
     
  8. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,403
    The mesh cutter feature is great! Is the "cut" function accessible during runtime?
     
  9. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Yes,

    via 2 public methods:

    Code (csharp):
    1.  
    2. public static float Cut(GameObject obj, Utils.Plane plane, bool triangulateHoles, bool deleteOriginal, out GameObject cut0, out GameObject cut1)
    3. public static float Cut(Mesh mesh, Transform meshTransform, Utils.Plane plane, bool triangulateHoles, out Mesh mesh0, out Mesh mesh1)
    4.  
    You can see a webplayer demo: Demo
     
    Last edited: May 2, 2013
  10. Jerware

    Jerware

    Joined:
    May 15, 2012
    Posts:
    41
    I shutter to think how many horses were harmed in the making of this update. Great stuff!!! Thanks for making PrimitivesPro even more useful.
     
  11. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Many :D.

    Thanks.
     
  12. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,146
    WOW ! Crazy !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    Thanks a lot !

    @ Jerware : Ha ! Ha !

    6R
     
  13. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    242
    SUPER!!! This Asset excites me more and more.:D

    How is the color of the new faces after cutting calculated? Is it just the color from the material? Would be great if we could assign a special texture for the new cut-faces.

    Can we expect some further texture-mapping features/modes for the other primitves?

    Right now it seems that the texture-mapping for the capsule, triangle, torus and ellipsoid is incorrect (mirrored) on the x-axis.
     
  14. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Well, the color you see is the original texture, just the uv mappings are all set to zero. And yes, I want to fix the uv mapping, make it planar and possibly assignable with custom texture.

    Yeah, definitely, I will be updating the project. And if you know about any problems or bugs, just write it here.
     
  15. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,317

    I found a workaround in Box.cs
    For some reason, if a new Mesh() is created for the sharedMesh, then the boxes can be controlled independently. Othewise, all boxes are affected.
    Perhaps mesh.Clear(); is not working?
    What would be the impact of creating a new Mesh() each time GenerateGeometry() is called? Perhaps you can check out the reason for this problem.


    public void GenerateGeometry(float width, float height, float depth, int widthSegments, int heightSegments, int depthSegments, bool cubeMap, PivotPosition pivot)
    {

    // generate new mesh and clear old one
    var meshFilter = GetComponent<MeshFilter>();


    //if (meshFilter.sharedMesh == null)
    // {
    meshFilter.sharedMesh = new Mesh();
    // }

    var mesh = meshFilter.sharedMesh;
    mesh.Clear();
     
  16. Jerware

    Jerware

    Joined:
    May 15, 2012
    Posts:
    41
    Getting a bunch of warnings in console related to activating GameObjects. E.g.:

    Assets/PrimitivesPro/Editor/CreateCuttingPlane.cs(62,50): warning CS0618: `UnityEngine.GameObject.active' is obsolete: `GameObject.active is obsolete. Use GameObject.SetActive(), GameObject.activeSelf or GameObject.activeInHierarchy.'

    No biggie, just letting you know.
     
  17. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    242
    Read the first page of this thread and you have the answer.=> leaking meshes into the scene.
     
  18. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,317
    Leaking Mesh, ouch.

    How to get independent instances without a Leaky scene.
     
  19. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    242
    What about the new Duplicate feature? Look at the inspector of your primitive. If you make a copy with just duplicating a sceneobject in the hierachy view you have the trouble with referencing the same mesh, but with the duplicate feature from the inspector you have two independet instances.:cool:
    (Another way would be to to save the mesh of your primitive to the assetdatabase and duplicate the primitve in the hierachy view, then selecting the saved mesh and assign it to the meshfilter of your duplicated instance)
     
  20. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,317
    Cool, the duplicate function did the job. The new clone object is treated as a separate instance and does not go through the "New Mesh()" code.

    Looks like the code is in Editor Only :

    Utils.DuplicateObject<PrimitivesPro.GameObjects.Box>(this);

    Can the next update add the functionality that we can call "DuplicateObject()" during Runtime?

    Thanks.
     
  21. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,317
    Really having lots of Fun playing with the new Mesh Cutting feature. Great addition.

    Was wondering if you could give some pointers of how to do the following:

    1. I'm cutting one mesh into a number of trianglular Pie-shaped pieces and assembling these pieces together into Round Pie.
    Once I have all of these separate triangular pieces, how to weld the common vertices of two adjacent pieces together.

    Was thinking that when the Plane cuts through a mesh, there must be an array of points that it intersects. I thought of getting access to the array of vertices for each piece and then welding it to the vertices of the adjacent piece.

    2. How to make sure that the UV mapping is still working after cutting and assembling these pieces together.


    Cheers.
     
  22. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, Good idea, I will add it.
     
  23. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    There is an array of intersecting points, you can find it in MeshCutter.cs file, if you look into a method Triangulate, first I find the "contour" of intersecting vertices and then triangulate them. But it might be a little bit complicated if you have lots of independent pieces. Ideal way would be to use a boolean operation "union". I have plans to do it, but I cannot promise when.

    There is no easy way to do this. You can have perfect UV mapping on primitives but if you cut them into pieces and weld them together there is no guarantee the UV mapping will fit together. You can always try to change the UV mapping in the code but it is not so simple and usually waste of time. The "proper" way to do this is to use unwrapping tool. Unwrap the model geometry onto a plane and manually change the uv mapping.
     
  24. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,317
    Thanks for the tips.

    1. "boolean operation "union" -- This would be Fantastic.

    Thanks.
     
  25. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    242
    Hey, just realized that there is a new version (1.4)
    What a great release!!!
    The Superellepsoid is fantastic and all the other stuff you added or fixed!!!
    Many thanks!

    Right now I only miss a bevel feature as I have to create a box with some beveled edges that I can't generate with your asset.
    With the RoundedCube I can't get the shape I want because I can't specify the rounding of the edges for the different axis separately.
    Are you planning to implement some bevel feature? (At least for the box it would be great)
    [Edit]I'll guess the Superellipsoid has the feature I need. Just played around with it and realized that I have better control of the roundings for the different axis :D[Edit]
     
    Last edited: May 9, 2013
  26. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    New version 1.4 is already on Asset Store.

    Features:

    * Superellipsoid (wiki)
    * Custom material for a "cut-face"
    * Triangle subdivision
    * Duplicating of a Primitive in runtime
    * Fixed UV mapping for triangle, torus, capsule, sphere and ellipsoid
    * Fixed pivot position of cutting objects

    $14.jpg


    Link to Asset Store
     
  27. darrinm

    darrinm

    Joined:
    Apr 6, 2013
    Posts:
    5
    I just bought this. Looks great! But I am hitting build problems after installing:

    Assets/PrimitivesPro/Editor/CreateBox.cs(41,27): error CS0117: `Utils' does not contain a definition for `SliderEdit'
    Assets/PrimitivesPro/Editor/CreateBox.cs(44,27): error CS0117: `Utils' does not contain a definition for `Toggle'
    Assets/PrimitivesPro/Editor/CreateBox.cs(71,27): error CS0117: `Utils' does not contain a definition for `PivotPosition'
    Assets/PrimitivesPro/Editor/CreateBox.cs(100,15): error CS0117: `Utils' does not contain a definition for `StatWindow'
    etc...

    UPDATE:
    I don't see the problem when I import PrimitivesPro into a new blank project. Looking for namespace collisions now...

    UPDATE 2:
    There was a conflict with another asset "Advanced Primitives". After removing it PrimitivesPro is compiling and working great.
     
    Last edited: May 9, 2013
  28. darrinm

    darrinm

    Joined:
    Apr 6, 2013
    Posts:
    5
    So now a feature request. It'd be great if PrimitivesPro could generate (user tuned) optimized collider meshes. As is, generated meshes are often too high poly for MeshCollider to deal with.
     
  29. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, great you fixed the conflict. Custom mesh colliders is a good idea, I will add it.
     
  30. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    242
    New feature request: Add a save/duplicate component to sliced objects or make a option on the cutting plane for saving the new meshes.
    Right now I have no chance to save my sliced objects to the Assetdatabase as a new mesh without adding my own script to handle this. I guess a lot of people (beside me) want to save the new generated meshes after slicing a primitive.
     
  31. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Good point, wait for next update...
     
  32. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    New version 1.5 is already on Asset Store.

    Features:

    * Boolean operations
    * Custom mesh colliders
    * Duplicating and saving "result" mesh (after cutting or applying boolean operations)

    (The boolean operations work best with convex models, however you can use non-convex model as well, the only issue here is a higher number of generated vertices/triangles)

    $15.jpg

    Link to Asset Store
     
  33. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Forgot to add a Youtube video...

    [video=youtube_share;pRdbg0n_D6k]http://youtu.be/pRdbg0n_D6k
     
  34. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    242
    WOW!!! :D This Asset is now so supercool.(And I'm a bit dissapointed that I have no idea what else should come now :wink: )

    I have only one question: Does the invert feature in the BooleanOperations component only invert the normals of the first operand or what does this function in terms of a boolean operation?
     
  35. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Thanks, I am also happy with this package, I don't think I will add more big features, just bug fixes or optimizations... I will focus now on new assets, more game related.

    Yes, exactly. It just flips normals of the first operand.
     
  36. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,146
    Bravo !!!

    6R
     
  37. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,317
    Super Cool. This Boolean Operations is Sweeet.

    Thanks so much for adding this feature.
     
  38. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,317
    Got a question that's un-related to boolean operations.

    I am doing a really simple Prefab creation by doing the following:

    1. I have a CylinderPro object in the hierarchy.
    2. Created empty prefab in project
    3. Dragged CylinderPro object from hierarchy into the empty prefab.
    4. clicked on the prefab to view it's info.
    MeshFilter:[none]
    Mesh None(Mesh)

    5. In the original CylinderPro object, MeshFiler is not empty.
    6. Because the MeshFilter is empty. when the prefab is dragged into the scene, nothing shows up.

    Thanks.

    Edit: Found the Bug -- If you change the slider values in the inspector for the prefab that got dragged into the scene, then the geometry shows up with mesh and materials. The problem is that GenerateGeometry() did not fire to generate the mesh. Interesting Bug.

    Another Bug that might be related: Meshes that are generated by the cutting operation also lose both the Mesh and Material when they are turned into a Prefab. I haven't tested the Boolean operations yet.
     
    Last edited: May 30, 2013
  39. Jerware

    Jerware

    Joined:
    May 15, 2012
    Posts:
    41
    Hi reindeer games,

    I'm trying to create a "pacman" shape using the CylinderPro primitive (like a pizza with a slice removed). I can't find another shape to slice it with using the new boolean operation that gives precise cuts (45 degree opening, for instance). Can you make a suggestion, or even better add a "slice" parameter to the cylinder just like you did to the tube? It would make my project so much simpler to edit. Thank you!
     
  40. idlebyte

    idlebyte

    Joined:
    Feb 3, 2013
    Posts:
    17
    Can the original shape be saved relative to the gameobject so that the boolean operations can be undone/changed later without recreating the shape?

    thanks,
    -D
     
  41. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hello there,

    I am sorry for late reply, notification system does not work at all :(.

    I will look at your requests and make update for next version.
     
  42. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,317
    Another Bug Report:

    1. CylinderPro Scaling -- When the SCALE changes, the shapes goes very weird, doesn't maintain its shape. When CylinderPro is created, it comes in with a default scale of (0.2237137,1,0.6369426). I haven't tested other primitivePro objects yet.

    Edit: This happens on and off and not all of the time. Is it normal that it's not meant to keep its cylinder shape when scaled.

    2. Cutting Plane's UV's are not Normalized. The UV's coordinates that are produced in the final Mesh from the cutting plane operation are not from -1 to 1. I've seen -8 to 12.
     
    Last edited: Jun 10, 2013
  43. Taziar

    Taziar

    Joined:
    Jun 20, 2013
    Posts:
    2
    The lighting seems to be all screwy with the Boolean created objects. Take a Box, put a cylinder through it and run the Boolean subtract (creating a tunnel through the box). Put a point light in the hole, and the hole stays dark. Put the light above or below the hole and it lights up the inside of the hole. Basically it is flipped. As is the Boolean subtract is useless, which sucks as it is the reason I bought the package in the first place.
     
  44. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hello there,

    I looked at your problem and it is a known limitation of Unity. Basically you cannot create a prefab from code generated mesh.

    More in this post:

    http://answers.unity3d.com/questions/285144/generated-meshesmaterials-cannot-be-made-into-pref.html

    The only way to create a prefab is to save a mesh (via inspector view button "Save mesh") and then create a prefab with that mesh.

    Prefab is nothing else then a list of project assets (model, material, mesh) and they need to be saved in asset folder.
     
  45. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hello there,

    I just tested and found a quick fix to your problem. Please locate the file

    "CSG.cs"

    go to line 142, there should be this code:

    Code (csharp):
    1. mesh.SetTriangles(triangles1.ToArray(), 1);
    After that add a new line with this code:

    Code (csharp):
    1. mesh.RecalculateNormals();
    .


    So it should look something like this:

    Code (csharp):
    1.  
    2.             mesh.SetTriangles(triangles1.ToArray(), 1);
    3.  
    4.             mesh.RecalculateNormals();
    5.  
    6.             mesh.Optimize();
    7.  
    That's it, now the lighting should work. If you still have problems I will send you the file via PM.

    Regards,
    RG
     
  46. Jerware

    Jerware

    Joined:
    May 15, 2012
    Posts:
    41
    My request may have gotten lost in the shuffle. Would it be possible to add a slice parameter to the cylinder (like tube has)?
     
  47. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Not in the shuffle, still in my TODO list, I was just busy with different projects last few weeks. I will update the package very soon.
     
  48. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    I was just about to implement the slicing parameter to CylinderPro and I just realized that you can achieve the same effect (Pacman) with TubePro
    with inner radius set to 0:

    $pacmanBug.jpg

    Is this what you wanted to achieve?
     
  49. Jerware

    Jerware

    Joined:
    May 15, 2012
    Posts:
    41
    Well that's embarrassing. You're right! Thanks for the tip.
     
  50. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    You are welcome :).