Search Unity

PrimitivesPro [RELEASED]

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

  1. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, I just tested scaling with CylinderPro and I don't see any problems. What do you mean by "doesn't maintain its shape"? The default scale is really weird, because I don't change scale parameter at all. Is it still happening on your side?

    You are right, if it is a problem I can fix that.
     
  2. reindeer-games

    reindeer-games

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

    I am not sure if I understand you correctly. The boolean operation inspector view has an option "Delete original objects". If you leave it unchecked you can still access original objects:

    $booleanDialog.jpg

    Or did you mean something else?
     
  3. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    336
    Suggestions:
    1. It would be nice if the Primitive was selected when it is created.
    2. Bake/Save to prefab. (Yes I know the current way to make a prefab)
    3. After checking "Generate mesh collider", create the collider with current settings automatically. Right now you have to switch edit modes, then go change a parameter to update/create the collider.

    Bugs?
    1. When Edit mode is Collider
    -Flip normals can only be checked
    -Clicking Share material will uncheck Flip normals (ahah a bug that fixes another bug :) )

    2. If you uncheck "Generate mesh collider" and was in "edit collider mode", parameter changes don't effect the mesh.
    *oblivious fix would be to set edit mode back to mesh when "Generate mesh collider" is being unchecked.
     
  4. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    thank you for your feedback, I will make an update for the next version.
     
  5. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    New version 1.5.3 is already in the Asset Store.

    I fixed most issues mentioned here and added a "Create prefab" feature. Note that by creating the prefab it will also save the mesh, collider mesh (if any) and material (if does not exist).

    Regards,
    RG
     
  6. VectorF22

    VectorF22

    Joined:
    Jul 19, 2013
    Posts:
    5
    Hi there,

    I've just bought your amazing kit, but I've hit a wall pretty quick...

    I'm using playmaker to program my game and I'm trying to animate the property of a parameter value on the fly, in game... For example...
    I have a tube and I'm using an 'Ease Float' animation on a float variable and I'm passing that animated float to one of the radius parameters of the tube. The problem I'm having is that while you can see the variable animating (say, going from 0 to 1 over 10 seconds) it isn't visually represented in the game. The tube just stays the same. If on the other hand, I manually play around with the unity sliders during run-time, it updates the model just fine.
    I've also noticed on one of your demo's that you have the parameters of a primitive animating over time, so it's definitely possible...

    Is this just a problem with playmaker, or am I missing something?

    Many thanks.
     
  7. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, I don't have Playmaker here, but I think it should work, make sure you call GenerateGeometry() after you change the parameters:

    Code (csharp):
    1.  
    2. var box = Box.Create(1, 2, 3, 1, 1, 1, PivotPosition.Bottom);
    3. box.width = 43;
    4. box.GenerateGeometry();
    5.  
    The demo is also included in the package, look for Demo.cs.

    Cheers.
     
  8. VectorF22

    VectorF22

    Joined:
    Jul 19, 2013
    Posts:
    5
    Thanks for the reply!

    I'm not generating the primitive by code, I'm creating the primitive in the editor as a game object and adding the playmaker FSM to that game object...

    Is there a simple, generic script that I could pass into playmaker that would call GenerateGeometry? Something like (and I know this wont work, but..)


    Code (csharp):
    1. using System.Collections.Generic;
    2. using PrimitivesPro.GameObjects;
    3. using PrimitivesPro.Primitives;
    4. using UnityEngine;
    5. using Plane = PrimitivesPro.GameObjects.PlaneObject;
    6.  
    7. public class GenerateGeometry : MonoBehaviour {
    8.  
    9.     void Start () {
    10.    
    11.     }
    12.    
    13.     void Update () {
    14.        
    15.         GameObject.GenerateGeometry();
    16.    
    17.    
    18.     }
    19. }
    [/script]

    Edit - Or better yet, is there a script I could attach to the primitive to force it to call GenerateGeometry every frame?

    Thanks
     
    Last edited: Jul 19, 2013
  9. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    to be honest I never used Playmaker before and I have no idea how does it work. But I am just watching tutorial videos to understand it, I will figure it out...
     
  10. VectorF22

    VectorF22

    Joined:
    Jul 19, 2013
    Posts:
    5
    Hey,

    That's really awesome of you!! Playmaker is incredibly powerful and simple so I'm sure after watching a few of the tutorial videos you'll understand the basic concept behind it really quickly...

    Many developers of 3rd party asset kits also make custom playmaker addons or 'action packs' for easy integration. For those that don't do that, playmaker allows you to use a 'Set Property' action which gives you generic access to parameters of a script... This is what I was using to change the radius parameters on the tube primitive. Like I say, the number value of the parameter was being changed just fine, it just wasn't being updated visually...


    On a completely un-related note -

    I've been using the pyramid and triangle primitives and I've noticed that the pivot point isn't central, even when you set it to be center... It's slightly above the center point, so when you rotate it, it doesn't rotate uniformly.... Is it possible to make it perfectly central somehow?


    Thanks again :)
     
  11. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, the updated version of PrimitivesPro is finally on the asset store. I added flag for generating geometry every frame, I tested it with Playmaker and it seems to be working. You just only need to set the property "generateGeometryEveryFrame" to True and then you can change parameters as you wish.

    About the pyramid, I was looking at the center point and it is really a center :). I think it might look like an optical illusion, but after measuring it is really a center.

    Please test and let me know if you have any more problems.
     
  12. VectorF22

    VectorF22

    Joined:
    Jul 19, 2013
    Posts:
    5
    You're a legend, it works great! How would I go about applying the same variables to the Collision Mesh so that it's updated at the same time?

    I've taken some screenshots of the triangle primitive to show you what I mean...
    $triangles.png
    When you rotate the triangle, it doesn't rotate in an even circle (which I've drawn in for you).


    Thanks!!
     
  13. Leuthil

    Leuthil

    Joined:
    Jul 26, 2013
    Posts:
    94
    Wow this asset looks extremely impressive. I was about to dive into doing my own boolean operations but I wasn't really sure where to even start. My one question is: Are the boolean subtractions only available to the primitives from this asset package or do they work on any meshes? Also can these functions be done completely in scripting because the project I am developing is 100% in script.
     
  14. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Try this:

    Open "BaseObject.cs" located in PrimitivesPro/Scripts/GameObjects/BaseObject.cs

    and replace Update() with this:

    Code (csharp):
    1.  
    2.         void Update()
    3.         {
    4.             if (generateGemoetryEveryFrame)
    5.             {
    6.                 GenerateGeometry();
    7.  
    8.                 if (generateMeshCollider)
    9.                 {
    10.                     AddMeshCollider(true);
    11.                     GenerateColliderGeometry();
    12.                 }
    13.             }
    14.         }
    15.  
    No in Playmaker set property generateMeshColliders to True and it will get your colliders.

    I see your point about the Pyramid, you are looking for centroid (http://en.wikipedia.org/wiki/Centroid). Ok, I can fix that.
     
  15. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, thanks, the boolean operations should work with any meshes (except 2d planes, but I am making an update). Also you can access boolean operations from the script via "BooleanOp.cs" script component and its public methods (substract, intersect, ...).

    However there are few limitations to consider:

    It doesn't work well with high-poly meshes, the algorithm I am using is recursive therefore not very robust for dense meshes.
    Another point is that the result mesh might have too many triangles, especially if you are using non-convex meshes.

    Otherwise it should work fine, the algorithm I am using is based on this simple but excellent library.
     
  16. Leuthil

    Leuthil

    Joined:
    Jul 26, 2013
    Posts:
    94
    Ok great, thanks for the info!
     
  17. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    242
    Perhaps another approach circumvents the recursive problem: I found this on stackoverflow : http://stackoverflow.com/questions/929276/how-to-recursively-list-all-the-files-in-a-directory-in-c . Scroll a bit down and there is a queue- based algorithm for parsing. Perhaps it is useful.
     
  18. VectorF22

    VectorF22

    Joined:
    Jul 19, 2013
    Posts:
    5
    The code works perfectly, thank you!!

    Yeah, you're absolutely right, the centroid on the pyramid and triangle is exactly what I need.

    Thanks again!
     
  19. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    718
    Hi,

    Great work it's like 3ds max or maya come in unity 3d
     
  20. Techdread

    Techdread

    Joined:
    Sep 10, 2010
    Posts:
    25
    Hi nice asset, wish you had published this a while back had to roll my own cylinders, spheres, cubes.

    I compiled your demo in to Android but the updating and tweening of the demo does not work.

    All the shapes do draw.
     
  21. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, thanks.

    I just tested with my Android phone (Galaxy S2) both demos (primitives and cutter) and everything works fine. Minimum API level 2.0.1 Eclair (6), Unity free 4.1.5f1.
     
  22. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
  23. Techdread

    Techdread

    Joined:
    Sep 10, 2010
    Posts:
    25
    i'm using Unity 4.2 Pro Android Pro, Tested it on Nexus 4 4.3.0, Nexus 10 4.2.2 and Samsung Galaxy Tab 7.7 4.0.4. The Primitives demo has problems.

    Will try it using a lower version of Unity 3D.
     
  24. Leuthil

    Leuthil

    Joined:
    Jul 26, 2013
    Posts:
    94
    I've been having some problems getting the boolean subtraction to work. I tried creating a new scene just to test it and when I added two objects and subtracted them, the resultant mesh looked very odd. I tried it in code as well which looked mostly correct, but a few triangles were in the wrong place and in some of the more complicated subtractions, the normals were also off. I haven't had much luck tracing through the code though.
     
  25. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Can you send me some screenshots? I see this algorithm is not so robust as I thought. I am thinking about replacing it with something more stable.
     
  26. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,323
    Please replace it because it really is not so solid for production.
     
  27. Techdread

    Techdread

    Joined:
    Sep 10, 2010
    Posts:
    25
    Downgraded my Unity to 4.1.5 and it works! I think the new Unity 4.2 is the culprit.
     
  28. Leuthil

    Leuthil

    Joined:
    Jul 26, 2013
    Posts:
    94
    Ok I will post some screenshots when I can. If it matters I am using Unity 4.2. I was trying to do a boolean subtraction between a box and a rounded box and got very strange results. I also tried the other boolean operations and none of them worked the way they are intended.

    When I also tried the boolean subtraction in code I was just subtracting 2 boxes and still didn't get the correct result.
     
  29. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, I don't have 4.2 yet (just downloading) but I have just made few tests in version 3.5 and 4.1 (both free).

    $booleanProblem.jpg

    As you can see in 3.5 seems to be everything ok however in 4.1 is a problem with rounded box. It is possible that with Unity 4.2 is everything screwed up :(. I am still developing with 3.5 for backward compatibility and I should test more with newer versions. I apologize for that. I am now thinking that this boolean operations needs to be rewritten, I am not very happy with the results (lots of coplanar triangles, recursive algorithm, performance).
     
  30. Leuthil

    Leuthil

    Joined:
    Jul 26, 2013
    Posts:
    94
    Hmm yeah I was afraid that it might be because I am using 4.2. Strange that it would change in the newer versions.
     
  31. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, I just tested with Unity4.2 and it is really wrong, I have also problems with other primitives on Android version. I will fix that, unfortunately not now. I am going to vacation for two weeks so it must wait a little bit...
     
  32. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,323
    Have a Fantastic Vacation.
     
  33. Leuthil

    Leuthil

    Joined:
    Jul 26, 2013
    Posts:
    94
    Looking forward to the fix :). Have a great vacation! I also just wanted to mention that I reverted back to Unity 3.5 to see if I have the same issues and indeed I do. Basically what I'm doing is that I have two boxes which are 1x1x1 and they have the same Y and Z transform values with the X value just slightly off (let's say 0.2). When I do a subtraction it doesn't work properly, and in fact none of the boolean operations work properly. If I offset the Y and Z transform values slightly then the boolean operation works correctly. It's a bit odd since the CSG.js library does not have this issue.
     
  34. DevoMage

    DevoMage

    Joined:
    Dec 19, 2012
    Posts:
    16
    Hi, I am looking for a procedural arch and half-arch. Examples attached.

    Can your asset produce these 2 shapes? The full arch starting at one vertical height and ending at the opposite. The half-arch starting at zero and ending at the opposite vertical height.

    Alternately, the opposite of an arch would be a curved ramp.



    $full-arch.png

    $half-arch.png
     
  35. reindeer-games

    reindeer-games

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

    unfortunately my asset cannot produce these 2 shapes. Closest match is a half-pipe with zero inner radius, but that is not what you want. I can make it in future release, it shouldn't be a problem. With so many shapes in the package the generation algorithm is very similar.
     
  36. DevoMage

    DevoMage

    Joined:
    Dec 19, 2012
    Posts:
    16
    If you could commit to add those shapes I will purchase now. Great asset and will work perfectly for my needs.
     
  37. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    I will add it, it can take me around 1-2 weeks, I have lots of requests now...
     
  38. mindmap

    mindmap

    Joined:
    Oct 12, 2012
    Posts:
    5
    Hello,

    are there any requirements for the meshes i want to use boolean operations on?
    I tried it with some different models (simple to complex) but i got a StackOverflowException every time...
    First lines of error stack:

    StackOverflowException: The requested operation caused a stack overflow.
    PrimitivesPro.CSG.CSGNode.Build (System.Collections.Generic.List`1 polygons) (at Assets/PrimitivesPro/Scripts/CSG/CSGNode.cs:210)
    PrimitivesPro.CSG.CSGNode.Build (System.Collections.Generic.List`1 polygons) (at Assets/PrimitivesPro/Scripts/CSG/CSGNode.cs:210)
    ...
     
    Last edited: Sep 2, 2013
  39. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    this system is best working with low-poly convex meshes, I have seen this error with high-poly models, can you tell me how many polygons (triangles) you using? Also this algorithm isn't very robust, I am working on different boolean operation system, which should be more stable.
     
  40. mindmap

    mindmap

    Joined:
    Oct 12, 2012
    Posts:
    5
    Thanks for the quick reply =)

    The simplest model i tried had 1542 tris, 2303 verts.
    The most complex had around 16500 tris.
    They are both not completely convex however, since they are models of houses with completely modelled facades.
    I tried to perform a boolean operation of the model with a simple cube.

    Is it necessary for the algorithm to work that the meshes are completely closed (no holes)?
    Are multi-submaterials a problems?
    Or is it just the number of polygons that produces the error?

    Here is a screenshot of the simple model:
    $simple_house.PNG
     
  41. reindeer-games

    reindeer-games

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

    I have just finished procedural arch, you can see the result on this video:

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


    I submitted the code to Unity, it usually takes around 3 working days to be available for download...
     
  42. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    It is not necessary to have closed mesh but highly recommended. The stack overflow error is caused by high number of polygons, but not necessary because of your house model but because the algorithm generates large number of new polygons and even more when the mesh contains holes. I am afraid I can't recommend to use current version of boolean operations with that house model. It is more suitable for small convex meshes.
     
  43. mindmap

    mindmap

    Joined:
    Oct 12, 2012
    Posts:
    5
    Okay thank you. I will look for alternatives then...
     
  44. DevoMage

    DevoMage

    Joined:
    Dec 19, 2012
    Posts:
    16
    Perfection! This is a great asset for 2.5D grids. Thanks for the upgrade...
     
  45. jimmyfo

    jimmyfo

    Joined:
    Sep 5, 2013
    Posts:
    1
    Do you have an estimate of what the upper limit is for closed meshes?

    Also, based on what I've read and seen, it seems likely, but would it be possible to do the boolean operations real-time with meshes not created in your code? For example, I procedurally generate a large closed mesh and would like to do subtraction operations against it by doing something like passing in two meshes and an operation and receiving a new mesh when finished?

    In the case of exceeding the upper limit, do you think it feasible to use your cutting operation to subdivide it, use the operation, then merge the results back?

    Thanks!

    Edit: also, are the issues with 4.2 resolved?
     
  46. Leuthil

    Leuthil

    Joined:
    Jul 26, 2013
    Posts:
    94
    It's not just a 4.2 issue. I reverted back to 3.5 and tried with my scenario and again I still had issues. It definitely did work better for other scenarios but if you have two cubes completely side by side it doesn't work properly. Basically two cube faces can't be overlapping or it glitches.
     
  47. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Yes, the boolean operation bug is not yet resolved. I spent on it couple of days with no luck, sorry for such a long time. Also I was playing with this library a little bit which seems to be pretty robust. However it is a native library which would require unity pro. I don't want to spend much time on writing my own boolean operation library from scratch, I found it quite difficult to make it robust and stable that's why I rather rely on 3rd party solutions. Anyway I try to fix current boolean operation issue and let you know.
     
  48. Leuthil

    Leuthil

    Joined:
    Jul 26, 2013
    Posts:
    94
    That would be awesome :)
     
  49. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,323
    Last edited: Sep 24, 2013
  50. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
unityunity