📄 sprite3d.html
字号:
(W = 1) before computing the distance.</p><blockquote>dx = | <b>x</b>'/x'<sub>w</sub> - <b>o</b>'/o'<sub>w</sub> |<br>dy = | <b>y</b>'/y'<sub>w</sub> - <b>o</b>'/o'<sub>w</sub> |</blockquote><p>Note that the W components of the homogeneous points cancelout in the subtraction, and the lengths computed are those ofthe 3D vectors. We then define (new) X and Y reference pointsthat lie on the X and Y axes of the camera and whose distancesfrom the origin are dx and dy, respectively. Applying theprojection matrix, we transform the origin and the referencepoints into clip space:</p><blockquote><b>o</b>'' = <b>P</b> <b>o</b>'<br><b>x</b>'' = <b>P</b> [<b>o</b>' + (dx, 0, 0, 0)<sup>T</sup>]<br><b>y</b>'' = <b>P</b> [<b>o</b>' + (0, dy, 0, 0)<sup>T</sup>]</blockquote><p>Again, we compute the distances from the origin to the X andY reference points. This gives us the dimensions of the spritein normalized device coordinates.</p><blockquote>sx = | <b>x</b>''/x''<sub>w</sub> - <b>o</b>''/o''<sub>w</sub> |<br>sy = | <b>y</b>''/y''<sub>w</sub> - <b>o</b>''/o''<sub>w</sub> |</blockquote><p>These dimensions are used when testing the sprite for anintersection with a pick ray. For rendering the sprite, weneed to apply the viewport transformation (see Graphics3D)to obtain the final on-screen size in pixels:</p><blockquote>w = 0.5 sx w<sub>vp</sub><br>h = 0.5 sy h<sub>vp</sub></blockquote><p>where w<sub>vp</sub> and h<sub>vp</sub> are the dimensions of theviewport.</p><p>Note that this formula may produce unintuitive results if themodelview matrix <b>M</b> incorporates, for example, non-uniformscaling and/or skewing components. However, the size computationis well-defined and predictable.</p><p>Also note that in the equations above, we transform and projectthe X and Y axes of the sprite node as two homogeneous points each;implementations may obtain the same result by transforming themdifferently.</p>
<P>
<P>
<DL>
<DT><B>See Also:</B><DD><a href="../../../file-format.html#Sprite3D">Binary format</a></DL>
<HR>
<P>
<!-- ======== NESTED CLASS SUMMARY ======== -->
<!-- =========== FIELD SUMMARY =========== -->
<A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Field Summary</B></FONT></TD>
</TR>
</TABLE>
<A NAME="fields_inherited_from_class_javax.microedition.m3g.Node"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Fields inherited from class javax.microedition.m3g.<A HREF="../../../javax/microedition/m3g/Node.html">Node</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../../javax/microedition/m3g/Node.html#NONE">NONE</A>, <A HREF="../../../javax/microedition/m3g/Node.html#ORIGIN">ORIGIN</A>, <A HREF="../../../javax/microedition/m3g/Node.html#X_AXIS">X_AXIS</A>, <A HREF="../../../javax/microedition/m3g/Node.html#Y_AXIS">Y_AXIS</A>, <A HREF="../../../javax/microedition/m3g/Node.html#Z_AXIS">Z_AXIS</A></CODE></TD>
</TR>
</TABLE>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../javax/microedition/m3g/Sprite3D.html#Sprite3D(boolean, javax.microedition.m3g.Image2D, javax.microedition.m3g.Appearance)">Sprite3D</A></B>(boolean scaled, <A HREF="../../../javax/microedition/m3g/Image2D.html">Image2D</A> image, <A HREF="../../../javax/microedition/m3g/Appearance.html">Appearance</A> appearance)</CODE>
<BR>
Constructs a new Sprite3D with the given scaling mode, image and appearance. </TD>
</TR>
</TABLE>
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../../javax/microedition/m3g/Appearance.html">Appearance</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/m3g/Sprite3D.html#getAppearance()">getAppearance</A></B>()</CODE>
<BR>
Gets the current Appearance of this Sprite3D.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/m3g/Sprite3D.html#getCropHeight()">getCropHeight</A></B>()</CODE>
<BR>
Gets the current cropping rectangle height within the source image. </TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/m3g/Sprite3D.html#getCropWidth()">getCropWidth</A></B>()</CODE>
<BR>
Gets the current cropping rectangle width within the source image. </TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/m3g/Sprite3D.html#getCropX()">getCropX</A></B>()</CODE>
<BR>
Retrieves the current cropping rectangle X offset relative to the source image top left corner.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/m3g/Sprite3D.html#getCropY()">getCropY</A></B>()</CODE>
<BR>
Retrieves the current cropping rectangle Y offset relative to the source image top left corner.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../../javax/microedition/m3g/Image2D.html">Image2D</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/m3g/Sprite3D.html#getImage()">getImage</A></B>()</CODE>
<BR>
Gets the current Sprite3D image.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/m3g/Sprite3D.html#isScaled()">isScaled</A></B>()</CODE>
<BR>
Returns the automatic scaling status of this Sprite3D. </TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/m3g/Sprite3D.html#setAppearance(javax.microedition.m3g.Appearance)">setAppearance</A></B>(<A HREF="../../../javax/microedition/m3g/Appearance.html">Appearance</A> appearance)</CODE>
<BR>
Sets the Appearance of this Sprite3D. </TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/m3g/Sprite3D.html#setCrop(int, int, int, int)">setCrop</A></B>(int cropX, int cropY, int width, int height)</CODE>
<BR>
Sets a cropping rectangle within the source image. </TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/m3g/Sprite3D.html#setImage(javax.microedition.m3g.Image2D)">setImage</A></B>(<A HREF="../../../javax/microedition/m3g/Image2D.html">Image2D</A> image)</CODE>
<BR>
Sets the sprite image to display. </TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_javax.microedition.m3g.Node"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class javax.microedition.m3g.<A HREF="../../../javax/microedition/m3g/Node.html">Node</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../../javax/microedition/m3g/Node.html#align(javax.microedition.m3g.Node)">align</A>, <A HREF="../../../javax/microedition/m3g/Node.html#getAlphaFactor()">getAlphaFactor</A>, <A HREF="../../../javax/microedition/m3g/Node.html#getParent()">getParent</A>, <A HREF="../../../javax/microedition/m3g/Node.html#getScope()">getScope</A>, <A HREF="../../../javax/microedition/m3g/Node.html#getTransformTo(javax.microedition.m3g.Node, javax.microedition.m3g.Transform)">getTransformTo</A>, <A HREF="../../../javax/microedition/m3g/Node.html#isPickingEnabled()">isPickingEnabled</A>, <A HREF="../../../javax/microedition/m3g/Node.html#isRenderingEnabled()">isRenderingEnabled</A>, <A HREF="../../../javax/microedition/m3g/Node.html#setAlignment(javax.microedition.m3g.Node, int, javax.microedition.m3g.Node, int)">setAlignment</A>, <A HREF="../../../javax/microedition/m3g/Node.html#setAlphaFactor(float)">setAlphaFactor</A>, <A HREF="../../../javax/microedition/m3g/Node.html#setPickingEnable(boolean)">setPickingEnable</A>, <A HREF="../../../javax/microedition/m3g/Node.html#setRenderingEnable(boolean)">setRenderingEnable</A>, <A HREF="../../../javax/microedition/m3g/Node.html#setScope(int)">setScope</A></CODE></TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_javax.microedition.m3g.Transformable"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class javax.microedition.m3g.<A HREF="../../../javax/microedition/m3g/Transformable.html">Transformable</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../../javax/microedition/m3g/Transformable.html#getCompositeTransform(javax.microedition.m3g.Transform)">getCompositeTransform</A>, <A HREF="../../../javax/microedition/m3g/Transformable.html#getOrientation(float[])">getOrientation</A>, <A HREF="../../../javax/microedition/m3g/Transformable.html#getScale(float[])">getScale</A>, <A HREF="../../../javax/microedition/m3g/Transformable.html#getTransform(javax.microedition.m3g.Transform)">getTransform</A>, <A HREF="../../../javax/microedition/m3g/Transformable.html#getTranslation(float[])">getTranslation</A>, <A HREF="../../../javax/microedition/m3g/Transformable.html#postRotate(float, float, float, float)">postRotate</A>, <A HREF="../../../javax/microedition/m3g/Transformable.html#preRotate(float, float, float, float)">preRotate</A>, <A HREF="../../../javax/microedition/m3g/Transformable.html#scale(float, float, float)">scale</A>, <A HREF="../../../javax/microedition/m3g/Transformable.html#setOrientation(float, float, float, float)">setOrientation</A>, <A HREF="../../../javax/microedition/m3g/Transformable.html#setScale(float, float, float)">setScale</A>, <A HREF="../../../javax/microedition/m3g/Transformable.html#setTransform(javax.microedition.m3g.Transform)">setTransform</A>, <A HREF="../../../javax/microedition/m3g/Transformable.html#setTranslation(float, float, float)">setTranslation</A>, <A HREF="../../../javax/microedition/m3g/Transformable.html#translate(float, float, float)">translate</A></CODE></TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_javax.microedition.m3g.Object3D"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class javax.microedition.m3g.<A HREF="../../../javax/microedition/m3g/Object3D.html">Object3D</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../../javax/microedition/m3g/Object3D.html#addAnimationTrack(javax.microedition.m3g.AnimationTrack)">addAnimationTrack</A>, <A HREF="../../../javax/microedition/m3g/Object3D.html#animate(int)">animate</A>, <A HREF="../../../javax/microedition/m3g/Object3D.html#duplicate()">duplicate</A>, <A HREF="../../../javax/microedition/m3g/Object3D.html#find(int)">find</A>, <A HREF="../../../javax/microedition/m3g/Object3D.html#getAnimationTrack(int)">getAnimationTrack</A>, <A HREF="../../../javax/microedition/m3g/Object3D.html#getAnimationTrackCount()">getAnimationTrackCount</A>, <A HREF="../../../javax/microedition/m3g/Object3D.html#getReferences(javax.microedition.m3g.Object3D[])">getReferences</A>, <A HREF="../../../javax/microedition/m3g/Object3D.html#getUserID()">getUserID</A>, <A HREF="../../../javax/microedition/m3g/Object3D.html#getUserObject()">getUserObject</A>, <A HREF="../../../javax/microedition/m3g/Object3D.html#removeAnimationTrack(javax.microedition.m3g.AnimationTrack)">removeAnimationTrack</A>, <A HREF="../../../javax/microedition/m3g/Object3D.html#setUserID(int)">setUserID</A>, <A HREF="../../../javax/microedition/m3g/Object3D.html#setUserObject(java.lang.Object)">setUserObject</A></CODE></TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class java.lang.Object</B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
<P>
<!-- ============ FIELD DETAIL =========== -->
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="Sprite3D(boolean, javax.microedition.m3g.Image2D, javax.microedition.m3g.Appearance)"><!-- --></A><H3>
Sprite3D</H3>
<PRE>
public <B>Sprite3D</B>(boolean scaled, <A HREF="../../../javax/microedition/m3g/Image2D.html">Image2D</A> image, <A HREF="../../../javax/microedition/m3g/Appearance.html">Appearance</A> appearance)</PRE>
<DL>
<DD><p>Constructs a new Sprite3D with the given scaling mode, image and appearance. The sprite image and appearance can be changed at any time, but the scaling mode is fixed at construction. If the appearance is null, rendering and picking of the sprite is disabled.</p> <p>The crop rectangle is set such that its top left corner is at the top left corner of the image, and its width and height are equal to the dimensions of the image. However, if the width (or height) of the crop rectangle would exceed the implementation defined maximum, the width (or height) is set to the maximum value
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -