From: Michail Vidiassov <master@iaas.msu.ru>
To: Hans Hagen <pragma@wxs.nl>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Context 2010.05.08 - 3D annotations
Date: Thu, 13 May 2010 15:57:37 +0400 (MSD) [thread overview]
Message-ID: <alpine.OSX.2.00.1005131547580.964@macbook.local> (raw)
In-Reply-To: <4BEBE5E3.4000304@wxs.nl>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1429 bytes --]
Dear Hans,
On Thu, 13 May 2010, Hans Hagen wrote:
> On 13-5-2010 12:16, Michail Vidiassov wrote:
>> is it worth trying to fix 3D annotations now?
>> I have a patch I have posted here (3D annotations thread),
>> but it is both a fix for errors (like == used instead of = )
>> and a work-around for missing base features (bitmap preview done
>> "by hand" while, it seems, the authors dalayed the question till
>> something is implemented in luatex/ConTeXt the right way)
>> - so it may not classify exactly as just a bugfix.
>
> some things were fixed, so best first check against the latest beta and then
> summarize the problems
first - it does not work due to typos like
local name = viewname
local name = pdfunicode((view.name ~= "" and name) or "unknown view")
- likely someone started to write code, but dropped the idea and never tested
Or
local subtype, subdata = "U3D", io.readdata(foundname) or ""
if find(subdata,"^PRC") then
subtype == "PRC"
elseif find(subdata,"^U3D") then
subtype == "U3D"
elseif file.extname(foundname) == "prc" then
subtype == "PRC"
end
it seems == is used instead of =, io.readdata instead of file.readdata -
again, some one wrote the code but had no time to read the result
Second, more important - no preview image is created.
patch and test case attached
Sincerely, Michail
[-- Attachment #2: Type: APPLICATION/octet-stream, Size: 29627 bytes --]
[-- Attachment #3: Type: TEXT/PLAIN, Size: 4822 bytes --]
--- lpdf-u3d.lua.org 2010-03-26 18:24:44.000000000 +0300
+++ lpdf-u3d.lua 2010-04-14 14:24:28.000000000 +0400
@@ -17,6 +17,7 @@
local cos, sin, sqrt, pi, atan2, abs = math.cos, math.sin, math.sqrt, math.pi, math.atan2, math.abs
local pdfconstant = lpdf.constant
+local pdfnumber = lpdf.number
local pdfboolean = lpdf.boolean
local pdfunicode = lpdf.unicode
local pdfdictionary = lpdf.dictionary
@@ -62,8 +63,7 @@
local function make3dview(view)
- local name = viewname
- local name = pdfunicode((view.name ~= "" and name) or "unknown view")
+ local name = pdfunicode((view.name ~= "" and view.name) or "unknown view")
local viewdict = pdfdictionary {
Type = pdfconstant("3DView"),
@@ -311,9 +311,6 @@
for i=1,#nodes do
local node = checkedkey(nodes,i,"table")
if node then
- local position = checkedkey(node,"position","table")
- position = position and #position == 12 and pdfarray(position)
- if position then
nodelist[#nodelist+1] = pdfdictionary {
Type = pdfconstant("3DNode"),
N = node.name or ("node_" .. i), -- pdfunicode ?
@@ -325,13 +322,18 @@
},
M = position,
}
+ local position = checkedkey(node,"position","table")
+ position = position and #position == 12 and pdfarray(position)
+ if position then
+ nodelist[#nodelist].M = position
end
end
end
- viewdict.NR = true
viewdict.NA = nodelist
end
+ viewdict.NR = true
+
return viewdict
end
@@ -349,19 +351,19 @@
local activationdict = pdfdictionary {
TB = pdfboolean(param.toolbar,true),
- NP = pdfboolean(param.tree,true),
+ NP = pdfboolean(param.tree,false),
}
local stream = streams[label]
if not stream then
- local subtype, subdata = "U3D", io.readdata(foundname) or ""
+ local subtype, subdata = "U3D", file.readdata(foundname) or ""
if find(subdata,"^PRC") then
- subtype == "PRC"
+ subtype = "PRC"
elseif find(subdata,"^U3D") then
- subtype == "U3D"
+ subtype = "U3D"
elseif file.extname(foundname) == "prc" then
- subtype == "PRC"
+ subtype = "PRC"
end
local attr = pdfdictionary {
@@ -423,12 +425,35 @@
local ref = stored_pr[tag]
if not ref then
-- weird, has to be a /Form and not an /Image so we need a wrap = true key
- -- local figure = img.immediatewrite { filename = preview, width = width, height = height }
- local figure = img.immediatewrite { stream = ".5 .75 .75 rg 0 0 20 10 re f", bbox = {0,0,20,10 } }
+ local figure = img.immediatewrite { filename = preview, width = width, height = height }
+ -- local figure = img.immediatewrite { stream = ".5 .75 .75 rg 0 0 20 10 re f", bbox = {0,0,20,10 } }
ref = figure.objnum
stored_pr[tag] = ref
end
- annot.AP = ref and pdfdictionary { N = pdfreference(ref) }
+ if ref then
+ local pw = pdfdictionary {
+ Type = pdfconstant("XObject"),
+ Subtype = pdfconstant("Form"),
+ FormType = pdfnumber(1),
+ BBox = pdfarray { pdfnumber(0), pdfnumber(0), pdfnumber(factor*width), pdfnumber(factor*height) },
+ Matrix = pdfarray { pdfnumber(1), pdfnumber(0), pdfnumber(0), pdfnumber(1), pdfnumber(0), pdfnumber(0) },
+ Resources = pdfdictionary {
+ XObject = pdfdictionary {
+ IM = pdfreference(ref)
+ }
+ },
+ ExtGState = pdfdictionary {
+ GS = pdfdictionary {
+ Type = pdfconstant("ExtGState"),
+ CA = pdfnumber(1),
+ ca = pdfnumber(1)
+ }
+ },
+ ProcSet = pdfarray { pdfconstant("PDF"), pdfconstant("ImageC") },
+ }
+ local pwd = pdf.immediateobj("stream",format("q /GS gs %s 0 0 %s 0 0 cm /IM Do Q",factor*width,factor*height),pw())
+ annot.AP = pdfdictionary { N = pdfreference(pwd) }
+ end
return annot, figure, ref
else
activationdict.A = pdfconstant("PV")
[-- Attachment #4: Type: text/plain, Size: 486 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2010-05-13 11:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-10 11:58 Context 2010.05.08 Taco Hoekwater
2010-05-12 21:18 ` Context 2010.05.08 - pdfboolean problem Michail Vidiassov
2010-05-13 10:16 ` Context 2010.05.08 - 3D annotations Michail Vidiassov
2010-05-13 11:43 ` Hans Hagen
2010-05-13 11:57 ` Michail Vidiassov [this message]
2010-05-13 15:00 ` Hans Hagen
2010-05-14 4:37 ` Michail Vidiassov
2010-05-14 15:03 ` Hans Hagen
[not found] ` <96547d6cc6eaa6ffd0f8318c39220df4.squirrel@squirrelmail.iaas.msu.ru>
[not found] ` <4BED7795.50402@wxs.nl>
2010-05-15 2:40 ` Michail Vidiassov
2010-05-15 2:59 ` Aditya Mahajan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.OSX.2.00.1005131547580.964@macbook.local \
--to=master@iaas.msu.ru \
--cc=ntg-context@ntg.nl \
--cc=pragma@wxs.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).