Hack Forums
[Python] 2 Python Scripts (Visualizer & Destructable Scene Engine) - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] 2 Python Scripts (Visualizer & Destructable Scene Engine) (/showthread.php?tid=2172134)



2 Python Scripts (Visualizer & Destructable Scene Engine) - PseudoMander - Feb 2, 2012

Visualiser:




Destructible Scene




Both scripts are available at http://www.trogramming.com/Programs/index.html (Just made the site, still got to add content.)

Or directly downloadable at :
http://www.trogramming.com/Programs/Scripts/visualiser.py
http://www.trogramming.com/Programs/Scripts/bomb.py


* - 1nf4m0us - Feb 2, 2012

This is fucking amazing :p
First time I see something like that :P


* - creepycreeper - Feb 2, 2012

wow, especially that visualiser in 26 rows is great achievement...

interesting that I haven't ever heard about that visual library before...


* - PseudoMander - Feb 2, 2012

Thanks heaps guys appreciate the responses, here's a small bonus script I just whipped up then. Sorry for the lack of commenting, I'm happy to answer any questions people may be having.

Code
from __future__ import division
from visual import *
from math import *
a=[]
loops=10
radius=1
for degr in range(36*loops):
    x= cos(radians(degr*10))*radius
    y= sin(radians(degr*10))*radius
    z= cos(radians(degr*10*loops))
    a.insert(degr,[sphere(pos=(x,y,z),radius=(abs(x)+abs(y))/16,visible=False),curve(color=(1,1,1))])
    radius = radius+degrees(1.618033989)
b=0
while 1:
    rate(20)
    b=b+1
    radius=1
    for i in range(len(a)):
  x= cos(radians((i+b)*10))*radius
  y= sin(radians((i+b)*10))*radius
  z= cos(radians((i+b)*10*loops))*radius*cos(radians(b))
  a[i][0].pos=(x,y,z)
  a[i][1].append(a[i][0].pos)
  a[i][1].color= color.hsv_to_rgb(((b+i)%256/256,(b+1+64)%256/256,(b+1+128)%100/256+.6))
  radius = radius+degrees(1.618033989)






* - creepycreeper - Feb 2, 2012

(Feb 2, 2012 12:40 PM)PseudoMander Wrote:  Thanks heaps guys appreciate the responses, here's a small bonus script I just whipped up then. Sorry for the lack of commenting, I'm happy to answer any questions people may be having.

Code
from __future__ import division
from visual import *
from math import *
a=[]
loops=10
radius=1
for degr in range(36*loops):
    x= cos(radians(degr*10))*radius
    y= sin(radians(degr*10))*radius
    z= cos(radians(degr*10*loops))
    a.insert(degr,[sphere(pos=(x,y,z),radius=(abs(x)+abs(y))/16,visible=False),curve(color=(1,1,1))])
    radius = radius+degrees(1.618033989)
b=0
while 1:
    rate(20)
    b=b+1
    radius=1
    for i in range(len(a)):
  x= cos(radians((i+b)*10))*radius
  y= sin(radians((i+b)*10))*radius
  z= cos(radians((i+b)*10*loops))*radius*cos(radians(b))
  a[i][0].pos=(x,y,z)
  a[i][1].append(a[i][0].pos)
  a[i][1].color= color.hsv_to_rgb(((b+i)%256/256,(b+1+64)%256/256,(b+1+128)%100/256+.6))
  radius = radius+degrees(1.618033989)
Awesome, although I can't really understand how do you come up with it - do you use same frame and randomly change constants or are your changes purposeful (e.g. can you imagine it before actually running it)?



* - PseudoMander - Feb 2, 2012

Usually I imagine a structure then make it to the best of my ability. However mid-way through design I'm often inspired to take it in a different direction and will usually do so, so to answer your question they're not always congruent to the pictures in my head but are quite slight adaptions of such (On a mathematical level anyway).


* - Dmaster_773 - Feb 3, 2012

This is awesome...
btw managed to crash your cannon sim/ w/e, here's error for future bug fix :P
Code
Traceback (most recent call last):
  File "C:\Users\Dom\Desktop\visualiser.py", line 207, in <module>
    checkcolbomb()
  File "C:\Users\Dom\Desktop\visualiser.py", line 121, in checkcolbomb
    burst(bomb[i][0].pos,bomb[i][0].velocity)
  File "C:\Users\Dom\Desktop\visualiser.py", line 76, in burst
    makewall(blockwall[i1-e].pos,dire,blockwall[i1-e].size[1]/6)
  File "C:\Users\Dom\Desktop\visualiser.py", line 143, in makewall
    for i2 in range(height):
TypeError: range() integer end argument expected, got float.



* - PseudoMander - Feb 3, 2012

(Feb 3, 2012 05:01 AM)Dmaster_773 Wrote:  This is awesome...
btw managed to crash your cannon sim/ w/e, here's error for future bug fix :P
Code
...
    for i2 in range(height):
TypeError: range() integer end argument expected, got float.
...

Thanks for that, I've never encountered it perhaps it could be patched by simply replacing the aforementioned line with.
Code
for i2 in range(int(round(height))):