summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-03-28 23:03:12 +0000
committerKarl Berry <karl@freefriends.org>2012-03-28 23:03:12 +0000
commit6d8118c3d435067d6970edfdcd831a4141654dcc (patch)
treec33ec1f62724fd4a6aa6ad06b8c5197fe49db5e1 /Master
parente54b7d07dfb4f3b812d1e90a7b56fe7f0fb37ac6 (diff)
install media9
git-svn-id: svn://tug.org/texlive/trunk@25769 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/media9/ChangeLog8
-rw-r--r--Master/texmf-dist/doc/latex/media9/README84
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/3dsystem.fig273
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/3dsystem.pdfbin0 -> 5989 bytes
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/3dsystem.tex29
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/dice.u3dbin0 -> 160672 bytes
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/dice.vws22
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/dice.wrl119
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/epix.asy22
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/epix.prcbin0 -> 63020 bytes
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/mailto.pngbin0 -> 962 bytes
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/random.mp4bin0 -> 28652 bytes
-rw-r--r--Master/texmf-dist/doc/latex/media9/media9.pdfbin0 -> 1004035 bytes
-rw-r--r--Master/texmf-dist/doc/latex/media9/media9.tex761
-rw-r--r--Master/texmf-dist/tex/latex/media9/javascript/3Dmenu.js885
-rw-r--r--Master/texmf-dist/tex/latex/media9/javascript/3Dspintool.js31
-rw-r--r--Master/texmf-dist/tex/latex/media9/javascript/animation.js118
-rw-r--r--Master/texmf-dist/tex/latex/media9/javascript/asylabels.js106
-rw-r--r--Master/texmf-dist/tex/latex/media9/media9.sty1996
-rw-r--r--Master/texmf-dist/tex/latex/media9/players/APlayer.mxml143
-rw-r--r--Master/texmf-dist/tex/latex/media9/players/APlayer.swfbin0 -> 320911 bytes
-rw-r--r--Master/texmf-dist/tex/latex/media9/players/VPlayer.mxml93
-rw-r--r--Master/texmf-dist/tex/latex/media9/players/VPlayer.swfbin0 -> 440128 bytes
-rwxr-xr-xMaster/tlpkg/bin/tlpkg-ctan-check2
-rwxr-xr-xMaster/tlpkg/libexec/ctan2tds1
-rw-r--r--Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc1
-rw-r--r--Master/tlpkg/tlpsrc/media9.tlpsrc0
27 files changed, 4692 insertions, 2 deletions
diff --git a/Master/texmf-dist/doc/latex/media9/ChangeLog b/Master/texmf-dist/doc/latex/media9/ChangeLog
new file mode 100644
index 00000000000..8c71cf9651d
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/ChangeLog
@@ -0,0 +1,8 @@
+2012-03-15
+ * v0.2
+ * new: LuaLaTeX support
+ * fix: wrong poster dimension in dvi output; fp numbers in PDF objects had
+ too many decimal places for dvipdfmx
+
+2012-03-01
+ * initial release (v0.1) to CTAN
diff --git a/Master/texmf-dist/doc/latex/media9/README b/Master/texmf-dist/doc/latex/media9/README
new file mode 100644
index 00000000000..6d6ee2b48d9
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/README
@@ -0,0 +1,84 @@
+ ==========================
+ The media9 LaTeX Package
+ ==========================
+
+
+Author:
+
+Alexander Grahn
+
+
+Description:
+
+This package provides an interface to embed interactive Flash (SWF)
+and 3D objects (Adobe U3D & PRC) as well as video and sound files or
+streams in the popular MP4, FLV and MP3 formats into PDF documents
+with Acrobat-9/X compatibility. Playback of multimedia files uses the
+built-in Flash Player of Adobe Reader and does, therefore, not depend
+on external plug-ins. Flash Player supports the efficient H.264 codec
+for video compression.
+
+This package is based on the RichMedia Annotation, an Adobe addition to
+the PDF specification. It replaces the now obsolete `movie15' package.
+
+*
+* Note that Adobe Reader for Linux has dropped Flash support since
+* version 9.4.2.
+*
+
+Supported PDF making workflows are:
+ * pdfLaTeX, LuaLaTeX
+ * (Lua)LaTeX --> dvips --> ps2pdf/Distiller
+ * (Xe)LaTeX --> (x)dvipdfmx
+
+The package was written in the new LaTeX3 syntax.
+
+
+Requirements:
+
+ * l3kernel (LaTeX package), version >=2011/06/19
+ * l3packages (LaTeX package), version >=2011/07/02
+ * pdfTeX, version >=1.30
+ * Ghostscript, version >=8.31 or Adobe Distiller for PS to PDF conversion
+ * dvipdfmx, version >=20080607 for DVI to PDF conversion
+ * Adobe Reader, version >=9
+
+
+Installation:
+
+MiKTeX users should run the package manager for installation.
+
+Unfortunately, `media9' is not in TeXLive. It must be installed manually
+into the local TeX-Directory-Structure (TDS) root directory along the
+following steps:
+
+1.) Download the TDS compliant package file
+http://tug.ctan.org/tex-archive/install/macros/latex/contrib/media9.tds.zip.
+
+2.) Find the local TDS root directory which is intended for packages
+that are not maintained by the TeXLive package manager by running
+
+ kpsewhich -var-value TEXMFLOCAL
+
+on the command line.
+
+3.) Unzip media9.tds.zip into the local TDS root directory previously
+found. Depending on the location of this directory, you may need to be
+logged in as Root/Administrator.
+
+4.) After installation, update the filename database by running
+
+ texhash
+
+on the command line. Again, Root/Administrator privileges may be required.
+
+For updating the package, repeat the steps given above.
+
+
+License:
+
+This material is subject to the LaTeX Project Public License. See
+
+ http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
+
+for the details of that license.
diff --git a/Master/texmf-dist/doc/latex/media9/files/3dsystem.fig b/Master/texmf-dist/doc/latex/media9/files/3dsystem.fig
new file mode 100644
index 00000000000..e2273139db8
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/files/3dsystem.fig
@@ -0,0 +1,273 @@
+#FIG 3.2
+Landscape
+Center
+Metric
+A4
+100.00
+Single
+-2
+1200 2
+0 32 #9c0000
+0 33 #8c8c8c
+0 34 #8c8c8c
+0 35 #424242
+0 36 #8c8c8c
+0 37 #424242
+0 38 #8c8c8c
+0 39 #424242
+0 40 #8c8c8c
+0 41 #424242
+0 42 #8c8c8c
+0 43 #424242
+0 44 #e2e2ee
+0 45 #94949a
+0 46 #dbdbdb
+0 47 #a1a1b7
+0 48 #ededed
+0 49 #e0e0e0
+0 50 #86acff
+0 51 #7070ff
+0 52 #c6b797
+0 53 #eff8ff
+0 54 #dccba6
+0 55 #404040
+0 56 #808080
+0 57 #c0c0c0
+0 58 #8e8f8e
+0 59 #aaaaaa
+0 60 #555555
+0 61 #8e8e8e
+0 62 #d7d7d7
+0 63 #aeaeae
+0 64 #bebebe
+0 65 #515151
+0 66 #e7e3e7
+0 67 #000049
+0 68 #797979
+0 69 #303430
+0 70 #414141
+0 71 #c7b696
+0 72 #414541
+0 73 #e7e7e7
+0 74 #717571
+0 75 #dd9d93
+0 76 #f1ece0
+0 77 #c3c3c3
+0 78 #e2c8a8
+0 79 #e1e1e1
+0 80 #d2d2d2
+0 81 #da7a1a
+0 82 #f1e41a
+0 83 #887dc2
+0 84 #d6d6d6
+0 85 #8c8ca5
+0 86 #4a4a4a
+0 87 #8c6b6b
+0 88 #5a5a5a
+0 89 #636363
+0 90 #b79b73
+0 91 #4193ff
+0 92 #bf703b
+0 93 #db7700
+0 94 #dab800
+0 95 #006400
+0 96 #5a6b3b
+0 97 #d3d3d3
+0 98 #8e8ea4
+0 99 #f3b95d
+0 100 #89996b
+0 101 #646464
+0 102 #b7e6ff
+0 103 #86c0ec
+0 104 #bdbdbd
+0 105 #d39552
+0 106 #98d2fe
+0 107 #8c9c6b
+0 108 #f76b00
+0 109 #5a6b39
+0 110 #8c9c6b
+0 111 #8c9c7b
+0 112 #184a18
+0 113 #adadad
+0 114 #f7bd5a
+0 115 #636b9c
+0 116 #f7f7f7
+0 117 #de0000
+0 118 #adadad
+0 119 #f7bd5a
+0 120 #adadad
+0 121 #f7bd5a
+0 122 #636b9c
+0 123 #526b29
+0 124 #949494
+0 125 #006300
+0 126 #00634a
+0 127 #7b844a
+0 128 #e7bd7b
+0 129 #a5b5c6
+0 130 #6b6b94
+0 131 #846b6b
+0 132 #529c4a
+0 133 #d6e7e7
+0 134 #526363
+0 135 #186b4a
+0 136 #9ca5b5
+0 137 #ff9400
+0 138 #ff9400
+0 139 #00634a
+0 140 #7b844a
+0 141 #63737b
+0 142 #e7bd7b
+0 143 #184a18
+0 144 #f7bd5a
+0 145 #dedede
+0 146 #f3eed3
+0 147 #f5ae5d
+0 148 #95ce99
+0 149 #b5157d
+0 150 #eeeeee
+0 151 #848484
+0 152 #7b7b7b
+0 153 #005a00
+0 154 #e77373
+0 155 #ffcb31
+0 156 #29794a
+0 157 #de2821
+0 158 #2159c6
+0 159 #f8f8f8
+0 160 #e6e6e6
+0 161 #21845a
+0 162 #cccccc
+0 163 #999999
+0 164 #b2b2b2
+0 165 #c9c9c9
+0 166 #dfd8df
+0 167 #f7f3f7
+0 168 #cdcdcd
+0 169 #6c6c6c
+5 1 0 1 0 7 45 -1 -1 0.000 0 0 1 1 1543.224 2237.643 2833 2393 2598 2996 2143 3390
+ 2 0 1.00 60.00 120.00
+ 2 0 1.00 60.00 120.00
+5 1 2 1 0 7 52 -1 -1 4.000 1 0 1 1 11576.552 9623.869 442 3442 1349 2035 2462 729
+ 0 0 1.00 60.00 120.00
+ 0 0 1.00 60.00 120.00
+5 1 2 1 0 7 52 -1 -1 4.000 1 1 1 1 7430.119 -1873.223 802 1109 1315 2055 2088 3055
+ 0 0 1.00 60.00 120.00
+ 0 0 1.00 60.00 120.00
+6 4753 4744 6037 5510
+5 1 0 1 0 7 100 -1 -1 0.000 0 0 0 0 5712.721 5265.408 5756 4952 5978 5093 6024 5322
+5 1 2 1 0 7 100 -1 -1 2.000 1 0 0 0 5442.537 5285.331 4944 5096 5258 4785 5692 4814
+5 1 2 1 0 7 100 -1 -1 2.000 1 1 0 0 5841.704 5281.825 5968 5335 5808 5149 5709 5316
+5 1 2 1 0 7 100 -1 -1 2.000 1 0 0 0 5122.611 5132.487 4986 5129 5207 5025 5230 5217
+5 1 0 1 0 7 98 -1 -1 0.000 1 0 0 0 5468.833 4766.333 5072 5236 5056 5222 5039 5206
+5 1 0 1 0 7 98 -1 -1 0.000 1 1 0 0 5071.511 5140.272 5011 5132 5012 5154 5026 5181
+5 1 0 1 0 7 98 -1 -1 0.000 1 0 0 0 5945.000 5164.000 5794 5382 5778 5370 5760 5354
+5 1 0 1 0 7 50 -1 -1 0.000 1 1 0 0 5659.846 5403.315 5786 5455 5627 5271 5528 5438
+5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 5260.632 5406.447 4760 5215 5074 4904 5510 4932
+5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 5529.852 5383.891 5574 5071 5795 5212 5841 5439
+5 1 0 1 0 7 50 -1 -1 0.000 1 0 0 0 4941.237 5252.972 4804 5250 5026 5145 5049 5338
+5 1 0 1 0 7 98 -1 -1 0.000 1 0 0 0 5442.380 5294.428 5068 4904 5255 4787 5689 4813
+5 1 0 1 0 7 98 -1 -1 0.000 1 1 0 0 5789.373 5293.415 5732 5285 5733 5307 5747 5333
+5 1 0 1 0 7 98 -1 -1 0.000 1 1 0 0 5825.000 5279.500 5704 5271 5704 5288 5706 5303
+1 3 2 1 0 7 100 -1 -1 2.000 1 6.0772 5123 5130 111 111 5123 5130 5234 5130
+1 3 2 1 0 7 100 -1 -1 2.000 1 6.0772 5844 5281 111 111 5844 5281 5955 5281
+1 3 0 1 0 7 50 -1 -1 0.000 1 6.0772 4940 5254 111 111 4940 5254 5050 5274
+1 3 0 1 0 7 50 -1 -1 0.000 1 6.0772 5662 5402 111 111 5662 5402 5703 5507
+2 1 0 1 0 7 100 -1 -1 0.000 0 0 -1 0 0 2
+ 5692 4814 5756 4952
+2 1 2 1 0 7 100 -1 -1 2.000 0 1 -1 0 0 2
+ 6024 5320 5968 5335
+2 1 2 1 0 7 100 -1 -1 2.000 0 1 -1 0 0 2
+ 4941 5094 4986 5129
+2 1 2 1 0 7 100 -1 -1 2.000 0 1 -1 0 0 2
+ 4761 5215 4944 5096
+2 1 2 1 0 7 98 -1 -1 2.000 0 1 -1 0 0 2
+ 5049 5338 5228 5220
+2 1 2 1 0 7 98 -1 -1 2.000 0 1 -1 0 0 2
+ 5528 5438 5709 5319
+2 1 2 1 0 7 98 -1 -1 2.000 0 1 -1 0 0 2
+ 4806 5250 4989 5131
+2 1 2 1 0 7 98 -1 -1 2.000 0 1 -1 0 0 2
+ 5786 5454 5968 5336
+2 1 0 1 0 7 98 -1 -1 0.000 0 1 -1 0 0 2
+ 4953 5157 4992 5131
+2 1 0 1 0 7 80 -1 -1 0.000 0 0 -1 0 0 2
+ 4971 4954 5153 4835
+2 1 0 1 0 7 50 -1 -1 0.000 0 1 -1 0 0 2
+ 4804 5251 4842 5227
+2 1 0 1 0 7 50 -1 -1 0.000 0 1 -1 0 0 2
+ 4760 5215 4804 5250
+2 1 0 1 0 7 50 -1 -1 0.000 0 1 -1 0 0 2
+ 5049 5338 5528 5438
+2 1 0 1 0 7 50 -1 -1 0.000 0 1 -1 0 0 2
+ 5841 5439 5786 5455
+2 1 0 1 0 7 50 -1 -1 0.000 0 1 -1 0 0 2
+ 5510 4932 5574 5071
+2 1 0 1 0 7 50 -1 -1 0.000 0 1 -1 0 0 2
+ 5528 5438 5565 5413
+2 1 0 1 0 7 50 -1 -1 0.000 0 1 -1 0 0 2
+ 5841 5439 6023 5322
+2 1 0 1 0 7 50 -1 -1 0.000 0 1 -1 0 0 2
+ 5755 4952 5574 5071
+2 1 0 1 0 7 50 -1 -1 0.000 0 1 -1 0 0 2
+ 5690 4814 5510 4932
+2 1 2 1 0 7 100 -1 -1 2.000 0 1 -1 0 0 2
+ 5228 5217 5708 5316
+-6
+6 1009 1590 1714 2595
+6 1399 1782 1714 2435
+5 1 0 0 0 7 55 -1 2 0.000 0 0 0 0 1438.929 2167.804 1604 1949 1708 2220 1500 2435
+2 3 0 0 7 7 55 -1 2 0.000 1 0 -1 0 0 6
+ 1399 1782 1604 1948 1501 2435 1462 2428 1460 1899 1399 1782
+-6
+2 3 0 2 0 7 50 -1 14 0.000 1 0 -1 0 0 5
+ 1300 1607 1613 2067 1322 2533 1024 2058 1300 1607
+2 3 0 2 0 7 54 -1 14 0.000 1 0 -1 0 0 6
+ 1322 2534 1406 2580 1692 2125 1610 2073 1323 2535 1322 2534
+2 3 0 2 0 7 54 -1 10 0.000 1 0 -1 0 0 5
+ 1300 1605 1384 1668 1693 2117 1618 2072 1300 1605
+-6
+1 1 1 1 0 7 50 -1 -1 4.000 1 5.7596 3060 3330 405 900 3060 3330 3465 3337
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 3
+ 1 1 2.00 120.00 240.00
+ 1 1 2.00 120.00 240.00
+ 2205 1305 2205 6165 7245 7155
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+ 1 1 2.00 120.00 240.00
+ 2205 6165 5985 4095
+2 1 1 1 4 7 50 -1 -1 4.000 0 1 -1 1 0 2
+ 2 0 1.00 60.00 120.00
+ 5440 5973 5440 5112
+2 1 1 1 4 7 50 -1 -1 4.000 0 1 -1 1 0 2
+ 2 0 1.00 60.00 120.00
+ 4331 6582 5440 5973
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 -1 1 0 2
+ 2 0 2.00 120.00 240.00
+ 2205 6165 5440 5112
+2 1 1 1 1 7 50 -1 -1 4.000 0 1 -1 1 0 2
+ 2 0 1.00 60.00 120.00
+ 4621 4954 4014 5283
+2 1 1 1 1 7 50 -1 -1 4.000 0 1 -1 1 0 2
+ 2 0 1.00 60.00 120.00
+ 4014 5283 4014 4048
+2 1 0 2 1 7 60 -1 -1 0.000 0 0 -1 1 0 2
+ 2 0 2.00 120.00 240.00
+ 5441 5112 4014 4048
+2 1 1 1 1 7 60 -1 -1 4.000 0 1 -1 1 0 2
+ 2 0 1.00 66.00 130.50
+ 5441 5112 4622 4953
+2 1 1 1 4 7 49 -1 -1 4.000 0 1 -1 1 0 2
+ 2 0 1.00 60.00 120.00
+ 2205 6165 4331 6582
+2 1 3 2 1 7 70 -1 -1 7.500 0 1 -1 0 0 2
+ 5443 5112 1683 2312
+2 1 1 1 0 7 100 -1 -1 4.000 0 0 -1 0 0 3
+ 3465 2532 1335 2060 2532 4025
+4 0 1 50 -1 0 12 0.0000 3 195 1845 4470 4308 $\\overrightarrow{C2C}$\001
+4 0 0 50 -1 0 12 0.0000 3 165 315 6013 4272 $Y$\001
+4 0 0 50 -1 0 12 0.0000 3 165 315 7140 7372 $X$\001
+4 0 0 50 -1 0 12 0.0000 3 165 300 2266 1297 $Z$\001
+4 0 4 50 -1 0 12 0.0000 3 195 1905 4090 5815 $\\overrightarrow{COO}$\001
+4 2 0 50 -1 0 12 0.0000 3 195 690 2160 6210 $(0,0,0)$\001
+4 1 0 50 -1 0 12 0.0000 3 195 1755 2835 2310 $\\sphericalangle AAC$\001
+4 0 1 50 -1 0 12 0.0000 3 165 570 3635 3680 $ROO$\001
diff --git a/Master/texmf-dist/doc/latex/media9/files/3dsystem.pdf b/Master/texmf-dist/doc/latex/media9/files/3dsystem.pdf
new file mode 100644
index 00000000000..4d09d34fc43
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/files/3dsystem.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/media9/files/3dsystem.tex b/Master/texmf-dist/doc/latex/media9/files/3dsystem.tex
new file mode 100644
index 00000000000..6bd2ffa1964
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/files/3dsystem.tex
@@ -0,0 +1,29 @@
+\begin{picture}(0,0)%
+\includegraphics[clip, scale=1, viewport=0 0 435 423.334371108344]{3dsystem}%
+\end{picture}%
+\setlength{\unitlength}{4144sp}%
+%
+\begingroup\makeatletter\ifx\SetFigFont\undefined%
+\gdef\SetFigFont#1#2#3#4#5{%
+ \reset@font\fontsize{#1}{#2pt}%
+ \fontfamily{#3}\fontseries{#4}\fontshape{#5}%
+ \selectfont}%
+\fi\endgroup%
+\begin{picture}(6905.17992277992,6720)(435,-6602)%
+\put(4471,-3469){\makebox(0,0)[lb]{\smash{{\SetFigFont{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,1}$\overrightarrow{C2C}$}%
+}}}}%
+\put(6014,-3433){\makebox(0,0)[lb]{\smash{{\SetFigFont{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$Y$}%
+}}}}%
+\put(7141,-6533){\makebox(0,0)[lb]{\smash{{\SetFigFont{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$X$}%
+}}}}%
+\put(2267,-458){\makebox(0,0)[lb]{\smash{{\SetFigFont{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$Z$}%
+}}}}%
+\put(4091,-4976){\makebox(0,0)[lb]{\smash{{\SetFigFont{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{1,0,0}$\overrightarrow{COO}$}%
+}}}}%
+\put(2161,-5371){\makebox(0,0)[rb]{\smash{{\SetFigFont{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$(0,0,0)$}%
+}}}}%
+\put(2836,-1471){\makebox(0,0)[b]{\smash{{\SetFigFont{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$\sphericalangle AAC$}%
+}}}}%
+\put(3636,-2841){\makebox(0,0)[lb]{\smash{{\SetFigFont{12}{14.4}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,1}$ROO$}%
+}}}}%
+\end{picture}%
diff --git a/Master/texmf-dist/doc/latex/media9/files/dice.u3d b/Master/texmf-dist/doc/latex/media9/files/dice.u3d
new file mode 100644
index 00000000000..ae14b756a16
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/files/dice.u3d
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/media9/files/dice.vws b/Master/texmf-dist/doc/latex/media9/files/dice.vws
new file mode 100644
index 00000000000..df43434781b
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/files/dice.vws
@@ -0,0 +1,22 @@
+VIEW=Front
+ ROO=27
+END
+VIEW=Back
+ ROO=27
+ C2C=0 1 0
+END
+VIEW=Left
+ ROO=27
+ C2C=-1 0 0
+END
+VIEW=Right
+ ROO=27
+ C2C=1 0 0
+END
+VIEW=Top
+ ROO=27
+ C2C=0 0 1
+END
+VIEW=Fish Eye at Centre
+ AAC=130
+END
diff --git a/Master/texmf-dist/doc/latex/media9/files/dice.wrl b/Master/texmf-dist/doc/latex/media9/files/dice.wrl
new file mode 100644
index 00000000000..23b1ef92a26
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/files/dice.wrl
@@ -0,0 +1,119 @@
+#VRML V1.0 ascii
+
+# dice.wrl
+# based on the work of
+# Peter Whitehouse <pwhitehouse@optusnet.com.au>
+# http://www.wonko.info/vrml/dice.txt
+
+Separator {
+ DEF _dice Shape {
+ geometry Box {
+ size 8 8 8
+ }
+ }
+ DEF _sphere0 Separator {
+ Material { diffuseColor [ 0.2 0.8 0.2 ] }
+ Translation { translation -2 2 -4 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_0 Separator {
+ Material { diffuseColor [ 0.2 0.8 0.2 ] }
+ Translation { translation 2 -2 -4 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1 Separator {
+ Material { diffuseColor [ 1 0.5 0.8 ] }
+ Translation { translation -2 2 4 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_0_1 Separator {
+ Material { diffuseColor [ 1 0.5 0.8 ] }
+ Translation { translation 2 -2 4 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1_2 Separator {
+ Material { diffuseColor [ 1 0.5 0.8 ] }
+ Translation { translation 0 0 4 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1_3 Separator {
+ Material { diffuseColor [ 0.3 0.3 1 ] }
+ Translation { translation -4 2 1.5 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_0_1_3 Separator {
+ Material { diffuseColor [ 0.3 0.3 1 ] }
+ Translation { translation -4 2 -1.5 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1_3_4 Separator {
+ Material { diffuseColor [ 0.3 0.3 1 ] }
+ Translation { translation -4 0 1.5 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_0_1_3_4 Separator {
+ Material { diffuseColor [ 0.3 0.3 1 ] }
+ Translation { translation -4 -2 -1.5 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1_2_3_4 Separator {
+ Material { diffuseColor [ 0.3 0.3 1 ] }
+ Translation { translation -4 -2 1.5 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1_2_3_5_6 Separator {
+ Material { diffuseColor [ 1 1 0 ] }
+ Translation { translation 0 4 0 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1_2_3_5_7 Separator {
+ Material { diffuseColor [ 1 1 0 ] }
+ Translation { translation 2 4 -2 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1_2_3_5_6_7 Separator {
+ Material { diffuseColor [ 1 1 0 ] }
+ Translation { translation 2 4 2 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1_2_3_5_7_8 Separator {
+ Material { diffuseColor [ 1 0 0 ] }
+ Translation { translation -2 -4 -2 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1_2_3_5_6_7_8 Separator {
+ Material { diffuseColor [ 1 0 0 ] }
+ Translation { translation -2 -4 2 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1_2_3_5_7_9 Separator {
+ Material { diffuseColor [ 1 0 0 ] }
+ Translation { translation 2 -4 -2 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1_2_3_5_6_7_9 Separator {
+ Material { diffuseColor [ 1 0 0 ] }
+ Translation { translation 2 -4 2 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1_2_3_5_7_8_9 Separator {
+ Material { diffuseColor [ 1 1 0 ] }
+ Translation { translation -2 4 -2 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1_2_3_5_6_7_8_9 Separator {
+ Material { diffuseColor [ 1 1 0 ] }
+ Translation { translation -2 4 2 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1_3_10 Separator {
+ Material { diffuseColor [ 0 1 1 ] }
+ Translation { translation 4 0 0 }
+ Sphere { radius 1.00000 }
+ }
+ DEF _sphere0_1_3_4_12 Separator {
+ Material { diffuseColor [ 0.3 0.3 1 ] }
+ Translation { translation -4 0 -1.5 }
+ Sphere { radius 1.00000 }
+ }
+}
diff --git a/Master/texmf-dist/doc/latex/media9/files/epix.asy b/Master/texmf-dist/doc/latex/media9/files/epix.asy
new file mode 100644
index 00000000000..48e25aa5591
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/files/epix.asy
@@ -0,0 +1,22 @@
+//Asymptote source file of epix.prc
+//
+//taken from http://asymptote.sourceforge.net/gallery/3D%20graphs/
+//and slightly modified
+//
+//run asy -k --tex=pdflatex on this file to generate standalone PRC
+
+import graph3;
+
+size(200,200,IgnoreAspect);
+
+//currentprojection=perspective(4,2,3);
+currentprojection=perspective(0,0,1);
+
+real f(pair z) {return z.y^3/2-3z.x^2*z.y;}
+
+draw(surface(f,(-1,-1),(1,1),nx=10,Spline),green,render(merge=true));
+draw(Label("$y$",1),(0,0,0)--(0,2,0),red,Arrow3);
+
+draw(Label("$x$",1),(0,0,0)--(2,0,0),red,Arrow3);
+draw(Label("$z$",1),(0,0,0)--(0,0,2.5),red,Arrow3);
+label("$z=\frac{1}{2}y^3-3x^2y$",(0.25,0.25,2),NE);
diff --git a/Master/texmf-dist/doc/latex/media9/files/epix.prc b/Master/texmf-dist/doc/latex/media9/files/epix.prc
new file mode 100644
index 00000000000..fa22b4ca5eb
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/files/epix.prc
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/media9/files/mailto.png b/Master/texmf-dist/doc/latex/media9/files/mailto.png
new file mode 100644
index 00000000000..12831c2410b
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/files/mailto.png
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/media9/files/random.mp4 b/Master/texmf-dist/doc/latex/media9/files/random.mp4
new file mode 100644
index 00000000000..cde209339b8
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/files/random.mp4
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/media9/media9.pdf b/Master/texmf-dist/doc/latex/media9/media9.pdf
new file mode 100644
index 00000000000..9a469702e9a
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/media9.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/media9/media9.tex b/Master/texmf-dist/doc/latex/media9/media9.tex
new file mode 100644
index 00000000000..d8c003089b3
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/media9.tex
@@ -0,0 +1,761 @@
+% Copyright 2012 Alexander Grahn
+%
+% This material is subject to the LaTeX Project Public License. See
+% http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
+% for the details of that license.
+%
+%\pdfcompresslevel=0
+%\pdfobjcompresslevel=0
+\documentclass[a4paper]{article}
+\frenchspacing
+%\usepackage[draft]{media9}
+\usepackage{media9}
+\usepackage{animate}
+\usepackage{fancyvrb}
+
+\usepackage{float}
+\usepackage{amssymb}
+\usepackage[UKenglish]{babel}
+\usepackage{graphicx}
+\usepackage{color}
+\usepackage{lmodern}
+\usepackage{microtype}
+\usepackage[T1]{fontenc}
+%\usepackage{float}
+\usepackage{parskip}
+\usepackage{tabls}
+\usepackage{menukeys}
+\usepackage{hyperref}
+\def\keywords{embed Flash movie LaTeX PDF 3D include sound swf mp3 video MP4 H.264 FLV audio multimedia streamed media rtmp YouTube animation JavaScript pdfLaTeX dvips ps2pdf dvipdfmx XeLaTeX U3D PRC Adobe Reader RichMedia annotation LuaLaTeX}
+\hypersetup{
+ bookmarksnumbered,linktocpage,breaklinks,
+ pdftitle={The media9 Package},
+ pdfsubject={Documentation},
+ pdfauthor={Alexander Grahn},
+ pdfkeywords={\keywords},
+ citebordercolor={0 0 1},
+ filebordercolor={0 0 1},
+ linkbordercolor={0 0 1},
+ menubordercolor={0 0 1},
+ pagebordercolor={0 0 1},
+ urlbordercolor={0 0 1}
+}
+
+\def\XeLaTeX{X\kern-.1667em\lower.5ex\hbox{\reflectbox{E}}\kern-.125em\LaTeX}
+\def\pXepLaTeX{(X\kern-.1667em\lower.5ex\hbox{\reflectbox{E}})\kern-.125em\LaTeX}
+
+\graphicspath{{files/}}
+\addmediapath{files}
+
+\hyphenation{Ja-va-Script}
+
+\newsavebox{\COO}
+\savebox{\COO}{$\overrightarrow{COO}$}
+\newsavebox{\CtoC}
+\savebox{\CtoC}{$\overrightarrow{C2C}$}
+
+\renewcommand{\textfraction}{0.0}
+\renewcommand{\topfraction}{1.0}
+\renewcommand{\bottomfraction}{1.0}
+
+\ifpdf\else
+ \makeatletter
+ \@latex@error{Please use pdfLaTeX to compile this documentation}
+ \makeatother
+\fi
+
+\begin{document}
+\title{The {\sffamily media9} Package}
+\author{Alexander Grahn\\[1ex]\includegraphics[height=2.7ex]{mailto}}
+\maketitle
+
+\begin{abstract}\noindent
+A \LaTeX{} package for embedding interactive Adobe Flash (SWF) and 3D files (Adobe U3D \& PRC) as well as video and sound files or streams (FLV, MP4/H.246, MP3) into PDF documents with Acrobat-9/X compatibility.\\[0.2\baselineskip]
+\emph{Keywords}: \keywords
+\end{abstract}
+
+\tableofcontents
+
+\section{Introduction}
+This package provides an interface to embed interactive Flash (SWF) and 3D objects (Adobe U3D \& PRC) as well as video and sound files or streams in the popular MP4, FLV and MP3 formats into PDF documents. Playback of multimedia files uses the built-in Flash Player of Adobe Reader and does, therefore, not depend on external plug-ins. Flash Player supports the efficient H.264 codec for video compression.
+
+Among the supported media types, video and sound files require an additional Flash (SWF) application for playback, which must be either embedded into the PDF or loaded at runtime from the internet. There are numerous such players, both open-source and commercial, available on the internet. One of them is the highly configurable open-source `Strobe Media Playback'~\cite{strobe}, maintained by Adobe and downloadable from SourceForge.net. Package `media9' comes with two simple players for video and audio, `VPlayer.swf' and `APlayer.swf', which can be used instead. They provide sufficient functionality for playing embedded files and streamed media.
+
+\emph{Note:} `media9' package replaces the now obsolete `movie15' package. `media9' is based on the RichMedia Annotation, an Adobe addition to the PDF specification~\cite{supplement}, while `movie15' uses the old multimedia framework (`Screen Annotation') of pre-9 Readers which depends on external plug-ins and which does not support recent media file formats. Annotations are the interactive parts in a document, in PDF specification parlance.
+
+Package `media9' supports the usual PDF making workflows, i.\,e. pdf\LaTeX{}, Lua\LaTeX, \LaTeX{} $\rightarrow$ \verb+dvips+ $\rightarrow$ \verb+ps2pdf+/Distiller and \pXepLaTeX{} $\rightarrow$ \verb+(x)dvipdfmx+.
+
+The final PDF can be viewed in current Adobe Readers on MS Windows and other platforms. On Unix platforms including Linux, however, support of Flash, video and sound was discontinued at Reader version 9.4.2, probably for security reasons.
+
+\section{Requirements}
+\begin{trivlist}
+\item l3kernel (\LaTeX{} package), version $\ge 2011/06/19$
+\item l3packages (\LaTeX{} package), version $\ge 2011/07/02$
+\item pdf\TeX{}, version $\ge1.30$
+\item Ghostscript, version $\ge8.31$ or Adobe Distiller for PS to PDF conversion
+\item dvipdfmx, version $\ge20080607$ for DVI to PDF conversion
+\item Adobe Reader, version $\ge9$
+\end{trivlist}
+
+\section{Installation}
+MiK\TeX{} users should run the package manager for installation.
+
+Unfortunately, `media9' is not in TeXLive. It must be installed manually into the \emph{local} TeX-Directory-Structure (TDS) root directory along the following steps:
+\begin{enumerate}
+ \item Download the TDS compliant package file `\href{http://tug.ctan.org/tex-archive/install/macros/latex/contrib/media9.tds.zip}{media9.tds.zip}' from CTAN.
+ \item Find the local TDS root directory by running\\
+ {\tt\phantom{xx}kpsewhich -var-value TEXMFLOCAL}\\
+on the command line. The local TDS root directory is intended for packages that are not maintained by the TeXLive package manager.
+ \item Unzip `\href{http://tug.ctan.org/tex-archive/install/macros/latex/contrib/media9.tds.zip}{media9.tds.zip}' into the local TDS root directory previously found. Depending on the location of this directory, you may need to be logged in as Root/Administrator.
+ \item After installation, update the filename database by running `{\tt texhash}' on the command line. Again, Root/Administrator privileges may be required.
+\end{enumerate}
+For updating the package, repeat the steps given above.
+
+\section{Using the package}\label{pkguse}
+Invoke the package by putting the line
+\begin{verbatim}
+ \usepackage[<package options>]{media9}
+\end{verbatim}
+to the preamble of your document, i.\,e. somewhere between \verb+\documentclass+ and \verb+\begin{document}+.
+
+`media9' honours the package options:
+\begin{verbatim}
+dvipdfmx
+xetex
+draft
+final
+activate=...
+deactivate=...
+transparent
+passcontext
+3Dplaytype=...
+3Dplaycount=...
+3Dplayspeed=...
+3Dtoolbar
+3Dnavpane
+3Dmenu
+3Dbg=...
+3Dlights=...
+3Drender=...
+\end{verbatim}
+Except for `\verb+dvipdfmx+' and `\verb+xetex+', the options above are also available (among others) as command options and will be explained shortly. However, if used as package options they have global scope, taking effect on all embedded media in the document. In turn, command options locally override global settings. Options without an argument are boolean options and can be negated by appending `\verb+=false+'.
+
+\XeLaTeX{} will be auto-detected. Therefore package option `\verb+xetex+' is optional. However, in case of \verb+dvipdfmx+, package option `\verb+dvipdfmx+' is mandatory because it cannot be auto-detected.
+
+\begin{animateinline}[autoplay,loop]{1.5}\strut\emph{Important:}\newframe\newframe[5]\end{animateinline} If PDF is generated via DVI and Postscript by the command sequence \verb+latex+ $\rightarrow$ \verb+dvips+ $\rightarrow$ \verb+ps2pdf+, \verb+dvips+ option `\verb+-Ppdf+' should \emph{not} be set when converting the intermediate DVI into Postscript. If you cannot do without, put `\verb+-D 1200+' \emph{after} `\verb+-Ppdf+' on the command line. Users of \LaTeX-aware text editors with menu-driven toolchain invocation, such as \TeX{}nicCenter, should check the configuration of the \verb+dvips+ call.
+
+\section{The user interface}
+Package `media9' provides the command
+\begin{verbatim}
+\includemedia[<options>]{<poster text>}{
+ <main Flash (SWF) file or URL | 3D (PRC, U3D) file>}
+\end{verbatim}
+Its last argument, \verb+<main Flash (SWF) file or URL | 3D (PRC, U3D) file>+, is the main interactive application to be inserted into the PDF. In case of Flash, this can be a local SWF file, or a URL, such as a YouTube video. A local file will become part of the final PDF file, while Flash content from a URL requires an internet connection when the user activates it in Adobe Reader. As for 3D content, Adobe Reader only supports U3D or PRC files embedded in the PDF; they cannot be loaded or streamed during runtime. The most frequent use of \verb+\includemedia+ will likely be embedding video or sound files for playback in Adobe Reader. For this we need some media player, which is an SWF file we embed as our main application. It will be configured to load, upon activation, a particular video or sound file that was embedded as a resource into the PDF or is to be streamed from the internet. This will be shown later. Note that a local file (main application or resource) will only once be physically embedded in order to keep final PDF file size small. If the same file (identified by MD5 checksum) appears in other \verb+\includemedia+ commands, only a reference will be inserted that points to the same storage location in the PDF.
+
+Argument \verb+<poster text>+ defines the size of the rectangular region of the document page in which the media will be displayed. Moreover, \verb+<poster text>+ will be shown in case the media has not been activated.
+%(Internally, \verb+<poster text>+ is put into a \LaTeX{} box, which is used as the appearance of the PDF annotation, i.\,e. the interactive region created by \verb+\includemedia+, in PDF specification parlance.)
+\verb+<poster text>+ can be anything that \LaTeX{} can typeset, such as an \verb+\includegraphics+ command serving as a poster image, a PGF/TikZ/PSTricks inline graphics or just ordinary text. Alternatively, \verb+<poster text>+ can be left blank in which case the size of the media rectangle should be set with options `\verb+width+', `\verb+height+' and optionally with `\verb+depth+'. If sizing options `\verb+width+' and `\verb+height+' are given \emph{together} with \verb+<poster text>+, \verb+<poster text>+ will be shrunk or stretched to fit exactly into the rectangle defined by the options, possibly changing the original aspect ratio of the poster text. On the other hand, if only one of `\verb+width+' or `\verb+height+' is given, the other dimension of \verb+<poster text>+ is scaled such that the original aspect ratio is preserved.
+
+A list of directories where \TeX{} searches for media and resource files can be set-up by means of
+\begin{verbatim}
+\addmediapath{<directory>}
+\end{verbatim}
+This command appends one directory at a time to the search list. To specify more directories, just use it repeatedly. The path separator is always `\verb+/+', independent from the operating system.
+
+The following section explains all command options provided. They are passed to the media inclusion command as a comma separated list enclosed in a pair of square brackets.
+
+\section{Command options}
+A subset of the command options (see Sect. \ref{pkguse}) can also be used as package options, which lets them apply to all embedded media. Some of the options listed here are meaningful only for a specific media type (either Flash or 3D), which will be noted explicitly if not obvious. Dedicated sections covering Flash, video and sound as well as 3D inclusion will follow later on in this document.
+
+\begin{verbatim}
+width=<width>,
+height=<height>,
+depth=<depth>
+\end{verbatim}
+Resize the media playback area, overriding the original dimensions of the {\tt<poster text>} argument. Option `\verb+depth+' specifies how far the playback area should extend below the base line of the running text. If only one or two of these options are given, the remaining, unspecified dimensions are scaled to maintain the aspect ratio of \verb+<poster text>+. Any valid \TeX{} dimension is accepted as a parameter. In addition, the length commands \verb+\width+, \verb+\height+, \verb+\depth+ and \verb+\totalheight+ can be used to refer to the original dimensions of \verb+<poster text>+.
+
+\begin{verbatim}
+scale=<factor>
+\end{verbatim}
+Scales the playback area by \verb+<factor>+.
+
+\begin{verbatim}
+url
+\end{verbatim}
+(Flash only) The \emph{last argument} of \verb+\includemedia+ is interpreted as a URL from which the Flash content is to be downloaded on activation of the playback area. Does \emph{not} refer to online resources configured via `\verb+flashvars+' option.
+\begin{verbatim}
+addresource=<local file>,
+addresource=<another local file>,
+...
+\end{verbatim}
+Every invocation of this option embeds another local file that is required to run the main Flash application or 3D file (last argument of \verb+\includemedia+). Typically, this option is used to embed video files, media player skins, XML files (such as databases), additional objects to appear in a 3D scene etc. If an already embedded file is needed in another \verb+\includemedia+ command, this option must be given there again. However, the file in question will only once be physically embedded in order to keep the PDF file small.
+\begin{verbatim}
+flashvars={<some_var=some_val&another_var=another_val&...>}
+\end{verbatim}
+(Flash only) Usually, Flash applications can be configured via ActionScript variables the programmer of the application has made visible from outside. A typical use would be to set the video source of a media player to point to an embedded MP4 file or to a live stream, or to set the speaker volume for playback of an MP3 file. The argument of the \verb+flashvars+ option is a list of \verb+<variable>=<value>+ pairs separated by `\verb+&+' and enclosed in a pair of braces (\verb+{...}+). Note: If a variable is to be set to point to an embedded resource, the value of the variable must be given in exactly the same way as with the `\verb+addresource+' option. Otherwise the name of the embedded file cannot be resolved. For example,
+\begin{verbatim}
+ addresource=path/to/video.mp4
+\end{verbatim}
+implies
+\begin{verbatim}
+ flashvars={vid=path/to/video.mp4&...}
+\end{verbatim}
+if, for a particular media player, the video source is set through ActionScript variable `\verb+vid+'.
+
+(Note for 3D) Resource files used in 3D scenes cannot be loaded by means of ActionScript variables. This must be done by 3D JavaScript during activation of the 3D scene in the Reader. 3D JavaScript can be attached using option `\verb+add3Djscript+', see below.
+\begin{verbatim}
+activate=onclick | pageopen | pagevisible
+\end{verbatim}
+Decides on how to activate the media annotation. `\verb+activate=onclick+' is default behaviour and does not need be given explicitly; embedded media is activated when the user clicks on it or through a JavaScript. It is recommended to provide a poster image with the \verb+<poster text>+ argument in that case. `\verb+pageopen+' and `\verb+pagevisible+' automatically activate the media when the page becomes visible; `{\tt pagevisible}' is better for two-up and continuous page display.
+\begin{verbatim}
+deactivate=onclick | pageclose | pageinvisible
+\end{verbatim}
+Decides on how to de-activate the media annotation. `\verb+deactivate=onclick+' is default behaviour and does not need be given explicitly; media is de-activated when the user right-clicks on it and selects `Disable Content', or through a JavaScript. `\verb+pageclose+' and `\verb+pageinvisible+' automatically de-activate the media when the user navigates away from the page containing the media; `{\tt page\-in\-visible}' is better for two-up and continuous page display.
+\begin{verbatim}
+draft
+final
+\end{verbatim}
+With `\verb+draft+' the media is not embedded. Instead, a box is inserted that has the dimensions of \verb+<poster text>+, subject to the resizing options `\verb+width+', `\verb+height+', `\verb+depth+' and `\verb+scale+'. Option `\verb+final+' does the opposite as it forces the media to be embedded. Both options can be used to reduce compilation time during authoring of a document. To get the most out of them it is recommended to set `\verb+draft+' globally as a package or class option and to set `\verb+final+' locally as a command option of the media annotation that is currently worked on. After the document has been finished, the global `\verb+draft+' option can be removed.
+\begin{verbatim}
+transparent
+\end{verbatim}
+Indicates whether underlying page content is visible through transparent areas of the embedded media. Doesn't seem to work well for Flash content. Default is `\verb+transparent=false+'; media artwork is drawn over an opaque background prior to composition over the page content.
+\begin{verbatim}
+passcontext
+\end{verbatim}
+(Flash only) If set, user right-clicks are passed through to the context menu of the embedded Flash application, replacing the default Adobe Reader context menu. Useful for cases where the Flash programmer provided additional functionality through the context menu of his application.
+\begin{verbatim}
+3Dtoolbar
+\end{verbatim}
+Indicates whether a 3D toolbar should be shown in the Reader on top of the embedded 3D model.
+\begin{verbatim}
+3Dnavpane
+\end{verbatim}
+If set, the 3D navigation pane displaying the 3D Model Tree becomes visible in the Reader when the content is initially activated.
+\begin{verbatim}
+3Dcoo=<x> <y> <z>
+\end{verbatim}
+\verb+<x> <y> <z>+ specify the positional vector $\overrightarrow{COO}$ of the centre of orbit of the virtual camera. Real numbers in fixed and floating point notation are accepted.
+\begin{verbatim}
+3Dc2c=<x> <y> <z>
+\end{verbatim}
+\verb+<x> <y> <z>+ specify a direction vector $\overrightarrow{C2C}$ of arbitrary length, originating in the centre of orbit and pointing to the virtual camera. Real numbers in fixed and floating point notation are accepted.
+\begin{verbatim}
+3Droll=<roll>
+\end{verbatim}
+Prescribes an initial camera roll around the optical axis (in clockwise direction, if \verb+<roll>+ is greater that zero); measured in degrees and given as fixed or floating point real number.
+\begin{verbatim}
+3Dc2w=<12 element camera-to-world matrix>
+\end{verbatim}
+This option directly sets the camera-to-world transformation matrix according to the PDF specification. This is an expert option to be used \emph{instead} of the `\verb+3Dc2c+', `\verb+3Dcoo+' and `\verb+3Droll+' options. Only fixed point real numbers are accepted.
+\begin{verbatim}
+3Droo=<r>
+\end{verbatim}
+\verb+<r>+ is a positive fixed or floating point number specifying the radius of orbit $ROO$ of the virtual camera. Good values can be found by means of the `\verb+3Dmenu+' option.
+\begin{verbatim}
+3Daac=<angle>
+\end{verbatim}
+This option sets the aperture angle of the camera, measured in degrees, for the perspective view mode. Fixed and floating point real numbers between 0 and 180 are admissible. A sensible value of 30 is pre-set by default. Larger values can be used to achieve wide-angle or fish-eye effects. See example~\ref{u3dex} in section~\ref{sec:3Dintro}. This option excludes the use of the `\verb+3Dortho+' option.
+\begin{verbatim}
+3Dortho[=<orthographic scaling factor>]
+\end{verbatim}
+Switches from the default perspective to orthographic view mode. In orthographic view, the 3D object is parallelly projected onto the virtual camera chip. The projected image is scaled by \verb+<orthographic scaling factor>+ before reaching the camera chip; default value is 1. The optimal value for the scaling factor is given by $1/D$, where $D$ is the diameter of the smallest enclosing sphere of the 3D object in World coordinate units. Fixed and floating point real numbers are accepted. The camera should be positioned outside the 3D object. For this, the radius of orbit (option `\verb+3Droo+') should be greater than $D/2$. Good values for orthographic scaling and orbital radius can easily be found by means of the `\verb+3Dmenu+' option. Option `\verb+3Dortho+' excludes the use of the `\verb+3Daac+' option.
+\hypertarget{3dmenu}{}%
+\begin{verbatim}
+3Dmenu
+\end{verbatim}
+Mainly used during document authoring. Adds three entries, `\emph{\sffamily Generate Default View}', `\emph{\sffamily Get Current View}' and `\emph{\sffamily Cross Section}' to the context (right-click) menu of an activated 3D annotation. Moreover, it allows individual parts of the scene to be scaled, translated and rotated against the remaining scene objects using the keyboard. Their new position can be saved in the current view. Parts to be modified should be highlighted with the mouse first (the part's bounding box becomes visible). Then, arrow keys \keys{\arrowkeyleft}, \keys{\arrowkeyright} let the part spin around its vertical axis, and \keys{\arrowkeyup}, \keys{\arrowkeydown} tilt against the vertical position. \keys{X}, \keys{\shift+X}, \keys{Y}, \keys{\shift+Y}, \keys{Z}, \keys{\shift+Z} translate the selected part along the World axes and \keys{S}, \keys{\shift+S} scale the part.
+
+`\emph{\sffamily Generate Default View}' computes optimal camera settings such that the visual parts of the object fit tightly into the viewing area. The result is printed, formatted as a list of \verb+\includemedia+ options, into the JavaScript console. The calculation is based on the 3D object size and its position in the World coordinate system as well as the current viewing mode (perspective or orthographic).
+
+`\emph{\sffamily Cross Section}' is a toggle switch to add or remove a cross section to or from the current view. If a part of the 3D scene was previously selected, the central rotating point of the section plane is put into the part's centre, otherwise into the target point of the camera. The section plane can be rotated around the vertical axis and tilted against its upright position using the arrow keys \keys{\arrowkeyleft}, \keys{\arrowkeyright}, \keys{\arrowkeyup} and \keys{\arrowkeydown}. Keys \keys{X}, \keys{\shift+X}, \keys{Y}, \keys{\shift+Y}, \keys{Z}, \keys{\shift+Z} move the section plane along the World axes.
+
+`\emph{\sffamily Get Current View}' from the context menu writes camera settings, any part alterations, an optional cross section as well as part and scene rendering attributes of the current view into the JavaScript console. The output is a readily formatted \verb+VIEW+ section to be inserted into or appended to a file of predefined views. See option `\verb+3Dviews+'. All settings reachable via the `\emph{\sffamily Part Options}' and `\emph{\sffamily Viewing Options}' context menu items are written to the \verb+VIEW+ section.
+
+\begin{verbatim}
+3Dbg=<r> <g> <b>
+\end{verbatim}
+This option sets the background colour of the 3D scene. Only fixed point real numbers in the range from 0 to 1 are allowed for the colour components. Option `\verb+transparent+' may not be set at the same time.
+\begin{verbatim}
+3Dlights=<lighting scheme>
+\end{verbatim}
+Sets the default lighting scheme. The following values are honoured: `\verb+None+', `\verb+White+', `\verb+Day+', `\verb+Night+', `\verb+Hard+', `\verb+Primary+', `\verb+Blue+', `\verb+Red+', `\verb+Cube+', `\verb+CAD+', `\verb+HeadLamp+'. The default is to use the lighting scheme as specified within the 3D artwork.
+\begin{verbatim}
+3Drender=<render mode>
+\end{verbatim}
+\begin{flushleft}
+Sets the default render mode. The following values are honoured: `\verb+Solid+', `\verb+SolidWireframe+', `\verb+Transparent+', `\verb+TransparentWireframe+', `\verb+BoundingBox+', `\verb+TransparentBoundingBox+', `\verb+TransparentBoundingBoxOutline+', `\verb+Wireframe+', `\verb+ShadedWireframe+', `\verb+HiddenWireframe+', `\verb+Vertices+', `\verb+ShadedVertices+', `\verb+SolidOutline+', `\verb+Illustration+', `\verb+ShadedIllustration+'.
+\end{flushleft}
+\begin{verbatim}
+3Dviews=<views file>
+\end{verbatim}
+Instead of or in addition to the default view (options `\verb+3Dcoo+', `\verb+3Dc2c+', `\verb+3Droll+', `\verb+3Droo+', `\verb+3Daac+', `\verb+3Dortho+'), further \emph{named views} can be set in an auxiliary file \verb+<views file>+. Besides the virtual camera position, it is possible to adjust the rendering attributes, such as visibility and transparency, as well as position and scaling of every single part in the 3D scene. Moreover, background colour and scene lighting can be set individually for every view. The additional views can later be selected either from a drop down list in the tool bar that is associated with the activated 3D object in the Reader or from the context menu of the 3D object.
+
+The file \verb+<views file>+ is structured into view sections, one for every view:
+\begin{verbatim}
+ VIEW[=<optional name>]
+ COO=<x> <y> <z>
+ C2C=<x> <y> <z>
+ ROLL=<roll>
+ % C2W=<camera-to-world matrix> % instead of COO, C2C and ROLL
+ ROO=<roo>
+ AAC=<aac>
+ % ORTHO[=<othographic scaling factor>] % instead of AAC
+ BGCOLOR=<r> <g> <b>
+ RENDERMODE=<render mode>
+ LIGHTS=<lighting scheme>
+ CROSSSECT
+ CENTER=<x> <y> <z>
+ NORMAL=<x> <y> <z>
+ END
+ PART=<part name as in the Model Tree (required, optional if UTF16NAME present)>
+ UTF16NAME=<part name as hex encoded Unicode string>
+ VISIBLE=true | false
+ OPACITY=<part opacity>
+ RENDERMODE=<part render mode>
+ TRANSFORM=<12 element transformation matrix>
+ END
+ PART=<...>
+ ...
+ END
+ etc.
+ END
+
+ VIEW
+ ...
+ END
+
+ etc.
+\end{verbatim}
+A view section starts with the keyword \verb+VIEW+, optionally followed by a name for the view, and ends with the keyword \verb+END+. If no name is given to the view, a default one is created, consisting of `View' followed by the number of the current \verb+VIEW+ section in the file. A \verb+VIEW+ section may contain optional entries for setting the camera position and global rendering attributes of the scene, a \verb+CROSSSECT+ subsection as well as \verb+PART+ subsections for setting rendering and other attributes of parts individually. Table~\ref{tab:views} lists the entries in a \verb+VIEW+ section.
+
+Part sub-sections are opened by \verb+PART=<part name>+ and closed by \verb+END+. There may be as many part subsections as there are parts in a 3D scene. Table~\ref{tab:parts} lists the possible entries in a \verb+PART+ sub-section. All entries are optional. However, a \verb+UTF16NAME+ entry is recommended, as the part name may contain non-ASCII characters. The value of the \verb+UTF16NAME+ key is the part name as a hex-encoded Unicode string. If \verb+UTF16NAME+ is not used, the part name in the 3D file must be entirely composed of ASCII characters. In that case, \verb+<part name>+ is mandatory and must match the part name as indicated in the Model Tree of the 3D object (accessible via right-click onto the model in the Reader). The part can be scaled and repositioned by means of a \verb+TRANSFORM+ entry which takes a 12-element transformation matrix as its value. Remaining entries in a part sub-section control the visual appearance of the part.
+
+A view section may contain at most one \verb+CROSSSECT+ sub-section. It inserts a section plane at a definite position and orientation in the 3D space, controlled by optional \verb+CENTER+ and \verb+NORMAL+ entries. See Table~\ref{tab:crosss} for explanation.
+
+The views file can be commented. As usual, comments start with the percent sign.
+
+To facilitate the creation of a views file, option `\verb+3Dmenu+' can be added to \verb+\includemedia+ (see above). It creates context (right-click) menu entry `Get Current View' which outputs a complete \verb+VIEW+ section corresponding to the current view of the 3D object in the Reader, including camera position, an optional cross section, and all part and viewing options that can be modified via the 3D toolbar (option `\verb+3Dtoolbar+') or the context menu of the 3D object (entries `\emph{\sffamily Part Options}', `\emph{\sffamily Viewing Options}'). Hence, apart from tweaking one or another entry, there should no need for writing views files by hand.
+\begin{verbatim}
+3Dplaytype=linear | oscillating
+\end{verbatim}
+According to the PDF specification, embedded keyframe animations can be played in two ways. If set to `\verb+linear+', keyframe animations are driven linearly from beginning to end, while `\verb+oscillating+' lets the animation play in a forth-and-back manner.
+\begin{verbatim}
+3Dplaycount=<integer number>
+\end{verbatim}
+A non-negative \verb+<integer number>+ represents the number of times the animation is played. A negative integer indicates that the animation is infinitely repeated. This value is ignored if option \verb+3Dplaytype+ is not set.
+\begin{verbatim}
+3Dplayspeed=<positive number>
+\end{verbatim}
+This option can be used to adjust the keyframe animation speed. A value of `1' corresponds to the default speed defined in the 3D file.
+\begin{verbatim}
+add3Djscript=<3D JavaScript file>,
+add3Djscript=<another 3D JavaScript file>,
+...
+\end{verbatim}
+Things like animation, lighting, background of 3D objects etc. may also be script driven. Every invocation of `\verb+add3Djscript+' associates another JavaScript file with the 3D object. Upon activation of the 3D object, the scripts are executed once in the order of their inclusion. Refer to the Acrobat 3D JavaScript Reference~\cite{jscript3D} for syntax details. The following 3D JavaScript loads an image file that was attached by `\verb+addresource=images/sunset.jpg+' and uses it as the scene background.
+\begin{verbatim}
+ sunset = new Image(new Resource('pdf://images/sunset.jpg'));
+ reh = new RenderEventHandler();
+ reh.onEvent = function(event) {
+ runtime.removeEventHandler(this);
+ event.canvas.background.image=sunset;
+ }
+ runtime.addEventHandler(reh);
+\end{verbatim}
+\hypertarget{3dscripts}{}For convenience, subdirectory `javascript' of the `media9' installation contains three 3D JavaScript files which may come in handy at times: `animation.js' enables embedded keyframe animation in 3D files; `3Dspintool.js' enables the Spin tool of the 3D plugin for easier rotating the 3D object with the mouse; `asylabels.js' adds `billboard behaviour' to text labels in Asymptote generated PRC files for improved visibility, they always face the camera while dragging the 3D object with the mouse.
+
+\begin{table}[bp]%[p]%[htbp]
+ \centering
+ \caption{Entries in a {\tt VIEW} section.}\label{tab:views}
+ \begin{tabular}[t]{p{0.24\linewidth}lp{0.4\linewidth}}\hline
+ key & type & remarks\\\hline\hline
+ COO & three numbers & centre of orbit, see option `{\tt 3Dcoo}'\\
+ C2C & three numbers & centre of orbit to camera vector, see option `{\tt 3Dc2c}'\\
+ ROO & number & radius of orbit, see option `{\tt 3Droo}'\\
+ C2W & 12 numbers & camera-to-world transformation matrix, see option `{\tt 3Dc2w}'\\
+ AAC & number & camera aperture angle, see option `{\tt 3Daac}'\\
+ ORTHO & number (optional) & enables orthographic view, see option `{\tt 3Dortho}'\\
+ ROLL & number & camera roll, see option `{\tt 3Droll}'\\
+ BGCOLOR & three numbers & 3D scene background colour (RGB), see option `{\tt 3Dbg}'\\
+ RENDERMODE & string & render mode of the 3D object, see option `{\tt 3Drender}'\\
+ LIGHTS & string & lighting scheme, see option `{\tt 3Dlights}'\\
+ PART\,\,(sub-sec\-tion) & string & part name as in the model tree; optional if a UTF16NAME entry is present in the sub-section opened by a PART keyword, otherwise required; see Table~\ref{tab:parts} for list of possible entries\\
+ CROSSSECT~(sub-section) & -- & see Table~\ref{tab:crosss} for list of possible entries\\
+ \hline
+ \end{tabular}
+\end{table}
+
+\begin{table}%[p]%[htbp]
+ \centering
+ \caption{Entries in a {\tt PART} sub-section.}\label{tab:parts}
+ \begin{tabular}[t]{llp{0.5\linewidth}}\hline
+ key & type & remarks\\\hline\hline
+ UTF16NAME & hex string & part name in UTF-16 (aka Unicode), encoded as a hexadecimal string; optional, but useful for part names composed of non-latin characters;\\
+ VISIBLE & boolean & a flag (`{\tt true}' or `{\tt false}') indicating the visibility of this part\\
+ OPACITY & number & a number between 0.0 and 1.0 specifying the opacity of this part\\
+ RENDERMODE & string & rendermode of this part, overrides global {\tt RENDERMODE} value in parent {\tt VIEW} section, see option `{\tt 3Drender}'\\
+ TRANSFORM & 12 numbers & transformation matrix defining the part's position and scaling\\
+ \hline
+ \end{tabular}
+\end{table}
+
+\begin{table}%[p]%[htbp]
+ \centering
+ \caption{Entries in a {\tt CROSSSECT} sub-section.}\label{tab:crosss}
+ \begin{tabular}[t]{llp{0.5\linewidth}}\hline
+ key & type & remarks\\\hline\hline
+ CENTER & three numbers & central point coordinates of the section plane\\
+ NORMAL & three numbers & normal vector coordinates of the section plane pointing into the cut-off region\\
+ \hline
+ \end{tabular}
+\end{table}
+
+\clearpage
+\section[Embedding Flash, video and sound (with examples)]{Embedding Flash, video and sound}
+A YouTube video clip, as shown in Fig.~\ref{alien}, may serve as a basic example of loading Flash content from a URL to be displayed in an embedded fashion in a PDF document. Indeed, a YouTube clip is nothing more than a small SWF file which loads a video stream and other necessary resources, such as user controls and a player skin from a remote server. It can be configured via ActionScript variables, to play several videos in a row, to play a video in a loop etc. Player parameters are documented on \url{http://code.google.com/apis/youtube/player_parameters.html} and can be passed to the player using either the `\verb+flashvars+' option, as in the example, or appended to the URL string after the video ID. A question mark `\verb+?+' must be put between the video ID and the parameter string. Some of the documented parameters, such as `\verb+rel+', seem to have an effect only if they are passed as part of the URL.
+
+\begin{figure}[bp]
+\begin{Verbatim}
+\includemedia[
+ width=0.6\linewidth,height=0.45\linewidth,
+ activate=pageopen,
+ flashvars={%
+ modestbranding=1% no YT logo in control bar
+ &autohide=1% % controlbar autohide
+ &showinfo=0% % no title and other info before start
+ &rel=0% % no related videos after end
+ },%
+ url % Flash loaded from URL
+]{}{http://www.youtube.com/v/Mdc3o7wOwNA?rel=0}
+\end{Verbatim}
+%\begin{minipage}{0.5\linewidth}
+\begin{center}
+\includemedia[
+ width=0.6\linewidth,height=0.45\linewidth,
+ activate=pageopen,
+ flashvars={%
+ modestbranding=1% no YT logo in control bar
+ &autohide=1% controlbar autohide
+ &showinfo=0% no title and other info before start
+% &rel=0% no display of related videos
+ },
+ url
+]{}{http://www.youtube.com/v/Mdc3o7wOwNA?rel=0}
+%]{}{http://www.youtube.com/v/k0BGuONQWUw?loop=1}
+\end{center}
+%\end{minipage}
+\caption{A YouTube video as an example of a Flash application loaded from a URL.}\label{alien}
+\end{figure}
+
+Video and sound files are always loaded and then played by a media player application. Two simple players, `VPlayer.swf' for video and `APlayer.swf' for sound, are installed along with the `media9.sty' package file. Although they do not have user controls, minimal interactivity for play, pause and resume is provided via left mouse button press and release. The players support MP4 video and MP3 sound files and streams. They were compiled, using the free Adobe Flex SDK~\cite{flex}, from XML source files which reside in the same directory as the players. More sophisticated players are available, e.\,g.~\cite{strobe}. There is no need to copy `VPlayer.swf' and `APlayer.swf' into the directory of the document source for embedding. They will be found by \LaTeX{} without taking any further action.
+
+Like YouTube videos, media players are configured via ActionScript variables which are passed using option `\verb+flashvars+'. Table~\ref{playerparams} lists parameters available for VPlayer.swf and APlayer.swf.
+
+Playback of an embedded video is shown in Fig.~\ref{video}a. Besides embedded files, `VPlayer.swf' also supports video that is streamed from remote servers via HTTP and RTMP protocols, as shown in Fig.~\ref{video}b.
+
+\begin{table}
+\centering
+\caption{Parameters for media players VPlayer.swf and APlayer.swf shipping with media9. Parameters must be passed as `{\tt\&}'-separated string using `{\tt flashvars}' option.}\label{playerparams}
+\begin{tabular}[t]{p{0.4\linewidth}p{0.5\linewidth}}\hline
+parameter & description\\\hline\hline
+{\tt source=<file path or URL>} & (required) path to embedded media file (see option `{\tt addresource}'), or URL (http, rtmp) to stream or online media file\\
+{\tt autoPlay=true|false} & if {\tt=true}, automatically starts playback after activation (see option `{\tt activation})'\\
+{\tt loop=true|false} & if {\tt=true}, media is played in a loop\\
+{\tt volume=<value between 0.0 and 1.0>} & sets volume of the sound\\
+{\tt balance=<value between -1.0 and 1.0>} & (APlayer.swf only) sets balance of sound speakers\\\hline
+\end{tabular}
+\end{table}
+
+\begin{figure}
+\centering
+\begin{Verbatim}
+\includemedia[
+ width=0.4\linewidth,height=0.3\linewidth,
+ activate=pageopen,
+ addresource=files/random.mp4,
+ flashvars={%
+ source=files/random.mp4% same path as in addresource!
+ &loop=true% loop video
+ }
+]{}{VPlayer.swf}
+\end{Verbatim}
+\makebox[\linewidth]{a)\hfill\includemedia[
+ width=0.6\linewidth,height=0.45\linewidth,
+ activate=pageopen,
+ addresource=files/random.mp4, %embeds video file
+ flashvars={%
+ source=files/random.mp4% same path as in addresource!
+ &loop=true% % loop video
+ }
+]{}{VPlayer.swf}\hfill}
+\vskip 1ex
+\begin{Verbatim}
+\includemedia[
+ width=0.6\linewidth,height=0.45\linewidth,
+ activate=pageopen,
+ flashvars={%
+ autoPlay=true%
+ &source=rtmp://streaming.music.indiana.edu:1935/onDemand/%
+ mp4:media/20090327_VarRussianTheme-h264-480.m4v%
+ }
+]{}{VPlayer.swf}
+\end{Verbatim}
+\makebox[\linewidth]{b)\hfill\includemedia[
+ width=0.6\linewidth,height=0.45\linewidth,
+ activate=pageopen,
+ flashvars={%
+ autoPlay=true%
+ &source=rtmp://streaming.music.indiana.edu:1935/onDemand/mp4:media/20090327_VarRussianTheme-h264-480.m4v%
+ }
+]{}{VPlayer.swf}\hfill}
+\caption{Example of (a) an embedded MP4 video file and (b) streamed video from an RTMP server. Both examples use `VPlayer.swf', physically embedded in the PDF.}\label{video}
+\end{figure}
+
+%\enlargethispage{2ex}
+Sound files and streams in the MP3 format can be played with `APlayer.swf'. Fig.~\ref{radio} contains examples of an audio live stream and a downloaded MP3 sound file. Instead of being embedded, the player is loaded from a CTAN mirror during runtime because an internet connection is required anyway for streaming the audio.
+
+\begin{figure}[bp]
+%\flushright
+\begin{Verbatim}
+ \includemedia[
+ flashvars={%
+ source=http://mp3.live.tv-radio.com/franceculture%
+ /all/franceculturehautdebit.mp3%
+ &autoPlay=true%
+ },
+ url %refers to APlayer.swf, not to `source' flashvar!
+ ]{\color{blue}\fbox{Listen live to Radio France Culture}}{%
+ http://mirrors.ibiblio.org/pub/mirrors/CTAN/macros/latex/%
+ contrib/media9/players/APlayer.swf%
+ }
+\end{Verbatim}
+\makebox[\linewidth]{a)\hfill\includemedia[
+ flashvars={%
+ source=http://mp3.live.tv-radio.com/franceculture/all/franceculturehautdebit.mp3%
+ &autoPlay=true%
+ },
+ url
+]{\color{blue}\fbox{Listen live to Radio France Culture}}{%
+%APlayer.swf%
+%http://www.ctan.org/tex-archive/macros/latex/contrib/media9/players/APlayer.swf%
+http://mirrors.ibiblio.org/pub/mirrors/CTAN/macros/latex/contrib/media9/players/APlayer.swf%
+}\hfill}
+\vskip 4ex
+\begin{Verbatim}
+ \includemedia[
+ flashvars={%
+ source=http://www.openbsd.org/songs/song50.mp3%
+ &autoPlay=true%
+ },
+ url
+ ]{\color{blue}\fbox{Listen to OpenBSD 4.9 release song.}}{%
+ http://mirrors.ibiblio.org/pub/mirrors/CTAN/macros/latex/%
+ contrib/media9/players/APlayer.swf%
+ }
+\end{Verbatim}
+\makebox[\linewidth]{b)\hfill\includemedia[
+ flashvars={%
+ source=http://www.openbsd.org/songs/song49.mp3%
+ &autoPlay=true%
+ },
+ url
+]{\color{blue}\fbox{Listen to OpenBSD 4.9 release song.}}{%
+%APlayer.swf%
+http://mirrors.ibiblio.org/pub/mirrors/CTAN/macros/latex/contrib/media9/players/APlayer.swf%
+}\hfill}
+\caption{Example of (a) streamed audio and (b) progressively downloaded MP3. The sound player, APlayer.swf, is loaded from a CTAN mirror upon activation.}\label{radio}
+\end{figure}
+
+\clearpage
+\section[Embedding 3D objects (with examples)]{Embedding 3D objects}
+\subsection{Introduction}\label{sec:3Dintro}
+Adobe Acrobat/Reader 7 was the first version to allow for embedding 3-di\-men\-sion\-al graphic objects, such as CAD models or 3D scientific data, that can be manipulated interactively by the user. U3D was the first supported format and was mainly developed by Right Hemisphere and Adobe. U3D had some deficiencies and was later replaced by the PRC format after Adobe purchased the original developer, the French company `Trade and Technology France'. U3D is still supported, but PRC is preferred as it allows for exact representation of curved surfaces and better compression. Both, U3D and PRC specifications are public~\cite{u3d,prc}.
+
+Currently, the only open-source PRC writing software is Asymptote~\cite{asy}. It is a descriptive 2D and 3D vector graphics language and interpreter which uses \TeX{} to typeset labels and equations, allowing for high quality mathematical figures and technical drawings. An impressive gallery of examples can be found on its Web site.
+
+MathGL~\cite{mathgl} is an open-source library for the creation of mathematical drawings which can export to the intermediate IDTF format. IDTF can then be converted into U3D using the open-source `Universal 3D Sample Software'~\cite{u3dlib}.
+
+MeshLab~\cite{meshlab} is an open-source conversion and processing software for 3D mesh data which can import from and export to a number of file formats. Its U3D export filter is based on~\cite{u3dlib}.
+
+There are a few options to \verb+\includemedia+ which define how the 3D object is positioned within the view port of a virtual camera, or conversely, how the virtual camera is positioned and oriented within a coordinate system, called `The World', which bears the 3D object at a fixed position. Fig.~\ref{3dscene} should help to visualize the scenery: The virtual camera is orbiting at a distance of $ROO$ (option `\verb+3Droo+') around the centre of orbit, specified by the position vector $\overrightarrow{COO}$ (option `\verb+3Dcoo+'); $\sphericalangle AAC$ (option `\verb+3Daac+') is the camera's aperture angle. The direction vector $\overrightarrow{C2C}$ (option `\verb+3Dc2c+') is needed to specify the initial camera position. The camera may be given an initial roll angle (option `\verb+3Droll+') around its optical axis $(-1)\cdot\overrightarrow{C2C}$.
+\begin{figure}[ht]
+ \resizebox{\linewidth}{!}{\input{files/3dsystem}}
+ \caption{Camera and 3D object in the World System $XYZ$; centre of orbit position vector \usebox{\COO}, centre of orbit to camera direction vector \usebox{\CtoC}, radius of orbit $ROO$, aperture angle of camera $\sphericalangle AAC$.}\label{3dscene}
+\end{figure}
+Fig.~\ref{3dscene} shows the camera parameters for the perspective view mode. Alternatively, the orthographic view mode may be chosen. In orthographic view, the 3D object is parallelly projected onto the virtual camera chip. Before reaching the camera chip, the projected image must be scaled in order to fit onto the chip. Orthographic view can be enabled using the `\verb+3Dortho+' option which takes the scaling factor as its argument.
+
+Above options define the default view, i.\,e. the view that is shown initially after activating the 3D object in the Reader. Of course, once activated, the camera position can be changed using the mouse and one can change forth and back between perspective and orthographic viewing modes using the 3D tool bar.
+
+By default, the virtual camera sits at the origin $(0,0,0)$ of the World, looking in the positive $Y$ direction, i.\,e. default settings of \verb+3Droo=0+, \verb+3Dcoo=0 0 0+ and \verb+3Dc2c=0 -1 0+ are assumed. (Note that $\overrightarrow{C2C}$ is the opposite of the optical axis vector.) Thus, in order to get a `front view' of the 3D object it is sufficient to set the radius of orbit, i.\,e. the distance between camera and object appropriately. Sometimes you may want to adjust the orbital centre, i.\,e. the target of the camera as well, in particular, if the object is irregularly shaped or if it is not centred around the World origin. Fortunately, it is possible to let the values of the corresponding options be determined automatically. Choosing option `\verb+3Dmenu+' adds `\emph{\sffamily Generate Default View}' to the context menu of the activated 3D scene. Selecting this entry calculates and outputs optimal camera settings which can be inserted into the option list of \verb+\includemedia+.
+
+Additional resource files that are needed to render the 3D scene can be embedded using the `\verb+addresource+' option. Typical resources are bitmaps and Flash files (even animated and interactive ones), to be used as materials or scene backgrounds, as well as additional 3D objects in the U3D or PRC file format. The allowed file formats of \emph{bitmapped} image files depend on the \LaTeX workflow. \LaTeX{} $\rightarrow$ \verb+dvips+ $\rightarrow$ \verb+ps2pdf+/Distiller accepts PS and EPS files; pdf\LaTeX{} accepts PNG, JPEG and JBIG2; \pXepLaTeX{} $\rightarrow$ \verb+(x)dvipdfmx+ accepts PNG and JPEG. 3D JavaScript is necessary to load these resources upon activation. 3D JavaScript files are attached using the `\verb+add3Djscript+' option.
+
+Below, two examples of embedded 3D files are shown. The first one, Fig.~\ref{asyex} is a PRC file generated with Asymptote. Note the text labels always facing the camera thanks to the attached 3D JavaScript file `asylabels.js'. The second example, Fig.~\ref{u3dex}, demonstrates the use of a views file which defines additional named views of the 3D object. Moreover, the possibilities of the extended 3D context menu can be evaluated. They were enabled by adding the `\verb+3Dmenu+' option to \verb+\includemedia+. All part and scene rendering attributes that can be changed via the `\emph{\sffamily Part Options}' and `\emph{\sffamily Viewing Options}' menu entries, as well as a cross section to be added with the `\emph{\sffamily Cross Section}' menu entry can be saved into a new view (`\emph{\sffamily Get Current View}'). Position, orientation and scaling of individual parts and of the cross section can be changed using the keyboard (keys \keys{\arrowkeyleft}, \keys{\arrowkeyright}, \keys{\arrowkeyup}, \keys{\arrowkeydown}, \keys{X}, \keys{\shift+X}, \keys{Y}, \keys{\shift+Y}, \keys{Z}, \keys{\shift+Z}, \keys{S}, \keys{\shift+S}).
+
+\begin{figure}[bp]
+\begin{Verbatim}
+\includemedia[
+ width=0.8\linewidth,height=0.8\linewidth,
+ activate=pageopen,
+ add3Djscript=asylabels.js, %upright text labels
+ add3Djscript=3Dspintool.js, %let scene rotate about z-axis
+ % 3Dcoo, 3Droo values found with `Generate Default View' from
+ % context menu
+ 3Dmenu,
+ 3Dcoo=-21.371112823486328 -19.702425003051758 -395.4008483886719,
+ 3Droo=472.3543474473915,
+ 3Dc2c=4 2 3
+]{}{epix.prc}
+\end{Verbatim}
+\centering
+\includemedia[
+ width=0.8\linewidth,height=0.8\linewidth,
+ activate=pageopen,
+ add3Djscript=asylabels.js, %upright text labels
+ add3Djscript=3Dspintool.js, %let scene rotate about z-axis
+ % 3Dcoo, 3Droo values found with `Generate Default View' from
+ % context menu
+ 3Dmenu,
+ 3Dcoo=-21.371112823486328 -19.702425003051758 -395.4008483886719,
+ 3Droo=472.3543474473915,
+ 3Dc2c=4 2 3,
+]{}{epix.prc}
+\caption{Embedded PRC file produced with Asymptote, making use of convenience 3D JavaScripts `asylabels.js' and `3Dspintool.js' mentioned
+{\leavevmode\pdfstartlink attr{/Border[0 0 1]/C[0 0 1]/H/I}user{/Subtype/Link/A<</D(3dscripts)/S/GoTo>>}above\pdfendlink}.}\label{asyex}
+\end{figure}
+
+\begin{figure}[bp]
+\begin{Verbatim}
+\includemedia[
+ width=0.5\linewidth,height=0.5\linewidth,
+ activate=pageopen,
+ 3Dtoolbar,
+ 3Dviews=dice.vws,
+ 3Dmenu
+]{}{dice.u3d}
+\end{Verbatim}
+Contents of `dice.vws':
+\begin{Verbatim}
+ VIEW=Front
+ ROO=27
+ END
+ VIEW=Back
+ ROO=27
+ C2C=0 1 0
+ END
+ VIEW=Left
+ ROO=27
+ C2C=-1 0 0
+ END
+ VIEW=Right
+ ROO=27
+ C2C=1 0 0
+ END
+ VIEW=Top
+ ROO=27
+ C2C=0 0 1
+ END
+ VIEW=Fish Eye at Centre
+ AAC=130
+ END
+\end{Verbatim}
+\centering
+\includemedia[
+ width=0.5\linewidth,height=0.5\linewidth,
+ activate=pageopen,
+ 3Dtoolbar,
+ 3Dviews=dice.vws,
+ 3Dmenu,
+]{}{dice.u3d}
+\caption{Embedded U3D file, based on a VRML model by Peter Whitehouse, \url{http://www.wonko.info/vrml/index.htm}; conversion to U3D was done using DeepExploration\textsuperscript{\scriptsize\textregistered}\cite{dexp}. The file `{\tt dice.vws}' provides predefined views to be selected from the 3D toolbar or by right click.}\label{u3dex}
+\end{figure}
+
+\clearpage
+\subsection{3D quick-start guide}\label{sec:3Dtut}
+\begin{enumerate}
+ \item Insert the 3D object with default camera settings and with extended context menu enabled (option `\verb+3Dmenu+'):
+
+\begin{Verbatim}
+ \includemedia[
+ width=0.5\linewidth,height=0.5\linewidth,
+ activate=pageopen,
+ 3Dmenu
+ ]{}{myfile.u3d}
+\end{Verbatim}
+
+ \item Compile the document.
+ \item Open the PDF document in Adobe Reader and go to the page containing the 3D object. Select `\emph{\sffamily Generate Default View}' from the 3D context menu (right mouse click) and wait for the JavaScript console to pop up. Optionally, drag the object with the mouse to change the viewpoint of the camera and select `\emph{\sffamily Generate Default View}' again. This will re-adjust the distance between camera and target to fit all visible parts tightly into the viewport. The options printed into the console are updated accordingly.
+ \item Copy the camera settings ({\tt 3Droo=...}, {\tt 3Dcoo=...}, etc.) from the console into the option list of {\tt \string\include\-media}.
+ \item Compile the document again.
+ \xdef\lastcount{\theenumi}
+\end{enumerate}
+
+\emph{Optional steps} (option `{\tt 3Dmenu}' required):
+
+\begin{enumerate}
+ \setcounter{enumi}{\lastcount}
+ \item Additional, named views; cross sections; rescaled, repositioned parts:
+ \begin{itemize}
+ \item[a)] Open a text file, e.\,g. `myviews.vws', to be populated with additional views of the 3D object.
+ \item[b)] Manipulate the 3D object using the mouse (camera position) and via 3D context menu items `\emph{\sffamily Part Options}' and `\emph{\sffamily Viewing Options}' (visibility, rendering attributes, background etc.); the camera target can be moved into the centre of a single part via `\emph{\sffamily Part Options}'$\rightarrow$`\emph{\sffamily Zoom to Part}'.
+ \item[c)] Add a cross section plane, adjust its position using the keyboard, keyboard keys are given \hyperlink{3dmenu}{here}.
+ \item[d)] Adjust scaling and position of individual parts using the keyboard, keyboard keys are given \hyperlink{3dmenu}{here}.
+ \item[e)] Re-adjust the camera distance using either `\emph{\sffamily Generate Default View}' or `\emph{\sffamily Part Options}'$\rightarrow$`\emph{\sffamily Fit Visible}'.
+ \item[f)] When you are done, select `\emph{\sffamily Get Current View}' to get the {\tt VIEW} section, readily formatted for insertion into the views file. Repeat steps (a)--(f) to get any number of views you want to define. The views file can be edited manually to give meaningful names to the views (change the value of the {\tt VIEW} key), or to further tweak camera settings, opacity, part options etc.
+ \item[g)] Attach the views file with option `{\tt 3Dviews}':
+\begin{Verbatim}
+ \includemedia[
+ width=0.5\linewidth,height=0.5\linewidth,
+ activate=pageopen,
+ 3Dviews=myviews.vws,
+ 3Dmenu
+ ]{}{myfile.u3d}
+\end{Verbatim}
+ If you are satisfied with the predefined views in the views file, the default view first specified through the options of {\tt\string\includemovie} can be deleted. The first view in the views file becomes the default view then.
+ \end{itemize}
+ \item Associate any number of 3D JavaScript files with the 3D object:
+\begin{Verbatim}
+ \includemedia[
+ width=0.5\linewidth,height=0.5\linewidth,
+ activate=pageopen,
+ add3Djscript=somescript.js,
+ add3Djscript=otherscript.js,
+ 3Dviews=myviews.vws,
+ 3Dmenu
+ ]{}{myfile.u3d}
+\end{Verbatim}
+A few 3D JavaScript files ready to be used are already installed along with `media9.sty', see \hyperlink{3dscripts}{above}.
+\end{enumerate}
+
+\section{Acknowledgements}
+This package was written using the new \LaTeX3 syntax which was a lot of fun. Many thanks to the \LaTeX3 team!
+
+\begin{thebibliography}{9}
+ \bibitem{strobe} Adobe Systems Inc.: \emph{Strobe Media Playback}, 2010, available at \url{http://osmf.org/strobe_mediaplayback.html}
+
+ \bibitem{supplement} Adobe Systems Inc.: \emph{Adobe Supplement to ISO 32000, BaseVersion 1.7, ExtensionLevel 3}, 2008, available at \url{http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/adobe_supplement_iso32000.pdf}
+
+ \bibitem{jscript3D} Adobe Systems Inc.: \emph{JavaScript for Acrobat 3D Annotations API Ref\-er\-ence}, available at \url{http://livedocs.adobe.com/acrobat_sdk/10/Acrobat10_HTMLHelp/JS_3D_Intro.90.1.html}
+
+ \bibitem{jscript} Adobe Systems Inc.: \emph{JavaScript for Acrobat API Reference}, available at \url{http://livedocs.adobe.com/acrobat_sdk/10/Acrobat10_HTMLHelp/JS_API_AcroJSPreface.87.1.html}
+
+ \bibitem{flex} Adobe Systems Inc.: \emph{Adobe Flex SDK}, available at \url{http://www.adobe.com/products/flex.html}
+
+ \bibitem{u3d} ECMA International: \emph{Universal 3D File Format (ECMA-363), 4th Edition}, 2007, available at \url{http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-363\%204th\%20Edition.pdf}
+
+ \bibitem{prc} Adobe Systems Inc.: \emph{PRC Format Specification}, available at \url{http://livedocs.adobe.com/acrobat_sdk/10/Acrobat10_HTMLHelp/API_References/PRCReference/PRC_Format_Specification/index.html}
+
+ \bibitem{asy} A. Hammerlindl, J. Bowman and T. Prince: \emph{Asymptote: The Vector Graphics Language}, available at \url{http://asymptote.sourceforge.net}
+
+ \bibitem{mathgl} A. A. Balakin: \emph{MathGL - library for scientific graphics}, available at \url{http://mathgl.sourceforge.net}
+
+ \bibitem{u3dlib} T. O'Rourke, T. Strelchun: \emph{Universal 3D Sample Software}, available at \url{http://sourceforge.net/projects/u3d}
+
+ \bibitem{meshlab} P. Cignoni \emph{et al.}: \emph{MeshLab}, available at \url{http://meshlab.sourceforge.net}
+
+ \bibitem{dexp} RightHemisphere Inc.: \emph{DeepExploration}, \url{http://www.righthemisphere.com/products/dexp/}
+% \bibitem{swftools} R. B\"ohme, M. Kramm: \emph{Swftools}, available at \url{http://www.swftools.org}
+\end{thebibliography}
+
+\end{document}
diff --git a/Master/texmf-dist/tex/latex/media9/javascript/3Dmenu.js b/Master/texmf-dist/tex/latex/media9/javascript/3Dmenu.js
new file mode 100644
index 00000000000..b6c82a22876
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/media9/javascript/3Dmenu.js
@@ -0,0 +1,885 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// (C) 2012, Alexander Grahn
+//
+// 3Dmenu.js
+//
+// version 20120301
+//
+////////////////////////////////////////////////////////////////////////////////
+//
+// 3D JavaScript used by media9.sty
+//
+// Extended functionality of the (right click) context menu of 3D annotations.
+//
+// 1.) Adds the following items to the 3D context menu:
+//
+// * `Generate Default View'
+//
+// Finds good default camera settings, returned as options for use with
+// the \includemedia command.
+//
+// * `Get Current View'
+//
+// Determines camera, cross section and part settings of the current view,
+// returned as `VIEW' section that can be copied into a views file of
+// additional views. The views file is inserted using the `3Dviews' option
+// of \includemedia.
+//
+// * `Cross Section'
+//
+// Toggle switch to add or remove a cross section into or from the current
+// view. The cross section can be moved in the x, y, z directions using x,
+// y, z and X, Y, Z keys on the keyboard and be tilted against and spun
+// around the upright Z axis using the Up/Down and Left/Right arrow keys.
+//
+// 2.) Enables manipulation of position and orientation of indiviual parts in
+// the 3D scene. Parts which have been selected with the mouse can be
+// moved around and rotated like the cross section as described above, as
+// well as scaled using the s and S keys.
+//
+// This work may be distributed and/or modified under the
+// conditions of the LaTeX Project Public License, either version 1.3
+// of this license or (at your option) any later version.
+// The latest version of this license is in
+// http://www.latex-project.org/lppl.txt
+// and version 1.3 or later is part of all distributions of LaTeX
+// version 2005/12/01 or later.
+//
+// This work has the LPPL maintenance status `maintained'.
+//
+// The Current Maintainer of this work is A. Grahn.
+//
+// The code borrows heavily from Bernd Gaertners `Miniball' software,
+// originally written in C++, for computing the smallest enclosing ball of a
+// set of points; see: http://www.inf.ethz.ch/personal/gaertner/miniball.html
+//
+////////////////////////////////////////////////////////////////////////////////
+//host.console.show();
+
+//constructor for doubly linked list
+function List(){
+ this.first_node=null;
+ this.last_node=new Node(undefined);
+}
+List.prototype.push_back=function(x){
+ var new_node=new Node(x);
+ if(this.first_node==null){
+ this.first_node=new_node;
+ new_node.prev=null;
+ }else{
+ new_node.prev=this.last_node.prev;
+ new_node.prev.next=new_node;
+ }
+ new_node.next=this.last_node;
+ this.last_node.prev=new_node;
+};
+List.prototype.move_to_front=function(it){
+ var node=it.get();
+ if(node.next!=null && node.prev!=null){
+ node.next.prev=node.prev;
+ node.prev.next=node.next;
+ node.prev=null;
+ node.next=this.first_node;
+ this.first_node.prev=node;
+ this.first_node=node;
+ }
+};
+List.prototype.begin=function(){
+ var i=new Iterator();
+ i.target=this.first_node;
+ return(i);
+};
+List.prototype.end=function(){
+ var i=new Iterator();
+ i.target=this.last_node;
+ return(i);
+};
+function Iterator(it){
+ if( it!=undefined ){
+ this.target=it.target;
+ }else {
+ this.target=null;
+ }
+}
+Iterator.prototype.set=function(it){this.target=it.target;};
+Iterator.prototype.get=function(){return(this.target);};
+Iterator.prototype.deref=function(){return(this.target.data);};
+Iterator.prototype.incr=function(){
+ if(this.target.next!=null) this.target=this.target.next;
+};
+//constructor for node objects that populate the linked list
+function Node(x){
+ this.prev=null;
+ this.next=null;
+ this.data=x;
+}
+function sqr(r){return(r*r);}//helper function
+
+//Miniball algorithm by B. Gaertner
+function Basis(){
+ this.m=0;
+ this.q0=new Array(3);
+ this.z=new Array(4);
+ this.f=new Array(4);
+ this.v=new Array(new Array(3), new Array(3), new Array(3), new Array(3));
+ this.a=new Array(new Array(3), new Array(3), new Array(3), new Array(3));
+ this.c=new Array(new Array(3), new Array(3), new Array(3), new Array(3));
+ this.sqr_r=new Array(4);
+ this.current_c=this.c[0];
+ this.current_sqr_r=0;
+ this.reset();
+}
+Basis.prototype.center=function(){return(this.current_c);};
+Basis.prototype.size=function(){return(this.m);};
+Basis.prototype.pop=function(){--this.m;};
+Basis.prototype.excess=function(p){
+ var e=-this.current_sqr_r;
+ for(var k=0;k<3;++k){
+ e+=sqr(p[k]-this.current_c[k]);
+ }
+ return(e);
+};
+Basis.prototype.reset=function(){
+ this.m=0;
+ for(var j=0;j<3;++j){
+ this.c[0][j]=0;
+ }
+ this.current_c=this.c[0];
+ this.current_sqr_r=-1;
+};
+Basis.prototype.push=function(p){
+ var i, j;
+ var eps=1e-32;
+ if(this.m==0){
+ for(i=0;i<3;++i){
+ this.q0[i]=p[i];
+ }
+ for(i=0;i<3;++i){
+ this.c[0][i]=this.q0[i];
+ }
+ this.sqr_r[0]=0;
+ }else {
+ for(i=0;i<3;++i){
+ this.v[this.m][i]=p[i]-this.q0[i];
+ }
+ for(i=1;i<this.m;++i){
+ this.a[this.m][i]=0;
+ for(j=0;j<3;++j){
+ this.a[this.m][i]+=this.v[i][j]*this.v[this.m][j];
+ }
+ this.a[this.m][i]*=(2/this.z[i]);
+ }
+ for(i=1;i<this.m;++i){
+ for(j=0;j<3;++j){
+ this.v[this.m][j]-=this.a[this.m][i]*this.v[i][j];
+ }
+ }
+ this.z[this.m]=0;
+ for(j=0;j<3;++j){
+ this.z[this.m]+=sqr(this.v[this.m][j]);
+ }
+ this.z[this.m]*=2;
+ if(this.z[this.m]<eps*this.current_sqr_r) return(false);
+ var e=-this.sqr_r[this.m-1];
+ for(i=0;i<3;++i){
+ e+=sqr(p[i]-this.c[this.m-1][i]);
+ }
+ this.f[this.m]=e/this.z[this.m];
+ for(i=0;i<3;++i){
+ this.c[this.m][i]=this.c[this.m-1][i]+this.f[this.m]*this.v[this.m][i];
+ }
+ this.sqr_r[this.m]=this.sqr_r[this.m-1]+e*this.f[this.m]/2;
+ }
+ this.current_c=this.c[this.m];
+ this.current_sqr_r=this.sqr_r[this.m];
+ ++this.m;
+ return(true);
+};
+function Miniball(){
+ this.L=new List();
+ this.B=new Basis();
+ this.support_end=new Iterator();
+}
+Miniball.prototype.mtf_mb=function(it){
+ var i=new Iterator(it);
+ this.support_end.set(this.L.begin());
+ if((this.B.size())==4) return;
+ for(var k=new Iterator(this.L.begin());k.get()!=i.get();){
+ var j=new Iterator(k);
+ k.incr();
+ if(this.B.excess(j.deref()) > 0){
+ if(this.B.push(j.deref())){
+ this.mtf_mb(j);
+ this.B.pop();
+ if(this.support_end.get()==j.get())
+ this.support_end.incr();
+ this.L.move_to_front(j);
+ }
+ }
+ }
+};
+Miniball.prototype.check_in=function(b){
+ this.L.push_back(b);
+};
+Miniball.prototype.build=function(){
+ this.B.reset();
+ this.support_end.set(this.L.begin());
+ this.mtf_mb(this.L.end());
+};
+Miniball.prototype.center=function(){
+ return(this.B.center());
+};
+Miniball.prototype.radius=function(){
+ return(Math.sqrt(this.B.current_sqr_r));
+};
+
+//functions called by menu items
+function calc3Dopts () {
+ //create Miniball object
+ var mb=new Miniball();
+ //auxiliary vector
+ var corner=new Vector3();
+ //iterate over all visible mesh nodes in the scene
+ for(i=0;i<scene.meshes.count;i++){
+ var mesh=scene.meshes.getByIndex(i);
+ if(!mesh.visible) continue;
+ //local to parent transformation matrix
+ var trans=mesh.transform;
+ //build local to world transformation matrix by recursively
+ //multiplying the parent's transf. matrix on the right
+ var parent=mesh.parent;
+ while(parent.transform){
+ trans=trans.multiply(parent.transform);
+ parent=parent.parent;
+ }
+ //get the bbox of the mesh (local coordinates)
+ var bbox=mesh.computeBoundingBox();
+ //transform the local bounding box corner coordinates to
+ //world coordinates for bounding sphere determination
+ //BBox.min
+ corner.set(bbox.min);
+ corner.set(trans.transformPosition(corner));
+ mb.check_in(new Array(corner.x, corner.y, corner.z));
+ //BBox.max
+ corner.set(bbox.max);
+ corner.set(trans.transformPosition(corner));
+ mb.check_in(new Array(corner.x, corner.y, corner.z));
+ //remaining six BBox corners
+ corner.set(bbox.min.x, bbox.max.y, bbox.max.z);
+ corner.set(trans.transformPosition(corner));
+ mb.check_in(new Array(corner.x, corner.y, corner.z));
+ corner.set(bbox.min.x, bbox.min.y, bbox.max.z);
+ corner.set(trans.transformPosition(corner));
+ mb.check_in(new Array(corner.x, corner.y, corner.z));
+ corner.set(bbox.min.x, bbox.max.y, bbox.min.z);
+ corner.set(trans.transformPosition(corner));
+ mb.check_in(new Array(corner.x, corner.y, corner.z));
+ corner.set(bbox.max.x, bbox.min.y, bbox.min.z);
+ corner.set(trans.transformPosition(corner));
+ mb.check_in(new Array(corner.x, corner.y, corner.z));
+ corner.set(bbox.max.x, bbox.min.y, bbox.max.z);
+ corner.set(trans.transformPosition(corner));
+ mb.check_in(new Array(corner.x, corner.y, corner.z));
+ corner.set(bbox.max.x, bbox.max.y, bbox.min.z);
+ corner.set(trans.transformPosition(corner));
+ mb.check_in(new Array(corner.x, corner.y, corner.z));
+ }
+ //compute the smallest enclosing bounding sphere
+ mb.build();
+ //
+ //current camera settings
+ //
+ var camera=scene.cameras.getByIndex(0);
+ var res=''; //initialize result string
+ //aperture angle of the virtual camera (perspective projection) *or*
+ //orthographic scale (orthographic projection)
+ if(camera.projectionType==camera.TYPE_PERSPECTIVE){
+ var aac=camera.fov*180/Math.PI;
+ if(host.util.printf('%.4f', aac)!=30)
+ res+=host.util.printf('\n3Daac=%s,', aac);
+ }else{
+ camera.viewPlaneSize=2.*mb.radius();
+ res+=host.util.printf('\n3Dortho=%s,', 1./camera.viewPlaneSize);
+ }
+ //camera roll
+ var roll = camera.roll*180/Math.PI;
+ if(host.util.printf('%.4f', roll)!=0)
+ res+=host.util.printf('\n3Droll=%s,',roll);
+ //target to camera vector
+ var c2c=new Vector3();
+ c2c.set(camera.position);
+ c2c.subtractInPlace(camera.targetPosition);
+ c2c.normalize();
+ var x=(Math.abs(c2c.x) < 1e-12 ? 0 : c2c.x);
+ var y=(Math.abs(c2c.y) < 1e-12 ? 0 : c2c.y);
+ var z=(Math.abs(c2c.z) < 1e-12 ? 0 : c2c.z);
+ if(!(x==0 && y==-1 && z==0))
+ res+=host.util.printf('\n3Dc2c=%s %s %s,', x, y, z);
+ //
+ //new camera settings
+ //
+ //bounding sphere centre --> new camera target
+ var coo=new Vector3();
+ coo.set((mb.center())[0], (mb.center())[1], (mb.center())[2]);
+ coo.x = (Math.abs(coo.x) < 1e-12 ? 0 : coo.x);
+ coo.y = (Math.abs(coo.y) < 1e-12 ? 0 : coo.y);
+ coo.z = (Math.abs(coo.z) < 1e-12 ? 0 : coo.z);
+ if(coo.length)
+ res+=host.util.printf('\n3Dcoo=%s %s %s,', coo.x, coo.y, coo.z);
+ //radius of orbit
+ if(camera.projectionType==camera.TYPE_PERSPECTIVE){
+ var roo=mb.radius()/ Math.sin(aac * Math.PI/ 360.);
+ }else{
+ //orthographic projection
+ var roo=mb.radius();
+ }
+ res+=host.util.printf('\n3Droo=%s,', roo);
+ //update camera settings in the viewer
+ var currol=camera.roll;
+ camera.targetPosition.set(coo);
+ camera.position.set(coo.add(c2c.scale(roo)));
+ camera.roll=currol;
+ //determine background colour
+ rgb=scene.background.getColor();
+ if(!(rgb.r==1 && rgb.g==1 && rgb.b==1))
+ res+=host.util.printf('\n3Dbg=%s %s %s,', rgb.r, rgb.g, rgb.b);
+ //determine lighting scheme
+ switch(scene.lightScheme){
+ case scene.LIGHT_MODE_FILE:
+ curlights='Artwork';break;
+ case scene.LIGHT_MODE_NONE:
+ curlights='None';break;
+ case scene.LIGHT_MODE_WHITE:
+ curlights='White';break;
+ case scene.LIGHT_MODE_DAY:
+ curlights='Day';break;
+ case scene.LIGHT_MODE_NIGHT:
+ curlights='Night';break;
+ case scene.LIGHT_MODE_BRIGHT:
+ curlights='Hard';break;
+ case scene.LIGHT_MODE_RGB:
+ curlights='Primary';break;
+ case scene.LIGHT_MODE_BLUE:
+ curlights='Blue';break;
+ case scene.LIGHT_MODE_RED:
+ curlights='Red';break;
+ case scene.LIGHT_MODE_CUBE:
+ curlights='Cube';break;
+ case scene.LIGHT_MODE_CAD:
+ curlights='CAD';break;
+ case scene.LIGHT_MODE_HEADLAMP:
+ curlights='Headlamp';break;
+ }
+ if(curlights!='Artwork')
+ res+=host.util.printf('\n3Dlights=%s,', curlights);
+ //determine global render mode
+ switch(scene.renderMode){
+ case scene.RENDER_MODE_BOUNDING_BOX:
+ currender='BoundingBox';break;
+ case scene.RENDER_MODE_TRANSPARENT_BOUNDING_BOX:
+ currender='TransparentBoundingBox';break;
+ case scene.RENDER_MODE_TRANSPARENT_BOUNDING_BOX_OUTLINE:
+ currender='TransparentBoundingBoxOutline';break;
+ case scene.RENDER_MODE_VERTICES:
+ currender='Vertices';break;
+ case scene.RENDER_MODE_SHADED_VERTICES:
+ currender='ShadedVertices';break;
+ case scene.RENDER_MODE_WIREFRAME:
+ currender='Wireframe';break;
+ case scene.RENDER_MODE_SHADED_WIREFRAME:
+ currender='ShadedWireframe';break;
+ case scene.RENDER_MODE_SOLID:
+ currender='Solid';break;
+ case scene.RENDER_MODE_TRANSPARENT:
+ currender='Transparent';break;
+ case scene.RENDER_MODE_SOLID_WIREFRAME:
+ currender='SolidWireframe';break;
+ case scene.RENDER_MODE_TRANSPARENT_WIREFRAME:
+ currender='TransparentWireframe';break;
+ case scene.RENDER_MODE_ILLUSTRATION:
+ currender='Illustration';break;
+ case scene.RENDER_MODE_SOLID_OUTLINE:
+ currender='SolidOutline';break;
+ case scene.RENDER_MODE_SHADED_ILLUSTRATION:
+ currender='ShadedIllustration';break;
+ case scene.RENDER_MODE_HIDDEN_WIREFRAME:
+ currender='HiddenWireframe';break;
+ }
+ if(currender!='Solid')
+ res+=host.util.printf('\n3Drender=%s,', currender);
+ //write result string to the console
+ host.console.show();
+// host.console.clear();
+ host.console.println('%%\n%% Copy and paste the following text to the\n'+
+ '%% option list of \\includemedia!\n%%' + res + '\n');
+}
+
+function get3Dview () {
+ var camera=scene.cameras.getByIndex(0);
+ var coo=camera.targetPosition;
+ var c2c=camera.position.subtract(coo);
+ var roo=c2c.length;
+ c2c.normalize();
+ var res='VIEW%=insert optional name here\n';
+ var x = (Math.abs(coo.x) < 1e-12 ? 0 : coo.x);
+ var y = (Math.abs(coo.y) < 1e-12 ? 0 : coo.y);
+ var z = (Math.abs(coo.z) < 1e-12 ? 0 : coo.z);
+ if(!(x==0 && y==0 && z==0))
+ res+=host.util.printf(' COO=%s %s %s\n', coo.x, coo.y, coo.z);
+ x = (Math.abs(c2c.x) < 1e-12 ? 0 : c2c.x);
+ y = (Math.abs(c2c.y) < 1e-12 ? 0 : c2c.y);
+ z = (Math.abs(c2c.z) < 1e-12 ? 0 : c2c.z);
+ if(!(x==0 && y==-1 && z==0))
+ res+=host.util.printf(' C2C=%s %s %s\n', x, y, z);
+ if(roo > 0.11e-17)
+ res+=host.util.printf(' ROO=%s\n', roo);
+ var roll = camera.roll*180/Math.PI;
+ if(host.util.printf('%.4f', roll)!=0)
+ res+=host.util.printf(' ROLL=%s\n', roll);
+ if(camera.projectionType==camera.TYPE_PERSPECTIVE){
+ var aac=camera.fov * 180/Math.PI;
+ if(host.util.printf('%.4f', aac)!=30)
+ res+=host.util.printf(' AAC=%s\n', aac);
+ }else{
+ if(host.util.printf('%.4f', camera.viewPlaneSize)!=1)
+ res+=host.util.printf(' ORTHO=%s\n', 1./camera.viewPlaneSize);
+ }
+ rgb=scene.background.getColor();
+ if(!(rgb.r==1 && rgb.g==1 && rgb.b==1))
+ res+=host.util.printf(' BGCOLOR=%s %s %s\n', rgb.r, rgb.g, rgb.b);
+ switch(scene.lightScheme){
+ case scene.LIGHT_MODE_FILE:
+ curlights='Artwork';break;
+ case scene.LIGHT_MODE_NONE:
+ curlights='None';break;
+ case scene.LIGHT_MODE_WHITE:
+ curlights='White';break;
+ case scene.LIGHT_MODE_DAY:
+ curlights='Day';break;
+ case scene.LIGHT_MODE_NIGHT:
+ curlights='Night';break;
+ case scene.LIGHT_MODE_BRIGHT:
+ curlights='Hard';break;
+ case scene.LIGHT_MODE_RGB:
+ curlights='Primary';break;
+ case scene.LIGHT_MODE_BLUE:
+ curlights='Blue';break;
+ case scene.LIGHT_MODE_RED:
+ curlights='Red';break;
+ case scene.LIGHT_MODE_CUBE:
+ curlights='Cube';break;
+ case scene.LIGHT_MODE_CAD:
+ curlights='CAD';break;
+ case scene.LIGHT_MODE_HEADLAMP:
+ curlights='Headlamp';break;
+ }
+ if(curlights!='Artwork')
+ res+=' LIGHTS='+curlights+'\n';
+ switch(scene.renderMode){
+ case scene.RENDER_MODE_BOUNDING_BOX:
+ defaultrender='BoundingBox';break;
+ case scene.RENDER_MODE_TRANSPARENT_BOUNDING_BOX:
+ defaultrender='TransparentBoundingBox';break;
+ case scene.RENDER_MODE_TRANSPARENT_BOUNDING_BOX_OUTLINE:
+ defaultrender='TransparentBoundingBoxOutline';break;
+ case scene.RENDER_MODE_VERTICES:
+ defaultrender='Vertices';break;
+ case scene.RENDER_MODE_SHADED_VERTICES:
+ defaultrender='ShadedVertices';break;
+ case scene.RENDER_MODE_WIREFRAME:
+ defaultrender='Wireframe';break;
+ case scene.RENDER_MODE_SHADED_WIREFRAME:
+ defaultrender='ShadedWireframe';break;
+ case scene.RENDER_MODE_SOLID:
+ defaultrender='Solid';break;
+ case scene.RENDER_MODE_TRANSPARENT:
+ defaultrender='Transparent';break;
+ case scene.RENDER_MODE_SOLID_WIREFRAME:
+ defaultrender='SolidWireframe';break;
+ case scene.RENDER_MODE_TRANSPARENT_WIREFRAME:
+ defaultrender='TransparentWireframe';break;
+ case scene.RENDER_MODE_ILLUSTRATION:
+ defaultrender='Illustration';break;
+ case scene.RENDER_MODE_SOLID_OUTLINE:
+ defaultrender='SolidOutline';break;
+ case scene.RENDER_MODE_SHADED_ILLUSTRATION:
+ defaultrender='ShadedIllustration';break;
+ case scene.RENDER_MODE_HIDDEN_WIREFRAME:
+ defaultrender='HiddenWireframe';break;
+ }
+ if(defaultrender!='Solid')
+ res+=' RENDERMODE='+defaultrender+'\n';
+ for(var i=0;i<scene.meshes.count;i++){
+ var mesh=scene.meshes.getByIndex(i);
+ var meshUTFName = '';
+ for (var j=0; j<mesh.name.length; j++) {
+ var theUnicode = mesh.name.charCodeAt(j).toString(16);
+ while (theUnicode.length<4) theUnicode = '0' + theUnicode;
+ meshUTFName += theUnicode;
+ }
+ var end=mesh.name.lastIndexOf('.');
+ if(end>0) var meshUserName=mesh.name.substr(0,end);
+ else var meshUserName=mesh.name;
+ respart=' PART='+meshUserName+'\n';
+ respart+=' UTF16NAME='+meshUTFName+'\n';
+ defaultvals=true;
+ if(!mesh.visible){
+ respart+=' VISIBLE=false\n';
+ defaultvals=false;
+ }
+ if(mesh.opacity<1.0){
+ respart+=' OPACITY='+mesh.opacity+'\n';
+ defaultvals=false;
+ }
+ currender=defaultrender;
+ switch(mesh.renderMode){
+ case scene.RENDER_MODE_BOUNDING_BOX:
+ currender='BoundingBox';break;
+ case scene.RENDER_MODE_TRANSPARENT_BOUNDING_BOX:
+ currender='TransparentBoundingBox';break;
+ case scene.RENDER_MODE_TRANSPARENT_BOUNDING_BOX_OUTLINE:
+ currender='TransparentBoundingBoxOutline';break;
+ case scene.RENDER_MODE_VERTICES:
+ currender='Vertices';break;
+ case scene.RENDER_MODE_SHADED_VERTICES:
+ currender='ShadedVertices';break;
+ case scene.RENDER_MODE_WIREFRAME:
+ currender='Wireframe';break;
+ case scene.RENDER_MODE_SHADED_WIREFRAME:
+ currender='ShadedWireframe';break;
+ case scene.RENDER_MODE_SOLID:
+ currender='Solid';break;
+ case scene.RENDER_MODE_TRANSPARENT:
+ currender='Transparent';break;
+ case scene.RENDER_MODE_SOLID_WIREFRAME:
+ currender='SolidWireframe';break;
+ case scene.RENDER_MODE_TRANSPARENT_WIREFRAME:
+ currender='TransparentWireframe';break;
+ case scene.RENDER_MODE_ILLUSTRATION:
+ currender='Illustration';break;
+ case scene.RENDER_MODE_SOLID_OUTLINE:
+ currender='SolidOutline';break;
+ case scene.RENDER_MODE_SHADED_ILLUSTRATION:
+ currender='ShadedIllustration';break;
+ case scene.RENDER_MODE_HIDDEN_WIREFRAME:
+ currender='HiddenWireframe';break;
+ //case scene.RENDER_MODE_DEFAULT:
+ // currender='Default';break;
+ }
+ if(currender!=defaultrender){
+ respart+=' RENDERMODE='+currender+'\n';
+ defaultvals=false;
+ }
+ if(!mesh.transform.isEqual(origtrans[mesh.name])){
+ var lvec=mesh.transform.transformDirection(new Vector3(1,0,0));
+ var uvec=mesh.transform.transformDirection(new Vector3(0,1,0));
+ var vvec=mesh.transform.transformDirection(new Vector3(0,0,1));
+ respart+=' TRANSFORM='
+ +(Math.abs(lvec.x) < 1e-12 ? 0 : lvec.x)+' '
+ +(Math.abs(lvec.y) < 1e-12 ? 0 : lvec.y)+' '
+ +(Math.abs(lvec.z) < 1e-12 ? 0 : lvec.z)+' '
+ +(Math.abs(uvec.x) < 1e-12 ? 0 : uvec.x)+' '
+ +(Math.abs(uvec.y) < 1e-12 ? 0 : uvec.y)+' '
+ +(Math.abs(uvec.z) < 1e-12 ? 0 : uvec.z)+' '
+ +(Math.abs(vvec.x) < 1e-12 ? 0 : vvec.x)+' '
+ +(Math.abs(vvec.y) < 1e-12 ? 0 : vvec.y)+' '
+ +(Math.abs(vvec.z) < 1e-12 ? 0 : vvec.z)+' '
+ +(Math.abs(mesh.transform.translation.x) < 1e-12 ? 0 : mesh.transform.translation.x)+' '
+ +(Math.abs(mesh.transform.translation.y) < 1e-12 ? 0 : mesh.transform.translation.y)+' '
+ +(Math.abs(mesh.transform.translation.z) < 1e-12 ? 0 : mesh.transform.translation.z)+'\n';
+ defaultvals=false;
+ }
+ respart+=' END\n';
+ if(!defaultvals) res+=respart;
+ }
+
+ //detect existing Clipping Plane (3DCrossSection)
+ var clip=null;
+ try {
+ clip=scene.nodes.getByName("Clipping Plane");
+ }catch(e){
+ var ndcnt=scene.nodes.count;
+ clip=scene.createClippingPlane();
+ if(ndcnt!=scene.nodes.count){
+ clip.remove();
+ clip=null;
+ }
+ }
+ if(clip){
+ var centre=clip.transform.translation;
+ var normal=clip.transform.transformDirection(new Vector3(0,0,1));
+ res+=' CROSSSECT\n';
+ var x = (Math.abs(centre.x) < 1e-12 ? 0 : centre.x);
+ var y = (Math.abs(centre.y) < 1e-12 ? 0 : centre.y);
+ var z = (Math.abs(centre.z) < 1e-12 ? 0 : centre.z);
+ if(!(x==0 && y==0 && z==0))
+ res+=host.util.printf(' CENTER=%s %s %s\n', x, y, z);
+ var x = (Math.abs(normal.x) < 1e-12 ? 0 : normal.x);
+ var y = (Math.abs(normal.y) < 1e-12 ? 0 : normal.y);
+ var z = (Math.abs(normal.z) < 1e-12 ? 0 : normal.z);
+ if(!(x==1 && y==0 && z==0))
+ res+=host.util.printf(' NORMAL=%s %s %s\n', x, y, z);
+ res+=' END\n';
+ }
+ res+='END\n';
+ host.console.show();
+// host.console.clear();
+ host.console.println('%%\n%% Add the following VIEW section to a file of\n'+
+ '%% predefined views (See option "3Dviews"!).\n%%\n' +
+ '%% The view may be given a name after VIEW=...\n' +
+ '%% (Remove \'%\' in front of \'=\'.)\n%%');
+ host.console.println(res + '\n');
+}
+
+//add items to 3D context menu
+runtime.addCustomMenuItem("dfltview", "Generate Default View", "default", 0);
+runtime.addCustomMenuItem("currview", "Get Current View", "default", 0);
+runtime.addCustomMenuItem("csection", "Cross Section", "checked", 0);
+
+//menu event handlers
+menuEventHandler = new MenuEventHandler();
+menuEventHandler.onEvent = function(e) {
+ switch(e.menuItemName){
+ case "dfltview": calc3Dopts(); break;
+ case "currview": get3Dview(); break;
+ case "csection":
+ addremoveClipPlane(e.menuItemChecked);
+ break;
+ }
+};
+runtime.addEventHandler(menuEventHandler);
+
+//global variable taking reference to currently selected mesh node;
+var mshSelected=null;
+selectionEventHandler=new SelectionEventHandler();
+selectionEventHandler.onEvent=function(e){
+ if(e.selected && e.node.constructor.name=="Mesh"){
+ mshSelected=e.node;
+ }else{
+ mshSelected=null;
+ }
+}
+runtime.addEventHandler(selectionEventHandler);
+
+cameraEventHandler=new CameraEventHandler();
+cameraEventHandler.onEvent=function(e){
+ //store current transformation matrices of all mesh nodes in the scene
+ var curtrans=getCurTrans();
+ //detect existing clipping plane (cross section)
+ var ndcnt=scene.nodes.count;
+ var clip=scene.createClippingPlane();
+ if(ndcnt!=scene.nodes.count){
+ clip.remove();
+ runtime.removeCustomMenuItem("csection");
+ runtime.addCustomMenuItem("csection", "Cross Section", "checked", 0);
+ } else {
+ runtime.removeCustomMenuItem("csection");
+ runtime.addCustomMenuItem("csection", "Cross Section", "checked", 1);
+ }
+ //restore previous position of mesh nodes
+ restoreTrans(curtrans);
+}
+runtime.addEventHandler(cameraEventHandler);
+
+//key event handler for moving, spinning and tilting objects
+keyEventHandler=new KeyEventHandler();
+keyEventHandler.onEvent=function(e){
+ var target=null;
+ var backtrans=new Matrix4x4();
+ if(mshSelected){
+ target=mshSelected;
+ var trans=target.transform;
+ var parent=target.parent;
+ while(parent.transform){
+ //build local to world transformation matrix
+ trans.multiplyInPlace(parent.transform);
+ //also build world to local back-transformation matrix
+ backtrans.multiplyInPlace(parent.transform.inverse.transpose);
+ parent=parent.parent;
+ }
+ backtrans.transposeInPlace();
+ }else{
+ try {
+ target=scene.nodes.getByName("Clipping Plane");
+ }catch(e){
+ var ndcnt=scene.nodes.count;
+ target=scene.createClippingPlane();
+ if(ndcnt!=scene.nodes.count){
+ target.remove();
+ target=null;
+ }
+ }
+ }
+ if(!target) return;
+ switch(e.characterCode){
+ case 30://tilt up
+ tiltTarget(target, -Math.PI/900);
+ break;
+ case 31://tilt down
+ tiltTarget(target, Math.PI/900);
+ break;
+ case 28://spin right
+ spinTarget(target, -Math.PI/900);
+ break;
+ case 29://spin left
+ spinTarget(target, Math.PI/900);
+ break;
+ case 120: //x
+ translateTarget(target, new Vector3(1,0,0), e);
+ break;
+ case 121: //y
+ translateTarget(target, new Vector3(0,1,0), e);
+ break;
+ case 122: //z
+ translateTarget(target, new Vector3(0,0,1), e);
+ break;
+ case 88: //shift + x
+ translateTarget(target, new Vector3(-1,0,0), e);
+ break;
+ case 89: //shift + y
+ translateTarget(target, new Vector3(0,-1,0), e);
+ break;
+ case 90: //shift + z
+ translateTarget(target, new Vector3(0,0,-1), e);
+ break;
+ case 115: //s
+ scaleTarget(target, 1, e);
+ break;
+ case 83: //shift + s
+ scaleTarget(target, -1, e);
+ break;
+ }
+ if(mshSelected)
+ target.transform.multiplyInPlace(backtrans);
+}
+runtime.addEventHandler(keyEventHandler);
+
+function tiltTarget(t,a){
+ var centre=new Vector3();
+ if(mshSelected) {
+ centre.set(t.transform.transformPosition(t.computeBoundingBox().center));
+ }else{
+ centre.set(t.transform.translation);
+ }
+ var rotVec=t.transform.transformDirection(new Vector3(0,1,0));
+ rotVec.normalize();
+ t.transform.translateInPlace(centre.scale(-1));
+ t.transform.rotateAboutVectorInPlace(a, rotVec);
+ t.transform.translateInPlace(centre);
+}
+
+function spinTarget(t,a){
+ var centre=new Vector3();
+ var rotVec=new Vector3(0,0,1);
+ if(mshSelected) {
+ centre.set(t.transform.transformPosition(t.computeBoundingBox().center));
+ rotVec.set(t.transform.transformDirection(rotVec));
+ rotVec.normalize();
+ }else{
+ centre.set(t.transform.translation);
+ }
+ t.transform.translateInPlace(centre.scale(-1));
+ t.transform.rotateAboutVectorInPlace(a, rotVec);
+ t.transform.translateInPlace(centre);
+}
+
+//translates object by amount calculated based on Canvas size
+function translateTarget(t, d, e){
+ var cam=scene.cameras.getByIndex(0);
+ if(cam.projectionType==cam.TYPE_PERSPECTIVE){
+ var scale=Math.tan(cam.fov/2)
+ *cam.targetPosition.subtract(cam.position).length
+ /Math.min(e.canvasPixelWidth,e.canvasPixelHeight);
+ }else{
+ var scale=cam.viewPlaneSize/2
+ /Math.min(e.canvasPixelWidth,e.canvasPixelHeight);
+ }
+ t.transform.translateInPlace(d.scale(scale));
+}
+
+//scales object by amount calculated based on Canvas size
+function scaleTarget(t, d, e){
+ if(mshSelected) {
+ var bbox=t.computeBoundingBox();
+ var diag=new Vector3(bbox.max.x, bbox.max.y, bbox.max.z);
+ diag.subtractInPlace(bbox.min);
+ var dlen=diag.length;
+
+ var cam=scene.cameras.getByIndex(0);
+ if(cam.projectionType==cam.TYPE_PERSPECTIVE){
+ var scale=Math.tan(cam.fov/2)
+ *cam.targetPosition.subtract(cam.position).length
+ /dlen
+ /Math.min(e.canvasPixelWidth,e.canvasPixelHeight);
+ }else{
+ var scale=cam.viewPlaneSize/2
+ /dlen
+ /Math.min(e.canvasPixelWidth,e.canvasPixelHeight);
+ }
+ var centre=new Vector3();
+ centre.set(t.transform.transformPosition(t.computeBoundingBox().center));
+ t.transform.translateInPlace(centre.scale(-1));
+ t.transform.scaleInPlace(1+d*scale);
+ t.transform.translateInPlace(centre);
+ }
+}
+
+function addremoveClipPlane(chk) {
+ var clip=scene.createClippingPlane();
+ if(chk){
+ //add Clipping Plane and place its center either into the camera target
+ //position or into the centre of the currently selected mesh node
+ var centre=new Vector3();
+ if(mshSelected){
+ //local to parent transformation matrix
+ var trans=mshSelected.transform;
+ //build local to world transformation matrix by recursively
+ //multiplying the parent's transf. matrix on the right
+ var parent=mshSelected.parent;
+ while(parent.transform){
+ trans=trans.multiply(parent.transform);
+ parent=parent.parent;
+ }
+ //get the centre of the mesh (local coordinates)
+ centre.set(mshSelected.computeBoundingBox().center);
+ //transform the local coordinates to world coords
+ centre.set(trans.transformPosition(centre));
+ mshSelected=null;
+ }else{
+ centre.set(scene.cameras.getByIndex(0).targetPosition);
+ }
+ clip.transform.setView(
+ new Vector3(0,0,0), new Vector3(1,0,0), new Vector3(0,1,0));
+ clip.transform.translateInPlace(centre);
+ }else{
+ clip.remove();
+ }
+}
+
+//function to store current transformation matrix of all mesh nodes in the scene
+function getCurTrans() {
+ var nc=scene.meshes.count;
+ var tA=new Array(nc);
+ for(var i=0; i<nc; i++){
+ var cm=scene.meshes.getByIndex(i);
+ tA[cm.name]=new Matrix4x4(cm.transform);
+ }
+ return tA;
+}
+
+//function to restore transformation matrices given as arg
+function restoreTrans(tA) {
+ for(var i=0; i<tA.length; i++){
+ var msh=scene.meshes.getByIndex(i);
+ msh.transform.set(tA[msh.name]);
+ }
+}
+
+//store original transformation matrix of all mesh nodes in the scene
+var origtrans=getCurTrans();
+
+//set initial state of "Cross Section" menu entry
+cameraEventHandler.onEvent(1);
+
+//host.console.clear();
diff --git a/Master/texmf-dist/tex/latex/media9/javascript/3Dspintool.js b/Master/texmf-dist/tex/latex/media9/javascript/3Dspintool.js
new file mode 100644
index 00000000000..ed348d37bec
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/media9/javascript/3Dspintool.js
@@ -0,0 +1,31 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// (C) 2012, Alexander Grahn
+//
+// 3Dspintool.js
+//
+// version 20120301
+//
+////////////////////////////////////////////////////////////////////////////////
+//
+// 3D JavaScript to be used with media9.sty (option `add3Djscript')
+//
+// enables the Spin tool (also accessible via 3D toolbar or context menu)
+// upon activation of the 3D scene; the scene then rotates around the upright
+// axis while dragging with the mouse
+//
+// This work may be distributed and/or modified under the
+// conditions of the LaTeX Project Public License, either version 1.3
+// of this license or (at your option) any later version.
+// The latest version of this license is in
+// http://www.latex-project.org/lppl.txt
+// and version 1.3 or later is part of all distributions of LaTeX
+// version 2005/12/01 or later.
+//
+// This work has the LPPL maintenance status `maintained'.
+//
+// The Current Maintainer of this work is A. Grahn.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+runtime.setCurrentTool(runtime.TOOL_NAME_SPIN);
diff --git a/Master/texmf-dist/tex/latex/media9/javascript/animation.js b/Master/texmf-dist/tex/latex/media9/javascript/animation.js
new file mode 100644
index 00000000000..c09ac17d58d
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/media9/javascript/animation.js
@@ -0,0 +1,118 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// (C) 2012, Alexander Grahn
+//
+// animation.js
+//
+// version 20120301
+//
+////////////////////////////////////////////////////////////////////////////////
+//
+// JavaScript for use with `add3DJScript' option of \includemedia
+//
+// * Activates keyframe animation embedded in the u3d file.
+// * Arrow keys `Down', `Up' can be used for speeding up and
+// slowing down a running animation, key `Home' for reverting
+// to the default speed.
+//
+// * Adjustable parameters:
+var rate = 1; // 1 --> use original speed as default
+var palindrome = true; // true --> play forth and back
+//
+// This work may be distributed and/or modified under the
+// conditions of the LaTeX Project Public License, either version 1.3
+// of this license or (at your option) any later version.
+// The latest version of this license is in
+// http://www.latex-project.org/lppl.txt
+// and version 1.3 or later is part of all distributions of LaTeX
+// version 2005/12/01 or later.
+//
+// This work has the LPPL maintenance status `maintained'.
+//
+// The Current Maintainer of this work is A. Grahn.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+//get the first animation in the scene
+var myAnim = scene.animations.getByIndex(0);
+myAnim.wallTime = 0;
+myAnim.speed = 1;
+myAnim.myLength = myAnim.endTime - myAnim.startTime;
+scene.activateAnimation(myAnim);
+
+//method to set animation speed
+myAnim.setSpeed = function (speed) {
+ speed = Math.abs(speed);
+ this.wallTime /= speed/this.speed; //correct the walltime
+ this.speed = speed;
+};
+
+//method to change animation speed by a factor
+myAnim.changeSpeed = function (mult) {
+ this.wallTime /= mult; //correct the walltime
+ this.speed *= mult;
+};
+
+//set default speed
+myAnim.setSpeed(rate);
+
+//menu items
+runtime.addCustomMenuItem("faster", "Faster (Key Up)", "default", 0);
+runtime.addCustomMenuItem("slower", "Slower (Key Down)", "default", 0);
+runtime.addCustomMenuItem("default", "Default Speed (Key Home)", "default", 0);
+
+//menu handler to control speed
+menuEventHandler = new MenuEventHandler();
+menuEventHandler.onEvent = function(e) {
+ if (e.menuItemName == "faster") {
+ myAnim.changeSpeed(1.25);
+ }
+ else if (e.menuItemName == "slower") {
+ myAnim.changeSpeed(1/1.25);
+ }
+ else if (e.menuItemName == "default") {
+ myAnim.setSpeed(rate);
+ }
+};
+runtime.addEventHandler(menuEventHandler);
+
+//key handler to control speed
+keyEventHandler = new KeyEventHandler();
+keyEventHandler.onKeyDown = true;
+keyEventHandler.onEvent = function(e) {
+ switch(e.characterCode) {
+ case 30: //key up
+ myAnim.changeSpeed(1.05);
+ break;
+
+ case 31: //key down
+ myAnim.changeSpeed(1/1.05);
+ break;
+
+ case 4: //key home
+ myAnim.setSpeed(rate);
+ break;
+
+ case 1: //key end
+ myAnim.setSpeed(rate);
+ break;
+ }
+};
+runtime.addEventHandler(keyEventHandler);
+
+//run the animation using a TimeEventHandler
+myTimer = new TimeEventHandler();
+myTimer.onTimeChange = true;
+myTimer.onEvent = function(e) {
+ myAnim.wallTime += e.deltaTime;
+ if (palindrome == true) {
+ myAnim.currentTime =
+ myAnim.startTime
+ + myAnim.myLength/2
+ * (1 - Math.cos(Math.PI * myAnim.speed/myAnim.myLength * myAnim.wallTime));
+ } else {
+ myAnim.currentTime = myAnim.startTime
+ + (myAnim.speed * myAnim.wallTime % myAnim.myLength);
+ }
+};
+runtime.addEventHandler(myTimer);
diff --git a/Master/texmf-dist/tex/latex/media9/javascript/asylabels.js b/Master/texmf-dist/tex/latex/media9/javascript/asylabels.js
new file mode 100644
index 00000000000..dfe1899d5f5
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/media9/javascript/asylabels.js
@@ -0,0 +1,106 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// (C) 2012, Alexander Grahn
+//
+// asylabels.js
+//
+// version 20120301
+//
+////////////////////////////////////////////////////////////////////////////////
+//
+// 3D JavaScript to be used with media9.sty (option `add3Djscript') for
+// Asymptote generated PRC files
+//
+// adds billboard behaviour to text labels in Asymptote PRC files for improved
+// visibility, they always face the camera while dragging the 3d object with the
+// mouse.
+//
+//
+// This work may be distributed and/or modified under the
+// conditions of the LaTeX Project Public License, either version 1.3
+// of this license or (at your option) any later version.
+// The latest version of this license is in
+// http://www.latex-project.org/lppl.txt
+// and version 1.3 or later is part of all distributions of LaTeX
+// version 2005/12/01 or later.
+//
+// This work has the LPPL maintenance status `maintained'.
+//
+// The Current Maintainer of this work is A. Grahn.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+//recursive function which computes the lower left BBox corner of a text
+//label; it marches through all sibling mesh nodes the label is composed of;
+//the returned Vector3 object will become the pivot point of the label
+function nextCenter(msh){
+ //compute local-to-world transf. matrix of current mesh node
+ var trans=new Matrix4x4(msh.transform);
+ var parent=msh.parent;
+ while(parent.transform){
+ trans.multiplyInPlace(parent.transform);
+ parent=parent.parent;
+ }
+
+ //min BBox corner of current mesh node
+ var min=new Vector3();
+ min.set(msh.computeBoundingBox().min);
+ min.set(trans.transformPosition(min));
+
+ //get min BBox corner closest to origin (0,0,0)
+ if(msh.nextSibling){
+ var nextmin=nextCenter(msh.nextSibling);
+ return(min.length < nextmin.length ? min : nextmin);
+ }else{
+ return(min);
+ }
+}
+
+//find all text labels in the scene and determine pivoting points
+var zero=new Vector3(0,0,0);
+var nodes=scene.nodes;
+var center=new Array();
+var index=new Array();
+for(var i=0; i<nodes.count; i++){
+ var node=nodes.getByIndex(i);
+ var name=node.name;
+ var end=name.lastIndexOf(".")-1;
+ if(end > 0){
+ if(name.charAt(end) == "\001"){
+ var start=name.lastIndexOf("-")+1;
+ if(end-start > 0) {
+ index.push(i);
+ center.push(nextCenter(node.firstChild));
+ node.name=name.substr(0,start-1);
+ }
+ }
+ }
+}
+
+var camera=scene.cameras.getByIndex(0);
+
+//event handler to maintain upright position of text labels
+billboardHandler=new RenderEventHandler();
+billboardHandler.onEvent=function(event)
+{
+ var position=camera.position;
+ var direction=position.subtract(camera.targetPosition);
+ var up=camera.up.subtract(position);
+
+ for(var i=0; i<index.length; i++){
+ var node=nodes.getByIndex(index[i]);
+ var R=Matrix4x4();
+ R.setView(zero,direction,up);
+ var c=center[i];
+ var T=node.transform;
+ T.setIdentity();
+ T.translateInPlace(c.scale(-1));
+ T.multiplyInPlace(R);
+ T.translateInPlace(c);
+ }
+
+ runtime.refresh();
+}
+runtime.addEventHandler(billboardHandler);
+
+runtime.refresh();
diff --git a/Master/texmf-dist/tex/latex/media9/media9.sty b/Master/texmf-dist/tex/latex/media9/media9.sty
new file mode 100644
index 00000000000..c47d1df7f60
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/media9/media9.sty
@@ -0,0 +1,1996 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% media9.sty
+%
+% multimedia inclusion package
+%
+% Copyright 2012 Alexander Grahn
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% This package implements Adobe-Reader 9 and X compatible RichMedia
+% annotation for multimedia (Flash & 3D) inclusion according to:
+%
+% Adobe Supplement to ISO 32000, BaseVersion 1.7, ExtensionLevel 3
+%
+% Supported workflows:
+%
+% pdflatex, lualatex
+% (lua)latex-->dvips-->ps2pdf/Distiller
+% latex-->dvipdfmx
+% xelatex
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is A. Grahn.
+
+\RequirePackage{expl3}
+\RequirePackage{xparse}
+\RequirePackage{l3keys2e}
+\RequirePackage{ifpdf}
+
+\def\g@mix@date@tl{2012/03/16}
+\def\g@mix@version@tl{0.2}
+\ProvidesExplPackage{media9}{\g@mix@date@tl}{\g@mix@version@tl}
+{acrobat-9 compatible media}
+
+\tl_gset:Nx\g_mix_date_tl{\g@mix@date@tl}
+\tl_gset:Nx\g_mix_version_tl{\g@mix@version@tl}
+
+\cs_if_exist:NTF\msg_set:nnnn{
+ \msg_set:nnnn{media9}{support~outdated}{
+ Support~package~#1~too~old.
+ }{
+ Please~install~an~up~to~date~version~of~#1.\\
+ Loading~media9~will~abort!
+ }
+}{
+ \PackageError{media9}{Support~package~expl3~too~old.}{
+ Please~install~an~up~to~date~version~of~expl3.\\
+ Loading~media9~will~abort!
+ }
+ \tex_endinput:D
+}
+\@ifpackagelater{expl3}{2011/09/08}{}{
+ \msg_error:nnx{media9}{support~outdated}{l3kernel}
+ \tex_endinput:D
+}
+\@ifpackagelater{xparse}{2011/09/08}{}{
+ \msg_error:nnx{media9}{support~outdated}{l3packages}
+ \tex_endinput:D
+}
+\@ifpackagelater{l3keys2e}{2011/09/08}{}{
+ \msg_error:nnx{media9}{support~outdated}{l3packages}
+ \tex_endinput:D
+}
+
+%testing for PDF output
+\bool_new:N\g_mix_pdfoutput_bool
+\bool_gset_false:N\g_mix_pdfoutput_bool
+%\cs_if_exist:NT\pdfoutput{
+% \int_compare:nT{\pdfoutput>0}{\bool_gset_true:N\g_mix_pdfoutput_bool}
+%}
+\ifpdf \bool_gset_true:N\g_mix_pdfoutput_bool \fi
+
+%pdfTeX version check
+\pdftex_if_engine:T{
+ \int_compare:nT{\pdftexversion<130}{
+ \msg_interrupt:xxx{media9~error}{pdfTeX,~version~>=~1.30~required.}{}
+ }
+}
+
+%package options
+
+%unknown package option error message
+\msg_set:nnnn{media9}{unknown~package~option}{Unknown~package~option~`#1'.}{
+ Package option~'#1'~is~not~known~by~media9:\\
+ perhaps~it~is~spelled~incorrectly.
+}
+
+\bool_new:N\g_mix_dvipdfmx_bool
+\bool_new:N\g_mix_pkgdraft_bool
+\tl_gset:Nn\g_mix_pkgact_tl{/XA}
+\tl_gset:Nn\g_mix_pkgdeact_tl{/XD}
+\tl_gset:Nn\g_mix_pkgtransp_tl{false}
+\tl_gset:Nn\g_mix_pkgcontextclick_tl{false}
+\tl_gset:Nn\g_mix_pkgplaycnt_tl{-1}
+\tl_gset:Nn\g_mix_pkgplayspd_tl{1}
+\tl_gset:Nn\g_mix_pkgplaytpe_tl{None}
+\tl_gset:Nn\g_mix_pkgtools_tl{false}
+\tl_gset:Nn\g_mix_pkgnav_tl{false}
+\tl_gset:Nn\g_mix_pkgopt_bg_tl{}
+\tl_gset:Nn\g_mix_pkgopt_ls_tl{}
+\tl_gset:Nn\g_mix_pkgopt_rm_tl{}
+\bool_new:N\g_mix_pkgiiidcalc_bool
+\keys_define:nn{media9}{
+ dvipdfmx .bool_gset:N = \g_mix_dvipdfmx_bool,
+ xetex .bool_gset:N = \g_mix_dvipdfmx_bool,
+
+ draft .choice:,
+ draft / true .code:n = {\bool_gset_true:N\g_mix_pkgdraft_bool},
+ draft / false .code:n = {\bool_gset_false:N\g_mix_pkgdraft_bool},
+ draft .default:n = {true},
+
+ final .choice:,
+ final / true .code:n = {\bool_gset_false:N\g_mix_pkgdraft_bool},
+ final / false .code:n = {\bool_gset_true:N\g_mix_pkgdraft_bool},
+ final .default:n = {true},
+
+ activate .choice:,
+ activate / pagevisible .code:n = {\tl_gset:Nn\g_mix_pkgact_tl{/PV}},
+ activate / pageopen .code:n = {\tl_gset:Nn\g_mix_pkgact_tl{/PO}},
+ activate / onclick .code:n = {\tl_gset:Nn\g_mix_pkgact_tl{/XA}},
+
+ deactivate .choice:,
+ deactivate / pageinvisible .code:n = {\tl_gset:Nn\g_mix_pkgact_tl{/PI}},
+ deactivate / pageclose .code:n = {\tl_gset:Nn\g_mix_pkgact_tl{/PC}},
+ deactivate / onclick .code:n = {\tl_gset:Nn\g_mix_pkgact_tl{/XD}},
+
+ transparent .choice_code:n = {
+ \tl_gset:Nx\g_mix_pkgtransp_tl{\l_keys_choice_tl}},
+ transparent .generate_choices:n = {true,false},
+ transparent .default:n = {true},
+
+ passcontext .choice_code:n = {\tl_gset:Nx\g_mix_pkgcontextclick_tl{
+ \l_keys_choice_tl}},
+ passcontext .generate_choices:n = {true,false},
+ passcontext .default:n = {true},
+
+ %3D specific options
+ 3Dplaytype .choice:,
+ 3Dplaytype / none .code:n = {\tl_gset:Nn\g_mix_pkgplaytpe_tl{None}},
+ 3Dplaytype / linear .code:n = {\tl_gset:Nn\g_mix_pkgplaytpe_tl{Linear}},
+ 3Dplaytype / oscillating .code:n = {
+ \tl_gset:Nn\g_mix_pkgplaytpe_tl{Oscillating}},
+
+ 3Dplaycount .code:n = {\tl_gset:Nn\g_mix_pkgplaycnt_tl{
+ \exp_after:wN\int_value:w \dim_eval:w#1sp\dim_eval_end:}},
+ 3Dplaycount .value_required:,
+
+ 3Dplayspeed .tl_gset_x:N = \g_mix_pkgplayspd_tl,
+ 3Dplayspeed .value_required:,
+
+ 3Dtoolbar .choice_code:n = {\tl_gset:Nx\g_mix_pkgtools_tl{\l_keys_choice_tl}},
+ 3Dtoolbar .generate_choices:n = {true,false},
+ 3Dtoolbar .default:n = {true},
+
+ 3Dnavpane .choice_code:n = {\tl_gset:Nx\g_mix_pkgnav_tl{\l_keys_choice_tl}},
+ 3Dnavpane .generate_choices:n = {true,false},
+ 3Dnavpane .default:n = {true},
+
+ 3Dmenu .bool_gset:N = \g_mix_pkgiiidcalc_bool,
+
+ 3Dbg .code:n = {
+ \tl_gset:Nx\g_mix_pkgopt_bg_tl{
+ /BG<</Subtype/SC/CS/DeviceRGB/C[#1]/EA~true>>}
+ },
+ 3Dbg .value_required:,
+
+ 3Dlights .code:n = {
+ \tl_gset:Nx\g_mix_pkgopt_ls_tl{/LS<</Subtype/#1>>}
+ },
+ 3Dlights .value_required:,
+
+ 3Drender .code:n = {
+ \tl_gset:Nx\g_mix_pkgopt_rm_tl{/RM<</Subtype/#1>>}
+ },
+ 3Drender .value_required:,
+
+ unknown .code:n = {
+ \msg_error:nnx{media9}{unknown~package~option}{\exp_not:V\l_keys_key_tl}
+ },
+}
+\ProcessKeysOptions{media9}
+\xetex_if_engine:T{\bool_gset_true:N\g_mix_dvipdfmx_bool}
+
+\AtBeginDocument{
+ \@ifpackageloaded{babel}{}{\msg_error:nnx{media9}{missing~package}{babel}}
+}
+
+\box_new:N\l_mix_poster_box
+\dim_new:N\g_mix_wd_dim
+\dim_new:N\g_mix_ht_dim
+\dim_new:N\g_mix_dp_dim
+
+\int_new:N\g_mix_rmcnt_int
+\int_new:N\l_mix_viewcnt_int %counter for 3D views per annot
+
+\bool_new:N\g_mix_url_bool
+\bool_new:N\l_mix_url_bool
+\bool_new:N\g_mix_iiidcalc_bool
+
+%missing package error message
+%example usage:
+% \msg_error:nnxx{media9}{missing~package}{graphicx}{[dvipdfmx]}
+% \msg_error:nnx{media9}{missing~package}{graphicx}
+\msg_set:nnn{media9}{missing~package}{
+ Package~`#1'~has~not~been~loaded~yet.\\
+ Put~the~line\\
+ ~~\string\usepackage#2{#1}\\
+ to~the~preamble~of~your~document.
+}
+
+%file not found error message
+%example usage:
+% \msg_error:nnxx{media9}{file~not~found}{myfile.swf}
+\msg_set:nnnn{media9}{file~not~found}{
+ Loine~\msg_line_number: :~
+ File~`#1'~not~found.}{Make~sure~file~`#1'~exists~and~is~readable!}
+
+\pdftex_if_engine:TF{
+ %\pdfmdfivesum is used for hashing object references of embedded files
+ \cs_new:Nn\mix_filemdfivesum:n{\pdfmdfivesum~file~{#1}}
+ \cs_new:Nn\mix_filesize:n{\pdffilesize{#1}}
+ \cs_new:Nn\mix_filedump:nnn{\pdffiledump~offset~#1~length~#2~{#3}}
+ \cs_new:Nn\mix_unescapehex:n{(\pdfunescapehex{#1})}
+}{
+ \luatex_if_engine:TF{
+ \RequirePackage{pdftexcmds}
+ \cs_new:Nn\mix_filemdfivesum:n{\pdf@filemdfivesum{#1}}
+ \cs_new:Nn\mix_filesize:n{\pdf@filesize{#1}}
+ \cs_new:Nn\mix_filedump:nnn{\pdf@filedump{#1}{#2}{#3}}
+ \cs_new:Nn\mix_unescapehex:n{<#1>}
+ }{
+ \cs_new:Nn\mix_filemdfivesum:n{#1}
+ }
+}
+
+%reset various variables for every new media inclusion
+\cs_new:Nn\mix_reset:{
+ \tl_gset:Nx\g_mix_label_tl{rm.\int_use:N\g_mix_rmcnt_int}
+ \tl_gset:Nn\g_mix_flashvars_tl{}
+ \tl_gset:Nn\g_mix_assets_tl{}
+ \tl_gset:Nn\g_mix_configurations_tl{}
+ \tl_gset_eq:NN\g_mix_act_tl\g_mix_pkgact_tl
+ \tl_gset_eq:NN\g_mix_deact_tl\g_mix_pkgdeact_tl
+ \bool_gset_false:N\g_mix_url_bool
+ \box_clear:N\l_mix_poster_box
+ \tl_set:Nn\l_mix_scripts_tl{}
+ \bool_gset_eq:NN\g_mix_usrdraft_bool\g_mix_pkgdraft_bool
+ \seq_gclear:N\g_mix_res_seq
+ \seq_gclear:N\g_mix_script_seq
+ \int_gzero:N\g_mix_resizeflag_int
+ \tl_gset:Nn\g_mix_scalearg_tl{1.0}
+ \tl_gset:Nn\g_mix_wdarg_tl{\width}
+ \tl_gset:Nn\g_mix_htarg_tl{\height}
+ \tl_gset:Nn\g_mix_dparg_tl{\depth}
+ \tl_gset_eq:NN\g_mix_transp_tl\g_mix_pkgtransp_tl
+ \tl_gset_eq:NN\g_mix_contextclick_tl\g_mix_pkgcontextclick_tl
+
+ %3D specific settings
+ \bool_gset_false:N\g_mix_opt_iiidview_bool
+ \bool_gset_eq:NN\g_mix_iiidcalc_bool\g_mix_pkgiiidcalc_bool
+
+ \tl_gset_eq:NN\g_mix_playcnt_tl\g_mix_pkgplaycnt_tl
+ \tl_gset_eq:NN\g_mix_playspd_tl\g_mix_pkgplayspd_tl
+ \tl_gset_eq:NN\g_mix_playtpe_tl\g_mix_pkgplaytpe_tl
+ \tl_gset_eq:NN\g_mix_tools_tl\g_mix_pkgtools_tl
+ \tl_gset_eq:NN\g_mix_nav_tl\g_mix_pkgnav_tl
+
+ \tl_gset_eq:NN\g_mix_opt_bg_tl\g_mix_pkgopt_bg_tl
+ \tl_gset_eq:NN\g_mix_opt_ls_tl\g_mix_pkgopt_ls_tl
+ \tl_gset_eq:NN\g_mix_opt_rm_tl\g_mix_pkgopt_rm_tl
+ \tl_gset:Nn\g_mix_opt_coo_tl{0~0~0}
+ \tl_gset:Nn\g_mix_opt_ctoc_tl{0~-1~0}
+ \tl_gset:Nn\g_mix_opt_ciiw_tl{}
+ \fp_gset:Nn\g_mix_opt_roo_fp{1e-8}
+ \fp_gset:Nn\g_mix_opt_aac_fp{30}
+ \fp_gset:Nn\g_mix_opt_oscale_fp{1}
+ \fp_gset:Nn\g_mix_opt_roll_fp{0}
+
+ \bool_set_false:N\l_mix_roo_bool
+ \bool_gset_false:N\g_mix_opt_ciiw_bool
+ \bool_gset_false:N\g_mix_opt_iiidortho_bool
+
+ \tl_set:Nn\l_mix_iiidviewarray_tl{}
+ \tl_gset:Nn\g_mix_vfile_tl{}
+}
+
+%3D settings to be reset before creating an additional view
+\cs_new:Nn\mix_iiidreset:{
+ \tl_set:Nn\l_mix_bg_tl{}
+ \tl_set:Nn\l_mix_ls_tl{}
+ \tl_set:Nn\l_mix_rm_tl{}
+ \tl_set:Nn\l_mix_coo_tl{0~0~0}
+ \tl_set:Nn\l_mix_ctoc_tl{0~-1~0}
+ \tl_set:Nn\l_mix_ciiw_tl{}
+
+ \fp_set:Nn\l_mix_roo_fp{1e-8}
+ \fp_set:Nn\l_mix_aac_fp{30}
+ \fp_set:Nn\l_mix_oscale_fp{1}
+ \fp_set:Nn\l_mix_roll_fp{0}
+
+ \bool_set_false:N\l_mix_roo_bool
+ \bool_set_false:N\l_mix_ciiw_bool
+ \bool_set_false:N\l_mix_iiidortho_bool
+
+ \tl_set:Nn\l_mix_naarray_tl{} %array of node dicts
+ \tl_set:Nn\l_mix_saarray_tl{} %array of crosssect dicts
+}
+
+%wrong image resource for 3D
+\msg_set:nnn{media9}{wrong~image~resource}{
+ Image~resource~file\\~~'#1'\\has~wrong~type.\\\\
+ In~3D~context,~driver~#2~only~accepts~files~of~type\\#3\\
+ as~image~resources.
+}
+
+%commands for creating PDF objects, annots etc.
+\bool_if:NTF\g_mix_pdfoutput_bool{
+ %helper func to remove `0 R' part from pdf obj reference
+ \cs_new:Npn\mix_reftonum:w #1~0~R {#1}
+ \cs_new:Nn\mix_pdfobj:nnn{
+ % #1:objref; if empty, a new object number will be reserved
+ % #2:type of object (dict|array|stream|fstream)
+ % #3:content (key-value, file, string); may be empty
+ \tl_set:Nn\l_mix_usenum_tl{}
+ \tl_if_blank:oTF{#1}{
+ \pdfobj~reserveobjnum
+ \tl_set:Nx\l_mix_usenum_tl{useobjnum~\the\pdflastobj}
+ }{
+ \tl_set:Nx\l_mix_usenum_tl{useobjnum~\exp_after:wN \mix_reftonum:w #1}
+ }
+ \tl_if_blank:oF{#3}{
+ \prg_case_str:nnn{#2}{
+ {dict}{\immediate\pdfobj~\l_mix_usenum_tl~{<<#3>>}}
+ {array}{\immediate\pdfobj~\l_mix_usenum_tl~{[#3]}}
+ {stream}{\immediate\pdfobj~\l_mix_usenum_tl~stream~{#3}}
+ {fstream}{\immediate\pdfobj~\l_mix_usenum_tl~stream~file~{#3}}
+ }{}
+ }
+ \tl_gset:Nx\g_mix_pdflastobj_tl{\int_use:c{pdflastobj}~0~R}
+ }
+
+ \cs_new:Nn\mix_pdfannot:nnnn{
+ % #1:width, #2:height, #3:depth, #4:content (key-value)
+ \immediate\pdfannot~width~#1~height~#2~depth~#3 {#4}
+ \tl_gset:Nx\g_mix_pdflastann_tl{\int_use:c{pdflastannot}~0~R}
+ }
+
+ \cs_new:Nn\mix_pdfxform:n{%#1:savebox number
+ \immediate\pdfxform~resources~{\the\pdfpageresources}~#1
+ \tl_gset:Nx\g_mix_pdflastxform_tl{\int_use:c{pdflastxform}~0~R}
+ }
+
+ \cs_new:Nn\mix_pdfximage:n{%#1:bitmap file name
+ \bool_if:nF{
+ \str_if_eq_p:Vn\l_mix_ext_tl{png}
+ ||\str_if_eq_p:Vn\l_mix_ext_tl{jpg}
+ ||\str_if_eq_p:Vn\l_mix_ext_tl{jpeg}
+ ||\str_if_eq_p:Vn\l_mix_ext_tl{jbig2}
+ ||\str_if_eq_p:Vn\l_mix_ext_tl{jb2}
+ }{
+ \msg_error:nnxxx{media9}{wrong~image~resource}{#1}{pdftex}{
+ png,~jpeg~and~jbig2
+ }
+ }
+ \immediate\pdfximage{#1}
+ \tl_gset:Nx\g_mix_pdflastximage_tl{\int_use:c{pdflastximage}~0~R}
+ }
+
+ \cs_new:Nn\mix_ndname:n{%#1:HEX encoded string
+ %converted to binary UTF16BE using \pdfunescapehex (pdfTeX only)
+ \tl_set:Nn\l_mix_ndname_tl{\mix_unescapehex:n{#1}}
+ }
+}{
+ \int_new:N\g_mix_obj_int % object ID
+ \bool_if:NTF\g_mix_dvipdfmx_bool{ %dvipdfmx/XeTeX
+ \cs_new:Nn\mix_pdfobj:nnn{
+ % #1:objref; if empty, a new object number will be reserved
+ % #2:type of object (dict|array|stream|fstream)
+ % #3:content (key-value, file, string); may be empty
+ \tl_set:Nn\l_mix_usenum_tl{}
+ \tl_if_blank:oTF{#1}{
+ \prg_case_str:nnn{#2}{
+ {dict}{\special{pdf:obj~@mix@obj\int_use:N\g_mix_obj_int\space<<>>}}
+ {array}{\special{pdf:obj~@mix@obj\int_use:N\g_mix_obj_int\space[]}}
+ {stream}{\special{pdf:stream~@mix@obj\int_use:N\g_mix_obj_int\space(#3)}}
+ {fstream}{
+ \message{<#3>}
+ \special{pdf:fstream~@mix@obj\int_use:N\g_mix_obj_int\space(#3)}
+ }
+ }{}
+ \tl_set:Nx\l_mix_usenum_tl{@mix@obj\int_use:N\g_mix_obj_int}
+ \int_gincr:N\g_mix_obj_int
+ }{
+ \tl_set:Nx\l_mix_usenum_tl{#1}
+ }
+ \tl_if_blank:oF{#3}{
+ \prg_case_str:nnn{#2}{
+ {dict}{\special{pdf:put~\l_mix_usenum_tl\space<<#3>>}}
+ {array}{\special{pdf:put~\l_mix_usenum_tl\space#3}}
+ }{}
+ }
+ \tl_gset:Nx\g_mix_pdflastobj_tl{\l_mix_usenum_tl}
+ }
+
+ \cs_new:Nn\mix_pdfannot:nnnn{
+ % #1:width, #2:height, #3:depth, #4:content (key-value)
+ \special{pdf:ann~@mix@obj\int_use:N\g_mix_obj_int\space
+ width~#1\space
+ height~#2\space
+ depth~#3~<<#4>>
+ }
+ \tl_gset:Nx\g_mix_pdflastann_tl{@mix@obj\int_use:N\g_mix_obj_int}
+ \int_gincr:N\g_mix_obj_int
+ }
+
+ \cs_new:Nn\mix_pdfxform:n{%#1:savebox number
+ \special{pdf:bxobj~@mix@obj\int_use:N\g_mix_obj_int\space
+ width\space\dim_eval:n{\box_wd:N #1}\space
+ height\space\dim_eval:n{\box_ht:N #1}\space
+ depth\space\dim_eval:n{\box_dp:N #1}
+ }
+ \begin{picture}(0,0)\put(0,0){\box_use:N #1}\end{picture}
+ \special{pdf:exobj}
+ \tl_gset:Nx\g_mix_pdflastxform_tl{@mix@obj\int_use:N\g_mix_obj_int}
+ \int_gincr:N\g_mix_obj_int
+ }
+
+ \cs_new:Nn\mix_pdfximage:n{%#1:bitmap file name
+ \bool_if:nF{
+ \str_if_eq_p:Vn\l_mix_ext_tl{png}
+ ||\str_if_eq_p:Vn\l_mix_ext_tl{jpg}
+ ||\str_if_eq_p:Vn\l_mix_ext_tl{jpeg}
+ }{
+ \msg_error:nnxxx{media9}{wrong~image~resource}{#1}{dvipdfmx/xetex}{
+ png~and~jpeg
+ }
+ }
+ \special{pdf:image~@mix@obj\int_use:N\g_mix_obj_int\space
+ %move initial display off the page
+ matrix~0.000001~0~0~0.000001~-1000000~-1000000~(#1)}
+ \tl_gset:Nx\g_mix_pdflastximage_tl{@mix@obj\int_use:N\g_mix_obj_int}
+ \int_gincr:N\g_mix_obj_int
+ }
+
+ \cs_new:Nn\mix_ndname:n{%#1:HEX encoded UTF16BE string
+ \tl_set:Nn\l_mix_ndname_tl{<#1>}
+ }
+ }{
+ % dvips
+ \bool_new:N\g_mix_powerdot_bool %to cope with some powerdot oddity
+ \@ifclassloaded{powerdot}{\bool_gset_true:N\g_mix_powerdot_bool}{}
+
+ %define `?pdfmark' operator as in file hdvips.def from package `hyperref'
+ \AtBeginDvi{
+ \cs_if_exist:NF\pdfmark{
+ \special{!~
+ systemdict~/pdfmark~known
+ {
+ userdict~/?pdfmark~systemdict~/exec~get~put
+ }{
+ userdict~/?pdfmark~systemdict~/pop~get~put~
+ userdict~/pdfmark~systemdict~/cleartomark~get~put
+ }
+ ifelse~
+ }
+ }
+ }
+
+ \cs_new:Nn\mix_pdfobj:nnn{
+ % #1:objref; if empty, a new object number will be reserved
+ % #2:type of object (dict|array|stream|fstream)
+ % #3:content (key-value, file, string); may be empty
+ \tl_set:Nn\l_mix_usenum_tl{}
+ \tl_if_blank:oTF{#1}{
+ \special{ps:~mark~/_objdef~{mix@obj\int_use:N\g_mix_obj_int}~/type
+ \prg_case_str:nnn{#2}{
+ {dict}{/dict}
+ {array}{/array}
+ {stream}{/stream}
+ {fstream}{/stream}
+ }{}~
+ /OBJ~pdfmark~
+ }
+ \tl_set:Nx\l_mix_usenum_tl{{mix@obj\int_use:N\g_mix_obj_int}}
+ \int_gincr:N\g_mix_obj_int
+ }{
+ \tl_set:Nx\l_mix_usenum_tl{#1}
+ }
+ \tl_if_blank:oF{#3}{
+ \prg_case_str:nnn{#2}{
+ {dict}{\special{ps:~mark~\l_mix_usenum_tl~<<#3>>/PUT~pdfmark~}}
+ {array}{
+ \special{ps:~mark~\l_mix_usenum_tl~0~[#3]/PUTINTERVAL~pdfmark~}
+ }
+ {stream}{\special{ps:~mark~\l_mix_usenum_tl~(#3)/PUT~pdfmark~}}
+% {fstream}{
+% \special{ps:~
+% mark~\l_mix_usenum_tl~{(#3)~(r)~file}?pdfmark~/PUT~pdfmark~
+% }
+% }
+ {fstream}{
+ \tl_set:Nn\l_mix_offset_tl{0}
+ \tl_set:Nx\l_mix_fsize_tl{\mix_filesize:n{#3}}
+ \message{<#3}
+ %embed file in chunks of 32768 Bytes into PS as chunks of
+ %65536 Bytes of HEX code
+ \bool_while_do:nn{
+ \int_compare_p:n{\l_mix_offset_tl<\l_mix_fsize_tl}
+ }{
+ \special{ps:~
+ mark~
+ \l_mix_usenum_tl~
+ (\mix_filedump:nnn{\l_mix_offset_tl}{32767}{#3})~
+ /ASCIIHexDecode~filter~/PUT~
+ pdfmark~
+ }
+ \tl_set:Nx\l_mix_offset_tl{\int_eval:n{\l_mix_offset_tl+32767}}
+ \message{.}
+ }
+ \message{>}
+ \special{ps:~
+ mark~\l_mix_usenum_tl~/CLOSE~pdfmark~
+ }
+ }
+ }{}
+ }
+ \tl_gset:Nx\g_mix_pdflastobj_tl{\l_mix_usenum_tl}
+ }
+
+ \cs_new:Nn\mix_pdfannot:nnnn{
+ \hbox_set:Nn\l_tmpa_box{
+ \box_move_down:nn{#3}{
+ \hbox_to_zero:n{
+ \special{ps:~currentpoint~/mix@lly~exch~def~/mix@llx~exch~def}
+ }
+ }
+ \skip_horizontal:n{#1}
+ \box_move_up:nn{#2}{
+ \hbox_to_zero:n{
+ \special{ps:~currentpoint~/mix@ury~exch~def~/mix@urx~exch~def}
+ }
+ }
+ }
+ \box_set_wd:Nn\l_tmpa_box{\c_zero_dim}
+ \box_set_ht:Nn\l_tmpa_box{\c_zero_dim}
+ \box_set_dp:Nn\l_tmpa_box{\c_zero_dim}
+ \box_use_clear:N\l_tmpa_box
+ \special{ps:~
+ mark~
+ /_objdef~{mix@obj\int_use:N\g_mix_obj_int}
+ /Rect~[mix@llx~mix@lly~mix@urx~mix@ury]
+ #4~
+ /ANN~pdfmark~
+ }
+ \tl_gset:Nx\g_mix_pdflastann_tl{{mix@obj\int_use:N\g_mix_obj_int}}
+ \int_gincr:N\g_mix_obj_int
+ }
+
+ \cs_new:Nn\mix_pdfxform:n{%#1:savebox number
+ %mark bbox of box#1
+ \hbox_set:Nn\l_tmpa_box{
+ \box_move_down:nn{\box_dp:N #1}{
+ \hbox_to_zero:n{
+ \special{ps:~currentpoint~/mix@lly~exch~def~/mix@llx~exch~def}
+ }
+ }
+ \skip_horizontal:n{\box_wd:N #1}
+ \box_move_up:nn{\box_ht:N #1}{
+ \hbox_to_zero:n{
+ \special{ps:~currentpoint~/mix@ury~exch~def~/mix@urx~exch~def}
+ }
+ }
+ }
+ \box_set_wd:Nn\l_tmpa_box{\c_zero_dim}
+ \box_set_ht:Nn\l_tmpa_box{\c_zero_dim}
+ \box_set_dp:Nn\l_tmpa_box{\c_zero_dim}
+ \box_use_clear:N\l_tmpa_box
+ %define some length values in current PS coordinate units
+ \hbox_set:Nn\l_tmpa_box{
+ \special{ps:~currentpoint~/origin@y~exch~def~/origin@x~exch~def}
+ \skip_horizontal:n{72.27pt}
+ \box_move_up:nn{72.27pt}{
+ \hbox_to_zero:n{
+ \special{ps:~
+ currentpoint~origin@y~exch~sub~/one@inch@y~exch~def~
+ origin@x~sub~/one@inch@x~exch~def
+ }
+ }
+ }
+ }
+ \box_set_wd:Nn\l_tmpa_box{\c_zero_dim}
+ \box_set_ht:Nn\l_tmpa_box{\c_zero_dim}
+ \box_use_clear:N\l_tmpa_box
+ \special{ps:~
+ gsave~
+ %translate graphics to upper left page corner
+ \bool_if:NF\g_mix_powerdot_bool{
+ {
+ mix@llx~neg~mix@ury~neg~translate~
+ one@inch@x~DVImag~div~neg~one@inch@y~DVImag~div~neg~translate
+ }?pdfmark~
+ }
+ %distill graphics into XObject
+ mark~
+ /_objdef~{mix@obj\int_use:N\g_mix_obj_int}
+ /BBox~[mix@llx~mix@lly~mix@urx~mix@ury]
+ /BP~pdfmark~
+ {
+ isls{%landscape mode (powerdot, geometry /w landscape option)
+ /mix@dxdy~{
+ mix@urx~mix@llx~sub~abs~
+ mix@ury~mix@lly~sub~abs~div
+ }~bind~def
+ /mix@dydx~{1~mix@dxdy~div}~bind~def
+ /mix@cx~{mix@urx~mix@llx~add~2~div}~bind~def
+ /mix@cy~{mix@ury~mix@lly~add~2~div}~bind~def
+ % graphics needs to be rescaled for some reason ...
+ [mix@dxdy~0~0~mix@dydx~1~mix@dxdy~sub~mix@cx~mul~
+ 1~mix@dydx~sub~mix@cy~mul]~concat
+ %... rotated by 270 degrees ...
+ [0~-1~1~0~mix@cx~mix@cy~sub~mix@cx~mix@cy~add]~concat
+ %... and flipped around vertical axis
+ [-1~0~0~1~mix@llx~mix@urx~add~0]~concat
+ }{% flip around horizontal axis in portrait mode
+ [1~0~0~-1~0~mix@lly~mix@ury~add]~concat
+ }ifelse
+ }?pdfmark~
+ }
+ \begin{picture}(0,0)\put(0,0){\box_use:N #1}\end{picture}
+ \special{ps:~mark~/EP~pdfmark~grestore}
+ \tl_gset:Nx\g_mix_pdflastxform_tl{{mix@obj\int_use:N\g_mix_obj_int}}
+ \int_gincr:N\g_mix_obj_int
+ }
+
+ %Image XObject
+ \cs_new:Nn\mix_pdfximage:n{%#1:bitmap file name
+ \bool_if:nF{
+ \str_if_eq_p:Vn\l_mix_ext_tl{ps}
+ ||\str_if_eq_p:Vn\l_mix_ext_tl{eps}
+ }{
+ \msg_error:nnxxx{media9}{wrong~image~resource}{#1}{dvips}{
+ Postscript~(ps/eps)~with~bitmapped~content
+ }
+ }
+ \special{ps:~
+ mark~/_objdef~{mix@obj\int_use:N\g_mix_obj_int}~/NI~pdfmark~
+ }
+ \special{psfile=#1~hsize=0~vsize=0}
+ \special{ps:~
+ {
+ 0~0~1~[1~0~0~1~0~0]~{}~image~%empty dummy, in case #1 is not
+ }?pdfmark~ %a valid image file
+ }
+ \tl_gset:Nx\g_mix_pdflastximage_tl{{mix@obj\int_use:N\g_mix_obj_int}}
+ \int_gincr:N\g_mix_obj_int
+ }
+
+ %3DNode name
+ \cs_new:Nn\mix_ndname:n{%#1:HEX encoded unicode string
+ \special{ps:~
+ /mix@unicode~65535~string~def~
+ (#1)~/ASCIIHexDecode~filter~mix@unicode~readstring~pop~
+ /mix@unicode~exch~def~
+ }
+ %converted to binary UTF16BE by ps2pdf
+ \tl_set:Nn\l_mix_ndname_tl{mix@unicode}
+ }
+ }
+}
+
+\cs_new:Nn\mix_embedasset:n{ %#1 file name or url
+ \filename@parse{#1}
+ \tl_set:Nx\l_mix_ext_tl{\filename@ext}
+ \tl_replace_all:Nnn\l_mix_ext_tl{A}{a}
+ \tl_replace_all:Nnn\l_mix_ext_tl{B}{b}
+ \tl_replace_all:Nnn\l_mix_ext_tl{C}{c}
+ \tl_replace_all:Nnn\l_mix_ext_tl{D}{d}
+ \tl_replace_all:Nnn\l_mix_ext_tl{E}{e}
+ \tl_replace_all:Nnn\l_mix_ext_tl{F}{f}
+ \tl_replace_all:Nnn\l_mix_ext_tl{G}{g}
+ \tl_replace_all:Nnn\l_mix_ext_tl{H}{h}
+ \tl_replace_all:Nnn\l_mix_ext_tl{I}{i}
+ \tl_replace_all:Nnn\l_mix_ext_tl{J}{j}
+ \tl_replace_all:Nnn\l_mix_ext_tl{K}{k}
+ \tl_replace_all:Nnn\l_mix_ext_tl{L}{l}
+ \tl_replace_all:Nnn\l_mix_ext_tl{M}{m}
+ \tl_replace_all:Nnn\l_mix_ext_tl{N}{n}
+ \tl_replace_all:Nnn\l_mix_ext_tl{O}{o}
+ \tl_replace_all:Nnn\l_mix_ext_tl{P}{p}
+ \tl_replace_all:Nnn\l_mix_ext_tl{Q}{q}
+ \tl_replace_all:Nnn\l_mix_ext_tl{R}{r}
+ \tl_replace_all:Nnn\l_mix_ext_tl{S}{s}
+ \tl_replace_all:Nnn\l_mix_ext_tl{T}{t}
+ \tl_replace_all:Nnn\l_mix_ext_tl{U}{u}
+ \tl_replace_all:Nnn\l_mix_ext_tl{V}{v}
+ \tl_replace_all:Nnn\l_mix_ext_tl{W}{w}
+ \tl_replace_all:Nnn\l_mix_ext_tl{X}{x}
+ \tl_replace_all:Nnn\l_mix_ext_tl{Y}{y}
+ \tl_replace_all:Nnn\l_mix_ext_tl{Z}{z}
+ \bool_if:NTF\l_mix_url_bool{
+ \cs_if_exist:cF{url_#1}{
+ \mix_pdfobj:nnn{}{dict}{/FS/URL/F(#1)}
+ \tl_gset:cx{url_#1}{\g_mix_pdflastobj_tl}%
+ }
+ %every new url should be added to assets tree of the current annot
+ \cs_if_exist:cF{url_\int_use:c{g_mix_rmcnt_int}_#1}{
+ \tl_gput_right:Nx\g_mix_assets_tl{~(#1)~\tl_use:c{url_#1}}
+ \tl_new:c{url_\int_use:c{g_mix_rmcnt_int}_#1}
+ }
+ \tl_gset:Nx\g_mix_lastasset_tl{\tl_use:c{url_#1}}
+ }{
+ \file_if_exist:nTF{#1}{
+ \file_add_path:nN{#1}\l_mix_file_tl
+ }{
+ \msg_error:nnxx{media9}{file~not~found}{#1}
+ }
+ \bool_if:nTF{
+ %in 3D context, image resources must be embedded as Image XObjects, not
+ %files
+ \g_mix_iiid_bool && (
+ \str_if_eq_p:Vn\l_mix_ext_tl{jpg}
+ || \str_if_eq_p:Vn\l_mix_ext_tl{jpeg}
+ || \str_if_eq_p:Vn\l_mix_ext_tl{png}
+ || \str_if_eq_p:Vn\l_mix_ext_tl{jbig2}
+ || \str_if_eq_p:Vn\l_mix_ext_tl{jb2}
+ || \str_if_eq_p:Vn\l_mix_ext_tl{ps}
+ || \str_if_eq_p:Vn\l_mix_ext_tl{eps}
+ )
+ }{
+ %create Image XObject for bitmaps in 3D context
+ \cs_if_exist:cF{fileXimg_\mix_filemdfivesum:n{\l_mix_file_tl}}{
+ \mix_pdfximage:n{\l_mix_file_tl}
+ \tl_gset:cx{fileXimg_\mix_filemdfivesum:n{\l_mix_file_tl}}{
+ \g_mix_pdflastximage_tl
+ }
+ }
+ %fake FileSpec
+ \tl_gset:cx{fileSpec_#1}{\tl_use:c{
+ fileXimg_\mix_filemdfivesum:n{\l_mix_file_tl}}
+ }
+ }{
+ %remaining file types in 3D context and any file type in case of Flash
+ %context will be embedded as fstreams;
+ %create embedded file stream for every new file
+ \cs_if_exist:cF{fileEmb_\mix_filemdfivesum:n{\l_mix_file_tl}}{
+ \mix_pdfobj:nnn{}{fstream}{\l_mix_file_tl}
+ \tl_gset:cx{fileEmb_\mix_filemdfivesum:n{\l_mix_file_tl}}{
+ \g_mix_pdflastobj_tl
+ }
+ }
+ %every new file name not yet seen should get a new FileSpec dictionary
+ \cs_if_exist:cF{fileSpec_#1}{
+ \mix_pdfobj:nnn{}{dict}{
+ /Type/Filespec
+ /F~(#1)
+ /UF~(#1)
+ /EF~<</F~\tl_use:c{fileEmb_\mix_filemdfivesum:n{\l_mix_file_tl}}>>
+ }
+ \tl_gset:cx{fileSpec_#1}{\g_mix_pdflastobj_tl}
+ }
+ }
+ %add FileSpec to assets tree of current annot
+ \cs_if_exist:cF{fileAsset_\int_use:c{g_mix_rmcnt_int}_#1}{
+ \tl_gput_right:Nx\g_mix_assets_tl{
+ ~(#1)~\tl_use:c{fileSpec_#1}
+ }
+ \tl_new:c{fileAsset_\int_use:c{g_mix_rmcnt_int}_#1}
+ }
+ \tl_gset:Nx\g_mix_lastasset_tl{
+ \tl_use:c{fileSpec_#1}
+ }
+ }
+}
+
+\cs_new:Nn\mix_draftbox:n{ %#1 text string to be shown in the draft box centre
+ \hbox_overlap_right:n{
+ \hbox_to_wd:nn{\l_mix_wd_tl}{
+ \vrule~height~\l_mix_ht_tl~depth~\l_mix_dp_tl\hss
+ \vrule
+ }
+ }
+ \box_move_down:nn{\l_mix_dp_tl}{
+ \hbox_to_wd:nn{\l_mix_wd_tl}{
+ \vbox_to_ht:nn{\l_mix_tt_tl}{
+ \hrule~width~\l_mix_wd_tl\vss
+ \hbox_to_wd:nn{\l_mix_wd_tl}{\ttfamily{\tiny#1}\hss}\vss
+ \hrule
+ }
+ }
+ }
+}
+
+%calculates widget dimensions from natural ones, taking resizing options
+%into account
+\int_new:N\g_mix_resizeflag_int% resizing flags according to options given
+\cs_new:Nn\mix_scale:n{% #1 box number
+ %natural dimensions \width, \height, \depth, \totalheight
+ \tl_set:Nn\width {\box_wd:N#1}
+ \tl_set:Nn\height{\box_ht:N#1}
+ \tl_set:Nn\depth {\box_dp:N#1}
+ \tl_set:Nn\totalheight{(\height+\depth)}
+ \tl_set:Nx\l_mix_wd_tl{\dim_eval:n{\g_mix_wdarg_tl}}
+ \tl_set:Nx\l_mix_ht_tl{\dim_eval:n{\g_mix_htarg_tl}}
+ \tl_set:Nx\l_mix_dp_tl{\dim_eval:n{\g_mix_dparg_tl}}
+ \tl_set:Nx\l_mix_tt_tl{\dim_eval:n{\g_mix_htarg_tl+\g_mix_dparg_tl}}
+ %resize unspecified dimensions to keep aspect ratio
+ \bool_if:nF{
+ % original poster box must be two dimensional
+ \dim_compare_p:n{\width=\c_zero_dim}
+ ||\dim_compare_p:n{\totalheight=\c_zero_dim}
+ }{
+ \prg_case_int:nnn{\g_mix_resizeflag_int}{
+ {\c_zero}{}{\c_seven}{}
+ {\c_four}{
+ \tl_set:Nx\l_mix_ht_tl{
+ \dim_eval:n{\height*\dim_ratio:nn{\l_mix_wd_tl}{\width}}
+ }
+ \tl_set:Nx\l_mix_dp_tl{
+ \dim_eval:n{\depth*\dim_ratio:nn{\l_mix_wd_tl}{\width}}
+ }
+ }
+ {\c_five}{% resize height only if original height!=0
+ \dim_compare:nT{\height!=\c_zero_dim}{
+ \tl_set:Nx\l_mix_ht_tl{
+ \dim_eval:n{
+ \totalheight*\dim_ratio:nn{\l_mix_wd_tl}{\width}-\l_mix_dp_tl
+ }
+ }
+ }
+ }
+ {\c_six}{% resize depth only if original depth!=0
+ \dim_compare:nT{\depth!=\c_zero_dim}{
+ \tl_set:Nx\l_mix_dp_tl{
+ \dim_eval:n{
+ \totalheight*\dim_ratio:nn{\l_mix_wd_tl}{\width}-\l_mix_ht_tl
+ }
+ }
+ }
+ }
+ }{ % 1, 2, 3
+ \tl_set:Nx\l_mix_wd_tl{
+ \dim_eval:n{\width*\dim_ratio:nn{\l_mix_tt_tl}{\totalheight}}
+ }
+ }
+ }
+ %apply scaling factor
+ \dim_set:Nn\l_tmpa_dim{\l_mix_wd_tl}
+ \tl_set:Nx\l_mix_wd_tl{\dim_eval:n{\g_mix_scalearg_tl\l_tmpa_dim}}
+ \dim_set:Nn\l_tmpa_dim{\l_mix_ht_tl}
+ \tl_set:Nx\l_mix_ht_tl{\dim_eval:n{\g_mix_scalearg_tl\l_tmpa_dim}}
+ \dim_set:Nn\l_tmpa_dim{\l_mix_dp_tl}
+ \tl_set:Nx\l_mix_dp_tl{\dim_eval:n{\g_mix_scalearg_tl\l_tmpa_dim}}
+ \tl_set:Nx\l_mix_tt_tl{\dim_eval:n{\l_mix_ht_tl+\l_mix_dp_tl}}
+}
+
+\bool_new:N\g_mix_iiid_bool
+\int_new:N\l_mix_lineno_int
+
+\NewDocumentCommand\addmediapath{m}{\file_path_include:n{#1/}}
+
+\NewDocumentCommand\includemedia{omm}{%#1 options, #2 text/image #3 media file
+ \group_begin:
+ \leavevmode
+ \mix_reset:
+ \cs_if_exist:NT\Ginput@path{\cs_set_eq:NN\input@path\Ginput@path}
+ \hbox_set:Nn\l_mix_poster_box{#2}
+ \mix@uribegin %treat URI characters correctly
+ \keys_set:nn{media9/user}{#1}
+ \mix@uriend
+ \mix_scale:n{\l_mix_poster_box}
+ \dim_compare:nT{\width=\c_zero_dim}
+ {\box_set_wd:Nn\l_mix_poster_box{1pt}}
+ \dim_compare:nT{\totalheight=\c_zero_dim}
+ {\box_set_ht:Nn\l_mix_poster_box{1pt}}
+ \bool_if:NTF\g_mix_usrdraft_bool{
+ \mix_draftbox:n{\tl_to_str:n{#3}}
+ }{
+ \mix_pdfxform:n{\l_mix_poster_box}
+ %embed main asset
+ \group_begin:
+ \bool_set_eq:NN\l_mix_url_bool\g_mix_url_bool
+ \mix@uribegin
+ \mix_embedasset:n{#3}
+ \bool_gset:Nn\g_mix_iiid_bool{ %test on 3D file type
+ \str_if_eq_p:Vn\l_mix_ext_tl{prc}||\str_if_eq_p:Vn\l_mix_ext_tl{u3d}
+ }
+ \tl_gset:Nx\g_mix_mainasset_tl{~\g_mix_lastasset_tl}
+ \mix@uriend
+ \group_end:
+ %secondary assets (added by addresource)
+ \seq_map_function:NN\g_mix_res_seq\mix_embedasset:n
+ \seq_map_inline:Nn\g_mix_script_seq{
+ \mix_embedasset:n{##1}
+ \tl_put_right:Nx\l_mix_scripts_tl{~\g_mix_lastasset_tl}
+ }
+ %attach 3D calculation script
+ \bool_if:nT{\g_mix_iiid_bool && \g_mix_iiidcalc_bool}{
+ \mix_embedasset:n{3Dmenu.js}
+ \tl_put_left:Nx\l_mix_scripts_tl{~\g_mix_lastasset_tl}
+ }
+ %create 3D views from file (option 3Dviews)
+ \bool_if:nT{\g_mix_iiid_bool && !(\tl_if_blank_p:V\g_mix_vfile_tl)}{
+ \tl_set:Nn\l_mix_level_tl{\c_minus_one}
+ \int_zero:N\l_mix_viewcnt_int
+ \int_zero:N\l_mix_lineno_int
+ \ior_open:Nn\l_mix_vfile_stream{\g_mix_vfile_tl}
+
+ \group_begin:
+ \endlinechar=\c_minus_one
+ \ior_gto:NN\l_mix_vfile_stream\g_mix_inputline_tl
+ \group_end:
+ \bool_until_do:nn{\ior_if_eof_p:N\l_mix_vfile_stream}{
+ \int_incr:N\l_mix_lineno_int
+ %process input line
+ \tl_if_blank:VF\g_mix_inputline_tl{
+ \tl_set:Nx\l_mix_args_tl{{media9/views}{\g_mix_inputline_tl}}
+ \exp_after:wN\keys_set:nn\l_mix_args_tl
+ }
+ \group_begin:
+ \endlinechar=\c_minus_one
+ \ior_gto:NN\l_mix_vfile_stream\g_mix_inputline_tl
+ \group_end:
+ }
+
+ \ior_close:N\l_mix_vfile_stream
+ }
+ \bool_if:nT{ %create default 3D view if required
+ \g_mix_iiid_bool &&
+ (\g_mix_opt_iiidview_bool || \tl_if_blank_p:V\l_mix_iiidviewarray_tl)
+ }{
+ \tl_set_eq:NN\l_mix_bg_tl\g_mix_opt_bg_tl
+ \tl_set_eq:NN\l_mix_ls_tl\g_mix_opt_ls_tl
+ \tl_set_eq:NN\l_mix_rm_tl\g_mix_opt_rm_tl
+ \tl_set_eq:NN\l_mix_coo_tl\g_mix_opt_coo_tl
+ \tl_set_eq:NN\l_mix_ctoc_tl\g_mix_opt_ctoc_tl
+ \tl_set_eq:NN\l_mix_ciiw_tl\g_mix_opt_ciiw_tl
+
+ \fp_set_eq:NN\l_mix_roo_fp\g_mix_opt_roo_fp
+ \fp_set_eq:NN\l_mix_aac_fp\g_mix_opt_aac_fp
+ \fp_set_eq:NN\l_mix_oscale_fp\g_mix_opt_oscale_fp
+ \fp_set_eq:NN\l_mix_roll_fp\g_mix_opt_roll_fp
+
+ \bool_set_eq:NN\l_mix_ciiw_bool\g_mix_opt_ciiw_bool
+ \bool_set_eq:NN\l_mix_iiidortho_bool\g_mix_opt_iiidortho_bool
+ \tl_set:Nn\l_mix_naarray_tl{}
+
+ \bool_if:NF\l_mix_ciiw_bool{
+ \tl_set:Nx\l_mix_args_tl{\l_mix_coo_tl\space\l_mix_ctoc_tl\space}
+ \exp_after:wN\mix_calc_ciiw:w\l_mix_args_tl\q_stop
+ }
+
+ \tl_set:Nn\l_mix_naarray_tl{}
+ \tl_set:Nn\l_mix_saarray_tl{}
+
+ \mix_view:n{Default}
+ \tl_set:Nx\l_mix_dfltview_tl{\g_mix_pdflastobj_tl}
+
+ }
+ \mix_pdfobj:nnn{}{dict}{
+ /Subtype/\bool_if:NTF\g_mix_iiid_bool{3D}{Flash}
+ /Asset~\g_mix_mainasset_tl
+ \bool_if:NF\g_mix_iiid_bool{
+ /Params~<<
+ /Binding/Background
+ \tl_if_blank:VF\g_mix_flashvars_tl{
+ /FlashVars~(\g_mix_flashvars_tl)
+ }
+ >>
+ }
+ }
+ \mix_pdfobj:nnn{}{dict}{/Instances~[\g_mix_pdflastobj_tl]}%
+ \mix_pdfobj:nnn{}{dict}{
+ /Assets~<</Names~[\g_mix_assets_tl]>>
+ /Configurations~[\g_mix_pdflastobj_tl]
+ \bool_if:nT{
+ \g_mix_iiid_bool && !(\tl_if_empty_p:V\l_mix_iiidviewarray_tl)
+ }{
+ /Views~[\l_mix_iiidviewarray_tl]
+ }
+ }
+ \tl_set:Nx\l_mix_content_tl{\g_mix_pdflastobj_tl}
+ \bool_if:nT{
+ \g_mix_iiid_bool && \str_if_eq_p:Vn\g_mix_playtpe_tl{Oscillating}
+ }{
+ \tl_gset:Nx\g_mix_playcnt_tl{\int_eval:n{\g_mix_playcnt_tl*2}}
+ }
+ \mix_pdfobj:nnn{}{dict}{
+ /Activation~<<
+ /Condition\g_mix_act_tl
+ \bool_if:nT{
+ \g_mix_iiid_bool &&
+ !(\str_if_eq_p:Vn\g_mix_playtpe_tl{None})
+ }{%seems to work only with 3D content
+ /Animation~<<
+ /Subtype/\g_mix_playtpe_tl
+ /PlayCount~\g_mix_playcnt_tl
+ /Speed~\g_mix_playspd_tl
+ >>
+ }
+ \bool_if:nT{
+ \g_mix_iiid_bool && (
+ \g_mix_opt_iiidview_bool || \tl_if_blank_p:V\l_mix_iiidviewarray_tl
+ )
+ }{/View~\l_mix_dfltview_tl}
+ /Presentation~<<
+ /Transparent~\g_mix_transp_tl
+ /Style/Embedded
+ \bool_if:NTF\g_mix_iiid_bool{
+ /Toolbar~\g_mix_tools_tl
+ /NavigationPane~\g_mix_nav_tl
+ }{
+ /PassContextClick~\g_mix_contextclick_tl
+ }
+ >>
+ \tl_if_blank:VF\l_mix_scripts_tl{/Scripts~[\l_mix_scripts_tl]}
+ >>
+ /Deactivation~<</Condition\g_mix_deact_tl>>
+ }
+ \tl_set:Nx\l_mix_settings_tl{\g_mix_pdflastobj_tl}
+ \mix_pdfannot:nnnn{\l_mix_wd_tl}{\l_mix_ht_tl}{\l_mix_dp_tl}{
+ /Subtype/RichMedia
+ /F~4
+ /BS~<</W~0/S/S>>
+ /Contents~(media~embedded~by~media9~[\g_mix_version_tl~(\g_mix_date_tl)])
+ /NM~(\g_mix_label_tl)
+ /AP~<</N~\g_mix_pdflastxform_tl>>
+ /RichMediaSettings~\l_mix_settings_tl
+ /RichMediaContent~\l_mix_content_tl
+ }
+ \hbox_to_wd:nn{\l_mix_wd_tl}{
+ \vrule~width~\c_zero_dim~height~\l_mix_ht_tl~depth~\l_mix_dp_tl\hss
+ }
+ \int_gincr:N\g_mix_rmcnt_int
+ }
+ \group_end:
+}
+
+\ExplSyntaxOff
+\def\mix@uribegin{%
+ %make sure special characters in URIs (RFC 3986) are used unmodified
+ \begingroup%
+ \defineshorthand{:}{\detokenize{:}}%
+ \defineshorthand{/}{\detokenize{/}}%
+ \defineshorthand{?}{\detokenize{?}}%
+ \defineshorthand{[}{\detokenize{[}}%
+ \defineshorthand{]}{\detokenize{]}}%
+ \defineshorthand{@}{\detokenize{@}}%
+ \defineshorthand{!}{\detokenize{!}}%
+ \defineshorthand{$}{\detokenize{$}}%
+ \defineshorthand{&}{\detokenize{&}}%
+ \defineshorthand{'}{\detokenize{'}}%
+ \defineshorthand{(}{\detokenize{(}}%
+ \defineshorthand{)}{\detokenize{)}}%
+ \defineshorthand{*}{\detokenize{*}}%
+ \defineshorthand{+}{\detokenize{+}}%
+ \defineshorthand{,}{\detokenize{,}}%
+ \defineshorthand{;}{\detokenize{;}}%
+ \defineshorthand{=}{\detokenize{=}}%
+ \defineshorthand{-}{\detokenize{-}}%
+ \defineshorthand{.}{\detokenize{.}}%
+ \defineshorthand{_}{\detokenize{_}}%
+ \defineshorthand{~}{\detokenize{~}}%
+ \def\%{\string\%}%
+ \def\#{\string\#}%
+}
+\def\mix@uriend{\endgroup}%
+\ExplSyntaxOn
+
+% macro to format a real number in tl variable
+% * to show at most 9 places after `.'
+% * trailing zeros removed
+\cs_new:Nn\mix_format_num:N{
+ \tl_set:Nx#1{\exp_after:wN\mix_format_num:w#1\q_stop}
+}
+\cs_new:Npn\mix_format_num:w#1.#2\q_stop{
+ #1.\exp_after:wN\mix_trim_places:w#2000000000\q_stop
+}
+\cs_new:Npn\mix_trim_places:w#1#2#3#4#5#6#7#8#9\q_stop{
+ \mix_trim_zeros:f{\exp_after:wN\tl_head:w#9\q_stop#8#7#6#5#4#3#2#1}
+}
+\cs_new:Nn\mix_trim_zeros:n{
+ \exp_after:wN\mix_trim_zeros:w#1\q_stop
+}
+\cs_generate_variant:Nn\mix_trim_zeros:n{f}
+\cs_new:Npn\mix_trim_zeros:w#1#2\q_stop{
+ \str_if_eq:nnTF{#1}{0}{
+ \int_compare:nNnTF{\tl_length:n{#2}}>{\c_one}{
+ \exp_after:wN\mix_trim_zeros:w#2\q_stop
+ }{#2}
+ }{
+ \tl_reverse:n{#2}#1
+ }
+}
+
+%macro for building the C2W transformation matrix
+\cs_new:Npn\mix_calc_ciiw:w#1~#2~#3~#4~#5~#6\q_stop{
+ % #1,#2,#3 centre of orbit coordinates (coo)
+ % #4,#5,#6 centre of orbit to camera direction vector (c2c)
+ %view vector (opposite to c2c)
+ \fp_set:Nn\l_mix_viewx_fp{#4}
+ \fp_set:Nn\l_mix_viewy_fp{#5}
+ \fp_set:Nn\l_mix_viewz_fp{#6}
+ \fp_neg:N\l_mix_viewx_fp
+ \fp_neg:N\l_mix_viewy_fp
+ \fp_neg:N\l_mix_viewz_fp
+
+ %normalize view vector
+ \fp_set:Nn\l_mix_temp_fp{#4}
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_temp_fp}
+ \fp_set_eq:NN\l_mix_mag_fp\l_mix_temp_fp
+ \fp_set:Nn\l_mix_temp_fp{#5}
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_temp_fp}
+ \fp_add:Nn\l_mix_mag_fp{\l_mix_temp_fp}
+ \fp_set:Nn\l_mix_temp_fp{#6}
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_temp_fp}
+ \fp_add:Nn\l_mix_mag_fp{\l_mix_temp_fp}
+ \fp_pow:Nn\l_mix_mag_fp{0.5}
+ \fp_div:Nn\l_mix_viewx_fp{\l_mix_mag_fp}
+ \fp_div:Nn\l_mix_viewy_fp{\l_mix_mag_fp}
+ \fp_div:Nn\l_mix_viewz_fp{\l_mix_mag_fp}
+
+ %camera roll
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_roll_fp
+ \fp_div:Nn\l_mix_temp_fp{180}
+ \fp_mul:Nn\l_mix_temp_fp{\c_pi_fp}
+ \fp_sin:Nn\l_mix_sinroll_fp{\l_mix_temp_fp}
+ \fp_cos:Nn\l_mix_cosroll_fp{\l_mix_temp_fp}
+
+ %top and bottom views
+ \fp_set:Nn\l_mix_leftx_fp{-1.0}
+ \fp_set:Nn\l_mix_lefty_fp{0.0}
+ \fp_set:Nn\l_mix_leftz_fp{0.0}
+ \fp_compare:nNnTF\l_mix_viewz_fp<\c_zero_fp{% top view
+ %up-vector
+ \fp_set:Nn\l_mix_upx_fp{0.0}
+ \fp_set:Nn\l_mix_upy_fp{1.0}
+ \fp_set:Nn\l_mix_upz_fp{0.0}
+ }{% bottom view
+ %up-vector
+ \fp_set:Nn\l_mix_upx_fp{0.0}%
+ \fp_set:Nn\l_mix_upy_fp{-1.0}%
+ \fp_set:Nn\l_mix_upz_fp{0.0}%
+ }
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_viewx_fp
+ \fp_abs:N\l_mix_temp_fp
+ \fp_set_eq:NN\l_mix_sumxy_fp\l_mix_temp_fp
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_viewy_fp
+ \fp_abs:N\l_mix_temp_fp
+ \fp_add:Nn\l_mix_sumxy_fp{\l_mix_temp_fp}
+ \fp_if_zero:NF\l_mix_sumxy_fp{% other views than top and bottom
+ %up-vector = up_world - (up_world dot view) view
+ \fp_set_eq:NN\l_mix_upx_fp\l_mix_viewz_fp
+ \fp_mul:Nn\l_mix_upx_fp{\l_mix_viewx_fp}
+ \fp_neg:N\l_mix_upx_fp
+ \fp_set_eq:NN\l_mix_upy_fp\l_mix_viewz_fp
+ \fp_mul:Nn\l_mix_upy_fp{\l_mix_viewy_fp}
+ \fp_neg:N\l_mix_upy_fp
+ \fp_set_eq:NN\l_mix_upz_fp\l_mix_viewz_fp
+ \fp_mul:Nn\l_mix_upz_fp{\l_mix_viewz_fp}
+ \fp_neg:N\l_mix_upz_fp
+ \fp_add:Nn\l_mix_upz_fp{1.0}
+ %normalize up-vector
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_upx_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_temp_fp}
+ \fp_set_eq:NN\l_mix_mag_fp\l_mix_temp_fp
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_upy_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_temp_fp}
+ \fp_add:Nn\l_mix_mag_fp{\l_mix_temp_fp}
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_upz_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_temp_fp}
+ \fp_add:Nn\l_mix_mag_fp{\l_mix_temp_fp}
+ \fp_pow:Nn\l_mix_mag_fp{0.5}
+ \fp_div:Nn\l_mix_upx_fp{\l_mix_mag_fp}
+ \fp_div:Nn\l_mix_upy_fp{\l_mix_mag_fp}
+ \fp_div:Nn\l_mix_upz_fp{\l_mix_mag_fp}
+ %left vector = up x view
+ \fp_set_eq:NN\l_mix_leftx_fp\l_mix_viewz_fp
+ \fp_mul:Nn\l_mix_leftx_fp{\l_mix_upy_fp}
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_viewy_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_upz_fp}
+ \fp_sub:Nn\l_mix_leftx_fp{\l_mix_temp_fp}
+ \fp_set_eq:NN\l_mix_lefty_fp\l_mix_viewx_fp
+ \fp_mul:Nn\l_mix_lefty_fp{\l_mix_upz_fp}
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_viewz_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_upx_fp}
+ \fp_sub:Nn\l_mix_lefty_fp{\l_mix_temp_fp}
+ \fp_set_eq:NN\l_mix_leftz_fp\l_mix_viewy_fp
+ \fp_mul:Nn\l_mix_leftz_fp{\l_mix_upx_fp}
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_viewx_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_upy_fp}
+ \fp_sub:Nn\l_mix_leftz_fp{\l_mix_temp_fp}
+ %normalize left vector
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_leftx_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_temp_fp}
+ \fp_set_eq:NN\l_mix_mag_fp\l_mix_temp_fp
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_lefty_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_temp_fp}
+ \fp_add:Nn\l_mix_mag_fp{\l_mix_temp_fp}
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_leftz_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_temp_fp}
+ \fp_add:Nn\l_mix_mag_fp{\l_mix_temp_fp}
+ \fp_pow:Nn\l_mix_mag_fp{0.5}
+ \fp_div:Nn\l_mix_leftx_fp{\l_mix_mag_fp}
+ \fp_div:Nn\l_mix_lefty_fp{\l_mix_mag_fp}
+ \fp_div:Nn\l_mix_leftz_fp{\l_mix_mag_fp}
+ }
+
+ %apply camera roll
+ \fp_set_eq:NN\l_mix_leftxprime_fp\l_mix_leftx_fp
+ \fp_mul:Nn\l_mix_leftxprime_fp{\l_mix_cosroll_fp}
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_upx_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_sinroll_fp}
+ \fp_add:Nn\l_mix_leftxprime_fp{\l_mix_temp_fp}
+ \fp_set_eq:NN\l_mix_leftyprime_fp\l_mix_lefty_fp
+ \fp_mul:Nn\l_mix_leftyprime_fp{\l_mix_cosroll_fp}
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_upy_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_sinroll_fp}
+ \fp_add:Nn\l_mix_leftyprime_fp{\l_mix_temp_fp}
+ \fp_set_eq:NN\l_mix_leftzprime_fp\l_mix_leftz_fp
+ \fp_mul:Nn\l_mix_leftzprime_fp{\l_mix_cosroll_fp}
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_upz_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_sinroll_fp}
+ \fp_add:Nn\l_mix_leftzprime_fp{\l_mix_temp_fp}
+
+ \fp_set_eq:NN\l_mix_upxprime_fp\l_mix_upx_fp
+ \fp_mul:Nn\l_mix_upxprime_fp{\l_mix_cosroll_fp}
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_leftx_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_sinroll_fp}
+ \fp_sub:Nn\l_mix_upxprime_fp{\l_mix_temp_fp}
+ \fp_set_eq:NN\l_mix_upyprime_fp\l_mix_upy_fp
+ \fp_mul:Nn\l_mix_upyprime_fp{\l_mix_cosroll_fp}
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_lefty_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_sinroll_fp}
+ \fp_sub:Nn\l_mix_upyprime_fp{\l_mix_temp_fp}
+ \fp_set_eq:NN\l_mix_upzprime_fp\l_mix_upz_fp
+ \fp_mul:Nn\l_mix_upzprime_fp{\l_mix_cosroll_fp}
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_leftz_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_sinroll_fp}
+ \fp_sub:Nn\l_mix_upzprime_fp{\l_mix_temp_fp}
+
+ \fp_set_eq:NN\l_mix_leftx_fp\l_mix_leftxprime_fp
+ \fp_set_eq:NN\l_mix_lefty_fp\l_mix_leftyprime_fp
+ \fp_set_eq:NN\l_mix_leftz_fp\l_mix_leftzprime_fp
+ \fp_set_eq:NN\l_mix_upx_fp\l_mix_upxprime_fp
+ \fp_set_eq:NN\l_mix_upy_fp\l_mix_upyprime_fp
+ \fp_set_eq:NN\l_mix_upz_fp\l_mix_upzprime_fp
+
+ %translation vector
+ \fp_set:Nn\l_mix_transx_fp{#1}
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_roo_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_viewx_fp}
+ \fp_sub:Nn\l_mix_transx_fp{\l_mix_temp_fp}
+ \fp_set:Nn\l_mix_transy_fp{#2}
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_roo_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_viewy_fp}
+ \fp_sub:Nn\l_mix_transy_fp{\l_mix_temp_fp}
+ \fp_set:Nn\l_mix_transz_fp{#3}
+ \fp_set_eq:NN\l_mix_temp_fp\l_mix_roo_fp
+ \fp_mul:Nn\l_mix_temp_fp{\l_mix_viewz_fp}
+ \fp_sub:Nn\l_mix_transz_fp{\l_mix_temp_fp}
+
+ %format elements of transformation matrix
+ \tl_set:Nx\l_mix_leftx_tl {\fp_use:N\l_mix_leftx_fp }
+ \tl_set:Nx\l_mix_lefty_tl {\fp_use:N\l_mix_lefty_fp }
+ \tl_set:Nx\l_mix_leftz_tl {\fp_use:N\l_mix_leftz_fp }
+ \tl_set:Nx\l_mix_upx_tl {\fp_use:N\l_mix_upx_fp }
+ \tl_set:Nx\l_mix_upy_tl {\fp_use:N\l_mix_upy_fp }
+ \tl_set:Nx\l_mix_upz_tl {\fp_use:N\l_mix_upz_fp }
+ \tl_set:Nx\l_mix_viewx_tl {\fp_use:N\l_mix_viewx_fp }
+ \tl_set:Nx\l_mix_viewy_tl {\fp_use:N\l_mix_viewy_fp }
+ \tl_set:Nx\l_mix_viewz_tl {\fp_use:N\l_mix_viewz_fp }
+ \tl_set:Nx\l_mix_transx_tl{\fp_use:N\l_mix_transx_fp}
+ \tl_set:Nx\l_mix_transy_tl{\fp_use:N\l_mix_transy_fp}
+ \tl_set:Nx\l_mix_transz_tl{\fp_use:N\l_mix_transz_fp}
+ \mix_format_num:N\l_mix_leftx_tl
+ \mix_format_num:N\l_mix_lefty_tl
+ \mix_format_num:N\l_mix_leftz_tl
+ \mix_format_num:N\l_mix_upx_tl
+ \mix_format_num:N\l_mix_upy_tl
+ \mix_format_num:N\l_mix_upz_tl
+ \mix_format_num:N\l_mix_viewx_tl
+ \mix_format_num:N\l_mix_viewy_tl
+ \mix_format_num:N\l_mix_viewz_tl
+ \mix_format_num:N\l_mix_transx_tl
+ \mix_format_num:N\l_mix_transy_tl
+ \mix_format_num:N\l_mix_transz_tl
+
+ %concat elements to matrix
+ \tl_set:Nx\l_mix_ciiw_tl{
+ \l_mix_leftx_tl \space
+ \l_mix_lefty_tl \space
+ \l_mix_leftz_tl \space
+ \l_mix_upx_tl \space
+ \l_mix_upy_tl \space
+ \l_mix_upz_tl \space
+ \l_mix_viewx_tl \space
+ \l_mix_viewy_tl \space
+ \l_mix_viewz_tl \space
+ \l_mix_transx_tl\space
+ \l_mix_transy_tl\space
+ \l_mix_transz_tl
+ }
+}
+
+% 3D view object
+\cs_new:Nn\mix_view:n{
+ \tl_set:Nx\l_mix_oscale_tl{\fp_use:N\l_mix_oscale_fp}
+ \mix_format_num:N\l_mix_oscale_tl
+ \tl_set:Nx\l_mix_aac_tl{\fp_use:N\l_mix_aac_fp}
+ \mix_format_num:N\l_mix_aac_tl
+ \tl_set:Nx\l_mix_roo_tl{\fp_use:N\l_mix_roo_fp}
+ \mix_format_num:N\l_mix_roo_tl
+ \mix_pdfobj:nnn{}{dict}{
+ /MS/M
+ /P<<
+ \bool_if:NTF\l_mix_iiidortho_bool{
+ /Subtype/O/OS~\l_mix_oscale_tl/OB/Min
+ }{
+ /Subtype/P/FOV~\l_mix_aac_tl/PS/Min
+ }
+ >>
+ /C2W~[\l_mix_ciiw_tl]
+ /CO~\l_mix_roo_tl
+ /NR~true/NA~[\l_mix_naarray_tl]
+ /SA~[\l_mix_saarray_tl]
+ \l_mix_bg_tl\l_mix_ls_tl\l_mix_rm_tl
+ /XN~(#1)
+ }
+}
+
+%document command options
+
+\msg_set:nnnn{media9}{unknown~option}{
+ Line~\msg_line_number: :~Unknown~option~`#1'.
+}{
+ Option~'#1'~is~not~known~by~media9:\\
+ perhaps~it~is~spelled~incorrectly.
+}
+
+\msg_set:nnn{media9}{same~label}{
+ Line~\msg_line_number: :~Label~`#1'~multiply~defined.
+}
+\msg_set:nnn{media9}{multiple~labels}{\\
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\\
+ @@~There~were~multiply-defined~labels!~@@\\
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+}
+
+\bool_new:N\g_mix_usrdraft_bool
+\bool_new:N\g_mix_opt_iiidview_bool
+\bool_new:N\l_mix_roo_bool
+\bool_new:N\g_mix_opt_ciiw_bool
+\bool_new:N\g_mix_opt_iiidortho_bool
+\bool_new:N\l_mix_ciiw_bool
+\bool_new:N\l_mix_iiidortho_bool
+
+\seq_new:N\g_mix_res_seq
+\seq_new:N\g_mix_script_seq
+\keys_define:nn{media9/user}{
+ %user override automatic label
+ label .code:n = {
+ \tl_gset:Nx\g_mix_label_tl{rm.#1}
+ \cs_if_exist:cTF{rm.#1}{
+ \msg_warning:nnx{media9}{same~label}{#1}
+ \cs_if_exist:NF\g_mix_samelabel_tl{
+ \tl_new:N\g_mix_samelabel_tl
+ \AtEndDocument{\msg_warning:nn{media9}{multiple~labels}}
+ }
+ }{
+ \tl_new:c{rm.#1}
+ }
+ },
+ label .value_required:,
+
+ width .code:n = {
+ \tl_gset:Nn\g_mix_wdarg_tl{#1}
+ \int_gadd:Nn\g_mix_resizeflag_int{\c_four}
+ },
+ width .value_required:,
+
+ height .code:n = {
+ \tl_gset:Nn\g_mix_htarg_tl{#1}
+ \int_gadd:Nn\g_mix_resizeflag_int{\c_two}
+ },
+ height .value_required:,
+
+ depth .code:n = {
+ \tl_gset:Nn\g_mix_dparg_tl{#1}
+ \int_gadd:Nn\g_mix_resizeflag_int{\c_one}
+ },
+ depth .value_required:,
+
+ scale .code:n = {\tl_gset:Nx\g_mix_scalearg_tl{#1}},
+ scale .value_required:,
+
+ url .bool_gset:N = \g_mix_url_bool,
+
+ addresource .code:n = {\seq_gput_right:Nn\g_mix_res_seq{#1}},
+ addresource .value_required:,
+
+ add3Djscript .code:n = {\seq_gput_right:Nn\g_mix_script_seq{#1}},
+ add3Djscript .value_required:,
+
+ flashvars .tl_gset_x:N = \g_mix_flashvars_tl,
+ flashvars .value_required:,
+
+ activate .choice:,
+ activate / pagevisible .code:n = {\tl_gset:Nn\g_mix_act_tl{/PV}},
+ activate / pageopen .code:n = {\tl_gset:Nn\g_mix_act_tl{/PO}},
+ activate / onclick .code:n = {\tl_gset:Nn\g_mix_act_tl{/XA}},
+
+ deactivate .choice:,
+ deactivate / pageinvisible .code:n = {\tl_gset:Nn\g_mix_act_tl{/PI}},
+ deactivate / pageclose .code:n = {\tl_gset:Nn\g_mix_act_tl{/PC}},
+ deactivate / onclick .code:n = {\tl_gset:Nn\g_mix_act_tl{/XD}},
+
+ draft .choice:,
+ draft / true .code:n = {\bool_gset_true:N\g_mix_usrdraft_bool},
+ draft / false .code:n = {\bool_gset_false:N\g_mix_usrdraft_bool},
+ draft .default:n = {true},
+
+ final .choice:,
+ final / true .code:n = {\bool_gset_false:N\g_mix_usrdraft_bool},
+ final / false .code:n = {\bool_gset_true:N\g_mix_usrdraft_bool},
+ final .default:n = {true},
+
+ transparent .choice_code:n = {\tl_gset:Nx\g_mix_transp_tl{\l_keys_choice_tl}},
+ transparent .generate_choices:n = {true,false},
+ transparent .default:n = {true},
+
+ passcontext .choice_code:n = {\tl_gset:Nx\g_mix_contextclick_tl{
+ \l_keys_choice_tl}},
+ passcontext .generate_choices:n = {true,false},
+ passcontext .default:n = {true},
+
+ %3D specific options
+ 3Dplaytype .choice:,
+ 3Dplaytype / none .code:n = {\tl_gset:Nn\g_mix_playtpe_tl{None}},
+ 3Dplaytype / linear .code:n = {\tl_gset:Nn\g_mix_playtpe_tl{Linear}},
+ 3Dplaytype / oscillating .code:n = {
+ \tl_gset:Nn\g_mix_playtpe_tl{Oscillating}},
+
+ 3Dplaycount .code:n = {\tl_gset:Nn\g_mix_playcnt_tl{
+ \exp_after:wN\int_value:w \dim_eval:w#1sp\dim_eval_end:}},
+ 3Dplaycount .value_required:,
+
+ 3Dplayspeed .tl_gset_x:N = \g_mix_playspd_tl,
+ 3Dplayspeed .value_required:,
+
+ 3Dtoolbar .choice_code:n = {\tl_gset:Nx\g_mix_tools_tl{\l_keys_choice_tl}},
+ 3Dtoolbar .generate_choices:n = {true,false},
+ 3Dtoolbar .default:n = {true},
+
+ 3Dnavpane .choice_code:n = {\tl_gset:Nx\g_mix_nav_tl{\l_keys_choice_tl}},
+ 3Dnavpane .generate_choices:n = {true,false},
+ 3Dnavpane .default:n = {true},
+
+ 3Dcoo .code:n = {\tl_gset:Nn\g_mix_opt_coo_tl{#1}
+ \bool_gset_true:N\g_mix_opt_iiidview_bool},
+ 3Dcoo .value_required:,
+
+ 3Dc2c .code:n = {\tl_gset:Nn\g_mix_opt_ctoc_tl{#1}
+ \bool_gset_true:N\g_mix_opt_iiidview_bool},
+ 3Dc2c .value_required:,
+
+ 3Dc2w .code:n = {
+ \tl_gset:Nx\g_mix_opt_ciiw_tl{#1}
+ \bool_gset_true:N\g_mix_opt_iiidview_bool
+ \bool_gset_true:N\g_mix_opt_ciiw_bool
+ },
+ 3Dc2w .value_required:,
+
+ 3Droo .code:n = {
+ \fp_gset:Nn\g_mix_opt_roo_fp{#1}
+ \fp_abs:N\g_mix_opt_roo_fp
+ \fp_if_zero:NT\g_mix_opt_roo_fp{\fp_set:Nn\g_mix_opt_roo_fp{1e-8}}
+ \bool_gset_true:N\g_mix_opt_iiidview_bool
+ \bool_set_true:N\l_mix_roo_bool
+ },
+ 3Droo .value_required:,
+
+ 3Daac .code:n = {\fp_gset:Nn\g_mix_opt_aac_fp{#1}
+ \bool_gset_true:N\g_mix_opt_iiidview_bool},
+ 3Daac .value_required:,
+
+ 3Dortho .code:n = {
+ \bool_gset_true:N\g_mix_opt_iiidview_bool
+ \bool_gset_true:N\g_mix_opt_iiidortho_bool
+ \fp_compare:nNnF#1=\c_zero{
+ \fp_gset:Nn\g_mix_opt_oscale_fp{#1}
+ \bool_if:NF\l_mix_roo_bool{
+ \fp_set:Nn\l_mix_temp_fp{1}
+ \fp_div:Nn\l_mix_temp_fp{#1}
+ \fp_div:Nn\l_mix_temp_fp{2}
+ \fp_gset_eq:NN\g_mix_opt_roo_fp\l_mix_temp_fp
+ }
+ }
+ },
+ 3Dortho .default:n = {1},
+
+ 3Droll .code:n = {\fp_gset:Nn\g_mix_opt_roll_fp{#1}
+ \bool_gset_true:N\g_mix_opt_iiidview_bool},
+ 3Droll .value_required:,
+
+ 3Dmenu .bool_gset:N = \g_mix_iiidcalc_bool,
+
+ 3Dbg .code:n = {
+ \tl_gset:Nx\g_mix_opt_bg_tl{/BG<</Subtype/SC/CS/DeviceRGB/C[#1]/EA~true>>}
+ },
+ 3Dbg .value_required:,
+
+ 3Dlights .code:n = {
+ \tl_gset:Nx\g_mix_opt_ls_tl{/LS<</Subtype/#1>>}
+ },
+ 3Dlights .value_required:,
+
+ 3Drender .code:n = {
+ \tl_gset:Nx\g_mix_opt_rm_tl{/RM<</Subtype/#1>>}
+ },
+ 3Drender .value_required:,
+
+ 3Dviews .code:n = {
+ \file_if_exist:nTF{#1}{
+ \file_add_path:nN{#1}\l_mix_temp_tl
+ \tl_gset_eq:NN\g_mix_vfile_tl\l_mix_temp_tl
+ }{
+ \msg_error:nnxx{media9}{file~not~found}{#1}
+ }
+ },
+ 3Dviews .value_required:,
+
+ unknown .code:n = {
+ \msg_error:nnx{media9}{unknown~option}{\exp_not:V\l_keys_key_tl}
+ },
+}
+
+%3D views file parsing
+
+%messages related to 3D views file parsing
+\msg_set:nnn{media9}{nested~view}{
+ File~#1,~line~#2:\\
+ A~VIEW~section~cannot~be~nested~into~another~section.
+}
+
+\msg_set:nnn{media9}{key~not~allowed}{
+ File~#1,~line~#2:\\
+ Key~`#3'~not~allowed~here;~must~go~into~#4~section.
+}
+
+\msg_set:nnn{media9}{section~not~allowed}{
+ File~#1,~line~#2:\\
+ #3~not~allowed~here;~must~be~a~sub-section~of~a~#4~section.
+}
+
+\msg_set:nnn{media9}{missing~part~name}{
+ File~#1,~line~#2:\\
+ You~must~provide~a~valid~PART~name~(PART=<part name>),~as~displayed\\
+ in~the~model~tree~of~the~3D~object~(go~to~`View'->`Navigation~Panels'\\
+ ->`Model~Tree'~in~Adobe~Reader).
+}
+
+\msg_set:nnn{media9}{missing~utf16~name}{
+ File~#1,~line~#2:\\
+ You~must~provide~a~valid~hex~encoded~part~name~(UTF16NAME=<part~name\\
+ as~hex~encoded~UTF-16~string>).~Enable~`3Dmenu'~option~and~choose\\
+ `Get~Current~View'~from~3D~context~menu~to~generate~correct~views~file\\
+ entries.
+}
+
+\msg_set:nnn{media9}{too~many~cross~sections}{
+ File~#1,~line~#2:\\
+ Adobe~Reader~supports~only~one~cross~section~per~3D~view.\\
+ I~am~ignoring~this~CROSSSECT.
+}
+
+\msg_set:nnn{media9}{no~end~here}{
+ File~#1,~line~#2:\\
+ There~is~nothing~to~END~here.
+}
+
+\cs_new:Npn\mix_parse_vect:w#1~#2~#3\q_stop{
+ \fp_set:Nn\l_mix_x_fp{#1}
+ \fp_set:Nn\l_mix_y_fp{#2}
+ \fp_set:Nn\l_mix_z_fp{#3}
+}
+
+\cs_new:Nn\mix_arcsin:Nnnn{
+ %#1 result (rad), #2 argument, #3 current term no., #4 total number of
+ %terms
+ \int_compare:nTF{#3==\c_zero}{
+ \fp_set:Nn\l_mix_tmpa_fp{1.0}
+ \fp_set:Nn\l_mix_tmpb_fp{1.0}
+ \fp_set:Nn\l_mix_tmpc_fp{1.0}
+ \fp_set:Nn\l_mix_tmpd_fp{#2}
+
+ \fp_set:Nn#1{#2}
+ }{
+ \fp_mul:Nn\l_mix_tmpa_fp{\int_eval:n{2*#3-1}}
+ \fp_mul:Nn\l_mix_tmpb_fp{\int_eval:n{2*#3}}
+ \fp_set:Nn\l_mix_tmpc_fp{\int_eval:n{2*#3+1}}
+ \fp_mul:Nn\l_mix_tmpd_fp{#2}
+ \fp_mul:Nn\l_mix_tmpd_fp{#2}
+
+ \fp_set_eq:NN\l_mix_tmpe_fp\l_mix_tmpd_fp
+ \fp_mul:Nn\l_mix_tmpe_fp{\l_mix_tmpa_fp}
+ \fp_div:Nn\l_mix_tmpe_fp{\l_mix_tmpb_fp}
+ \fp_div:Nn\l_mix_tmpe_fp{\l_mix_tmpc_fp}
+
+ \fp_add:Nn#1{\l_mix_tmpe_fp}
+ }
+ \int_compare:nF{#3==#4}{
+ \mix_arcsin:Nnnn#1{#2}{\int_eval:n{#3+1}}{#4}
+ }
+}
+
+\cs_new:Nn\mix_angfromxy:Nnn{ %#1 result (deg), #2 x, #3 y
+ %#1 result, #2 x, #3 y
+ \fp_set:Nn\l_mix_tmpa_fp{#2}\fp_mul:Nn\l_mix_tmpa_fp{#2}
+ \fp_set:Nn\l_mix_tmpb_fp{#3}\fp_mul:Nn\l_mix_tmpb_fp{#3}
+ \fp_add:Nn\l_mix_tmpa_fp\l_mix_tmpb_fp
+ \fp_pow:Nn\l_mix_tmpa_fp{0.5}
+ \fp_set:Nn\l_mix_asinarg_fp{#3}
+ \fp_div:Nn\l_mix_asinarg_fp\l_mix_tmpa_fp
+ \fp_set:Nn\l_mix_acosarg_fp{#2}
+ \fp_div:Nn\l_mix_acosarg_fp\l_mix_tmpa_fp
+ \fp_set:Nn\l_mix_halfsqrttwo_fp{2}
+ \fp_pow:Nn\l_mix_halfsqrttwo_fp{0.5}
+ \fp_div:Nn\l_mix_halfsqrttwo_fp{2}
+ \mix_arcsin:Nnnn\l_mix_arcsin_fp{\l_mix_asinarg_fp}{0}{10}
+ \mix_arcsin:Nnnn\l_mix_arccos_fp{\l_mix_acosarg_fp}{0}{10}
+ \fp_abs:N\l_mix_asinarg_fp
+ %determine quadrant
+ \fp_compare:nTF{#2>=\c_zero_fp}{
+ \fp_compare:nTF{#3>=\c_zero_fp}{ %I
+ \fp_compare:nNnTF\l_mix_asinarg_fp<\l_mix_halfsqrttwo_fp{
+ \fp_set_eq:NN#1\l_mix_arcsin_fp
+ }{
+ \fp_set:Nn#1{\c_pi_fp}\fp_div:Nn#1{2}
+ \fp_sub:Nn#1\l_mix_arccos_fp
+ }
+ }{ %IV
+ \fp_compare:nNnTF\l_mix_asinarg_fp<\l_mix_halfsqrttwo_fp{
+ \fp_set_eq:NN#1\l_mix_arcsin_fp
+ }{
+ \fp_set:Nn#1{\c_pi_fp}\fp_div:Nn#1{2}
+ \fp_sub:Nn#1\l_mix_arccos_fp
+ \fp_neg:N#1
+ }
+ }
+ }{
+ \fp_compare:nTF{#3>=\c_zero_fp}{ %II
+ \fp_compare:nNnTF\l_mix_asinarg_fp<\l_mix_halfsqrttwo_fp{
+ \fp_set:Nn#1{\c_pi_fp}
+ \fp_sub:Nn#1\l_mix_arcsin_fp
+ }{
+ \fp_set:Nn#1{\c_pi_fp}\fp_div:Nn#1{2}
+ \fp_sub:Nn#1\l_mix_arccos_fp
+ }
+ }{ %III
+ \fp_compare:nNnTF\l_mix_asinarg_fp<\l_mix_halfsqrttwo_fp{
+ \fp_set:Nn#1{-\c_pi_fp}
+ \fp_sub:Nn#1\l_mix_arcsin_fp
+ }{
+ \fp_set:Nn#1{\c_pi_fp}\fp_div:Nn#1{2}
+ \fp_sub:Nn#1\l_mix_arccos_fp
+ \fp_neg:N#1
+ }
+ }
+ }
+ \fp_mul:Nn#1{180}\fp_div:Nn#1{\c_pi_fp}
+}
+
+\bool_new:N\l_mix_blankndname_bool
+
+%keys for parsing the 3D views file
+\keys_define:nn{media9/views}{
+ VIEW .code:n = {
+ \int_compare:nF{\l_mix_level_tl<\c_zero}{
+ \msg_error:nnxx{media9}{nested~view}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}
+ }
+ \tl_set:Nn\l_mix_level_tl{\c_zero}
+ \tl_set:Nn\l_mix_cscount_tl{\c_zero}
+ \tl_set:Nx\l_mix_xname_tl{#1}%optional name of the view
+ %reset 3D settings to defaults
+ \mix_iiidreset:
+ },
+ VIEW .default:n = {},
+
+ COO .code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_zero}{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{COO}{a~VIEW}
+ }
+ \tl_set:Nx\l_mix_coo_tl{#1}
+ },
+ COO .value_required:,
+
+ C2C .code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_zero}{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{C2C}{a~VIEW}
+ }
+ \tl_set:Nx\l_mix_ctoc_tl{#1}
+ },
+ C2C .value_required:,
+
+ C2W .code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_zero}{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{C2W}{a~VIEW}
+ }
+ \tl_set:Nx\l_mix_ciiw_tl{#1}
+ \bool_set_true:N\l_mix_ciiw_bool
+ },
+ C2W .value_required:,
+
+ ROO .code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_zero}{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{ROO}{a~VIEW}
+ }
+ \fp_set:Nn\l_mix_roo_fp{#1}
+ \fp_abs:N\l_mix_roo_fp
+ \fp_if_zero:NT\l_mix_roo_fp{\fp_set:Nn\l_mix_roo_fp{1e-8}}
+ \bool_set_true:N\l_mix_roo_bool
+ },
+ ROO .value_required:,
+
+ AAC .code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_zero}{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{AAC}{a~VIEW}
+ }
+ \fp_set:Nn\l_mix_aac_fp{#1}
+ },
+ AAC .value_required:,
+
+ ORTHO .code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_zero}{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{ORTHO}{a~VIEW}
+ }
+ \bool_set_true:N\l_mix_iiidortho_bool
+ \fp_compare:nNnF#1=\c_zero{
+ \fp_set:Nn\l_mix_oscale_fp{#1}
+ \bool_if:NF\l_mix_roo_bool{
+ \fp_set:Nn\l_mix_temp_fp{1}
+ \fp_div:Nn\l_mix_temp_fp{#1}
+ \fp_div:Nn\l_mix_temp_fp{2}
+ \fp_set_eq:NN\l_mix_roo_fp\l_mix_temp_fp
+ }
+ }
+ },
+ ORTHO .default:n = {1},
+
+ ROLL .code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_zero}{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{ROLL}{a~VIEW}
+ }
+ \fp_set:Nn\l_mix_roll_fp{#1}
+ },
+ ROLL .value_required:,
+
+ BGCOLOR .code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_zero}{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{BGCOLOR}{a~VIEW}
+ }
+ \tl_set:Nx\l_mix_bg_tl{/BG<</CS/DeviceRGB/C[#1]/EA~true>>}
+ },
+ BGCOLOR .value_required:,
+
+ LIGHTS .code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_zero}{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{LIGHTS}{a~VIEW}
+ }
+ \tl_set:Nx\l_mix_ls_tl{/LS<</Subtype/#1>>}
+ },
+ LIGHTS .value_required:,
+
+ RENDERMODE .code:n = {
+ \bool_if:nF{
+ \int_compare_p:n{\l_mix_level_tl=\c_zero} ||
+ \int_compare_p:n{\l_mix_level_tl=\c_one}
+ }{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}
+ {RENDERMODE}{a~VIEW~or~a~PART}
+ }
+ \int_compare:nT{\l_mix_level_tl=\c_zero}{
+ \tl_set:Nx\l_mix_rm_tl{/RM<</Subtype/#1>>}
+ }
+ \int_compare:nT{\l_mix_level_tl=\c_one}{
+ \tl_set:Nx\l_mix_ndrm_tl{/RM<</Subtype/#1>>} %part (=node) render mode
+ }
+ },
+ RENDERMODE .value_required:,
+
+ PART .code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_zero}{
+ \msg_error:nnxxxx{media9}{section~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{PART}{VIEW}
+ }
+ \bool_set_true:N\l_mix_blankndname_bool
+ \bool_set:Nn\l_mix_blankndname_bool{\tl_if_blank_p:o{#1}}
+ \tl_set:Nn\l_mix_level_tl{\c_one}
+ \tl_set:Nn\l_mix_ndname_tl{(#1)} %part (=node) name
+ \tl_set_eq:NN\l_mix_partlineno_int\l_mix_lineno_int
+ %default part settings
+ \tl_set:Nn\l_mix_ndop_tl{} %opacity
+ \tl_set:Nn\l_mix_ndvi_tl{} %visibility
+ \tl_set:Nn\l_mix_ndrm_tl{} %render mode
+ \tl_set:Nn\l_mix_ndtrans_tl{}%transformation matrix
+ },
+ PART .default:n = {},
+
+ UTF16NAME .code:n = { %part (=node) name, UTF16, HEX encoded
+ \int_compare:nF{\l_mix_level_tl=\c_one}{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{UTF16NAME}{PART}
+ }
+ \tl_if_blank:oT{#1}{
+ \msg_error:nnxx{media9}{missing~utf16~name}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}
+ }
+ \bool_set_false:N\l_mix_blankndname_bool
+ \mix_ndname:n{feff#1}
+ },
+ UTFNAME .default:n = {},
+
+ OPACITY .code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_one}{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{OPACITY}{PART}
+ }
+ \tl_set:Nx\l_mix_ndop_tl{/O~#1}
+ },
+ OPACITY .value_required:,
+
+ VISIBLE .choice_code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_one}{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{VISIBLE}{PART}
+ }
+ \tl_set:Nx\l_mix_ndvi_tl{/V~\l_keys_choice_tl}
+ },
+ VISIBLE .generate_choices:n = {true,false},
+ VISIBLE .default:n = {true},
+
+ TRANSFORM .code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_one}{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{TRANSLATE}{PART}
+ }
+ \seq_set_split:Nnn\l_mix_args_seq{~}{#1}
+ \seq_map_inline:Nn\l_mix_args_seq{
+ \fp_set:Nn\l_mix_tmpa_fp{##1}
+ \tl_set:Nx\l_mix_tmpa_tl{\fp_use:N\l_mix_tmpa_fp}
+ \mix_format_num:N\l_mix_tmpa_tl
+ \tl_put_right:Nx\l_mix_ndtrans_tl{~\l_mix_tmpa_tl}
+ }
+ },
+ TRANSFORM .value_required:,
+
+ CROSSSECT .code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_zero}{
+ \msg_error:nnxxxx{media9}{section~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{CROSSSECT}{VIEW}
+ }
+ \int_compare:nT{\l_mix_cscount_tl>\c_zero}{
+ \msg_warning:nnxx{media9}{too~many~cross~sections}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}
+ }
+ \tl_set:Nn\l_mix_level_tl{\c_two}
+ %default part settings
+ \tl_set:Nn\l_mix_cscentre_tl{0~0~0} %centre of clipping plane
+ \tl_set:Nn\l_mix_csorient_tl{null~0~0} %orientation of plane
+ },
+ CROSSSECT .value_forbidden:,
+
+ CENTER .code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_two}{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{CENTER}{CROSSSECT}
+ }
+ \tl_set:Nx\l_mix_args_tl{#1\space}
+ \exp_after:wN\mix_parse_vect:w\l_mix_args_tl\q_stop
+ \tl_set:Nx\l_mix_x_tl{\fp_use:N\l_mix_x_fp}
+ \mix_format_num:N\l_mix_x_tl
+ \tl_set:Nx\l_mix_y_tl{\fp_use:N\l_mix_y_fp}
+ \mix_format_num:N\l_mix_y_tl
+ \tl_set:Nx\l_mix_z_tl{\fp_use:N\l_mix_z_fp}
+ \mix_format_num:N\l_mix_z_tl
+ \tl_set:Nx\l_mix_cscentre_tl{
+ \l_mix_x_tl\space
+ \l_mix_y_tl\space
+ \l_mix_z_tl
+ }
+ },
+ CENTER .value_required:,
+
+ NORMAL .code:n = {
+ \int_compare:nF{\l_mix_level_tl=\c_two}{
+ \msg_error:nnxxxx{media9}{key~not~allowed}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}{NORMAL}{CROSSSECT}
+ }
+ \tl_set:Nx\l_mix_args_tl{#1\space}
+ \exp_after:wN\mix_parse_vect:w\l_mix_args_tl\q_stop
+ \fp_set_eq:NN\l_mix_tmpa_fp\l_mix_x_fp
+ \fp_mul:Nn\l_mix_tmpa_fp\l_mix_x_fp
+ \fp_set_eq:NN\l_mix_tmpb_fp\l_mix_y_fp
+ \fp_mul:Nn\l_mix_tmpb_fp\l_mix_y_fp
+ \fp_set_eq:NN\l_mix_magxy\l_mix_tmpa_fp
+ \fp_add:Nn\l_mix_magxy\l_mix_tmpb_fp
+ \fp_pow:Nn\l_mix_magxy{0.5} %sqrt(x^2+y^2)
+ %rot angle of normal vec around Y axis
+ \mix_angfromxy:Nnn\l_mix_roty_fp\l_mix_magxy\l_mix_z_fp
+ \fp_neg:N\l_mix_roty_fp
+ %rot angle of normal vec around Z axis
+ \mix_angfromxy:Nnn\l_mix_rotz_fp\l_mix_x_fp\l_mix_y_fp
+ \tl_set:Nx\l_mix_roty_tl{\fp_use:N\l_mix_roty_fp}
+ \mix_format_num:N\l_mix_roty_tl
+ \tl_set:Nx\l_mix_rotz_tl{\fp_use:N\l_mix_rotz_fp}
+ \mix_format_num:N\l_mix_rotz_tl
+ \tl_set:Nx\l_mix_csorient_tl{null~\l_mix_roty_tl\space\l_mix_rotz_tl}
+ },
+ NORMAL .value_required:,
+
+ END .code:n = {
+ \prg_case_int:nnn{\l_mix_level_tl}{
+ {0}{ %VIEW
+ \bool_if:NF\l_mix_ciiw_bool{
+ \tl_set:Nx\l_mix_args_tl{\l_mix_coo_tl\space\l_mix_ctoc_tl\space}
+ \exp_after:wN\mix_calc_ciiw:w\l_mix_args_tl\q_stop
+ }
+ \int_incr:N\l_mix_viewcnt_int
+ \tl_if_blank:VT\l_mix_xname_tl{
+ \tl_set:Nx\l_mix_xname_tl{View~\int_use:N\l_mix_viewcnt_int}
+ }
+ \mix_view:n{\l_mix_xname_tl}
+ \tl_put_right:Nx\l_mix_iiidviewarray_tl{~\g_mix_pdflastobj_tl}
+ \tl_set:Nn\l_mix_level_tl{\c_minus_one}
+ }
+
+ {1}{ %PART
+ \bool_if:NT\l_mix_blankndname_bool{
+ \msg_error:nnxx{media9}{missing~part~name}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_partlineno_int}
+ }
+
+ \mix_pdfobj:nnn{}{dict}{
+ /Type/3DNode/N~\l_mix_ndname_tl
+ \l_mix_ndop_tl\l_mix_ndvi_tl\l_mix_ndrm_tl
+ \tl_if_blank:VF\l_mix_ndtrans_tl{
+ /M~[\l_mix_ndtrans_tl]
+ }
+ }
+
+ \tl_put_right:Nx\l_mix_naarray_tl{~\g_mix_pdflastobj_tl}
+ \tl_set:Nn\l_mix_level_tl{\c_zero}
+ }
+ {2}{ %CROSSSECT
+ \int_compare:nT{\l_mix_cscount_tl=\c_zero}{
+ \mix_pdfobj:nnn{}{dict}{
+ /Type/3DCrossSection
+ /C~[\l_mix_cscentre_tl]
+ /O~[\l_mix_csorient_tl]
+ /IV~true
+ }
+ \tl_put_right:Nx\l_mix_saarray_tl{~\g_mix_pdflastobj_tl}
+ \tl_set:Nn\l_mix_cscount_tl{\c_one}
+ }
+ \tl_set:Nn\l_mix_level_tl{\c_zero}
+ }
+ }{
+ \msg_error:nnxx{media9}{no~end~here}
+ {\g_mix_vfile_tl}{\int_use:N\l_mix_lineno_int}
+ }
+ },
+ END .value_forbidden:,
+}
diff --git a/Master/texmf-dist/tex/latex/media9/players/APlayer.mxml b/Master/texmf-dist/tex/latex/media9/players/APlayer.mxml
new file mode 100644
index 00000000000..67375fb6a06
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/media9/players/APlayer.mxml
@@ -0,0 +1,143 @@
+<?xml version="1.0"?>
+<!-- -->
+<!-- Adobe Flex 4 source file of APlayer.swf, -->
+<!-- a FlashPlayer-10 compatible component for playing -->
+<!-- MP3 audio files and streams. -->
+<!-- -->
+<!-- version 20120301 -->
+<!-- -->
+<!-- -->
+<!-- The free Adobe Flex 4 SDK is required to compile -->
+<!-- this file. Get it from -->
+<!-- -->
+<!-- http://www.adobe.com/products/flex/ -->
+<!-- -->
+<!-- and run -->
+<!-- -->
+<!-- mxmlc -static-link-runtime-shared-libraries APlayer.mxml -->
+<!-- -->
+<!-- on the command line. -->
+<!-- -->
+<!-- -->
+<!-- Copyright (C) 2012 Alexander Grahn -->
+<!-- -->
+<!-- This work may be distributed and/or modified under the -->
+<!-- conditions of the LaTeX Project Public License, either -->
+<!-- version 1.3 of this license or (at your option) any later -->
+<!-- version. -->
+<!-- -->
+<!-- The latest version of this license is in -->
+<!-- http://www.latex-project.org/lppl.txt -->
+<!-- and version 1.3 or later is part of all distributions of -->
+<!-- LaTeX version 2005/12/01 or later. -->
+<!-- -->
+<!-- This work has the LPPL maintenance status `maintained'. -->
+<!-- -->
+<!-- The current maintainer of this work is A. Grahn. -->
+<!-- -->
+
+<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:s="library://ns.adobe.com/flex/spark"
+ xmlns:mx="library://ns.adobe.com/flex/mx"
+ preinitialize="initialise(FlexGlobals.topLevelApplication.parameters);"
+ applicationComplete="initSound();addEventListener(Event.ENTER_FRAME, onEnterFrame);"
+ mouseDown="pause();"
+ mouseUp="play();"
+>
+
+ <fx:Script>
+ <![CDATA[
+ [Bindable] private var source:String;
+ [Bindable] private var autoPlay:Boolean=false;
+ [Bindable] private var loop:Boolean=false;
+ [Bindable] private var volume:Number=0.75;
+ [Bindable] private var balance:Number=0;
+
+ private var snd:Sound;
+ private var sndCh:SoundChannel;
+ private var sndTr:SoundTransform;
+ private var playResumePosition:Number = 0;
+ private var playing:Boolean = false;
+
+ import mx.core.FlexGlobals;
+ private function initialise(flashVars:Object):void{
+ source=flashVars.source;
+ if(flashVars.autoPlay){autoPlay=(flashVars.autoPlay=='true')}
+ if(flashVars.loop){loop=(flashVars.loop=='true')}
+ if(flashVars.volume){volume=Number(flashVars.volume)}
+ if(flashVars.balance){balance=Number(flashVars.balance)}
+ }
+
+ import mx.controls.Alert;
+ private function initSound():void
+ {
+ snd = new Sound(new URLRequest(source));
+ sndTr = new SoundTransform(volume, balance);
+
+ snd.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
+ snd.addEventListener(ProgressEvent.PROGRESS, progressHandler);
+ snd.addEventListener(Event.COMPLETE, completeHandler);
+
+ if(autoPlay) play();
+ }
+
+ private function play():void
+ {
+ if (!playing)
+ {
+ try{sndCh = snd.play(playResumePosition, 0, sndTr);}
+ catch(err:Error){Alert.show(err.message,'Error');}
+ sndCh.addEventListener(Event.SOUND_COMPLETE, sndCompleteHandler);
+ playing = true;
+ }
+ }
+
+ private function pause():void
+ {
+ if (playing)
+ {
+ playResumePosition = sndCh.position;
+ sndCh.stop();
+ playing = false;
+ }
+ }
+
+ private function sndCompleteHandler(event:Event):void
+ {
+ playing = false;
+ playResumePosition = 0;
+ if(loop) play();
+ }
+
+ private function completeHandler(event:Event):void
+ {
+ playProgress.indeterminate=false;
+ }
+
+ import flash.events.ProgressEvent;
+ private function progressHandler(event:ProgressEvent):void{
+ playProgress.indeterminate=true;
+ if(playing){
+ playProgress.setProgress(0.5,1);
+ }
+ }
+
+ private function onEnterFrame(event:Event):void{
+ if(playProgress.indeterminate==false && playing){
+ playProgress.setProgress(sndCh.position,snd.length);
+ }
+ }
+
+ import flash.events.IOErrorEvent;
+ private function errorHandler(errorEvent:IOErrorEvent):void{
+ Alert.show(errorEvent.text + '\ncould not be loaded','Error');
+ }
+
+ ]]>
+ </fx:Script>
+
+ <mx:ProgressBar width="100%" mode="manual"
+ horizontalCenter="0" verticalCenter="0" labelPlacement="center"
+ label="" id="playProgress"
+ />
+</s:Application>
diff --git a/Master/texmf-dist/tex/latex/media9/players/APlayer.swf b/Master/texmf-dist/tex/latex/media9/players/APlayer.swf
new file mode 100644
index 00000000000..51f491dee5e
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/media9/players/APlayer.swf
Binary files differ
diff --git a/Master/texmf-dist/tex/latex/media9/players/VPlayer.mxml b/Master/texmf-dist/tex/latex/media9/players/VPlayer.mxml
new file mode 100644
index 00000000000..9d070ed2d40
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/media9/players/VPlayer.mxml
@@ -0,0 +1,93 @@
+<?xml version="1.0"?>
+<!-- -->
+<!-- Adobe Flex 4 source file of VPlayer.swf, -->
+<!-- a FlashPlayer-10 compatible component for playing -->
+<!-- FLV and MP4/H.264 video files and streams. -->
+<!-- -->
+<!-- version 20120301 -->
+<!-- -->
+<!-- -->
+<!-- The free Adobe Flex 4 SDK is required to compile -->
+<!-- this file. Get it from -->
+<!-- -->
+<!-- http://www.adobe.com/products/flex/ -->
+<!-- -->
+<!-- and run -->
+<!-- -->
+<!-- mxmlc -static-link-runtime-shared-libraries VPlayer.mxml -->
+<!-- -->
+<!-- on the command line. -->
+<!-- -->
+<!-- -->
+<!-- Copyright (C) 2011 Alexander Grahn -->
+<!-- -->
+<!-- This work may be distributed and/or modified under the -->
+<!-- conditions of the LaTeX Project Public License, either -->
+<!-- version 1.3 of this license or (at your option) any later -->
+<!-- version. -->
+<!-- -->
+<!-- The latest version of this license is in -->
+<!-- http://www.latex-project.org/lppl.txt -->
+<!-- and version 1.3 or later is part of all distributions of -->
+<!-- LaTeX version 2005/12/01 or later. -->
+<!-- -->
+<!-- This work has the LPPL maintenance status `maintained'. -->
+<!-- -->
+<!-- The current maintainer of this work is A. Grahn. -->
+<!-- -->
+
+<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:s="library://ns.adobe.com/flex/spark"
+ xmlns:mx="library://ns.adobe.com/flex/mx"
+ preinitialize="initialise(FlexGlobals.topLevelApplication.parameters);"
+>
+ <fx:Script>
+ <![CDATA[
+ [Bindable] private var source:String;
+ [Bindable] private var autoPlay:Boolean=false;
+ [Bindable] private var loop:Boolean=false;
+ [Bindable] private var volume:Number=0.75;
+ private var vidComplete:Boolean=false;
+
+ import mx.core.FlexGlobals;
+ private function initialise(flashVars:Object):void{
+ source=flashVars.source;
+ if(flashVars.autoPlay){autoPlay=(flashVars.autoPlay=='true')}
+ if(flashVars.loop){loop=(flashVars.loop=='true')}
+ if(flashVars.volume){volume=Number(flashVars.volume)}
+ }
+
+ import flash.events.ProgressEvent;
+ private function progressHandler(event:ProgressEvent):void{
+ if (event.bytesTotal) event.target.visible=true;
+ else event.target.visible=false;
+ }
+
+ import org.osmf.events.MediaPlayerStateChangeEvent;
+ import mx.controls.Alert;
+ private function stateChangeHandler(event:MediaPlayerStateChangeEvent):void{
+ vidComplete=false;
+ if(event.state=='playbackError')
+ Alert.show('Unable to play \''+event.target.source+'\'','Error');
+ }
+ ]]>
+ </fx:Script>
+
+ <s:VideoDisplay
+ id="vidDisp"
+ width="100%" height="100%" scaleMode="stretch"
+ source="{source}" volume="{volume}"
+ autoPlay="{autoPlay}" autoRewind="false" loop="{loop}"
+ mouseDown="vidDisp.pause();"
+ mouseUp="if(vidComplete){vidDisp.seek(0);}vidDisp.play();"
+ mediaPlayerStateChange="stateChangeHandler(event);"
+ complete="vidComplete=true;"
+ />
+
+ <mx:ProgressBar width="80%" mode="polled" source="vidDisp"
+ horizontalCenter="0" verticalCenter="0" labelPlacement="center"
+ id="loadingProgress" alpha="0.5"
+ complete="loadingProgress.visible=false;"
+ progress="progressHandler(event)"
+ />
+</s:Application>
diff --git a/Master/texmf-dist/tex/latex/media9/players/VPlayer.swf b/Master/texmf-dist/tex/latex/media9/players/VPlayer.swf
new file mode 100644
index 00000000000..daf19dbc7fe
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/media9/players/VPlayer.swf
Binary files differ
diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check
index 9bff281a378..f7fc0ffdc45 100755
--- a/Master/tlpkg/bin/tlpkg-ctan-check
+++ b/Master/tlpkg/bin/tlpkg-ctan-check
@@ -253,7 +253,7 @@ my @TLP_working = qw(
mathcomp mathdesign mathdots mathexam
mathmode mathspec mathspic mattens maybemath mbenotes
mcaption mceinleger mcite mciteplus
- mdframed mdputu mdsymbol mdwtools meetingmins memdesign memexsupp
+ mdframed mdputu mdsymbol mdwtools media9 meetingmins memdesign memexsupp
memoir MemoirChapStyles mentis
menu menukeys
metafont-beginners metago metalogo metaobj metaplot
diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds
index 9a4db996a53..198cde5b278 100755
--- a/Master/tlpkg/libexec/ctan2tds
+++ b/Master/tlpkg/libexec/ctan2tds
@@ -548,7 +548,6 @@ chomp ($Build = `cd $Master/../Build/source && pwd`);
'matlab', "die 'skipping, requires nonfree matlab'",
'mattex', "die 'skipping, requires nonfree matlab'",
'mdwfonts', "die 'skipping, too many tfm duplicates'",
- 'media9', "die 'skipping, requires nonfree flash in nonfree acrobat 9'",
'mem', "die 'skipping, experimental ca.2006'",
'memo2', "die 'skipping, latex 2.09'",
'memoirchapterstyles', "die 'skipping, use MemoirChapStyles'",
diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
index 1463722027b..cad8046377a 100644
--- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
@@ -424,6 +424,7 @@ depend mceinleger
depend mcite
depend mciteplus
depend mdframed
+depend media9
depend meetingmins
depend memexsupp
depend menu
diff --git a/Master/tlpkg/tlpsrc/media9.tlpsrc b/Master/tlpkg/tlpsrc/media9.tlpsrc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Master/tlpkg/tlpsrc/media9.tlpsrc