@inio @richlowenberg @jwmcglynn
how can i rotate a node to x or y-axis in scene view.
Use a TransformableNode. It supports basic transformations OTB. You can read about it here.
Here's an example:
Pose p = new Pose(new float[] {0, 0, 0, 0}, new float[] {0, 0, 0, 0});
AnchorNode anchorNode = new AnchorNode(arFragment.getArSceneView().getSession().createAnchor(p));
anchorNode.setParent(arFragment.getArSceneView().getScene());
TransformableNode node = new TransformableNode(arFragment.getTransformationSystem());
// Uses z axis and 180 degrees to return new quaternion
node.setLocalRotation(Quaternion.axisAngle(new Vector3(0, 0, 1f), 180));
node.setParent(anchorNode);
node.setRenderable(modelrenderable);
Thankyou @aayc
i m not using arFragment, i m using arsceneView so how can i create transformable node from arSceneView or you can proivde any other alternative.
No problem.
As far as I know,a TransformableNode requires a transformation system, and the AR Fragment can supply it. Are you sure you don't have access to your AR fragment, for example are you using rendering the scene without AR?
If you're using AR then I think it's likely you're also using an AR fragment somewhere...let me know and I'll try to help!
@aayc , @inio, @dakshsrivastava i am rendering scene with arSceneView.
here you go https://github.com/appoly/ARCore-Location.
I referred this library to place my modelrenderable at some lat/lng. now i want to rotate my model. that's it.
@aayc @inio
i don't want to see hand moving in scene. how can i remove it from scene
@aayc your code is not working i have tried it too
looking for some answers @gstanlo
I don't know much about using sceneform without an AR fragment; this is the code I used to disable the hand moving:
arFragment.getPlaneDiscoveryController().hide();
arFragment.getPlaneDiscoveryController().setInstructionView(null);
also this issue on the hand motion
As far as the rotation goes, I'm not sure how to do that without using the AR Fragment..
thanku @aayc
ok i solved it closing it by now! :)
@aayc can you tell me that why i'm getting crash when i tried to access my arFragment from activity.
In separate project it works good, but when i tried to add it another project as module, I, got this crash.
Looking for your help man!
java.lang.NoSuchMethodError: No virtual method requireActivity()Landroid/support/v4/app/FragmentActivity; in class Lcom/google/ar/sceneform/ux/BaseArFragment; or its super classes (declaration of 'com.google.ar.sceneform.ux.BaseArFragment' appears in /data/app/com.tipestrygo.lenovo.tipestry-1/base.apk:classes7.dex)
at com.google.ar.sceneform.ux.BaseArFragment.requestDangerousPermissions(BaseArFragment.java:264)
at com.google.ar.sceneform.ux.BaseArFragment.onCreateView(BaseArFragment.java:213)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2261)
at android.support.v4.app.FragmentManagerImpl.ensureInflatedFragmentView(FragmentManager.java:1655)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1390)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1650)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1906)
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3698)
at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:111)
at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:350)
at android.support.v4.app.BaseFragmentActivityApi14.onCreateView(BaseFragmentActivityApi14.java:39)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:67)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:784)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.inflate(LayoutInflater.java:525)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at android.view.LayoutInflater.inflate(LayoutInflater.java:378)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.tipestrygo.lenovo.tipestry.Activities.CoreArActivities.LocationActivity.onCreate(LocationActivity.java:84)
at android.app.Activity.performCreate(Activity.java:6912)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3001)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1643)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6642)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
This looks like a missing dependency for ArFragment. Can you add
implementation "com.android.support:appcompat-v7:27.1.1"
to your project?
requireActivity() was added in 27.1.0
We resolved this @basitsaleemmb's app crashing issue in https://github.com/google-ar/sceneform-android-sdk/issues/248
@aayc , @inio, @dakshsrivastava i am rendering scene with arSceneView.
here you go https://github.com/appoly/ARCore-Location.
I referred this library to place my modelrenderable at some lat/lng. now i want to rotate my model. that's it.
@basitsaleemmb
Have you found any solution for rotating models while using Appolly/ArCore-Location? I am also stuck with the same problem. Can you help me please?
@MuhammadAasharib put this code in your update lister to rotate 3D model
Pose p = new Pose(new float[] {10, 10, 10, 10}, new float[] {0, 0, 0, 1});
AnchorNode anchorNode = new AnchorNode(arFragment.getArSceneView().getSession().createAnchor(frame.getCamera().getPose()));
anchorNode.setParent(arFragment.getArSceneView().getScene());
node = new TransformableNode(arFragment.getTransformationSystem());
node.setParent(anchorNode);
node.select();
node.setLocalScale(new Vector3(0.3f, 0.3f, 0.3f));
// node.getRotationController().setRotationRateDegrees(90);
rotateableAndy.setParent(node);
rotateableAndy.setRenderable(andyRenderable);
// Adding a simple location marker of a 3D model
locationScene.mLocationMarkers.add(
new LocationMarker(
74.2510,
31.4231,
node));
}
if (rotateableAndy!=null) {
Quaternion rotation1 = Quaternion.axisAngle(new Vector3(0.0f, 3.0f, 0.0f), frameTime.getStartSeconds() * 100);
Quaternion rotation2 = Quaternion.axisAngle(new Vector3(0.0f, 3.0f, 0.0f), frameTime.getStartSeconds() * 100);
rotateableAndy.setLocalRotation(Quaternion.multiply(rotation1,rotation2));
}
@aayc @malik-at-work @claywilkinson
can i add rotation to my list of model renderables (andyrenderable)
how can i rotate the same model using the gestures? i mean in a particular direction
Most helpful comment
I don't know much about using sceneform without an AR fragment; this is the code I used to disable the hand moving:
also this issue on the hand motion
As far as the rotation goes, I'm not sure how to do that without using the AR Fragment..