about summary refs log tree commit diff
path: root/makeblend/stars.py
blob: 4f6eba0441acc0badc2541557afc48906f414993 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3

import sys
import json
#import bpy

def addStar(data):

    if None in data["Quadrants"]:
        x = data["Boundary"]["Center"]["X"]
        y = data["boundary"]["Center"]["Y"]
        w = data["boundary"]["Width"]

        bpy.ops.mesh.primitive_plane_add(size=w, view_align=False, enter_editmode=False, location=(x, y, 0))

    for subtree in data["Quadrants"]:
        if subtree != None:
            addPlane(subtree)

def getVerts(data):

    x = data["star"]["C"]["X"]
    y = data["star"]["C"]["Y"]

    if x != 0 and y != 0:
        localVerts = []
        star = [x, y]
        localVerts.append(star)   

        for subtree in data["Quadrants"]:
            if subtree != None:
                localVerts.append(getVerts(subtree))
         
        if localVerts != None:
            return localVerts

with open("real.json") as f:
    data = json.load(f)

    #addPlane(data[0]["Quadrants"][0])

    verts = []
    verts.append(getVerts(data[0]))
    print(verts)
    
"""
    # Create a mesh and an object
    mesh = bpy.data.meshes.new("0")
    object = bpy.data.objects.new("0",mesh)
    
    # Set the mesh location
    object.location = bpy.context.scene.cursor_location
    bpy.context.scene.objects.linl(object)

    # Create the mesh from the given data points
    mesh.from_pydata(verts,[],[])
    mesh.update(calc_edges=True)
"""