Search Unity

AVROS - Real Time 3D programming with oculus rift

Discussion in 'AR/VR (XR) Discussion' started by thaiwas, Jan 14, 2019.

  1. thaiwas

    thaiwas

    Joined:
    May 1, 2018
    Posts:
    8
    I got inspired by the people trying to code with a vr headset

    So I built a system for that with unity.

    It includes a 3d keyboard, screen mirror and a menu, that you can use to access the multiplayer server

    The multiplayer is completely empty right now, but you can use the API to program some app's for it.

    It works with soockets, so you need a nodejs install with a socket.io-client package

    'user joined'
    broadcasts 'user entered'
    data.user_id
    data.lastSeen

    "syncronization event"
    broadcasts "syncronization event"

    "user exit"
    'user exit'


    'object created'

    'object changed'


    Anyways



    Heres some example code

    Code (JavaScript):
    1. /* todo fix eof tilde confusion */
    2. console.log("including sockets")
    3. var socket = require('socket.io-client')('http://51.38.185.65:9774');
    4. var fs = require("fs")
    5. var waterfall = require('async-waterfall');
    6.  
    7. var appId  = 7357
    8. socket.on('connect', function(){});
    9. socket.on('disconnect', function(){});
    10.  
    11. var connected = false
    12.  
    13. socket.on('connection accepted', function(){
    14.     console.log("connected")
    15.     start()
    16.     connected = true
    17. })
    18.  
    19. setTimeout(function() {
    20.     if (!connected) {
    21.         console.log("failed to connect")
    22.         process.exit(0)
    23.     }
    24. }, 5000)
    25.  
    26. socket.on("load matrix", function (data) {
    27.     console.log("loading matrix")
    28. start()
    29. })
    30.  
    31. var cube = {
    32.     "object_id": "717",
    33.     "type": "cube",
    34.     "posX": "-0.1153316",
    35.     "posY": "-0.01580912",
    36.     "posZ": "-0.1566545",
    37.     "rotW": "-0.2689151",
    38.     "rotX": "-0.2196632",
    39.     "rotY": "0.8342858",
    40.     "rotZ": "-0.4282523",
    41.     "scaleX": "0.2000001",
    42.     "scaleY": "0.2000001",
    43.     "scaleZ": "0.02000001",
    44.     "user_id": "7357"
    45. }
    46. var plane = {
    47.     "object_id": "17",
    48.     "type": "plane",
    49.     "parent": "717",
    50.     "posX": "0",
    51.     "posY": "0",
    52.     "posZ": "-0.6",
    53.     "rotW": "-3.090862E-08",
    54.     "rotX": "-3.090862E-08",
    55.     "rotY": "-0.7071068",
    56.     "rotZ": "0.7071068",
    57.     "scaleX": "0.1",
    58.     "scaleY": "0.1",
    59.     "scaleZ": "0.1",
    60.     "user_id": "7357"
    61. }
    62.  
    63. function start() {
    64.     waterfall([
    65.       function(callback){
    66.           console.log("testing audio")
    67.           socket.emit("tts", {"say": "testing debugger audio"})
    68.           setTimeout(function() {
    69.               callback(null)
    70.           }, 2000)
    71.       },
    72.       function(callback){
    73.           socket.emit("tts", {"say": "testing gameobject spawn"})
    74.  
    75.  
    76.           socket.emit("object created", cube)
    77.           setTimeout(function() {
    78.                 callback(null)
    79.           }, 10000)
    80.       },
    81.       function(callback){
    82.           socket.emit("tts", {"say": "testing gameobject plane spawn"})
    83.  
    84.  
    85.           socket.emit("object created", plane)
    86.           setTimeout(function() {
    87.                 callback(null)
    88.           }, 10000)
    89.       },
    90.       function(callback){
    91.           socket.emit("tts", {"say": "testing texture"})
    92.  
    93.  
    94.           socket.emit("object created", plane)
    95.           setTimeout(function() {
    96.                 callback(null)
    97.           }, 10000)
    98.       },
    99.       function(callback){
    100.           socket.emit("tts", {"say": "testing gameobject despawn"})
    101.  
    102.           socket.emit("object destroyed", cube)
    103.           setTimeout(function() {
    104.                 callback(null)
    105.           }, 10000)
    106.       }
    107.     ], function (err, result) {
    108.         socket.emit("tts", {"say": "all test complete, exiting"})
    109.         process.exit(0)
    110.     });
    111. }
    112.  

    Code (JavaScript):
    1.  
    2. console.log("including sockets")
    3. var socket = require('socket.io-client')('http://51.38.185.65:9774');
    4. var fs = require("fs")
    5. var waterfall = require('async-waterfall');
    6.  
    7. var appId  = 7357
    8. socket.on('connect', function(){});
    9. socket.on('disconnect', function(){});
    10.  
    11. var connected = false
    12.  
    13. socket.on('connection accepted', function(){
    14.     console.log("connected")
    15.     start()
    16.     connected = true
    17. })
    18.  
    19. setTimeout(function() {
    20.     if (!connected) {
    21.         console.log("failed to connect")
    22.         process.exit(0)
    23.     }
    24. }, 5000)
    25.  
    26. socket.on("load matrix", function (data) {
    27.     console.log("loading matrix")
    28.     start()
    29. })
    30.  
    31. var cube = {
    32.     "object_id": "717",
    33.     "type": "cube",
    34.     "posX": "-0.1153316",
    35.     "posY": "-0.01580912",
    36.     "posZ": "-0.1566545",
    37.     "rotW": "-0.2689151",
    38.     "rotX": "-0.2196632",
    39.     "rotY": "0.8342858",
    40.     "rotZ": "-0.4282523",
    41.     "scaleX": "0.2000001",
    42.     "scaleY": "0.2000001",
    43.     "scaleZ": "0.02000001",
    44.     "user_id": "7357"
    45. }
    46. var plane = {
    47.     "object_id": "17",
    48.     "type": "plane",
    49.     "parent": "717",
    50.     "posX": "0",
    51.     "posY": "0",
    52.     "posZ": "-0.6",
    53.     "rotW": "-3.090862E-08",
    54.     "rotX": "-3.090862E-08",
    55.     "rotY": "-0.7071068",
    56.     "rotZ": "0.7071068",
    57.     "scaleX": "0.1",
    58.     "scaleY": "0.1",
    59.     "scaleZ": "0.1",
    60.     "user_id": "7357"
    61. }
    62. var w0t;
    63. function start() {
    64.     waterfall([
    65.         function(callback){
    66.             console.log("testing audio")
    67.             socket.emit("tts", {"say": "testing debugger audio"})
    68.             setTimeout(function() {
    69.                 callback(null)
    70.             }, 2000)
    71.         },
    72.         function(callback){
    73.             socket.emit("tts", {"say": "testing gameobject spawn"})
    74.  
    75.  
    76.             socket.emit("object created", cube)
    77.             setTimeout(function() {
    78.                 callback(null)
    79.             }, 2000)
    80.         },
    81.         function(callback){
    82.             socket.emit("tts", {"say": "testing gameobject plane spawn"})
    83.  
    84.  
    85.             socket.emit("object created", plane)
    86.             setTimeout(function() {
    87.                 callback(null)
    88.             }, 2000)
    89.         },
    90.         function(callback){
    91.             socket.emit("tts", {"say": "testing texture"})
    92.  
    93.  
    94.             socket.emit("texture update", {
    95.                 "object_id": plane.object_id,
    96.                 "texture": createTexture()
    97.             })
    98.             w0t = setInterval(function() {
    99.                 socket.emit("texture update", {
    100.                     "object_id": plane.object_id,
    101.                     "texture": createTexture()
    102.                 })
    103.             }, 1000)
    104.             setTimeout(function() {
    105.                 callback(null)
    106.  
    107.                 clearInterval(w0t);
    108.             }, 20000)
    109.         },
    110.         function(callback){
    111.             socket.emit("tts", {"say": "testing gameobject despawn"})
    112.  
    113.             //socket.emit("object destroyed", cube)
    114.             setTimeout(function() {
    115.                 callback(null)
    116.             }, 10000)
    117.         }
    118.     ], function (err, result) {
    119.         socket.emit("tts", {"say": "all test complete, exiting"})
    120.         process.exit(0)
    121.     });
    122. }


     
    Last edited: Jan 14, 2019
  2. thaiwas

    thaiwas

    Joined:
    May 1, 2018
    Posts:
    8