Vuforia / Android Studio:如何更改3D模型的顶点(.obj)?

时间:2018-07-02 12:11:27

标签: android vuforia

我正在使用Vuforia SDK开发用于增强现实的android应用程序。 Vuforia使用茶壶模型作为样本。我想用不同的3D模型进行更改。

首先,我读了here,但不明白如何更改它。

我将某些模型下载为.obj并用记事本打开。我可以到达模型的顶点。例如,

v -47.434967 -14.179193 41.621128
v -47.290016 -32.284641 30.312384
v -50.046577 -28.483284 28.886757
v -48.418915 -26.21903 33.460499
v -46.001163 -30.491556 33.941067
v -56.681168 -27.034826 15.786369
v -56.716259 -23.535177 19.358313
v -54.001244 -27.203417 22.164679
v -54.523552 -29.940945 18.01193

vt 0.162396 0.657685 0
vt 0.693161 0.224146 0
vt 0.926491 0.934053 0
vt 0.587396 0.694719 0
vt 0.312997 0.011653 0
vt 0.493802 0.29425 0
vt 0.571748 0.898927 0
vt 0.524454 0.694721 0
vt 0.919639 0.171535 0
vt 0.375939 0.011657 0

在Vuforia样本中,有一个称为“茶壶”的类,它具有一些获取模型顶点的方法。

 private void setVerts()
    {
        double[] TEAPOT_VERTS = { 11.222200, 0.110300, 20.030291, 10.302300,
                -4.461498, 20.030291, 10.152300, -4.397198, 20.644890,
                11.059500, 0.110900, 20.644890, 11.059500, 0.110900, 20.644890,
                10.152300, -4.397198, 20.644890, 10.326300, -4.471797,
                20.849890, 11.248200, 0.110300, 20.849890, 11.248200, 0.110300,
                20.849890, 10.326300, -4.471797, 20.849890, 10.679500,
                -4.623797, 20.644890, 11.632100, 0.108900, 20.644890,
                11.069200, -4.791098, 20.030291, 12.054700, 0.107300,
...

-21.810101, 1.635499, 11.037194, -19.837999, 1.628499,
                8.929396, -16.952299, 1.617799, 7.150197 };
        mVertBuff = fillBuffer(TEAPOT_VERTS);
        verticesNumber = TEAPOT_VERTS.length / 3;
    }


    private void setTexCoords()
    {
        double[] TEAPOT_TEX_COORDS = { 0.608828, 0.354913, 0.609037, 0.414650,
                0.627128, 0.412296, 0.626946, 0.353747, 0.626946, 0.353747,
                0.627128, 0.412296, 0.645212, 0.412296, 0.645121, 0.354854,
                0.645121, 0.354854, 0.645212, 0.412296, 0.665996, 0.413114,
                0.665992, 0.362321, 0.686991, 0.412965, 0.686888, 0.354543,
                0.609164, 0.471551, 0.627580, 0.470826, 0.627580, 0.470826,
                0.645666, 0.470826, 0.645666, 0.470826, 0.666214, 0.470826,
                0.686992, 0.471343, 0.609037, 0.528447, 0.627786, 0.529284,
...

0.195504, 0.141216, 0.182330, 0.579904, 0.174024, 0.485925,
                0.174243, 0.394528, 0.180175, 0.298414, 0.189013, 0.199932 };
        mTexCoordBuff = fillBuffer(TEAPOT_TEX_COORDS);

    }


    private void setNorms()
    {
        double[] TEAPOT_NORMS = { -0.964496, 0.067011, -0.255454, -0.865037,
                0.431362, -0.256198, -0.914727, 0.312709, -0.255904, -0.964979,
                -0.059958, -0.255382, -0.734604, 0.051028, 0.676574, -0.657992,
                0.328017, 0.677828, -0.696209, 0.237894, 0.677274, -0.735103,
                -0.045689, 0.676414, 0.470823, -0.032731, 0.881620, 0.421539,
                -0.210047, 0.882148, 0.608717, -0.267273, 0.747013, 0.665522,
...

0.773683, 0.222907, 0.593066, 0.590633, 0.196416, 0.782671,
                0.516476, 0.182725, 0.836579 };
        mNormBuff = fillBuffer(TEAPOT_NORMS);
    }


    private void setIndices()
    {
        short[] TEAPOT_INDICES = { 0, 1, 2, 2, 3, 0, 4, 5, 6, 6, 7, 4, 8, 9,
                10, 10, 11, 8, 11, 10, 12, 12, 13, 11, 1, 14, 15, 15, 2, 1, 5,
                16, 17, 17, 6, 5, 9, 18, 19, 19, 10, 9, 10, 19, 20, 20, 12, 10,
                14, 21, 22, 22, 15, 14, 16, 23, 24, 24, 17, 16, 18, 25, 26, 26,
                19, 18, 19, 26, 27, 27, 20, 19, 21, 28, 29, 29, 22, 21, 23, 30,
...

814, 816, 815, 817, 817, 818, 816, 819, 765, 768, 768, 820,
                819, 820, 768, 770, 770, 821, 820, 821, 770, 772, 772, 822,
                821, 822, 772, 774, 774, 823, 822 };
        mIndBuff = fillBuffer(TEAPOT_INDICES);
        indicesNumber = TEAPOT_INDICES.length;
    }

我的大脑非常盲目,我真的不知道该怎么做。

你能帮我吗?

谢谢

0 个答案:

没有答案