java-动态绘制多维数据集时出现问题

前端之家收集整理的这篇文章主要介绍了java-动态绘制多维数据集时出现问题 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我有一个声明为的float数组camObjCoord.

public static float camObjCoord [] = new float [8000];

然后,我将其索引填充到一个类似以下内容的类中.

                      public void addcube(float highx,float lowx,float highz,float lowz){
    //Constructing new cube...
    System.out.println("f = " + f);
    Global.cubes++;
    float y = 1.5f;
    System.out.println("highx = " + highx + "lowx = " + lowx + "highz = " + highz + "lowz = " + lowz);
    //FRONT
    camObjCoord[i] = lowx;
     i++;
    camObjCoord[i] = -y;
     i++;
    camObjCoord[i] = highz;
     i++;
    camObjCoord[i] = highx;
     i++;
    camObjCoord[i] = -y;
     i++;
    camObjCoord[i] = highz;
     i++;
    camObjCoord[i] = lowx;
     i++;
    camObjCoord[i] = y;
     i++;
    camObjCoord[i] = highz;
     i++;
    camObjCoord[i] = highx;
     i++;
    camObjCoord[i] = y;
     i++;
    camObjCoord[i] = highz;
    //BACK
     i++;
    camObjCoord[i] = lowx;
     i++;
    camObjCoord[i] = -y;
     i++;
    camObjCoord[i] = lowz;
     i++;
    camObjCoord[i] = lowx;
     i++;
    camObjCoord[i] = y;
     i++;
    camObjCoord[i] = lowz;
     i++;
    camObjCoord[i] = highx;
     i++;
    camObjCoord[i] = -y;
     i++;
    camObjCoord[i] = lowz;
     i++;
    camObjCoord[i] = highx;
     i++;
    camObjCoord[i] = y;
     i++;
    camObjCoord[i] = lowz;
     i++;
    //LEFT
    camObjCoord[i] = lowx;
     i++;
    camObjCoord[i] = -y;
     i++;
    camObjCoord[i] = highz;
     i++;
    camObjCoord[i] = lowx;
     i++;
    camObjCoord[i] = y;
     i++;
    camObjCoord[i] = highz;
     i++;
    camObjCoord[i] = lowx;
     i++;
    camObjCoord[i] = -y;
     i++;
    camObjCoord[i] = lowz;
     i++;
    camObjCoord[i] = lowx;
     i++;
    camObjCoord[i] = y;
     i++;
    camObjCoord[i] = lowz;
     i++;
    //RIGHT
    camObjCoord[i] = highx;
     i++;
    camObjCoord[i] = -y;
     i++;
    camObjCoord[i] = lowz;
     i++;
    camObjCoord[i] = highx;
     i++;
    camObjCoord[i] = y;
     i++;
    camObjCoord[i] = lowz;
     i++;
    camObjCoord[i] = highx;
     i++;
    camObjCoord[i] = -y;
     i++;
    camObjCoord[i] = highz;
     i++;
    camObjCoord[i] = highx;
     i++;
    camObjCoord[i] = y;
     i++;
    camObjCoord[i] = highz;
     i++;
    //TOP
    camObjCoord[i] = lowx;
     i++;
    camObjCoord[i] = y;
     i++;
    camObjCoord[i] = highz;
     i++;
    camObjCoord[i] = highx;
     i++;
    camObjCoord[i] = y; 
     i++;
    camObjCoord[i] = highz;
     i++;
    camObjCoord[i] = lowx;
     i++;
    camObjCoord[i] = y;
     i++;
    camObjCoord[i] = highz;
     i++;
    camObjCoord[i] = highx;
     i++;
    camObjCoord[i] = y;
     i++;
    camObjCoord[i] = lowz;
     i++;
    //BOTTOM
    camObjCoord[i] = lowx;
     i++;
    camObjCoord[i] = -y;
     i++;
    camObjCoord[i] = highz;
     i++;
    camObjCoord[i] = lowx;
     i++;
    camObjCoord[i] = -y;
     i++;
    camObjCoord[i] = lowz;
     i++;
    camObjCoord[i] = highx;
     i++;
    camObjCoord[i] = -y;
     i++;
    camObjCoord[i] = highz;
     i++;
    camObjCoord[i] = highx;
     i++;
    camObjCoord[i] = -y;
     i++;
    camObjCoord[i] = lowz;

    i++;
    int p = 0;
    System.out.println("FULL ARRAY");
    while(p < 72){
        System.out.println(camObjCoord[p]);
        p++;
    }
}

然后我打电话给makeview()

    public void makeview() {
     Intent myIntent = new Intent(this,GLCamTest.class);

        Bundle b = new Bundle();
        b.putFloatArray("tweets",camObjCoord);
        myIntent.putExtras(b);
    this.startActivity(myIntent);
}

然后在新课程中…

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle b = this.getIntent().getExtras();
    float original[] = b.getFloatArray("tweets");
    camObjCoord = original;
    counter++;
}   

然后,我还有另一个类GLLayer,它的外观如下所示.http://pastebin.org/394884在该类中,我正在从float数组中绘制多维数据集,我已经检查过了,并且确实存在多维数据集的值,当我m在其中编码数组可以工作,但是当我动态构建数组然后将其传递时,立方体无法绘制.我这样叫课.

           glView=new GLLayer(this);
           mPreview = new CamLayer(this,glView); 

有人知道为什么吗?我该如何解决我的问题?只是要补充一点,我在动态绘制时将完全相同的值赋予完全相同的索引

          final static float camObjCoord[] = new float[] {
            // FRONT
             -2.0f,-1.5f,2.0f,-2.0f,1.5f,// BACK
             -2.0f,// LEFT
             -2.0f,// RIGHT
              2.0f,// TOP
             -2.0f,// BOTTOM
             -2.0f,};

然后它将渲染此多维数据集.似乎不喜欢我先创建数组,然后动态添加索引.为什么?我该如何解决?为了获得奖励,我还将接受一个适用于Android的适当解决方法.

谢谢.

edit1:我尝试过各种事情,如果不是像这样声明数组,那不是数组的传递导致问题.

edit2:我也尝试过将数组放入GLLayer(渲染多维数据集的类)时进行打印,一切都与您期望的一样.我不知道为什么这些立方体不会出现:(

edit3:我已经添加了如何构造float数组.

edit4:我也尝试将数组的大小设置为等于我输入的值的数量.不起作用

最佳答案
我会稍微减少这个问题.如果您要使数组足够大以仅容纳一个多维数据集,并以相同的方式填充它(但仅填充一次),那么它将起作用吗?如果您将它放大到足以容纳两个多维数据集,并为其提供两个多维数据集的数据该怎么办?
原文链接:https://www.f2er.com/android/531539.html

猜你在找的Android相关文章