private void LoadModel(string modelDir)
{
string modelPath = "Clothing/" + modelDir + "/model";
UnityEngine.Object modelPrefab = Resources.Load(modelPath, typeof(GameObject));
if(modelPrefab == null)
return;
if(selModel != null)
{
GameObject.Destroy(selModel);
}
selModel = (GameObject)GameObject.Instantiate(modelPrefab);
selModel.name = "Model" + modelDir;
selModel.transform.position = Vector3.zero;
selModel.transform.rotation = Quaternion.Euler(0, 180f, 0);
AvatarController ac = selModel.AddComponent<AvatarController>();
ac.posRelativeToCamera = modelRelativeToCamera;
ac.posRelOverlayColor = (foregroundCamera != null);
ac.mirroredMovement = true;
ac.verticalMovement = true;
ac.smoothFactor = 0f;
KinectManager km = KinectManager.Instance;
ac.Awake();
if(km.IsUserDetected())
{
ac.SuccessfulCalibration(km.GetPrimaryUserID());
}
km.avatarControllers.Clear(); // = new List<AvatarController>();
km.avatarControllers.Add(ac);
AvatarScaler scaler = selModel.AddComponent<AvatarScaler>();
scaler.mirroredAvatar = true;
scaler.bodyScaleFactor = bodyScaleFactor;
scaler.continuousScaling = continuousScaling;
scaler.foregroundCamera = foregroundCamera;
scaler.Start();
}
void MenuWindow(int windowID)
{
menuWindowRectangle = new Rect(Screen.width - 160, 40, 150, Screen.height - 60);
if (modelThumbs != null)
{
GUI.skin.button.fixedWidth = 120;
GUI.skin.button.fixedHeight = 163;
scroll = GUILayout.BeginScrollView(scroll);
selected = GUILayout.SelectionGrid(selected, modelThumbs, 1);
if (selected >= 0 && selected < modelNames.Length && prevSelected != selected)
{
prevSelected = selected;
LoadModel(modelNames[selected]);
}
GUILayout.EndScrollView();
GUI.skin.button.fixedWidth = 0;
GUI.skin.button.fixedHeight = 0;
}
}
public void UserDetected(long userId, int userIndex)
public void GestureInProgress(long userId, int userIndex, KinectGestures.Gestures gesture,
float progress, KinectInterop.JointType joint, Vector3 screenPos)
public bool GestureCompleted(long userId, int userIndex, KinectGestures.Gestures gesture,
KinectInterop.JointType joint, Vector3 screenPos)
void Update()
{
if (!gestureListener)
return;
if (gestureListener.IsSwipeLeft())
{
selected++;
selected = (selected % numberOfModels);
Debug.Log("SwipeLeft.");
}
else if (gestureListener.IsSwipeRight())
{
selected--;
selected = (selected % numberOfModels);
Debug.Log("SwipeRight.");
}
}