private static extern void sarSmartar_SarSmartARController_sarSetLandmarkDrawerDrawNodePointData(IntPtr self, IntPtr landmark_self, ref smartar.Matrix44 pmvMatrix, IntPtr nodePoints, int numNodePoints);
 private static extern void sarSmartar_SarSmartARController_sarSetLandmarkDrawerDrawInitPointData(IntPtr self, IntPtr landmark_self, ref smartar.Matrix44 imageMatrix, IntPtr initPoints, int numInitPoints);
    void OnPreRender()
    {
        if (smartInitFailed_)
        {
            return;
        }
        if (self_ == IntPtr.Zero)
        {
            return;
        }

        drawStartTimeSec_ = Time.realtimeSinceStartup;

#if UNITY_5_0
    #if UNITY_ANDROID && !UNITY_EDITOR
        GL.IssuePluginEvent(0);
#elif UNITY_IOS && !UNITY_EDITOR
        GL.Clear(true, false, Color.green);
    #endif
#else
        GL.IssuePluginEvent(GetRenderEventFunc(), 0);
        GL.InvalidateState();
#endif

        // Draw landmarks
        if (miscSettings.showLandmarks)
        {
            // Get result
            var result = new smartar.RecognitionResult();
            result.maxLandmarks_  = smartar.Recognizer.MAX_NUM_LANDMARKS;
            result.landmarks_     = landmarkBuffer_;
            result.maxNodePoints_ = smartar.Recognizer.MAX_NUM_NODE_POINTS;
            result.nodePoints_    = nodePointBuffer_;
            result.maxInitPoints_ = smartar.Recognizer.MAX_NUM_INITIALIZATION_POINTS;
            result.initPoints_    = initPointBuffer_;
            GetResult(null, ref result);

            // Draw landmarks
            var adjustedPosition = new smartar.Vector3();
            var adjustedRotation = new smartar.Quaternion();
            sarSmartar_SarSmartARController_sarAdjustPose(self_, ref result.position_, ref result.rotation_, out adjustedPosition, out adjustedRotation);
            var mvMatrix = new smartar.Matrix44();
            smartar.Utility.convertPose2Matrix(adjustedPosition, adjustedRotation, out mvMatrix);
            var projMatrix      = getProjMatrix();
            var initPointMatrix = sarSmartar_SarSmartARController_sarGetInitPointMatrix(self_);
            var pmvMatrix       = projMatrix * mvMatrix;

            // Draw Preview, landmarks, node points, init points
            sarSmartar_SarSmartARController_sarSetDrawData(Screen.width, Screen.height, miscSettings.showCameraPreview);
            sarSmartar_SarSmartARController_sarSetLandmarkDrawerDrawLandmarkData(self_, landmarkDrawer_.self_, ref pmvMatrix, result.landmarks_, result.numLandmarks_);
            sarSmartar_SarSmartARController_sarSetLandmarkDrawerDrawNodePointData(self_, landmarkDrawer_.self_, ref pmvMatrix, result.nodePoints_, result.numNodePoints_);
            sarSmartar_SarSmartARController_sarSetLandmarkDrawerDrawInitPointData(self_, landmarkDrawer_.self_, ref initPointMatrix, result.initPoints_, result.numInitPoints_);
            GL.IssuePluginEvent(GetRenderEventFunc(), (int)RenderEventID.DoDraw);
            GL.InvalidateState();
        }
        else
        {
            sarSmartar_SarSmartARController_sarSetDrawData(Screen.width, Screen.height, miscSettings.showCameraPreview);
            GL.IssuePluginEvent(GetRenderEventFunc(), (int)RenderEventID.DoDraw);
            GL.InvalidateState();
        }
    }