cancel
Showing results for 
Search instead for 
Did you mean: 

mesh sequence playback in Unity -(simple DK2 demo inside)

Thomixioso
Level 2
Hi guys,

I have some interesting idea to create liquid simulation (flooding street, waterfalls, water explosions etc.) and play it back in Unity. As fx guy with DK2 at home this is something I would love to try experiencing inside Rift. I am really new in Unity, so I would really appreciate if anybody can help me with loading these mesh sequences to Unity. I understand its very performance intensive, but maybe I can try to optimize resolutions a lot.

Thank you, Tomas.
17 REPLIES 17

Thomixioso
Level 2
This is quick test. Polycount is around 1 mill polys, but growing in time. However, data size is very uncomfortable, so this short animation (70 frames) has 900 MB! So, if you have fast internet you can try it. I can create some youtube if somebody want that. Is there any other method how to attach multiple objects into that script? I did it manualy one by one and its quite slow if you have lot of frames.

Playback is very smooth, on my I7 4.GHz, GTX 770, 16 Gb Ram.

http://we.tl/UAqarGDJAj

Even though, possibilities are endless 🙂 Smoke/fire simulations, Destructions (Maya Ncloth/DMM), cloth simulations or Realflow/Bifrost liquids....etc. If you have guys some interesting idea you would like to experience, let me know.

Tomas

MikeF
Level 10
Cool stuff man! if i have some time i'll see what i can do to improve it so its easier to load in the frames.
I also want to run a few tests myself to see if we can get that filesize down somehow

Thomixioso
Level 2
Thanks Mike, 🙂

compiled demo size and loading into frames are now biggest obstacles. And of course loading OBJ files into Unity 🙂

If you solve this, I could create something more interesting. For example atomic explosion. or building collapse.

Tom.

rado_o
Level 2
Hi,

I'm sorry to restart a 4 years old discussion, but I'm out of luck in making the script work and I thought maybe somebody could help. I mean, the script seems to work- there is some mesh changing in the Project window- but I can't see anything in the Game window. Moreover, as soon as the meshes are dragged into the array, they dissapear from the game camera.
I would appreciate any help, thanks!

MikeF
Level 10
It looks like some stuff has been messed up in the formatting since i posted this in the old forums, and its in js which i dont think is supported in unity anymore

here's a cleaner simplified version in C#
just attach to the parent object of your frame sequence and hit play.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Mesh sequence playback, 1/04/2018 MikeF
/// Attach to gameobject containing a series of child gameobjects/meshes to cycle through
/// Modify public vars below in the inspector an hit play
/// </summary>
public class MeshSequence : MonoBehaviour {

public bool PingPong = false; //ping pong sequence
public float PlaybackSpeed = 1.0f; //framerate of sequence playback
public int StartFrame =0; //starting frame of sequence playback

private GameObject m_lastFrame;
private GameObject m_currentFrame;
private bool m_reverse = false;
private float CycleTimer = 0.0f;
private int m_NextFrame = 0;
private List<GameObject> m_frames = new List<GameObject>();

void Start () {
SetupFrames ();
}

private void SetupFrames(){
foreach (Transform child in transform) {
m_frames.Add (child.gameObject);
child.gameObject.SetActive (false);
}

if (StartFrame >= m_frames.Count) {
Debug.Log ("Start frame is higher than total number of frames, starting from frame 0");
StartFrame = 0;
}

m_currentFrame = m_frames [StartFrame];
m_currentFrame.gameObject.SetActive (true);
}


void Update () {
CycleTimer += Time.deltaTime*PlaybackSpeed;

if (CycleTimer >= 1) {
CycleTimer = 0;
m_lastFrame = m_currentFrame;
m_lastFrame.gameObject.SetActive (false);
m_currentFrame = m_frames [m_NextFrame];
m_currentFrame.gameObject.SetActive (true);

if (m_NextFrame == m_frames.Count-1 && !m_reverse) {

if (PingPong) {
m_reverse = true;
m_NextFrame--;
}

else if (!PingPong) {
m_NextFrame = 0;
}

}

if (m_reverse) {
m_NextFrame--;
if (m_NextFrame == 0) {
m_reverse = false;
m_NextFrame = 0;
}
}

else m_NextFrame++;
}
}
}


rado_o
Level 2
Hey,
sorry for the delayed answer, the system didn't notify me 😞
Anyways, you're DA MAN! Thank you so much for your reply!
I will try asap and come back with flowers :D!
As for 2017 Unity doesn't support js anymore, indeed (dev) but I took my chances since the script was 4 years old. Please tell me if I can offer you some 3d stuff in exchange!


rado_o
Level 2
Yep. It works like a charm!I can't thank you enough! My offer stands and I still need to send you flowers 😄

MikeF
Level 10
No problem, glad it worked for you!