Jetpack XR-এর জন্য ARCore-এর সাহায্যে, আপনার অ্যাপ ডিভাইসের পোজে অ্যাক্সেস করতে পারে: ওরিয়েন্টেশন (পিচ, ইয়, রোল) এবং ডিভাইসের পজিশন (X, Y, Z) যা ওয়ার্ল্ড অরিজিনের সাথে সম্পর্কিত।
বাস্তব জগতে ডিজিটাল কন্টেন্ট রেন্ডার করতে এই তথ্য ব্যবহার করুন অথবা লোকেশন-সচেতন ডেটা জেনারেট করতে ডিভাইস পোজকে জিওস্পেশিয়াল পোজ হিসেবে কনভার্ট করুন।
সেশন অ্যাক্সেস করা
Jetpack XR Runtime Session-এর মাধ্যমে ডিভাইস পোজ সংক্রান্ত তথ্য অ্যাক্সেস করুন,
যা আপনার অ্যাপকে তৈরি করতে হবে।
সেশন কনফিগার করা
XR সেশনে ডিফল্ট হিসেবে ডিভাইস পোজ সংক্রান্ত তথ্য চালু করা থাকে না। ডিভাইস পোজ সংক্রান্ত তথ্য পেতে আপনার
অ্যাপকে অনুমতি দিতে, সেশন কনফিগার করুন এবং
DeviceTrackingMode.SPATIAL মোড সেট করুন:
// Define the configuration object to enable tracking device pose. val newConfig = Config.Builder(session.config) .setDeviceTracking(DeviceTrackingMode.SPATIAL) .build() // Apply the configuration to the session. try { when (val configResult = session.configure(newConfig)) { is SessionConfigureSuccess -> { // The session is now configured to track the device's pose. } else -> { // Catch-all for other configuration errors returned using the result class. } } } catch (e: UnsupportedOperationException) { // Handle configuration failure. For example, if the specific mode is not supported on the current device or API version. }
সব XR ডিভাইসে DeviceTrackingMode.SPATIAL মোড কাজ করে না। Session.configure() সফল হলে, ডিভাইসটি এই মোড সাপোর্ট করে।
ডিভাইসের পোজ পাওয়া
সেশন কনফিগার করার পরে, আপনি ArDevice অবজেক্ট ব্যবহার করে
AR কোঅর্ডিনেট সিস্টেমের মধ্যে ডিভাইসের পোজ পেতে পারেন:
// Get the ArDevice instance val arDevice = ArDevice.getInstance(session) // There are two ways to get the device pose. // 1. Get the current device pose once. // This is the device's position and orientation relative to the tracking origin. val devicePose = arDevice.state.value.devicePose processDevicePose(devicePose) // 2. Continuously receive updates for the device pose. // `collect` is a suspending function that will run indefinitely and process new poses. arDevice.state.collect { state -> processDevicePose(state.devicePose) }
ডিভাইস পোজের ট্রান্সলেশন ও রোটেশন পাওয়া
ডিভাইস Pose ট্র্যাকিং অরিজিনের সাপেক্ষে ডিভাইসের পজিশন (ট্রান্সলেশন) ও ওরিয়েন্টেশন
(রোটেশন) দেখায়। আপনার অ্যাপের অভিজ্ঞতা
উন্নত করতে, আপনার অ্যাপে এই তথ্য ব্যবহার করুন:
- পজিশন অনুযায়ী সঠিক নেভিগেশন নির্দেশাবলী প্রদান করা: পজিশন সংক্রান্ত ডেটা ব্যবহার করে ব্যবহারকারীকে নিজেকে ওরিয়েন্ট করতে এবং ওভারলে করা ডিজিটাল কন্টেন্টের সাহায্যে তার আশেপাশের জায়গা নেভিগেট করতে সাহায্য করুন।
fun processDevicePose(pose: Pose) { // Extract Translation and Rotation val translation = pose.translation // Vector3(x, y, z) val rotation = pose.rotation // Quaternion (x, y, z, w) TODO(/* Use the translation and rotation in your app. */) }