Search Unity

PrimitivesPro [RELEASED]

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

  1. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,323
    Cool,

    Can it be done so that the X-axis is consistently lined up with one of the geometry's corner like in the video I sent. This is because I need to accurately rotate and position the created sphere according to its faces and segment corners.
     
  2. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    I just tested the sphere and I don't see any problems with pivot, I tested in Unity3.5 and Unity4.2, all pivot types (center, bottom, top) and the pivot seems to be stable no matter how many segments I change. Is your camera properly aligned with y axis? I noticed that you have a different rotation in scene view, your "Top" is x-up and z-left, my "Top" is z-up and x-right. I haven't find a way how to change it, can it be a problem? See my screenshot...

    $SphereBug.jpg
     
  3. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,323
    I did another video where the Z axis is the same as your setup.

    https://dl.dropboxusercontent.com/u/48378123/SphereProPivotProblem.mp4

    btw, you don't have to make the X-axis lined up with the segment, I noticed that the Z-axis is already lined up so I can use that. But the pivot centering problem is still happening for some of the lower segments.
     
  4. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    I still cannot reproduce the problem you have.

    1. I open Unity4.2
    2. Create new scene
    3. GameObject -> Create other -> PrimitivesPro -> Sphere
    4. Select "Top" camera view in scene window
    5. I change segments from 4 to ... any settings
    6. Pivot doesn't move at all

    Are you sure you have the latest version of the package?
     
  5. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,323
    Very strange,

    I deleted the PrimitivePro folder and imported the latest just to be sure, then I did exactly what you describe above a number of times yet still having the same issue.

    I have the latest package 1.6 with documentation saying 1.5.2 running UnityPro 4.2 on macbook pro.

    Could someone on the forum try this on their machine to see if they have the same problem ?

    Thanks.
     
  6. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    I have Unity 4.2 running on Windows 7. Very strange indeed, I will test it on different platforms.
     
  7. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Could you please try the new version on the asset store? Version 1.6.1 with doc saying the same. Not sure if it helps you but I just want to make sure we are using the same version.
     
  8. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,323
  9. NoXQS

    NoXQS

    Joined:
    Jan 26, 2013
    Posts:
    5
    Hi Reindeer games,

    Love your PrimitivesPro !

    We are using the MeshCutter, and we saw that you actually keep track of the contourList.
    Would it be too much to ask if you can update the meshcutter to return (besides the cut0 and cut1 gameobject) the intersectGame object based on the contourList ?

    We are trying to see the intersection in the scene (and eventually measure the length of this contour).

    Regards,
    NoXQS
     
  10. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,323
    Having access to the list of contours is really really helpful. There are many situations where this comes in handy.
    Also, would it be possible to get the list of Contours WITHOUT cutting ?
    Just to get the intersection points of the cutting plane and the object.

    Would be so Awesome if this feature could be added in the next update ?

    Cheers.
     
  11. reindeer-games

    reindeer-games

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

    I can definitely extend the mesh cutter, but I am not sure what you mean by "the intersectGame object based on the contourList". I see that there is already a method for getting a list of contour points:

    Code (csharp):
    1.  
    2. public float Cut(Mesh mesh, Transform meshTransform, Utils.Plane plane, bool triangulateHoles, out Mesh mesh0, out Mesh mesh1, out List<Vector3[]> contoursList)
    3.  
    But this method returns 2 meshes, not game objects, I can add a similar method with 2 game objects. Or is it something different you need?


    Sure, I can add this.
     
  12. reindeer-games

    reindeer-games

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

    I just made an update to the mesh cutter, I added a class for getting more information about contours and also to get contours without cutting. You can display contours with debug lines or create a polygonal object as in the picture. Update should be on asset store in 3 working days...

    Code (csharp):
    1.  
    2. // cut and get contour data in last parameter
    3. public float Cut(GameObject obj, Utils.Plane plane, bool triangulateHoles, bool deleteOriginal, out GameObject cut0, out GameObject cut1, out ContourData intersectionData)
    4.  
    5. // get contour without cutting
    6. public ContourData GetIntersectionData(GameObject obj, Utils.Plane plane)
    7.  
    $IntersectionBug.jpg
     
  13. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,323
    Super Awesomeness.
    Cheers Reindeer.
     
  14. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    242
    Just found a little Bug : In the Box/Pyramid Primitive the settings for "Cube" and "Uniform segments" are not stored in the editor. They are always deselected when I leave and reenter the gameobject.
     
  15. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,323
    Reindeer,

    The contour from the cutter is really cool.. So wicked that I'm using it quite a lot.

    Would it be too much to request for a small but very useful feature along the same idea as the meshCutter contour.

    To get the contours of two intersecting meshes.

    Edit: The contours of where the Outer Surfaces of the meshes meet.

    Cheers.
     
    Last edited: Oct 29, 2013
  16. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    unfortunately your feature request is not so simple as it seems. The problem of finding the contours of two intersecting meshes is the same as solving boolean operations problem which is quite complicated. My latest attempts to fix the boolean operations algorithm were not very successful, it works but there are lots of problematic edge cases, and after receiving negative comments on asset store I decided to disable the boolean operations until I figure out new algorithm.
     
  17. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,323
    Not a problem. Fingers Crossed for finding a better Boolean Idea.

    Cheers.
     
  18. ChaneDev

    ChaneDev

    Joined:
    Feb 12, 2013
    Posts:
    66
    Great package, I've been having fun with it, thanks! It would be great if you added integration with playMaker.

    I've got an asteroids style game where I wanted to randomly break apart the asteroids with the cutting feature. When I cut an object I want to copy the existing rigid body component to the copied objects so the keep the same physics characteristics and give each of the the pieces force.

    I am trying to script this in playMaker, but The problem I am having is that I am unsure which method to call to cut an object at run time (like you do with the cut button).

    Here is what I am trying to do: http://www.hutonggames.com/tutorials_game_design_with_playmaker.php

    $PlayMakerPrimitivesPro.jpg

    Can you point me in the right direction?

    Thanks,
    ~C
     
  19. reindeer-games

    reindeer-games

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

    first of all thanks. About Playmaker, I am not a very good expert on it, but I know that it does not allow you to call method with more than one parameters. But you can try to add this method to CuttingPlane.cs

    Code (csharp):
    1.  
    2.         public void Cut()
    3.         {
    4.             MeshUtils.Log("Cutting: " + cuttingObject.name);
    5.  
    6.             var cutter = new MeshCutter();
    7.  
    8.             // create cutting plane
    9.             var plane = ComputePlane();
    10.  
    11.             ContourData contour;
    12.  
    13.             GameObject cut0, cut1;
    14.             GenerationTimeMS = cutter.Cut(cuttingObject, plane, triangulateHoles, deleteOriginal, out cut0, out cut1, out contour);
    15.  
    16.             if (cut0 != null)
    17.             {
    18.                 cut0.AddComponent<DefaultObject>();
    19.                 cut1.AddComponent<DefaultObject>();
    20.             }
    21.         }
    22.  
    This method will be exposed to Playmaker and you should be able to cut the object in "cuttingObject" member.
     
  20. ChaneDev

    ChaneDev

    Joined:
    Feb 12, 2013
    Posts:
    66
    Thanks Reindeer,

    I added it to CuttingPlane.cs and am getting this:

    Assets/PrimitivesPro/Scripts/GameObjects/CuttingPlane.cs(27,13): error CS0246: The type or namespace name `ContourData' could not be found. Are you missing a using directive or an assembly reference?

    I'm a bit of a noob, I tried adding the namespace, but couldn't find ContourData

    On a side note I am looking at Exploder, do you think I could use it to create space junk that cracks and breaks apart in relatively random but visually interesting ways in space?

    Thanks,
    ~C
     
  21. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    I think you will need to download new version of the package. "CountourData" were added last week :).

    I think you definitely can. Exploder was made for breaking stuff apart, all fragments pieces have rigid bodies and all physical properties you would expect, you can play with the demos. And by the way, exploder will be on sale by the end of this month :).
     
  22. dl_studios

    dl_studios

    Joined:
    Oct 14, 2012
    Posts:
    76
    Hi, I just purchased Primitives Pro. Looks like it will be awesome! Unfortunately, I imported and I'm getting this:

    Assets/PrimitivesPro/Scripts/Demo/Demo.cs(113,35): error CS0117: `Box' does not contain a definition for `Create'

    and this

    Assets/PrimitivesPro/Scripts/Demo/Demo.cs(440,32): error CS0030: Cannot convert type `PrimitivesPro.GameObjects.BaseObject' to `Box'


    I'm running version 4.2.2f1 of Unity.

    Any suggestions as to how to fix this?

    Thanks

    ~D
     
  23. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, first of all thanks for your purchase!

    You see the error because you already have another class "Box" that is in conflict with Box from PrimitivesPro. You can easily fix this issue by adding namespace prefix before the Box like this:

    Code (csharp):
    1.  
    2. // old code
    3. shapeObject = Box.Create(1f, 1f, 1f, 1, 1, 1, false, PivotPosition.Botttom);
    4.  
    5. // replace with this
    6. shapeObject = PrimitivesPro.GameObjects.Box.Create(1f, 1f, 1f, 1, 1, 1, false, PivotPosition.Botttom);
    7.  
    This should work, let me know if you have more problems.
     
  24. dl_studios

    dl_studios

    Joined:
    Oct 14, 2012
    Posts:
    76


    Great! Thanks for the quick response! It fixed the issue.
     
  25. mohydineName

    mohydineName

    Joined:
    Aug 30, 2009
    Posts:
    301
    Hi this is perfect for what I need, but.... How can I export a model to .obj?

    Stephane
     
  26. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, thanks, export to obj is not currently part of this package, I might integrate it in next updates. However you can use now the obj exporter from unity wiki:

    http://wiki.unity3d.com/index.php?title=ObjExporter

    Cheers.
     
  27. vidjo

    vidjo

    Joined:
    Sep 8, 2013
    Posts:
    97
    Hello, I am wondering if we are permitted to release assets that have PrimitivesPro dependencies?
     
  28. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, you can, but you cannot resell the package. You can release your asset with description that it is dependent on pp, but you cannot include it.
     
  29. Andy2222

    Andy2222

    Joined:
    Nov 4, 2009
    Posts:
    81
    I have the same problem, so how is the primitives Pro work-flow in such a case? We use it for fast dummy asset testing/setup, so we don't actually want/need to save the mesh and would like to keep it as flexible, dynamic script.

    Atm we have to trigger the "uiChange" bool on all objects that use a primitive pro script, which actually defeats the purpose we bought this asset to quickly setup/test things?

    Is there no way to have the script automatically recreate the mesh for a newly placed prefab?


    Thx Andy
     
  30. reindeer-games

    reindeer-games

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

    if you want to create a prefab from PP the only way to do it is through the "Create prefab" button in the inspector view. (Implementation is in Editor/Utils.cs, SavePrefab). But I see you would like to create a prefab but not save the mesh. That can be a problem to do because Unity prefab is nothing else than a container (or a template) with links to mesh, material, script and other components that needs to be physically saved in Asset folder on the disk. You loose mesh connection when you drag&drop PP to assets folder simply because the mesh and material is not saved to disk. That's why I provide the "Create prefab" button that saves the mesh and material.

    I am not sure I can help you with this, the only way is to create some kind of "hack" check if the mesh is empty regenerate it again and if the material is empty recreate it again.

    Or can you simply forget about prefabs and create the PP objects in runtime?
     
    Last edited: Nov 28, 2013
  31. Andy2222

    Andy2222

    Joined:
    Nov 4, 2009
    Posts:
    81
    Hi,

    i don't consider fixing a "expected" prefab behavior a "hack", so i went ahead and added this.

    Code (csharp):
    1.  
    2.     [RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
    3.     public abstract class BaseObject : MonoBehaviour
    4.     {
    5.  
    6.         void OnValidate()
    7.         {
    8. #if UNITY_EDITOR
    9.             if (UnityEditor.EditorUtility.IsPersistent(this)) {
    10.                 return;
    11.             }
    12. #endif
    13.             var meshFilter = GetComponent<MeshFilter>();
    14.             if (meshFilter  meshFilter.sharedMesh == null) {
    15.                 GenerateGeometry();
    16.             }
    17.  
    18.             var meshCollider = GetComponent<MeshCollider>();
    19.             if (meshCollider  meshCollider.sharedMesh == null) {
    20.                 GenerateColliderGeometry();
    21.             }
    22.  
    23.             var meshRenderer = GetComponent<MeshRenderer>();
    24.             if (meshRenderer  meshRenderer.sharedMaterial == null) {
    25.                 meshRenderer.sharedMaterial = new Material(Shader.Find("Diffuse"));
    26.             }
    27.         }
    28. }
    29.  
    I was not sure why there is no "RequireComponent" attribute set, so we added it, since u can delete the MeshFilter/Renderer which will result in null exceptions, since a couple of null checks are missing.

    bye Andy
     
    Last edited: Nov 28, 2013
  32. Andy2222

    Andy2222

    Joined:
    Nov 4, 2009
    Posts:
    81
    I just noticed a problem/exception with the "generateMeshCollider" option and GenerateColliderGeometry(), i think i cant call it this way?
    Could u plz check my logic and give me a hint how to correctly generated/set the meshCollider as well?

    Maybe this:
    Code (csharp):
    1.  
    2. if (meshCollider.sharedMesh == meshFilter.sharedMesh)
    3. {
    4.       meshCollider.sharedMesh = new Mesh();
    5. }
    6.  
    should be this?
    Code (csharp):
    1. if (meshCollider.sharedMesh == null)
    2. {
    3.       meshCollider.sharedMesh = new Mesh();
    4. }
    5.  
    Thx Andy
     
    Last edited: Nov 28, 2013
  33. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    great job, I didn't know about OnValidate until now.

    To fix the mesh collider it is better to use:

    Code (csharp):
    1.  
    2. if (meshCollider.sharedMesh == meshFilter.sharedMesh || meshCollider.sharedMesh == null)
    3. {
    4.      meshCollider.sharedMesh = new Mesh();
    5. }
    6.  
    Because in general you might want to have different visual and collider mesh.
    Otherwise the code looks good, I will test it more and make a new update.

    Thanks.
     
  34. Ertai7

    Ertai7

    Joined:
    Nov 30, 2013
    Posts:
    11
    Hi

    Don't know if this was already covered. I could not find it anyhow and this seems the only support forum.

    I purchased Primitive Pro today.
    My level design requires a lot of slopes, so I use the cutting tool frequently.
    While it worked nicely for a while, now I get some strange behavior:
    - the cutting plane also cuts objects it does not touch
    - the cut happens to be in a place and angle that does not match the cutting plane (neither visually in the editor, nor coordinates in the inspector.)
    - additionally I get a number of errors in the console (NullReferenceExceptions, Assert - all points are collinear, Destroy may not be called form edit, ...)

    I restarted Unity - to no avail.
    Any idea what's wrong?
     
  35. Andy2222

    Andy2222

    Joined:
    Nov 4, 2009
    Posts:
    81
    Yes this looks good, btw its kinda impossible to quickly implement this, since the "base.GenerateColliderGeometry()" is called late instead of early in the derived classes. This means i cant put this fix into the BaseObject, since each derived version has its own copy&paste of this code. Might be a good idea to move this logic into the baseObject and call savestate separately.

    bye Andy
     
  36. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Yes, I know the API is kind of organic :). I'll put it to base class...
     
  37. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, to answer you questions:

    The cutting plane is infinite, the plane in editor is just a visual helper to see where the plane is, the size of plane doesn't impact the cutting, if you want to cut only one object, you can add the object in cutting plane inspector. Otherwise it will cut every game object.

    I haven't seen this type of error yet, it would be best if you can send me a package with scene and the object and cutting plane, so I can run the same situation on my machine and debug it. You can just create a simple scene with one object and one plane that causes the error, otherwise it will be hard for me to fix it. You can send it to me on email: gamesreindeer@gmail.com.

    Thanks.
     
  38. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    A new version 1.6.3 is already on asset store (couple of days actually, I didn't get any notification from Unity...).

    There are two new features:

    1. Creating the prefab with drag&drop is now working (the implementation of the OnValidate() as we discussed here recently).
    2. OBJ export, there is another button in the inspector for exporting to OBJ format.
     
  39. erictang

    erictang

    Joined:
    Jul 28, 2012
    Posts:
    15
    add slice in torus?
     
  40. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    yes, I can add it, I put it into the next release.
     
  41. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    The torus with slice parameter is already on Asset Store, version 1.6.4.

    Regards.
     
  42. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,323
    Been having lots of fun with this Great Package.

    A request for a procedural ramp shape. With this basic shape, we can make ramps and stairs.

    Cheers

    $ProceduralRamp.JPG
     
  43. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Version 1.7 was just published on asset store, it contains 20th primitive:

    Spherical cone
     

    Attached Files:

  44. Razmot

    Razmot

    Joined:
    Apr 27, 2013
    Posts:
    269
    PrimitivesPro is awesome.

    Can we get inner radius for the cone ( to make hollow cones) in a future update ?

    Thanks
     
  45. chocolate1

    chocolate1

    Joined:
    Feb 4, 2014
    Posts:
    3
    Hello!

    Are you considering to improve the boolean operations? I read in the asset store that's still a little problematic function of your package. I need it so much!

    Thanks!
     
  46. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hello,

    currently the boolean operations is disabled (or just commented out) because it is quite unstable, unfortunately I don't have plan to fix it in the near future, mainly because of time and complexity.
     
  47. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Yes, I can update it, but it might take some time, couple of weeks.
     
  48. chocolate1

    chocolate1

    Joined:
    Feb 4, 2014
    Posts:
    3
    Thanks for the answer and good luck with Primitives Pro, it lucks awesome!
     
  49. CydonB

    CydonB

    Joined:
    Feb 27, 2014
    Posts:
    1
    I need a thickness with cone primitive. Thank you for support
     
    Last edited: Feb 27, 2014
  50. vidjo

    vidjo

    Joined:
    Sep 8, 2013
    Posts:
    97
    Hello, can you please add Scene view handles to your primitives. It is difficult to manipulate them in the inspector. I am most interested in Sphere, Capsule, and Box types....

    It would also be helpful to create a function(and inspector button) to reposition/update the collider. I am most interested in primitive colliders types, not mesh colliders. Maybe a checkbox toggle to always lock the collider to match the generated mesh? I'd prefer if this was efficient, and only ran if a change was made, and didnt recreate the component, but instead just altered the width, height, radius, etc, parameters of the primitive. Then if I change the height of a capsule, for example, in game, it would automatically update my capsule collider to match the new longer capsule geometry.

    Lastly, It would be nice if there was a way to have the capsule primitive stay the same visual height even though you change the radius size. Again maybe a toggle switch can toggle between the different behaviours. And a function in the API to do it programatically as well.

    Thank you for the great support. I will continue to recommend your product.
     
unityunity