Alek Posted September 4, 2016 Share Posted September 4, 2016 Hi, I would like to create a dynamic pie chart. Let's say something like this What would be the best approach? In the outcome I would like to receive separate meshes to be able to select one of them, add animation, change material and so on. I tried with csg with a cone made of cylinder but I would like to switch to something simpler. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted September 4, 2016 Share Posted September 4, 2016 Sounds like a fun challenge if no one else gets on it I'll whip up a demo here for that, it would not be that hard if you know how to extrude custom shapes and how to work pi calculations. If if I have time tommrow I'll make a function with arguments for the slices so you can just call one thing. Quote Link to comment Share on other sites More sharing options...
Alek Posted September 4, 2016 Author Share Posted September 4, 2016 Thanks, Pryme8 I even thought about exporting object with a 1% slice from blender (and then rotate instances), to omit these math calculations. As I understand you think about something similar to this one:http://www.babylonjs-playground.com/#1EQWG8#4. but with correct calculations. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted September 5, 2016 Share Posted September 5, 2016 i might have time to do this tonight I'm about to do an important Skype call then I'll look into it. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted September 5, 2016 Share Posted September 5, 2016 http://www.babylonjs-playground.com/#1RAGWN#0 I was going to do a version with extrudes if I can, but I only had like 30 min's to do this trying to get it done before my girlfriend finishes dinner cause i promised Id pay her attention. If I can pump that out really fast before she is done I will but I figured this will at least get you going for now. ***Edit beat her to it, but um it does not work... something is up with the extrude I only used them for a limited time way back im not sure if this is the correct way to construct an extrude now, but once someone who knows better can chime in this is how a solid shape from that function would be done. http://www.babylonjs-playground.com/#1RAGWN#1@RaananW or maybe @Wingnut could comment on why the extrudes are not coming up but the paths work. You might even be able to figure it out if you read the section on parametric shapes http://doc.babylonjs.com/tutorials/parametric_shapes I just do not have time as of right now. Sorry to get back to you so late today was busy busy busy. also on a quick note I mentioned how you can make the gaps smaller between slices, if you like the effect you can leave it or do what i said in the comments, another option would be to add 0.5 to the 2nd to last point i think and subtract 0.5 from the 2nd point when generating the slicepaths from the j interval. If I get some more time ill refine it for you and push a module to the BJS git with a new BAYLON constructor if approved. Quote Link to comment Share on other sites More sharing options...
jerome Posted September 5, 2016 Share Posted September 5, 2016 http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone just use the "arc" parameter http://doc.babylonjs.com/classes/2.4/MeshBuilder#static-createcylinder-name-options-scene-rarr-mesh-classes-2-4-mesh- http://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379 RaananW and Pryme8 2 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted September 5, 2016 Share Posted September 5, 2016 i never saw that before jerome thanks ill rework that to use that. Quote Link to comment Share on other sites More sharing options...
jerome Posted September 5, 2016 Share Posted September 5, 2016 don't forget to read this former post also : Quote Link to comment Share on other sites More sharing options...
Alek Posted September 5, 2016 Author Share Posted September 5, 2016 Thanks jerome, arc parameter is excactly what I was looking for. I played with tessellation, which was not working for me. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted September 5, 2016 Share Posted September 5, 2016 Any idea why my extrude was not working @jerome Quote Link to comment Share on other sites More sharing options...
RaananW Posted September 5, 2016 Share Posted September 5, 2016 http://www.babylonjs-playground.com/#1RAGWN#2 - the shape you created had x and z defined, but you needed to define x and y (see line 69). But you pinged the right person to actually explain everything, which is jerome Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted September 5, 2016 Share Posted September 5, 2016 http://www.babylonjs-playground.com/#1RAGWN#3@RaananW thank you jerome 1 Quote Link to comment Share on other sites More sharing options...
Alek Posted September 5, 2016 Author Share Posted September 5, 2016 Thanks Pryme8, now I give myself a time to understand what you did Also thanks for well commented code. Quote Link to comment Share on other sites More sharing options...
jerome Posted September 5, 2016 Share Posted September 5, 2016 as Raanan said, the model to be extruded should be (at least) in the xOy plane : http://www.babylonjs-playground.com/#1RAGWN#4 http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion RaananW 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.