New version of ZigFu unity package

763 views
Skip to first unread message

Roee Shenberg

unread,
Oct 28, 2011, 10:29:59 PM10/28/11
to unity...@googlegroups.com
Hey guys,

We've wrapped up a new version of the Unity bindings, available at http://site.zigfu.com/main/dlrelease?release=unityopennibindings

Release notes (note that not every single bug-fix is listed):

New sample Scenes:
- Sample Loader - A simple vertical list with all samples scenes. Load samples with gestures!
- Mesh From Depth - Construct a mesh from the image & depth streams (re-written)
- Mesh From Depth With Light - An upgrade to the MeshFromDepth sample. Start a hand point session to see the mesh lit with an artificial light.

New features:
- Navigator for hand point controls
- Reset functionality in user tracker
- Swipe detector hand point control
- Push sliding to scroll fast in ScrollingMenu
- Out of bounds event when reaching the end of a ScrollingMenu
- EnableRegistration script to enable depth->rgb registration

Fixes:
- User tracker works when scene loads with users tracked from previous loaded scene
- Item selector only sends messages when active
- Exit on hitting Escape key in samples
- Fader is positioned correctly when navigated to in mid session
- Renamed SessionManager (singleton works properly when session manager is added manually to scene)


Schpitz

unread,
Oct 29, 2011, 6:59:18 AM10/29/11
to unitykinect
nice!
thank's for the update
keep the good work!

On 29 אוקטובר, 04:29, Roee Shenberg <shenb...@gmail.com> wrote:
> Hey guys,
>
> We've wrapped up a new version of the Unity bindings, available athttp://site.zigfu.com/main/dlrelease?release=unityopennibindings

nuno.ma...@gmail.com

unread,
Feb 7, 2014, 8:01:05 AM2/7/14
to unity...@googlegroups.com
Greetings,

I'm aware this an quite old thread but the MeshFromDepth and MeshFromDepthWithLight demos are no longer available on ZigFu's website, is there any chance of downloading them from somewhere else?

Regards,
Nuno

Michael Winterberg

unread,
Feb 7, 2014, 11:20:18 AM2/7/14
to unity...@googlegroups.com
do you know which version the demo had inside?


--
You received this message because you are subscribed to the Google Groups "unitykinect" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unitykinect...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Michael Winterberg
Lanzerather Feldstraße 12
41472 Neuss
Tel.: 01573 5464378
E-Mail: michael.w...@block23.de

nuno.ma...@gmail.com

unread,
Feb 7, 2014, 11:38:13 AM2/7/14
to unity...@googlegroups.com
Hello,

Unfortunately, I have no idea. The only information available is really the date that Rooe Shenberg posted the sample announcement, 10th October 2011, don't know if that will be enough for you though.

Regards,
Nuno

Michael Winterberg

unread,
Feb 7, 2014, 4:12:00 PM2/7/14
to unity...@googlegroups.com
i ziped it all together

nuno.ma...@gmail.com

unread,
Feb 10, 2014, 4:56:31 AM2/10/14
to unity...@googlegroups.com
Thanks!

nuno.ma...@gmail.com

unread,
Feb 13, 2014, 7:25:41 AM2/13/14
to unity...@googlegroups.com
Greetings,

Been around the code of the OpenNIDepthmapToMesh sample and have quite a few doubts. I added few personal comments to it and highlighted (in red) the code lines that I haven't understood.
I really want to fully understand this demo so any help would be greatly appreciated.

Regards,
Nuno

using UnityEngine;
using System;
using System.Collections;
using System.Runtime.InteropServices;
using OpenNI;

public class OpenNIDepthmapToMesh : MonoBehaviour
{
    public Vector3 gridScale = Vector3.one;
    public bool GenerateNormals = true;
    public bool GenerateUVs = true;
    public bool RealWorldPoints = true; // perform perspective transform on depth-map

    public Vector2 DesiredResolution = new Vector2(160, 120); // should be a divisor of 640x480
                                                              // and 320x240 is too high (too many vertices)
    int factorX;
    int factorY;

    short[] rawDepthMap;
    float[] depthHistogramMap;
    int XRes;
    int YRes;
    Mesh mesh;
    MeshFilter meshFilter;

    Vector2[] uvs;
    Vector3[] verts;
    int[] tris;
    Point3D[] pts;
    // Use this for initialization
    void Start()
    {
        // Init stuff
        MapOutputMode mom = OpenNIContext.Instance.Depth.MapOutputMode; // <MapOutputMode xRes="640" yRes="480" FPS="30"/>

        XRes = mom.XRes;                                                // XRes = 640
        YRes = mom.YRes;                                                // YRes = 480
       
        factorX = (int)(XRes / DesiredResolution.x);                    // Scale factor X = 3
        factorY = (int)(YRes / DesiredResolution.y);                    // Scale factor Y = 4
       
        // Depthmap data
        rawDepthMap = new short[(int)(mom.XRes * mom.YRes)];            // Depth map (640*480)

        // The actual mesh we'll use
        mesh = new Mesh();

        meshFilter = (MeshFilter)GetComponent(typeof(MeshFilter));      // Holds Mesh data
        meshFilter.mesh = mesh;

        int XScaled = XRes / factorX;                                   // X component of intended resolution: 640 / 4 = 160
        int YScaled = YRes / factorY;                                   // Y component of intended resolution: 480 / 4 = 120
       
        // In order to create a Mesh we need to:
        verts = new Vector3[XScaled * YScaled];                         // Create Vertices (Vector3) (160*120)
        uvs = new Vector2[verts.Length];                                // Create UVs (Vector2) (160*120)
        tris = new int[(XScaled - 1) * (YScaled - 1) * 2 * 3];          // Create triangles (list of vertices indices)
       
       
        pts = new Point3D[XScaled * YScaled];                           // (160 * 120)
       
        CalculateTriangleIndices(YScaled, XScaled);                     // (160 * 120)
        CalculateUVs(YScaled, XScaled);                                 // (160 * 120)
    }

    void UpdateDepthmapMesh()
    {
        if (meshFilter == null)
            return;
        Profiler.BeginSample("UpdateDepthmapMesh");

        // It is important to call Clear before assigning new vertices or triangles.
        // Unity always checks the supplied triangle indices whether they don't reference out of bounds vertices.
        // Calling Clear then assigning vertices then triangles makes sure you never have out of bounds data.
        mesh.Clear();
       
        // Flip the depthmap as we create the texture
        int YScaled = YRes / factorY;                                                             // Why flip?
        int XScaled = XRes / factorX;
       
        // Generate all vertices (next time, only vertices for 'valid' depths)
        // Decimate rather than average depth pixels
        UpdateVertices(YScaled, XScaled);
      
        if (GenerateUVs) {
            UpdateUVs(YScaled, XScaled);
        }

        UpdateTriangleIndices();
       
        // Normals - if we generate we need to update them according to the new mesh
        if (GenerateNormals) {
            mesh.RecalculateNormals();
        }

        Profiler.EndSample();
    }

    private void UpdateUVs(int YScaled, int XScaled)
    {
        Profiler.BeginSample("UpdateUVs");
        mesh.uv = uvs;
        Profiler.EndSample();
    }

    private void CalculateUVs(int YScaled, int XScaled)
    {
        for (int y = 0; y < YScaled; y++) {
            for (int x = 0; x < XScaled; x++) {
                //uvs[y * XScaled + x] = new Vector2((float)x / (float)XScaled,
                //                       (float)y / (float)YScaled);
                uvs[y * XScaled + x].x = (float)x / (float)XScaled;                           // ?
                uvs[y * XScaled + x].y = ((float)(YScaled - 1 - y) / (float)YScaled);         // ?
            }
        }
    }
   
    private void UpdateVertices(int YScaled, int XScaled)
    {
        int depthIndex = 0;
        Profiler.BeginSample("UpdateVertices");

        Profiler.BeginSample("FillPoint3Ds");
       
        DepthGenerator dg = OpenNIContext.Instance.Depth;
        short maxDepth = (short)OpenNIContext.Instance.Depth.DeviceMaxDepth;
       
        Vector3 vec = new Vector3();
        Point3D pt = new Point3D();
       
        for (int y = 0; y < YScaled; y++) {
            for (int x = 0; x < XScaled; x++, depthIndex += factorX) {              // Why factorX, could it be factorY?
               
                short pixel = rawDepthMap[depthIndex];                              // Retrieve a pixel, every 3 pixels (factorX) from rawDepthMap
                if (pixel == 0) pixel = maxDepth;                                   // If there's no depth,  default to max depth

                // RW coordinates 
                pt.X = x * factorX;
                pt.Y = y * factorY;
                pt.Z = pixel;                                                       // Z component = Depth value from each pixel

                // Structs are copied on assignment. When a struct is assigned to a new variable,
                // all the data is copied, and any modification to the new copy does not change
                //the data for the original copy
                pts[x + y * XScaled] = pt;                                          // Index?

            }
            // Skip lines
            depthIndex += (factorY - 1) * XRes;                                     // Index?
        }
        Profiler.EndSample();
        Profiler.BeginSample("ProjectiveToRW");
        if (RealWorldPoints) {
            pts = dg.ConvertProjectiveToRealWorld(pts);
        }
        else {                                                                      // What is this "else" for?
            for (int i = 0; i < pts.Length; i++) {
                pts[i].X -= XRes / 2;
                pts[i].Y = (YRes / 2) - pts[i].Y;                                   // Flip Y axis in projective
            }
        }
        Profiler.EndSample();
        Profiler.BeginSample("PointsToVertices");
        for (int y = 0; y < YScaled; y++) {
            for (int x = 0; x < XScaled; x++) {
                pt = pts[x + y * XScaled];
                vec.x = pt.X * gridScale.x;
                vec.y = pt.Y * gridScale.y;
                vec.z = -pt.Z * gridScale.z;
                verts[y * XScaled + x] = vec;                                       // Index?
            }
        }
        Profiler.EndSample();
        Profiler.BeginSample("AssignVerticesToMesh");
        mesh.vertices = verts;
        Profiler.EndSample();

        Profiler.EndSample();
    }

    private void UpdateTriangleIndices()
    {
        Profiler.BeginSample("UpdateTriangleIndices");

        mesh.triangles = tris;
        Profiler.EndSample();
    }

    private void CalculateTriangleIndices(int YScaled, int XScaled)
    {
        int triIndex = 0;
        int posIndex = 0;
        for (int y = 0; y < (YScaled - 1); y++) {
            for (int x = 0; x < (XScaled - 1); x++, posIndex++) {
                // Counter-clockwise triangles

                tris[triIndex++] = posIndex + 1;           // Bottom right           PosIndex + XScaled
                tris[triIndex++] = posIndex;               // Bottom left                     |
                tris[triIndex++] = posIndex + XScaled;     // Top left                     PosIndex -------------- PosIndex+1

               
                tris[triIndex++] = posIndex + 1;           // Bottom right           PosIndex + XScaled --------- PosIndex + XScaled + 1
                tris[triIndex++] = posIndex + XScaled;     // Top left                                                     |
                tris[triIndex++] = posIndex + XScaled + 1; // Top right                                                PosIndex + 1
            }
            posIndex++; // Finish row
        }
    }

    int lastFrameId;
    void FixedUpdate()
    {
        // Update only if we have a new depth frame
        if (lastFrameId != OpenNIContext.Instance.Depth.FrameID) {
            lastFrameId = OpenNIContext.Instance.Depth.FrameID;
            Marshal.Copy(OpenNIContext.Instance.Depth.DepthMapPtr,
                         rawDepthMap, 0, rawDepthMap.Length);
            UpdateDepthmapMesh();
        }
    }
}

DDD

unread,
Feb 24, 2014, 9:36:57 AM2/24/14
to unity...@googlegroups.com
@block23 
Any chance you could re-post this zip? The download you linked to doesn't seem to be available anymore. 
Thanks much!!!
d

block23

unread,
Feb 24, 2014, 3:20:08 PM2/24/14
to unity...@googlegroups.com
pm on fb!

Daniele Suppo

unread,
Dec 24, 2014, 10:01:02 AM12/24/14
to unity...@googlegroups.com
Hi block23
has been a long time since the last post,
how can I get the zip with demos?
Thank-you!

Michael Winterberg

unread,
Dec 24, 2014, 1:11:02 PM12/24/14
to unity...@googlegroups.com
Hi Daniel,

for the next seven days


For more options, visit https://groups.google.com/d/optout.

Daniele Suppo

unread,
Dec 24, 2014, 6:17:59 PM12/24/14
to unity...@googlegroups.com
Thank-you very much and Merry Christmas Michael!

..................................................................................................................................................................................................................................................................................................................
Daniele Suppo
...................................................................................................................................................................................................................................................................................................................
 
Vivo s.r.l.

Torino
Via Carlo Alberto 5

...................................................................................................................................................................................................................................................................................................................
Questo messaggio e-mail e ogni documento ad esso eventualmente allegato puÚ avere carattere riservato ed essere tutelato da segreto. Esso, comunque, Ë ad esclusivo utilizzo del destinatario in indirizzo. Qualora non foste il destinatario del messaggio vi preghiamo di volerci avvertire immediatamente per e-mail o telefono e di cancellare il presente messaggio e ogni eventuale allegato dal vostro sistema. E' vietata la duplicazione o l'utilizzo per qualunque fine del messaggio e di ogni allegato, nonchÈ la loro divulgazione, distribuzione o inoltro a terzi senza l'espressa autorizzazione del mittente. In ragione del mezzo di trasmissione utilizzato, il mittente non assume alcuna responsabilit‡ sulla segretezza/riservatezza delle informazioni contenute nel messaggio e nei relativi allegati.
...................................................................................................................................................................................................................................................................................................................
This e-mail and any file transmitted with it may contain material that is confidential, privileged and/or attorney work product for the sole use of the intended recipient. If you are not the intended recipient of this e-mail, please do not read it, notify us immediately by e-mail or by telephone and then delete this message and any file attached from your system. You should not copy or use it for any purpose, disclose the contents of the same to any other person or forward it without express permission. Considering the means of transmission, we do not undertake any liability with respect to the secrecy and confidentiality of the information contained in this e-mail and its attachments. Please consider the environment before printing this mail note
...................................................................................................................................................................................................................................................................................................................

Bernard Ionescu

unread,
Feb 8, 2018, 2:34:04 PM2/8/18
to unitykinect
Hello Michael

DO you still have that Zigfu archive somewhere?
Can you share it again, please?
Thanks

Amir Hirsch

unread,
Feb 8, 2018, 2:59:24 PM2/8/18
to unity...@googlegroups.com
https://github.com/zigfu now hosts everything from zigfu open source. there's some support for audio and facetracking with the kinect2 and it was (maybe still is) a reasonably good reference for setting textures from a plugin and binding a C++ with unity in C#.

To unsubscribe from this group and stop receiving emails from it, send an email to unitykinect+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages