So I know how to create polyhedral dices (dices used in D&D for example), but I don't know how to "stylize" them. For example, I use a code to create normal ph (polyhedral) dices that I found on another answer, here it is:

import bpy
import bmesh
from mathutils import Vector
import random
from math import pi, asin, atan2, cos, sin, radians

# parameters
n = 18  # number of points on sphere
rat = (n - 2) / n # how far along the radius to bisect
u_segments = 32  # UV sphere settings
v_segments = 32 
thickness = 0.2  # solidify thickness
TOL = 1e-5

points = [Vector((0, 0, 1))]
for i in range(n - 1):
    theta = random.random() * radians(360)
    phi = 2 * asin(random.random() * 2 - 1)
    points.append(Vector((cos(theta) * cos(phi), 
           sin(theta) * cos(phi), 

while True:
    # Determine the total force acting on each point.
    forces = []
    for i in range(len(points)):
        p = points[i]
        f = Vector()
        ftotal = 0
        for j in range(len(points)):
            if j == i: continue
            q = points[j]
            # Find the distance vector, and its length.
            dv = p - q
            dl = dv.length
            dl3 = dl * dl * dl
            fv = dv / dl3
            # Add to the total force on the point p.
            f = f + fv
        # Stick this in the forces array.
        # Add to the running sum of the total forces/distances.
        ftotal = ftotal + f.length

    fscale = 1 if ftotal <= 0.25 else 0.25 / ftotal

    # Move each point, and normalise. While we do this, also track
    # the distance each point ends up moving.
    dist = 0
    for i in range(len(points)):
        p = points[i]
        f = forces[i]
        p2 = (p + fscale * f).normalized()

        dv = p - p2
        dist = dist + dv.length
        points[i] = p2
    # Done. Check for convergence and finish.
    if dist < TOL: # TOL

context = bpy.context
scene = context.scene
# make one point north pole.
R = points[0].rotation_difference(Vector((0, 0, 1))).to_matrix()
points = [R * p for p in points]

bm = bmesh.new()
#bmesh.ops.create_icosphere(bm, diameter=1, subdivisions=5 )

for p in points:
    print("-" * 80)
    ret = bmesh.ops.bisect_plane(bm, 
            plane_co= rat * p,

    # fill the holes
    edges = [e for e in ret["geom_cut"] if isinstance(e, bmesh.types.BMEdge)]
    bmesh.ops.contextual_create(bm, geom=edges)

me = bpy.data.meshes.new("dice")
ob = bpy.data.objects.new("dice", me)   
scene.objects.active = ob
ob.select = True
ob.location = scene.cursor_location

Now, this code can create perfect functioning dices of any size (by size I mean the amount of "numbers" (sides)), but it can't help me any further. And by further I mean on how do I create dices that look like this: enter image description here

Should I just create abnormal looks on one side and the just copy it to every side or should I do something more? I know I need to watch out for the weight on every side so that the dices don't stop on just one side more often than the other...


Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.