English 中文(简体)
影响其他案文的开放式GL-ES材料
原标题:Materials in OpenGL-ES affecting other textures

我遇到了一个与开放式GL-ES(1.0)合作的问题,因为 i无法把我的头部围起来。 我有多件3D物体,通过开放式GL-ES显示,iv e决定提供一些材料,使用:

gl.glMaterialfv (GL10.GL_FRONT_AND_BACK, GL10.GL_......, ......, 0);

每一物体一 drawing,我就这样做:

gl.glPushMatrix();
*make some adjustment to object*
gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, ambient, 0);
gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, diffuse, 0);
gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_SPECULAR, specular, 0);
gl.glPopMatrix();

在“环境”、“扩散”和“光谱”是每个目标独有的地方。

其结果是,如果我使用较高数额的红比,例如在一个材料中,这将影响另一个明显的目标,即也显示红线很小。

如下文所示,左边三个物体中有两个被设定在材料中实现更大的野心。 右边的材料,因为材料有 has,但依然如此。 (主题显然作了修改,以使之更加明确)。

/></p>

<p>每个物体一使用都有自己的材料类别,包括材料信息。</p>

<p>任何一夫一妻的想法都错失了,或者这种材料如何在开放的GL中acc尽职?</p>

<p>(我用一个直截了当地照明灯向整个现场)</p>

<p>Edit:为了更清楚地说明这一点,它不仅指影响其他物体的雄性颜色,例如,含有精子、光谱和散射中所有颜色的0.2个材料的物体靠近另一个具有例如光谱等较高价值的物体,第一个物体也将受到更多的注意。</p>

<p>Edit2:</p>

<p>这是所有物体的提取功能。</p>

<pre><code>        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);


    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);

    Enumeration<String> key = objects.keys();
    while (key.hasMoreElements())
    {
        String k = key.nextElement();

        if(objects.get(k).visible)
        {
            gl.glPushMatrix();
            try
            {
                gl.glBindTexture(GL10.GL_TEXTURE_2D, texturemanager._tm.get(k.trim())
                    .getTexture()[filter]);
            }
            catch(Exception e){};

            adjust(gl, objects.get(k));
            objects.get(k).draw(gl, 1);
            gl.glPopMatrix();
        }
    }

    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glDisableClientState(GL10.GL_NORMAL_ARRAY);
</code></pre>

<p>物体类别中提取物的情况如下:</p>

<pre><code>    protected void draw(GL10 gl, int filter)
{
    updatePhysics();
    bounds.center.set(this);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, data.vertexBuffer);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, data.textureBuffer);
    gl.glNormalPointer(GL10.GL_FLOAT, 0, data.normalBuffer);

    gl.glDrawElements(GL10.GL_TRIANGLES, data.numIndices,
            GL10.GL_UNSIGNED_SHORT, data.indicesBuffer);
}
</code></pre>

<p><strong>adjust(gl, Object.get(k));</strong> 导致下列情况:</p>

<pre><code>// rotating, translating and scaling object

    if (obj.blend)
    {
        gl.glEnable(GL10.GL_BLEND);
        gl.glDisable(GL10.GL_DEPTH_TEST);
    } else
    {
        gl.glDisable(GL10.GL_BLEND);
        gl.glEnable(GL10.GL_DEPTH_TEST);
    }
    if(obj.enableMaterial)
    {
        obj.getMaterial().enable(gl);
    }
</code></pre>

<p>and where <strong>obj.getMaterial().enable(gl);</strong> will be the material for the object.
Following is my material class</p>

<pre><code>    public void enable(GL10 gl)
{
    gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, ambient, 0);
    gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, diffuse, 0);
    gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_SPECULAR, specular, 0);
    gl.glMaterialf(GL10.GL_FRONT_AND_BACK, GL10.GL_SHININESS, shininess);
}
</code></pre>

<p>Where the variables for ambient, diffuse, specular and shininess is set like following</p>

<pre><code>    public void setAmbient(float r, float g, float b, float a)
{
    ambient[0] = r;
    ambient[1] = g;
    ambient[2] = b;
    ambient[3] = a;
}
</code></pre>
    </div>

           </div>
   
      <div class=

最佳回答

因此,如果有一个“可变的Material”虚假的物体,会发生什么情况? 你们是否重新掌握了材料? 这似乎仍然适用于今后的任何物体。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...