I’m trying to make a real rendering in with four-dimension equations ( space-time equations )
for now I have this :
a man falling towards a black hole - in the bottom - with a no moving space ship far away -
light ray follow the flat space time
here is the blender python :
#V01 erreur la taille en frame 0 n'est pas bonne
import bpy
from mathutils import *
G,M,c=6.6742E-11 , 5.9736E24 *1.0E4 , 299792458.0
r0=6371000.0
rTN=G*M/c**2 #44.36024633096978
########## initialisation
rinit = rTN * 20.0
#r , t = rinit , 0.0
#dt,dr=1.0,0.0
#temps propre
Tp=0.0
scene=bpy.data.scenes['Scene']
cam=scene.objects['Camera']
obj=scene.objects['moi:jeans01decimate']
mesh=obj.data
obj.location=Vector((0.0,0.0,0.0))
scene.frame_current=0
for m in mesh.vertices:
#m.co+=Vector((0.0,0.0,rinit))
m.keyframe_insert('co')
Ctr=Vector((0.0,0.0,0.0))
points=[]
scene.frame_current=0
for n in range(len(mesh.vertices)):
m=mesh.vertices[n]
r=(m.co-Ctr).length
pos=[0.0,r]
vit=[1.0,0.0] # dt/da dr/da
points.append([pos,vit])
'''
for n in range(len(mesh.vertices)):
m=mesh.vertices[n]
#print("m.co",m.co)
'''
DTp=4.0E-8
def rva(DTp,pos,vit):
t , r = pos[0],pos[1]
K=2.0*G*M/r/c**2.0
dt,dr = vit[0],vit[1]
rr=r + dr * DTp
tt = t + dt * DTp
dr += DTp * 1.0 / (2.0*r) * K * (1-K) * ( - (c*dt) **2 + dr**2 )
dt += DTp * - (1.0 / r) *K / (1-K)**2.0 * dt *dr
return [tt,rr],[dt,dr]
def AfficheLaFrame(frame,dt):#temps= frame*dt
if frame % 1==0:
return True
if frame % 1 !=0:
return False
fini=False
for s in range(1,1000):
#print(s)
Tp=Tp+DTp
CentreGrav=Vector((0.0,0.0,0.0))
for n in range(len(mesh.vertices)):
if fini==False:
pos,vit=points[n][0],points[n][1]
pos,vit=rva(DTp,pos,vit)
points[n][0],points[n][1]=pos,vit
t,r=pos[0],pos[1]
#print('r=',r)
if r<rTN or abs(r)> 1E10:
fini=True
if fini==False and AfficheLaFrame(s,DTp)==True:
scene.frame_current=s
m=mesh.vertices[n]
m.co=(m.co-Ctr).normalized()*r+Ctr
m.keyframe_insert('co')
#CentreGrav+=m.co
#cam.location=CentreGrav/len(mesh.vertices)+Vector((0.0,50.0,0.0))
if fini==False and AfficheLaFrame(s,DTp)==True:
print(s)
cam.location=mesh.vertices[0].co+Vector((0.0,5.0,-2.0))
cam.keyframe_insert('location')
print(rinit,rTN)
Attachments
humainV02.blend (1.39 MB)