📄 texture2d.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc on Thu Nov 27 13:54:36 EET 2003 -->
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>
Texture2D (Mobile 3D Graphics API (M3G))
</TITLE>
<META NAME="keywords" CONTENT="javax.microedition.m3g.Texture2D,Texture2D class">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
</HEAD>
<SCRIPT>
function asd()
{
parent.document.title="Texture2D (Mobile 3D Graphics API (M3G))";
}
</SCRIPT>
<BODY BGCOLOR="white" onload="asd();">
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Texture2D.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<EM><B>Nov 19, 2003</B></EM></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../javax/microedition/m3g/Sprite3D.html"><B>PREV CLASS</B></A>
<A HREF="../../../javax/microedition/m3g/Transform.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A>
<A HREF="Texture2D.html" TARGET="_top"><B>NO FRAMES</B></A>
<SCRIPT> <!-- if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT><A HREF="../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A></NOSCRIPT></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
javax.microedition.m3g</FONT>
<BR>
Class Texture2D</H2>
<PRE>
java.lang.Object
|
+--<A HREF="../../../javax/microedition/m3g/Object3D.html">javax.microedition.m3g.Object3D</A>
|
+--<A HREF="../../../javax/microedition/m3g/Transformable.html">javax.microedition.m3g.Transformable</A>
|
+--<B>javax.microedition.m3g.Texture2D</B>
</PRE>
<HR>
<DL>
<DT>public class <B>Texture2D</B><DT>extends <A HREF="../../../javax/microedition/m3g/Transformable.html">Transformable</A></DL>
<P>
<p>An Appearance component encapsulating a two-dimensional texture image anda set of attributes specifying how the image is to be applied on submeshes.The attributes include wrapping, filtering, blending, and texture coordinatetransformation.</p><h3>Texture image data</h3><p>The texture image is stored as a reference to an Image2D. The image may bein any of the formats defined in Image2D. The width and height of the imagemust be non-negative powers of two, but they need not be equal. The maximumallowed size for a texture image is specific to each implementation, and itcan be queried with <A HREF="../../../javax/microedition/m3g/Graphics3D.html#getProperties()"><CODE>Graphics3D.getProperties()</CODE></A>.</p><p>Mipmap level images are generated automatically by repeated filteringof the base level image. No particular method of filtering is mandated,but a 2x2 box filter is recommended. It is not possible for the applicationto supply the mipmap level images explicitly.</p><p>If the referenced Image2D is modified by the application, or a new Image2Dis bound as the texture image, the modifications are immediately reflected inthe Texture2D. Be aware, however, that switching to another texture image orupdating the pre-existing image may trigger expensive operations, such asmipmap level image generation or (re)allocation of memory. It is thereforerecommended that texture images not be updated unnecessarily.</p><h3>Texture mapping</h3><h4>Transformation</h4><p>The first step in applying a texture image onto a submesh is toapply the <i>texture transformation</i> to the texture coordinatesof each vertex of that submesh. The transformation is defined in theTexture2D object itself, while the texture coordinates are obtainedfrom the VertexBuffer object associated with that submesh.</p><p>The incoming texture coordinates may have either two or threecomponents (see VertexBuffer), but for the purposes of multiplicationwith a 4x4 matrix they are augmented to have four components. If thethird component is not given, it is implicitly set to zero. The fourthcomponent is always assumed to be 1.</p><p>The texture transformation is very similar to the nodetransformation. They both consist of translation, orientation andscale components, as well as a generic 4x4 matrix component. The orderof concatenating the components is the same. The only difference isthat the bottom row of the matrix part must be (0 0 0 1) in case of anode transformation but not in case of a texture transformation. Themethods to manipulate the individual transformation components of bothnode and texture transformations are defined in the base class,<A HREF="../../../javax/microedition/m3g/Transformable.html">Transformable</A>.</p><p>Formally, a homogeneous vector <b>p</b> = (s, t, r, 1), representinga point in texture space, is transformed to a point <b>p</b>' = (s', t',r', q') as follows:</p><blockquote><b>p</b>' = <b>T</b> <b>R</b> <b>S</b> <b>M</b> <b>p</b></blockquote><p>where <b>T</b>, <b>R</b> and <b>S</b> denote the translation,orientation and scale components, respectively, and <b>M</b> is thegeneric 4x4 matrix.</p><p>The translation, orientation and scale components of the texturetransformation can be animated independently from each other. Thematrix component is not animatable at all; it can only be changedusing the <code>setTransform</code> method.</p><h4>Projection</h4><p>The texture transformation described above yields the transformedtexture coordinates (s', t', r', q') for each vertex of a triangle.The final texture coordinates for each rasterized fragment, in turn,are computed in two steps: interpolation and projection.</p><ul><li><p><b>Interpolation.</b> The per-vertex texture coordinates areinterpolated across the triangle to obtain the "un-projected" texturecoordinate for each fragment. If the implementation supports perspectivecorrection and the perspective correction flag in PolygonMode is enabled,this interpolation must perform some degree of perspective correction;otherwise, simple linear interpolation may (but does not have to) beused.</p></li><li><p><b>Projection.</b> The first three components of the interpolatedtexture coordinate are divided by the fourth component. Formally, theinterpolated texture coordinate <b>p</b>' = (s', t', r', q') istransformed into <b>p</b>'' = (s'', t'', r'', 1) as follows:</p><blockquote><b>p</b>'' = <b>p</b>'/q' = (s'/q', t'/q', r'/q', 1)</blockquote><p>Again, if perspective correction is either not supported or notenabled, the implementation may do the projection on a per-vertexbasis and interpolate the projected values instead of the originalvalues. Otherwise, some degree of perspective correction must beapplied. Ideally, the perspective divide would be done for eachfragment separately.</p></li></ul><p>The r'' component of the result may be ignored, because 3D textureimages are not supported in this version of the API; only the first twocomponents are required to index a 2D image.</p><h4>Texel fetch</h4><p>The transformed, interpolated and projected s'' and t'' texturecoordinates of a fragment are used to fetch texel(s) from the textureimage according to the selected wrapping and filtering modes.</p><p>The coordinates s'' and t'' relate to the texture image such that(0, 0) is the upper left corner of the image and (1, 1) is the lowerright corner. Thus, s'' increases from left to right and t'' increasesfrom top to bottom. The <code>REPEAT</code> and <code>CLAMP</code>texture wrapping modes define the treatment of coordinate values thatare outside of the [0, 1] range.</p><p>Note that the t'' coordinate is reversed with respect to its orientation inOpenGL; however, the texture image orientation is reversed as well. As a netresult, there is no difference in actual texture coordinate values betweenthis API and OpenGL in common texturing operations. The only difference ariseswhen rendering to a texture image that is subsequently mapped onto an object.In that case, the t texture coordinates of the object need to be reversed(t' = 1 - t). If this is not done at the modeling stage, it can be doneat run-time using the texture transformation. Of course, the whole issueof texture coordinate orientation is only relevant in cases where existingOpenGL code and meshes are ported to this API.</p><h3><a name="filtering"></a>Texture filtering</h3><p>There are two independent components in the texture filtering mode:filtering <i>between</i> mipmap levels and filtering <i>within</i> amipmap level. There are three choices for level filtering and two choicesfor image filtering, yielding the six combinations listed in the tablebelow.</p><table border="true" cellpadding="3" align="center"><tr bgcolor="#c0c0c0"><th align="left">Level filter</th><th align="left">Image filter</th><th align="left">Description</th><th align="left">OpenGL equivalent</th></tr><tr><td><code>BASE_LEVEL</code></td><td><code>NEAREST</code></td><td>Point sampling within the base level</td><td><code>NEAREST</code></td></tr><tr><td><code>BASE_LEVEL</code></td><td><code>LINEAR</code></td><td>Bilinear filtering within the base level</td><td><code>LINEAR</code></td></tr><tr><td><code>NEAREST</code></td><td><code>NEAREST</code></td><td>Point sampling within the nearest mipmap level</td><td><code>NEAREST_MIPMAP_NEAREST</code></td></tr><tr><td><code>NEAREST</code></td><td><code>LINEAR</code></td><td>Bilinear filtering within the nearest mipmap level</td><td><code>LINEAR_MIPMAP_NEAREST</code></td></tr><tr><td><code>LINEAR</code></td><td><code>NEAREST</code></td><td>Point sampling within two nearest mipmap levels</td><td><code>NEAREST_MIPMAP_LINEAR</code></td></tr><tr><td><code>LINEAR</code></td><td><code>LINEAR</code></td><td>Bilinear filtering within two nearest mipmap levels (trilinear filtering)</td><td><code>LINEAR_MIPMAP_LINEAR</code></td></tr></table><p>Only the first combination (point sampling within the base level) mustbe supported by all implementations. Any of the other five options may besilently ignored.</p><h3><a name="blending"></a>Texture blending</h3><p>The texture blending mode specifies how to combine the filtered texturecolor with the incoming fragment color in a texturing unit. This is equivalentto the texture environment mode in OpenGL.</p><p>The incoming fragment color C<sub>f</sub> = (R<sub>f</sub>, G<sub>f</sub>,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -