Planetary-Collision-VR
Immersive 3D visualizations of planetary collisions using smoothed particle hydrodynamics and virtual reality.
This project is supported by the University of Arizona/GPSC research grant, “Virtual Reality Gives New Insights Into How Planets Form”
Getting started with Unity
- Import our Unity Package
- Import SteamVR plugin from Asset Store
- Make sure HTC Vive is plugged in and SteamVR is on stand by
- Open “DemoScene” and hit Play
All code was tested with Unity v2018.3.10
Converting Paraview Models with Blender (.x3d -> .obj)
- Open Blender (v2.79)
- Navigate to script editor (crtl+right arrow)x3
- Open new script. Press button “+ New”
- Delete the square model, if present
- Paste code below
import bpy
import glob
file_loc = "C:\\Users\\Kyle\\Documents\\SPH_objects\\"
files = glob.glob(file_loc+"*.x3d")
for i in range(len(files)):
imported_object = bpy.ops.import_scene.x3d(filepath=files[i])
obj = bpy.context.selected_objects[0]
exported_object = bpy.ops.export_scene.obj(filepath=files[i].split('.x3d')[0]+'.obj')
print('Imported name: ', obj.name)
bpy.data.objects[obj.name].select = True
bpy.ops.object.delete()
Make sure to change the file location
Creating an animation from multiple obj files in Blender
# https://docs.blender.org/api/2.79b/info_quickstart.html
import bpy
import glob
file_loc = "C:\\Users\\Kyle\\Documents\\Unity Projects\\SPH_Visualization\\Assets\\models\\"
files = glob.glob(file_loc+"*.x3d")
scene = bpy.context.scene
scene.objects.keys()
bpy.context.scene.render.fps = 5
bpy.context.scene.frame_start = 0
bpy.context.scene.frame_end = len(files)
objs = []
for i in range(len(files)):
imported_object = bpy.ops.import_scene.x3d(filepath=files[i])
obj = bpy.context.selected_objects[0]
obj.hide = True
modifier=obj.modifiers.new('Decimate 0.5','DECIMATE')
modifier.ratio=0.5
modifier.use_collapse_triangulate=True
objs.append( obj)
def hide_true(objs,idx):
for i in range(len(objs)):
if i == idx:
objs[i].hide = False
objs[i].keyframe_insert(data_path="hide")
else:
objs[i].hide = True
objs[i].keyframe_insert(data_path="hide")
for i in range(len(files)):
scene.frame_set(i)
hide_true(objs,i)
for k in range(len(bpy.data.objects)-1,0,-1):
if 'Face' not in bpy.data.objects[k].name:
bpy.data.objects[k].select = True
else:
bpy.data.objects[k].select = False
bpy.ops.object.delete()