Changes between Version 9 and Version 10 of Examples/Brain


Ignore:
Timestamp:
04/11/17 13:48:24 (7 years ago)
Author:
Herwig Zilken
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Examples/Brain

    v9 v10  
    231231}}}
    232232
    233 Resulting movie sniplet:
     233Resulting movie snippet:
    234234[raw-attachment:orbit.wmv Camera Orbit]
    235235
     
    278278  animationScene.GoToNext()
    279279}}}
    280 Resulting movie sniplet:
     280Resulting movie snippet:
    281281[raw-attachment:camera_flight.wmv Camera Flight]
     282
     283=== Animation of Color and Opacity
     284As seen above, the color and opacity maps are stored in Python as lists.
     285Given a start and a end color/opacity list, it is very easy to implement a small python funtion to calculate a linear interpolation. In the following example, images for interpolated opacity values are rendered.
     286{{{
     287#!python
     288# t: timestep, in range [0.0, 1.0]
     289def interpolate(t, list1, list2):
     290  if len(list1) != len(list2):
     291    return []
     292  result = []
     293  for i in range(len(list1)):
     294    diff = list2[i]-list1[i]
     295    result.append(list1[i] + diff*t)
     296  return result
     297
     298
     299# start opacity list, t=0.0
     300pLIPWF1 = [0.0, 0.0, 0.5, 0.0,   0.0, 0.0, 0.5, 0.0,  254.0, 1.0, 0.5, 0.0]
     301#end opacity list, t=1.0
     302pLIPWF2 = [0.0, 0.0, 0.5, 0.0,  25.0, 0.0, 0.5, 0.0,  254.0, 1.0, 0.5, 0.0]
     303
     304camera.SetPosition(0.0, 0.0, 1.488)
     305camera.SetFocalPoint(0.0, 0.0, 0.0)
     306camera.SetViewUp(-1.0, 0.0, 0.0)
     307imageNum = 0
     308
     309for i in range(30):
     310  pLIPWF.Points = interpolate (i/29.0, pLIPWF1, pLIPWF2)
     311  print ("opacity interpolation: rendering image %04d" % (imageNum))
     312  Render()
     313  WriteImage("opacity_image_%04d.png" % (imageNum))
     314  imageNum = imageNum + 1
     315
     316}}}
     317Resulting movie snippet:
     318[raw-attachment:opacity.wmv Animation of opacity]
     319