Open Adityavj2601 opened 4 years ago
i want to change the postion of obj in real time based on node.getWorldPosition() here is my code i want to change the position of Model Renderable here is my code :
MaterialFactory .makeOpaqueWithColor(this, new Color(android.graphics.Color.BLUE)) .thenAccept(material -> { modelRenderable = ShapeFactory.makeCube(new Vector3(0.01f , 0.01f , 0.01f) ,new Vector3(0f , 0f , 0.1f) , material);
}); ArSceneView sceneView = customARFragment.getArSceneView(); sceneView.setCameraStreamRenderPriority(Renderable.RENDER_PRIORITY_FIRST); Scene scene = sceneView.getScene(); scene.addOnUpdateListener( (FrameTime frameTime) -> { /*if (modelRenderable == null) { return; }
*/
Collection<AugmentedFace> faceList = sceneView.getSession().getAllTrackables(AugmentedFace.class); // Make new AugmentedFaceNodes for any new faces. for (AugmentedFace face : faceList) { FloatBuffer buffer = face.getMeshVertices(); Vector3 vectorLeftEyeLeft = new Vector3(buffer.get(33 * 3), buffer.get((33 * 3) + 1), buffer.get((33 * 3) + 2)); Vector3 vectorLeftEyeRight = new Vector3(buffer.get(133 * 3),buffer.get((133 * 3) + 1), buffer.get((133 * 3) + 2)); Node node = new Node(); node.setLocalPosition(new Vector3((vectorLeftEyeLeft.x + vectorLeftEyeRight.x) / 2, (vectorLeftEyeLeft.y + vectorLeftEyeRight.y) / 2, (vectorLeftEyeLeft.z + vectorLeftEyeRight.z) / 2)); node.setParent(faceNodeMap.get(face)); Vector3 vector3 = node.getWorldPosition(); AugmentedFaceNode faceNode = new AugmentedFaceNode(face); faceNode.setParent(scene); faceNode.setFaceRegionsRenderable(modelRenderable); faceNodeMap.put(face, faceNode); } // Remove any AugmentedFaceNodes associated with an AugmentedFace that stopped tracking. Iterator<Map.Entry<AugmentedFace, AugmentedFaceNode>> iter = faceNodeMap.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<AugmentedFace, AugmentedFaceNode> entry = iter.next(); AugmentedFace face = entry.getKey(); if (face.getTrackingState() == TrackingState.STOPPED) { AugmentedFaceNode faceNode = entry.getValue(); faceNode.setParent(null); iter.remove(); } } });
i want to set modelrenderable on position of vector3 . if you know then let me know and help it's urgent ...
i want to change the postion of obj in real time based on node.getWorldPosition() here is my code i want to change the position of Model Renderable here is my code :
MaterialFactory .makeOpaqueWithColor(this, new Color(android.graphics.Color.BLUE)) .thenAccept(material -> { modelRenderable = ShapeFactory.makeCube(new Vector3(0.01f , 0.01f , 0.01f) ,new Vector3(0f , 0f , 0.1f) , material);
*/
i want to set modelrenderable on position of vector3 . if you know then let me know and help it's urgent ...