3

Is it possible to insert a button at the bottom of a working 3d animation done with Min3d framework in android. I do have a working 3d model car which is rotating. I want to put a button at the bottom of this working animation screen. Is it possible since i am not using any layout.Please explain me with an example so that i can replicate the same with my program.

4

1 回答 1

0

是的。相反,该过程是使用 glSurfaceView 将 min3d 框架添加到布局中。以下代码重点介绍了如何实现相同的目标,假设您已经涵盖了其他基础知识(例如加载对象)。如果没有,则在本简介的末尾提供相同的链接。

    //import statements
    public class threedviewActivity extends RendererActivity implements View.OnClickListener,View.OnTouchListener{ 
    //onClick and onTouch in case you want to recognize both touch and click on the button

         //initialize the variables you require

         @Override
         public void onCreateSetContentView() {

              setContentView(R.layout.activity_example);
              RelativeLayout R1 = (RelativeLayout)this.findViewById(R.id.SceneHolder);
              R1.addView(_glSurfaceView); //adding the min3d view into the layout

              Button example_1 = (Button)this.findViewById(R.id.example_1);
              Button example_2 = (Button)this.findViewById(R.id.example_2);

              example_1.setOnTouchListener(this);
              example_2.setOnClickListener(this);

         }

         public boolean onTouch(View $v, MotionEvent event) {

              switch($v.getId())
              {
                   case R.id.example_1:
                        //Your actions and things to do
                   case R.id.example_2:
                        //your code

              }

         }

         public void onClick(View $v)
         {
              //similar to above      
         }

         public void initScene()
         {
              //initialize object and other activities related to the 3d container

         }

         @Override
         public void updateScene()
         {

              //update effects such as rotation on the object here, based on the button click or touch, etc.

         }

    }

包含布局/活动的 xml 文件应如下所示:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
>

     <Button
         //your data
         android:id="@+id/example_1"
     />

     <Button
         //your data
         android:id="@+id/example_2"
     />

     <RelativeLayout
         //nested layout which will hold the 3d container
         android:id="@+id/SceneHolder">

     </RelativeLayout>

  </RelativeLayout>

要了解有关使用initScene()函数的更多信息,您可以参考此处此处

您还可以通过使用照明属性来添加额外的效果,如此处所述

添加到布局的基本示例取自此处。同一页面还提供了许多示例的链接,以备您将来使用。

于 2016-10-17T12:28:53.550 回答