⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loader.html

📁 J2ME Mobile3D API,高性能手机3D开发的api
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!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:35 EET 2003 -->
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>
Loader (Mobile 3D Graphics API (M3G))
</TITLE>
<META NAME="keywords" CONTENT="javax.microedition.m3g.Loader,Loader class">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
</HEAD>
<SCRIPT>
function asd()
{
parent.document.title="Loader (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>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Loader.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</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">
&nbsp;<A HREF="../../../javax/microedition/m3g/Light.html"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../javax/microedition/m3g/Material.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>  &nbsp;
&nbsp;<A HREF="Loader.html" TARGET="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<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:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<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 Loader</H2>
<PRE>
java.lang.Object
  |
  +--<B>javax.microedition.m3g.Loader</B>
</PRE>
<HR>
<DL>
<DT>public class <B>Loader</B><DT>extends java.lang.Object</DL>

<P>
<p>Downloads and deserializes scene graph nodes and node components, as wellas entire scene graphs. Downloading ready-made pieces of 3D content from anM3G file is generally the most convenient way for an application to createand populate a 3D scene.</p><h3>Supported data types</h3><p>The Loader can deserialize instances of any class derived from Object3D.These include scene graph nodes such as World, Group, Camera and Light;attribute classes such as Material, Appearance and Texture2D; animationclasses such as AnimationTrack and KeyframeSequence; and so on. No othertypes of objects are supported.</p><p>The data to be loaded must constitute a valid M3G file. Alternatively,it may be a PNG image file, in which case a single Image2D object is returned.Some implementations may support other formats as well. If the data is not ina supported format, is otherwise invalid, or can not be loaded for some otherreason, an exception is thrown.</p><h3>Using the Loader</h3><p>The Loader class cannot be instantiated, and its only members are the twostatic <code>load</code> methods. The methods are otherwise identical, butone of them takes in a byte array, while the other takes a named resource,such as a URI or an individual file in the JAR package.</p><p>Any external references in the given file or byte array are followedrecursively. When using the <code>load</code> variant that takes in a URI,the references may be absolute or relative, but when using the byte arrayvariant, only absolute references are allowed.</p><p>The <code>load</code> methods only return once the entire contents of thegiven file (or byte array) have been loaded, including any referenced files.This means that displaying content while downloading (progressive loading) isnot supported.</p><h3>Managing the loaded objects</h3><p>The <code>load</code> methods return an array of Object3Ds. Theseare the root level objects in the file; in other words, those objectsthat are not referenced by any other objects. The array is guaranteednot to contain any null objects, but the order of the objects in thearray is undefined.</p><p>The non-root objects (often the majority) can be found by followingreferences recursively, starting from the root objects. This can be doneconveniently with the <A HREF="../../../javax/microedition/m3g/Object3D.html#getReferences(javax.microedition.m3g.Object3D[])"><CODE>getReferences</CODE></A>method in Object3D. Another way to find a specific object is to tag itwith a known user ID at the authoring stage, and search for that amongthe loaded objects using the <code>find</code> method.. See the classdescription for <A HREF="../../../javax/microedition/m3g/Object3D.html">Object3D</A> for more information.</p><p>Since the root-level objects are returned in an Object3D array, theapplication must find out their concrete types before using their fullfunctionality. In the typical case, when the content is developed inconjunction with the application code and deployed in the same JAR file,the application should know what the root-level objects are. If thisinformation is not available, or there is a need to check that theobjects are as expected, the application can use the run-time typeinformation that is built into Java. For example, a simple animationplayer application might want to check that the downloaded object isindeed a World, and display an appropriate error message otherwise.</p><h3>Validity of the loaded objects</h3><p>The set of objects returned by the Loader, comprising the rootlevel objects as well as their descendants, is guaranteed to be validand consistent with the API.  In other words, it should be possible toconstruct the same scene graph using the API with no exceptions beingthrown. For example, if a Mesh object is returned, the application canrest assured that it is in a state that can be reached via theAPI.</p><p>However, it is not guaranteed that the loaded content isrenderable. Conditions that cause deferred exceptions are not checkedfor, and may exist within the loaded objects. This allows fragmentaryscene graphs, which are invalid for rendering, to be loaded andassembled by the application into a valid scene graph.</p><h3>Implementation guidelines</h3><p>Implementations must not rely on the file extension (such as ".png") todetermine the type of the file that is to be loaded. Instead, if the MIMEtype is available, that should be used to screen out unrecognized fileswithout examining the contents. If the MIME type is not available (suchas when loading from a byte array), or it does indicate a supported format,the implementation must ascertain the file type based on its contents. M3Gfiles can be recognized from the <a href="../../../file-format.html#FileIdentifier">file identifier</a>, and PNG files from their corresponding<a href="http://www.w3.org/TR/PNG/#5PNG-file-signature">signature</a>.</p>
<P>

<P>
<DL>
<DT><B>See Also:</B><DD><a href="../../../file-format.html">M3G (JSR-184) file format</a>, <a href="http://www.w3.org/TR/PNG">PNG file format</a><DT><b>Example:</b><DD><div class="example_title">A code fragment illustrating the use of Loader and <code>find</code>.</div><pre class="example"> <span class="example_class">Object</span>3D[] roots=<span class="example_literal">null</span>; <span class="example_control">try</span> {    <span class="example_comment">// Load a World and an individual Mesh over http.</span>     roots = <span class="example_class">Loader</span>.load(<span class="example_string">"http://www.example.com/myscene.m3g"</span>);} <span class="example_control">catch</span>(<span class="example_class">IOException</span> e) {    <span class="example_comment">// couldn't open the connection, or invalid data in the file</span>} <span class="example_comment">// The root objects must be cast from Object3D to their immediate types</span><span class="example_comment">// (Mesh and World) before their full functionality can be used. Since</span><span class="example_comment">// the relative ordering of the root objects is unspecified, we can't</span><span class="example_comment">// assume that the World object is always at index 0, for example. Instead,</span><span class="example_comment">// we identify the World by its user ID of 1, which we have assigned to it</span><span class="example_comment">// at the authoring stage.</span> <span class="example_class">World</span> myWorld;                      <span class="example_comment">// contains our entire scene graph</span><span class="example_class">Mesh</span> myMesh;                        <span class="example_comment">// an individual mesh for immediate mode</span> <span class="example_control">if</span> (roots[0].getUserID() == 1) {    <span class="example_comment">// our World has a user ID of 1</span>    myWorld = (<span class="example_class">World</span>) roots[0];    myMesh = (<span class="example_class">Mesh</span>) roots[1];} <span class="example_control">else</span> {    myWorld = (<span class="example_class">World</span>) roots[1];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -