Skip to main content
Up and Coming
July 27, 2013

Human scans in Unity. Unity dev help needed.

Hi all,

I'm trying to find the right place to ask if anyone can help me with Unity. I'm trying to publish some nude human scan assets so people can view them with Unity on the Rift. Similar to these:

https://vimeo.com/64769947

I have very little Unity experience. So far I can get my assets in no problem with the Rift OVRPlayerController and build a .exe but I'm trying to find out how to add a free roaming flying camera (script?), that works with the Rift rendering and OVRPlayerController.

I'm trying to match the smoothness of the controls in UDK. Whereby you can activate 'fly' and 'slowmo 0.3' to control camera flight and speed. I would publish with UDK but it doesn't seem as universal or as user friendly as a Unity pack.

Any help would be greatly appreciated and perhaps rewarded with some cool nude scan demos!
    This topic has been closed for replies.

    42 replies

    Inspiring
    August 1, 2013
    "Infinite" wrote:
    Sadly, no one noticed her heart beat yet :) well the sound of it! Unity rocks.


    Don't worry, I'm sure plenty of people noticed and simply didn't tell you (like me haha). I actually instinctively turned my head to the left and put my ear up to her chest to hear it. Nice touch. :)
    Titans of Space PLUS for Quest is now available on DrashVR.com
    Participant
    August 3, 2013
    I certainly noticed the heart beat - very odd experience! :)

    Thanks for the pointers on the "distant lights" - I figured that was how you were doing it after watching it for a bit.
    Participant
    August 3, 2013
    "Infinite" wrote:

    For anyone interested in the movement side of things with regards to scanning, I posted a question here http://forum.unity3d.com/threads/193959-Sequenced-obj-mesh-streaming?p=1316901#post1316901 over at the Unity forums, as it's not really Rift related. I would be interested to know what you guys think about a solution for mesh streaming?


    I've tried it to be honest, but would swapping the meshes out on an object not result in a loss of fidelity (less smooth)? If Unity can cope with it at 25fps for one thing, but would it not be better to rig the model, then animate it to the new position? And maybe swap the models after some of the animation has fired?

    Swapping the mesh on the GameObject should be fairly trivial - just a case of loading an array of meshes and cyclically applying them to a game object. Would be interesting to see if it would handle it with your models.
    InfiniteAuthor
    Up and Coming
    August 3, 2013
    "Slopey" wrote:
    I certainly noticed the heart beat - very odd experience! :)

    Thanks for the pointers on the "distant lights" - I figured that was how you were doing it after watching it for a bit.


    :D

    "CaliberMengsk" wrote:
    Unity is indeed awesome.

    T_T Unfortunately, me as a hobbiest, it's really hard to find time. T_T

    You can develop stuff extremely fast in Unity though. At the last game jam, we had a nearly polished game in the 48 hour span. Looked pretty too. http://www.stlgamejam.com/game-recap-turned-out/ if you want to see what 48 hours can be.

    It would be pretty awesome to see one of these scans being able to do full motion. With the proper shaders, it could turn into an amazing show piece.


    I plan to run some tests soon. Nice work btw.

    "drash" wrote:
    "Infinite" wrote:
    Sadly, no one noticed her heart beat yet :) well the sound of it! Unity rocks.


    Don't worry, I'm sure plenty of people noticed and simply didn't tell you (like me haha). I actually instinctively turned my head to the left and put my ear up to her chest to hear it. Nice touch. :)


    :lol:

    "Slopey" wrote:

    I've tried it to be honest, but would swapping the meshes out on an object not result in a loss of fidelity (less smooth)? If Unity can cope with it at 25fps for one thing, but would it not be better to rig the model, then animate it to the new position? And maybe swap the models after some of the animation has fired?

    Swapping the mesh on the GameObject should be fairly trivial - just a case of loading an array of meshes and cyclically applying them to a game object. Would be interesting to see if it would handle it with your models.


    Of course yes. I'm trying to test something new, not travel old ground, i.e. rigging, weighting, motion capture. I'm just looking to future proof 4D playback, enough to get a pitch across in Unity to a client. It's totally impractical and in the future something custom outside of Unity would have to be written, until we have more computing power and Alembic is fully supported.

    Your idea, would you know how to implement that? would a script be trivial to turn on or off meshes do you think?
    _________________________________________________ I N F I N I T E www.ir-ltd.net
    Participant
    August 4, 2013
    This code creates a game object (newMesh) with an initial cube mesh, and then every 0.04 seconds (i.e. 25 fps) swaps it to something else in order - cone, cylinder, cube


    var newMesh : GameObject;
    var item : int;
    var trigger : int;
    var timeSinceLastCall : float;

    function Start () {

    item = 0;
    trigger = 0;
    newMesh = Instantiate(Resources.Load("cube"));
    }

    function Update () {


    timeSinceLastCall += Time.deltaTime;

    if (timeSinceLastCall >=0.04 && trigger == 0){
    trigger = 1;
    item ++;
    var mesh;

    switch(item)
    {
    case 1:
    mesh = Resources.Load("cone", Mesh);
    break;
    case 2:
    mesh = Resources.Load("cylinder",Mesh);
    break;
    case 3:
    mesh = Resources.Load("cube",Mesh);
    item = 0;
    break;
    }

    newMesh.GetComponent(MeshFilter).mesh = mesh;

    timeSinceLastCall = 0;
    trigger = 0;
    }

    }


    Cone/Cylinder/Cube are just simple primitives created in Blender and dropped into a "Resources" folder in the Assets folder of the project (you need the Resources folder to do Resources.Load). The trigger variable is there to stop the if statement executing if the next frame/update fires before Unity has loaded the mesh.

    Obviously it'd be better to load these meshes into an object array first so you don't have to continually reload them, but it works for these simple shapes as an example.

    Just pop the script onto an empty GameObject in the scene, and with the files in place it should work. The gameobject/meshes are instantiated at 0,0,0.

    Hope that helps! :)
    Up and Coming
    August 6, 2013
    You can also set each "frame" as a game object, place them in the scene at the same point, disable the mesh renderer, and then through code, just loop through them when it's been long enough enableing the next "frame" and disabling the last "Frame".

    I do something similar with a 2d animation system, but instead of enable disabling, I'm just swapping out textures. The textures are already in the scene, so you only have to worry about memory management.

    That said, you could also have a system that loads the next say 10 frames, and have a 10 frame buffer. For example at frame 0, it would already have two batches, the currently being displayed batch 0-9, and the second batch 10-19. Then when it gets to frame 10, it starts to load the first batch with the third batch of data.

    The reason you'd load over the older batches is simply memory management, but you could thread the loading so that it'd be displaying at the same time it's loading. O-o.... I don't know how well that would work since I've not really loaded any resources at runtime... but it's an idea.
    Current Project: Virtual Reality Glove project
    InfiniteAuthor
    Up and Coming
    August 12, 2013
    "Slopey" wrote:
    This code creates a game object (newMesh) with an initial cube mesh, and then every 0.04 seconds (i.e. 25 fps) swaps it to something else in order - cone, cylinder, cube


    var newMesh : GameObject;
    var item : int;
    var trigger : int;
    var timeSinceLastCall : float;

    function Start () {

    item = 0;
    trigger = 0;
    newMesh = Instantiate(Resources.Load("cube"));
    }

    function Update () {


    timeSinceLastCall += Time.deltaTime;

    if (timeSinceLastCall >=0.04 && trigger == 0){
    trigger = 1;
    item ++;
    var mesh;

    switch(item)
    {
    case 1:
    mesh = Resources.Load("cone", Mesh);
    break;
    case 2:
    mesh = Resources.Load("cylinder",Mesh);
    break;
    case 3:
    mesh = Resources.Load("cube",Mesh);
    item = 0;
    break;
    }

    newMesh.GetComponent(MeshFilter).mesh = mesh;

    timeSinceLastCall = 0;
    trigger = 0;
    }

    }


    Cone/Cylinder/Cube are just simple primitives created in Blender and dropped into a "Resources" folder in the Assets folder of the project (you need the Resources folder to do Resources.Load). The trigger variable is there to stop the if statement executing if the next frame/update fires before Unity has loaded the mesh.

    Obviously it'd be better to load these meshes into an object array first so you don't have to continually reload them, but it works for these simple shapes as an example.

    Just pop the script onto an empty GameObject in the scene, and with the files in place it should work. The gameobject/meshes are instantiated at 0,0,0.

    Hope that helps! :)


    Thanks for that Slopey. I haven't checked back on this thread in a while. I will give this script a go.

    "CaliberMengsk" wrote:
    You can also set each "frame" as a game object, place them in the scene at the same point, disable the mesh renderer, and then through code, just loop through them when it's been long enough enableing the next "frame" and disabling the last "Frame".

    I do something similar with a 2d animation system, but instead of enable disabling, I'm just swapping out textures. The textures are already in the scene, so you only have to worry about memory management.

    That said, you could also have a system that loads the next say 10 frames, and have a 10 frame buffer. For example at frame 0, it would already have two batches, the currently being displayed batch 0-9, and the second batch 10-19. Then when it gets to frame 10, it starts to load the first batch with the third batch of data.

    The reason you'd load over the older batches is simply memory management, but you could thread the loading so that it'd be displaying at the same time it's loading. O-o.... I don't know how well that would work since I've not really loaded any resources at runtime... but it's an idea.


    That sounds ideal. Although a little out of my remit. Buffering would be wise as you suggest. Is this something you would be able to create?
    _________________________________________________ I N F I N I T E www.ir-ltd.net
    Up and Coming
    August 13, 2013
    To be honest, I have no clue if I could program something like that. O-o Would probably take some time to do, and unfortunately, my life is fairly busy at the moment. (programming a moba game takes quite a bit of time, with all the networking and such)

    I'd try it out if I had more time. The concept should be easy enough to follow though for anyone to try.
    Current Project: Virtual Reality Glove project
    Participant
    August 16, 2013
    You probably don't need to buffer them unless you're talking about thousands of frames.

    But if you are, you'd be more efficient rigging the model in the first place and animating it, depending what you'd be trying to achieve.

    It would likely be enough to just load the frames as an array of gameObjects and use those, although I'm not sure how you'd handle positioning in the best manner - you'd likely need an empty game object to map those onto to keep the position orientation correct, or hold the data in code.

    Probably easier just swapping the meshes out on a single gameobject as you move it around.
    Up and Coming
    August 22, 2013
    Did you ever try this? I would like to see these "animated". I'll post another script if you will try it.
    @st4rdog