📄 graphics3d.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:34 EET 2003 -->
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>
Graphics3D (Mobile 3D Graphics API (M3G))
</TITLE>
<META NAME="keywords" CONTENT="javax.microedition.m3g.Graphics3D,Graphics3D class">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
</HEAD>
<SCRIPT>
function asd()
{
parent.document.title="Graphics3D (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/Graphics3D.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/Fog.html"><B>PREV CLASS</B></A>
<A HREF="../../../javax/microedition/m3g/Group.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="Graphics3D.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> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: <A HREF="#field_detail">FIELD</A> | CONSTR | <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 Graphics3D</H2>
<PRE>
java.lang.Object
|
+--<B>javax.microedition.m3g.Graphics3D</B>
</PRE>
<HR>
<DL>
<DT>public class <B>Graphics3D</B><DT>extends java.lang.Object</DL>
<P>
<p>A singleton 3D graphics context that can be bound to a rendering target.All rendering is done through the <code>render</code> methods in this class,including the rendering of World objects. There is no other way to drawanything in this API.</p><h3>Quick introduction</h3><p>Using the Graphics3D is very straightforward. The application onlyneeds to obtain the Graphics3D instance (there is only one), bind atarget to it, render everything, and release the target. This is shownin the code fragment below.</p><blockquote><pre>public class MyCanvas extends Canvas{ Graphics3D myG3D = Graphics3D.getInstance(); public void paint(Graphics g) { try { myG3D.bindTarget(g); ... update the scene ... ... render the scene ... } finally { myG3D.releaseTarget(); }}</pre></blockquote><h3>Immediate mode and retained mode rendering</h3><p>There are four different <code>render</code> methods, operating atdifferent levels of granularity. The first method is for rendering anentire World. When this method is used, we say that the API operates in<i>retained mode</i>. The second method is for rendering scene graphnodes, including Groups. The third and fourth methods are for renderingan individual submesh. When the node and submesh rendering methods areused, the API is said to operate in <i>immediate mode</i>.</p><p>There is a <i>current camera</i> and an array of <i>current lights</i>in Graphics3D. These are used by the immediate mode rendering methods only.The retained mode rendering method <code>render(World)</code> uses the cameraand lights that are specified in the World itself, ignoring the Graphics3Dcamera and lights. Instead, <code>render(World)</code> <i>replaces</i> theGraphics3D current camera and lights with the active camera and lights in therendered World. This allows subsequent immediate mode rendering to utilizethe same camera and lighting setup as the World.</p><h3>Rendering targets</h3><p>Before rendering anything or even clearing the screen, theapplication must bind a <i>rendering target</i> to this Graphics3D,using the <code>bindTarget</code> method. When finished with renderinga frame, the application must release the rendering target by callingthe <code>releaseTarget</code> method. Implementations may queuerendering commands and only execute them when the target is released.</p><p>The rendering target can be either a Graphics object or an Image2D.The type of the Graphics object is specific to the Java profile thatthis API is implemented on. In case of the MID profile, it must be a<code>javax.microedition.lcdui.Graphics</code> object, and it may beassociated with a Canvas, mutable Image, or CustomItem.</p><p>Once a rendering target is bound to the Graphics3D, all renderingwill end up in the color buffer of its rendering target until<code>releaseTarget</code> is called. The contents of the renderingtarget, after releasing it, will be equal to what they were beforethe target was bound, augmented with any 3D rendering performed whileit was bound.</p><p>There can be only one rendering target bound to the Graphics3D at atime. Also, a bound rendering target should not be accessed via anyother interface than the host Graphics3D. This is not enforced, butthe results are unpredictable otherwise. For example, the followingscenarios will result in unpredictable output:</p><ul><li>2D graphics is rendered via MIDP into a bound Image or Canvas.</li><li>A bound Image is read from by the application or the MIDP implementation.</li><li>A bound Image2D is used by a Graphics3D <code>render</code> method.</li></ul><p>The contents of the depth buffer are unspecified after<code>bindTarget</code>, and they are discarded after<code>releaseTarget</code>. In order to clear depth buffer contents(and color buffer contents, if so desired) after binding a renderingtarget, the application must call the <code>clear</code> method,either explicitly, or implicitly by rendering a World.</p><H3>Origin translation and clipping</H3><p>The viewport can be freely positioned relative to the rendering target,without releasing and re-binding the target. The position of the viewportis specified relative to the origin of the rendering target. For Graphicstargets, this is the origin in effect when calling <code>bindTarget</code>;for Image2D targets, the origin is always at the top left corner. Changingthe origin of a bound Graphics object has no effect.</p><p>All 3D rendering is clipped to visible part of the viewport, that is,the intersection of the viewport specified in <code>setViewport</code>and the rendering target clip rectangle. Rendering operations (including<code>clear</code>) must not touch pixels falling outside of the visiblepart of the viewport. This is illustrated in the figure below.</p><center><img src="./doc-files/Graphics3D-clipping.png"/></center><p>For Graphics targets, the clipping rectangle is the MIDP/AWT clippingrectangle that is in effect when calling <code>bindTarget</code>. Similarto the origin, changing the clipping rectangle of a bound Graphics objecthas no effect. For Image2D targets, the clipping rectangle comprises allpixels in the target image.</p><p>Origin translation and clipping are independent of the viewport andprojection transformations, as well as rasterization. All other parametersbeing equal, rendering calls must produce the same pixels (prior to clipping)into the area bounded by the viewport regardless of the position of theviewport or the target clipping rectangle.</p><p>Note that when we refer to the viewport in this specification, weoccasionally mean only the visible part of it. If it is not obviousfrom the context whether we mean the full viewport or just the visibleportion, we state that explicitly.</p><h3><a name="hints">Rendering quality hints</a></h3><p>In some situations, image quality might be more important for an applicationthan rendering speed or memory usage. Some applications might also want toincrease or decrease the image quality based on device capabilities. Somemight go so far as to dynamically adjust the quality; for instance, bydisplaying freeze frames or slow-motion sequences in higher quality.</p><p>There are three global options in Graphics3D that allow applicationsto indicate a preference for higher rendering quality at the expense ofslower speed and/or extra memory usage. These are the following:</p><ul><p><li><b>Antialiasing</b>. Specifies that antialiasing should be used toincrease the perceived resolution of the screen. No particular method ofantialiasing is mandated. However, it is strongly recommended that themethod be independent of drawing order, and fast enough to operate atinteractive frame rates. If the chosen method requires post-processingper frame, that can be done in <code>releaseTarget</code>.</li></p><p><li><b>Dithering</b>. Specifies that dithering should be used to increasethe perceived color depth of the screen. No particular method of ditheringis mandated. However, the method should be optimized for animated content(as opposed to still images) and be able to operate at interactive framerates. For example, ordered dithering is recommended over error diffusion.Implementations may choose to do the dithering at rendering time (per pixel)or as a post-process (upon <code>releaseTarget</code>).</li></p><p><li><b>True color rendering</b>. Specifies that rendering should be donewith an internal color depth higher than what is supported by the device.For example, on a device with an RGB565 display, rendering could be doneinto an RGBA8 back buffer, truncating the pixels to 16 bits only upon<code>releaseTarget</code>. True color rendering is especially usefulwhen combined with dithering.</li></p></ul><p>These options are merely <i>hints</i>, meaning that implementationsmay silently ignore them. The application can use <A HREF="../../../javax/microedition/m3g/Graphics3D.html#getProperties()"><CODE>getProperties</CODE></A> to find out whether a particular hint is supported(acted upon) by the implementation. It is only meaningful for theimplementation to support a hint if that allows the application totrade performance for quality or vice versa. For example, if ditheringis built into the display hardware and is always enabled, theimplementation should not indicate support for the ditheringhint. Similarly, if the device has a 24 bpp display, the implementationshould not support the true color hint (unless, of course, it uses evenhigher color precision in the back buffer).</p><p>The rendering quality hints can be set in conjunction with binding arendering target, that is, using <A HREF="../../../javax/microedition/m3g/Graphics3D.html#bindTarget(java.lang.Object, boolean, int)"><CODE>bindTarget</CODE></A>.</p><H3>Reference pipelines</H3><p>The reference geometry and fragment pipelines are shown below. Themapping of Appearance components to the pipeline stages is also shown.Note that the ordering of the stages is the same as in OpenGL.</p><img src="./doc-files/Graphics3D-geometry.png"/><img src="./doc-files/Graphics3D-fragment.png"/><p>Implementations may optimize their operation by doing things in adifferent order, but only if the result is exactly the same as itwould be with the reference pipelines.</p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -