Ejemplo n.º 1
0
    def __init__(self):
        self.numVoxels = 25
        self.voxelSize = 4
        self.grad = color.GetGradient(10)
        self.targets = []
        for i in range(5):
            self.targets.append(
                geo.Particle(geo.RandomPoint(), geo.RandomVector3d(5)))
            self.targets[-1].radius = 5

        self.attr = rc.DocObjects.ObjectAttributes()
        self.attr.ColorSource = rc.DocObjects.ObjectColorSource.ColorFromObject
        self.attr.MaterialSource = rc.DocObjects.ObjectMaterialSource.MaterialFromObject
        #Setup Vertices
        self.vertices = []
        for x in range(self.numVoxels + 1):
            yRow = []
            for y in range(self.numVoxels + 1):
                zRow = []
                for z in range(self.numVoxels + 1):
                    zRow.append(
                        Vertex(self, x * self.voxelSize, y * self.voxelSize,
                               z * self.voxelSize, x, y, z))
                yRow.append(zRow)
            self.vertices.append(yRow)

        #Setup Voxels
        self.voxels = []
        index = 0
        for x in range(self.numVoxels):
            for y in range(self.numVoxels):
                for z in range(self.numVoxels):
                    self.voxels.append(
                        Voxel(self, x * self.voxelSize, y * self.voxelSize,
                              z * self.voxelSize, x, y, z))
Ejemplo n.º 2
0
 def __init__(self):
     self.p = geo.Particle()
     self.dots = []
     self.time = 0
     self.links = []
     for i in range(10000):
         self.dots.append(Dot(self))
Ejemplo n.º 3
0
 def __init__(self):
     numVoxels = 20
     self.voxelSize = 5
     
     self.targets = []
     for i in range(5):
         self.targets.append(geo.Particle(geo.RandomPoint(), geo.RandomVector3d(5)))
         self.targets[-1].radius = 5
     self.voxels = []
     for x in range(numVoxels):
         for y in range(numVoxels):
             for z in range(numVoxels):
                 self.voxels.append(Voxel(self, x*self.voxelSize, y*self.voxelSize, z*self.voxelSize))
     self.vertices = []
     for x in range(numVoxels):
         for y in range(numVoxels):
             for z in range(numVoxels):
                 self.vertices.append(Vertex(self, x*self.voxelSize, y*self.voxelSize, z*self.voxelSize))
Ejemplo n.º 4
0
def main():
    skNum = (datetime.date.today() - datetime.date(2020, 03, 29)).days + 201
    if int(skNum) > int(os.path.splitext(os.path.basename(__file__))[0]):
        print "!!!!SAVE THE SKETCH WITH A NEW NAME!!!!"

    rs.UnselectAllObjects()

    init_time = time.time()
    version = 'a'
    anim = mp4.Animation(
        os.path.splitext(os.path.basename(__file__))[0] + version)
    numFrames = 150
    numPasses = 100
    anim.fps = 30

    td = TempDisplay()
    display = HUD(os.path.splitext(os.path.basename(__file__))[0], numFrames)
    s = Scene()
    ################################
    #SETUP
    targets = []
    vSystems = []
    for i in range(5):
        targets.append(geo.Particle(geo.RandomPoint(), geo.RandomVector3d(5)))
        targets[-1].radius = 5

    for i in range(5):
        print(i * .05) + .3
        vSystems.append(VoxelSystem(targets, i * .05 + .3))

    ################################
    for i in range(numFrames):
        start_time = time.time()
        print "Frame {}".format(i)
        if sc.escape_test(False):
            anim.Cleanup()
            return
        ################################
        #MAIN LOOP
        for target in targets:
            target.Update()

        for vSystem in vSystems:
            vSystem.Update()
            vSystem.UpdateDisplay()

        ################################
        #HUD
        #display.UpdateParam1('boxes: ' + str(len(bSystem.boxes)))
        #display.UpdateParam2('links: ' + str(len(bSystem.links)))
        #display.UpdateParam3('z: ' + str(ball.pos.Z))
        display.UpdateScaleBar()

        ################################
        sc.doc.Views.Redraw()
        display.Update(i)
        anim.AddFrame(numberOfPasses=numPasses)

        rs.Sleep(500)

        ################################
        #Framerate
        frameTime = time.time() - start_time
        timeLeft = (numFrames - i) * frameTime
        timeLeftStr = str(datetime.timedelta(seconds=timeLeft))
        print "Time remaining: {}".format(timeLeftStr)

    frameTime = time.time() - init_time
    timeLeftStr = str(datetime.timedelta(seconds=frameTime))
    print "Total Time: {}".format(timeLeftStr)

    if int(skNum) > int(os.path.splitext(os.path.basename(__file__))[0]):
        print "!!!!SAVE THE SKETCH WITH A NEW NAME!!!!"

    if os.path.isdir(
            r"D:\Files\Work\LIBRARY\06_RHINO\10_Python\300 DAYS\anim"):
        anim.Create(r"D:\Files\Work\LIBRARY\06_RHINO\10_Python\300 DAYS\anim",
                    frames2Keep=[i / 2, i - 1])
    else:
        anim.Create(r"C:\Tim\300 Days\anim", frames2Keep=[i / 2, i - 1])