private bool CreateCylinderTargets() { int num = VuforiaWrapper.Instance.DataSetGetNumTrackableType((int)TypeMapping.GetTypeID(typeof(CylinderTarget)), this.mDataSetPtr); if (num <= 0) { return(false); } IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SimpleTargetData)) * num); if (VuforiaWrapper.Instance.DataSetGetTrackablesOfType((int)TypeMapping.GetTypeID(typeof(CylinderTarget)), intPtr, num, this.mDataSetPtr) == 0) { Debug.LogError("Could not create Cylinder Targets"); return(false); } for (int i = 0; i < num; i++) { SimpleTargetData simpleTargetData = (SimpleTargetData)Marshal.PtrToStructure(new IntPtr(intPtr.ToInt64() + (long)(i * Marshal.SizeOf(typeof(SimpleTargetData)))), typeof(SimpleTargetData)); if (!this.mTrackablesDict.ContainsKey(simpleTargetData.id)) { StringBuilder stringBuilder = new StringBuilder(128); VuforiaWrapper.Instance.DataSetGetTrackableName(this.mDataSetPtr, simpleTargetData.id, stringBuilder, 128); CylinderTarget value = new CylinderTargetImpl(stringBuilder.ToString(), simpleTargetData.id, this); this.mTrackablesDict[simpleTargetData.id] = value; } } Marshal.FreeHGlobal(intPtr); return(true); }
internal override bool InitializeTarget(Trackable trackable, bool applyTargetScaleToBehaviour) { base.InitializeTarget(trackable, applyTargetScaleToBehaviour); CylinderTargetImpl cylinderTargetImpl = (CylinderTargetImpl)trackable; if (cylinderTargetImpl == null) { return(false); } this.mTrackable = (this.mCylinderTarget = cylinderTargetImpl); this.mTrackableName = trackable.Name; this.mDataSetPath = cylinderTargetImpl.DataSet.Path; this.mTopDiameterRatio = cylinderTargetImpl.GetTopDiameter() / cylinderTargetImpl.GetSideLength(); this.mBottomDiameterRatio = cylinderTargetImpl.GetBottomDiameter() / cylinderTargetImpl.GetSideLength(); if (applyTargetScaleToBehaviour) { float sideLength = cylinderTargetImpl.GetSideLength(); base.transform.localScale = new Vector3(sideLength, sideLength, sideLength); base.CorrectScale(); } cylinderTargetImpl.SetSideLength(this.SideLength); if (this.mExtendedTracking) { this.mCylinderTarget.StartExtendedTracking(); } return(true); }