Giter VIP home page Giter VIP logo

unity.jl's Introduction

Unity.jl

A scientific visualization interface for Unity

This library provides a TCP-Interface for the transmission of 3d mesh-data between Julia and Unity. The Unity part of this interface cleary could be used with any other programming language, like Matlab or the-like, without much effort.

Installation

You need Unity to be installed with the UnityTCP project running, which is free for non-profit use. I got Version 2017.4.1f1 (9231f953d9d3) Personal installed on a MacBook with macOS 10.13.3.

Please run:

Pkg.clone("https://github.com/StreetLevel/Unity.jl")

Agenda

In numeric simulation we operate mostly on mesh-data, so we need easy-to-use but efficient tools for visualization for fast development cycles. The "de-facto-standard" MATLAB covers this with its patch-routine. Here, Unity is used for visualization, which is a great and actively developed platform. Once you've got your data imported into Unity, you can take advantage of a huge community and tons of add-ons for high-quality custom plots. Furthermore Unity runs on various platforms, so, with little effort, you could use your tablet or even mobile phone for displaying the output.

Usage

This package is in a very early development stage but to my knowledge it should work.

  1. Unity: Start Unity and load the Unity Project Unity_TCPInterface.
  2. Unity: Load Scene1
  3. Unity: Press Play
  4. Julia:
import Unity: UnityMesh, UnityText
using ColorTypes, GeometryTypes

#define vertices
verts = [Point3f0(0,0,0),Point3f0(1,0,0),Point3f0(1,1,0),Point3f0(0,1,0)]
#define indices for surface mesh
surf_inds = Int32[0,2,1,0,3,2]
#define indices for line mesh
line_inds = Int32[0,1,1,2,2,3,3,0]
#define indices for vertex mesh
vert_inds = Int32[0,1,2,3]
#define colors
colors = rand(RGBA{Float32},length(verts))
#colors = [RGBA{Float32}(1,1,1,.001) for vert in verts]

#define optons
options = ["surface_shader = flat"]
transparent = ["surface_shader = transparent"]
point_size = ["point_size = 0.05"]

#define text
unity_text = UnityText("Hello World!", Point3f0(1.5,2,0), Point3f0(0.1,0.1,.15), Point3f0(1,1,1))

#create meshes
surface_mesh = UnityMesh("Mesh 1", verts, Int32[], Int32[], surf_inds, colors, options, UnityText[unity_text])
line_mesh = UnityMesh("Mesh 2", map(x->Point3f0(x[1]+3,x[2],x[3]),verts), Int32[], line_inds, Int32[], colors, String[])
point_mesh = UnityMesh("Mesh 3", map(x->Point3f0(x[1],x[2]+3,x[3]),verts), vert_inds, Int32[], Int32[], colors, point_size)
mesh = UnityMesh("Mesh 4", map(x->Point3f0(x[1]+3,x[2]+3,x[3]),verts), vert_inds, line_inds, surf_inds, colors, vcat(point_size,transparent))

#send meshes to unity
socket = connect(8052)
write(socket, surface_mesh)
write(socket, line_mesh)
write(socket, point_mesh)
write(socket, mesh)
close(socket)

You should see something like this: Unity Mesh

Different shader for surface meshes

wireframe flat
img_bone img_bone
smooth transparent
img_bone img_bone

TODO

  • face colors (could be already done by duplicating the vertices for each connected face)
  • auto setup of tcp connection
  • simple gui for ip address etc.
  • partial transmission of meshes (e.g. only update the vertices or colors)
  • colorbar (partly done)
  • coordinate axes
  • nicer transparency shader
  • nicer shader for line mesh
  • nicer shader and primitive for point mesh
  • point size

unity.jl's People

Contributors

streetlevel avatar rleegates avatar

Stargazers

 avatar Fynn avatar Amin Yahyaabadi avatar  avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar Amin Yahyaabadi avatar  avatar

Forkers

rleegates

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.