protected void setPose(Transform transformObject, smartar.RecognitionResult result) { smartar.Vector3 zeroPos; zeroPos.x_ = 0f; zeroPos.y_ = 0f; zeroPos.z_ = 0f; setPose(transformObject, result, zeroPos); }
protected virtual void Start() { 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_; }
protected virtual void Start() { result_ = new smartar.RecognitionResult(); result_.maxLandmarks_ = smartar.Recognizer.MAX_NUM_LANDMARKS; result_.landmarks_ = landmarkBuffer_; result_.maxInitPoints_ = smartar.Recognizer.MAX_NUM_INITIALIZATION_POINTS; result_.initPoints_ = initPointBuffer_; showOrHideChildrens(false); }
protected override int CallNativeGetResult(IntPtr self, IntPtr target, ref smartar.RecognitionResult result) { if (self_ != IntPtr.Zero) { return(sarSmartar_SarSmartARController_sarGetResult(self_, target, ref result)); } else { return(smartar.Error.ERROR_INVALID_POINTER); } }
protected virtual void Start() { result_ = new smartar.RecognitionResult(); result_.maxInitPoints_ = smartar.Recognizer.MAX_NUM_INITIALIZATION_POINTS; result_.initPoints_ = initPointBuffer_; style_ = new GUIStyle(); style_.fontSize = 30; styleState_ = new GUIStyleState(); styleState_.textColor = Color.yellow; }
public int GetResult(string id, ref smartar.RecognitionResult result) { int ret = -1; if (id == null || string.Equals(id, "")) { ret = CallNativeGetResult(self_, IntPtr.Zero, ref result); isRecognized_ = result.isRecognized_; return(ret); } else if (recognizerSettings.useInstantTarget) { for (int i = 0; i < onlineTargets_.Length; i++) { if (onlineTargets_[i] == null) { break; } if (string.Compare(recognizerSettings.targets[i].id, id) == 0) { ret = CallNativeGetResult(self_, onlineTargets_[i].self_, ref result); isRecognized_ = result.isRecognized_; return(ret); } } result = new smartar.RecognitionResult(); isRecognized_ = result.isRecognized_; return(smartar.Error.ERROR_INVALID_VALUE); } else { for (int i = 0, num = recognizerSettings.targets.Length; i < num; ++i) { if (string.Compare(recognizerSettings.targets[i].id, id) == 0) { if (targets_ == null) { break; } ret = CallNativeGetResult(self_, targets_[i].self_, ref result); isRecognized_ = result.isRecognized_; return(ret); } } result = new smartar.RecognitionResult(); isRecognized_ = result.isRecognized_; return(smartar.Error.ERROR_INVALID_VALUE); } }
protected override void SetPose(Transform transformObject, smartar.RecognitionResult result, smartar.Vector3 rotPosition) { Transform lastRecognizedTransform = SmartAREffectorBase.GetLastRecognizedTransform(); if (lastRecognizedTransform == null) { return; } if (SmartAREffectorBase.IsLastRecognizedGameObject(targetEffector_.gameObject)) { smartAREffector_.setPose(transformObject, result, rotPosition); transformObject.position = transformObject.position - lastRecognizedTransform.position; } else { if (smartAREffector_.UseFrontCamera()) { if (smartAREffector_.GetImageSensorRotation() == smartar.Rotation.ROTATION_90) { // Nexus 6P,6,5X front camera rotPosition.x_ = -rotPosition.x_; rotPosition.y_ = -rotPosition.y_; } result.position_.x_ -= rotPosition.x_; result.position_.y_ += rotPosition.y_; result.position_.z_ -= rotPosition.z_; } else { result.position_.x_ -= rotPosition.x_; result.position_.y_ -= rotPosition.y_; result.position_.z_ -= rotPosition.z_; } smartar.Vector3 zeroVec = new smartar.Vector3(); zeroVec.x_ = zeroVec.y_ = zeroVec.z_ = 0.0f; var targetTransform = new GameObject().transform; smartAREffector_.setPose(targetTransform, result, zeroVec); targetTransform.rotation = lastRecognizedTransform.rotation * UnityEngine.Quaternion.Inverse(targetTransform.rotation); targetTransform.position = targetTransform.rotation * targetTransform.position; transformObject.position = lastRecognizedTransform.position - targetTransform.position; transformObject.rotation = targetTransform.rotation; Destroy(targetTransform.gameObject); } }
public void setPose(Transform transformObject, smartar.RecognitionResult result, smartar.Vector3 landmarkPos) { smartar.Vector3 rotPosition; smartar.Quaternion rotRotation; callAdjustPose(result.position_, result.rotation_, out rotPosition, out rotRotation); transformObject.rotation = Quaternion.identity; transformObject.RotateAround(Vector3.zero, Vector3.right, -90); var q = new Quaternion(rotRotation.x_, rotRotation.z_, rotRotation.y_, rotRotation.w_); float angle; Vector3 axis; q.ToAngleAxis(out angle, out axis); transformObject.RotateAround(Vector3.zero, axis, angle); transformObject.position = new Vector3( (rotPosition.x_ + landmarkPos.x_) * nearClipPlane_, (rotPosition.z_ + landmarkPos.z_) * nearClipPlane_, (rotPosition.y_ + landmarkPos.y_) * nearClipPlane_); }
protected abstract void SetPose(Transform transformObject, smartar.RecognitionResult result, smartar.Vector3 rotPosition);
protected abstract int CallNativeGetResult(IntPtr self, IntPtr target, ref smartar.RecognitionResult result);
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(); } }
private static extern int sarSmartar_SarRecognizer_sarPropagateResult(IntPtr self, ref RecognitionResult fromResult, out RecognitionResult toResult, ulong timestamp, bool useVelocity);
private static extern int sarSmartar_SarRecognizer_sarGetResult(IntPtr self, IntPtr target, out RecognitionResult result);
public int PropagateResult(RecognitionResult fromResult, out RecognitionResult toResult, ulong timestamp, bool useVelocity = true) { return(sarSmartar_SarRecognizer_sarPropagateResult(self_, ref fromResult, out toResult, timestamp, useVelocity)); }
public int GetResult(Target target, out RecognitionResult result) { return(sarSmartar_SarRecognizer_sarGetResult(self_, target.self_, out result)); }
protected abstract void GetResult(ref smartar.RecognitionResult result);
private static extern int sarSmartar_SarSmartARController_sarGetResult(IntPtr self, IntPtr target, ref smartar.RecognitionResult result);