Tải bản đầy đủ - 0 (trang)
Chapter 6. Vector This: Early Days and Markup

Chapter 6. Vector This: Early Days and Markup

Tải bản đầy đủ - 0trang

Language(VML),inadditiontothethree-dimensionalformats

suchasVirtualRealityModelingLanguage(VRML)andX3D.

InthischapterI'mgoingtospendabrieftimecoveringsomeof

theformatsjustmentionedaswellasproprietaryformsof

vectorgraphics.Then,therestofthechapterisdevotedtoan

introductiontooneofmyfavoritewebgraphicsformats:SVG.



6.1.WebCGM

HaveyoueverheardofWebCGM?Unlessyoufollowallthe

specificationscomingoutoftheW3Corareheavilyintothe

worldofwebgraphics,chancesareyouhaven't.TheCGMinthe

namestandsforComputerGraphicsMetafile,andtheWebCGM

1.0specificationhasbeenaW3Crecommendationsince1999.

There'salsoaWebCGM2.0specificationthatreached

recommendedstatusin2007.

TheW3CURLforWebCGMis

http://www.w3.org/Graphics/WebCGM/.

WebCGMisbasedonanearliernon-web-basedspecification,

CGM,anISOstandardinusesince1987.Withallthis

background,though,WebCGMhasneverreachedpopular

supporttothepointwhereanybrowserI'mawareofprovides

nativesupportfortheformat,thoughtherearebrowserpluginsandtoolstocreateWebCGMcontent.

SVG,whichI'llbecoveringlater,isalsoaW3Cvectorgraphics

recommendation,leadingtothequestion:whytwoformats?

Oddlyenough,attheXMLEurope2004conference,another

paperwaspresentedbyLoftonHendersonandDieter

Weidenbrüeck(see

http://idealliance.org/papers/dx_xmle04/papers/02-02-03/0202-03.html;I'massumingthisisthesameWeidenbrüeck

mentionedatthebeginningofthechapter).Intheirabstract,

theywrote:



In2003,theauthorssetouttoprovideanobjectiveanswer

tothepersistentquestion:whytherearetwoW3C

standards,WebCGMandSVG,forWeb-basedgraphics?Ina

nutshell,thereasonhasbeensummarizedas"WebCGMfor

Web-basedtechnicalgraphics,SVGforgraphicartsand

creativegraphics."

WebCGMisnotatrivialformat.Evenattemptingtofind

examplesandabetterunderstandingofhowitworksproved

surprisinglydifficult.Sinceitisaformatgearedmoretoward

complex,technicalspecifications;usedprimarilybythe

automotive,aerospace,andoilindustries;andnotnecessarily

deliveredinabrowser,I'mnotgoingtocoveritbeyondthis

briefintroduction.Ifyouhaveextratime—lotsofextratime—

andwanttolearnmore,IsuggestyoustartattheW3Csite,

andbesuretohaveplentyofcoffeeoranotherhighly

caffeinatedbeverageonhand.



Chapter6.VectorThis:EarlyDaysand

Markup

Thestrengthofvectorgraphicsistheirabilitytoscaletoany

size,smallorlarge,withoutaffectingthequalityoftheimage.

Thisisbecausetheimageisbasedonobjectdefinitions,such

asdrawalinefrompointAtopointB,andtheonlydifferencein

sizingisthelengthofthedrawnline.Thereisno"low,medium,

high"qualitytovectorgraphics:they'realwaysthehighest

quality.

Anotheradvantagetovectorgraphicsfromawebperspectiveis

thatwecancreaterelativelycomplex,andlarge,graphics,and

thebandwidthrequirementscanbeawholelotlessthanthe

requirementsforacomparablerasterimage.Additionally,

vectorgraphicslendthemselvestomanipulation,bothatthe

serverandinthepageonceitisloaded.Wecandynamically

generatearasterimage,suchasaJPEG,basedonchanging

data,buttheprocessisn'tassimpleasdoingthesamewitha

vectorformat,suchasSVG.

ApaperpresentedatXMLEurope2001byChrisLilleyand

DieterWeidenbrücktitled"WebCGMandSVG:AComparison"

liststhefollowingrequirementsforaweb-basedvectorgraphics

system:

Scalable

Efficient

Revisable

Object-addressable

Integratablewithotherwebcontent

Whatworkedfor2001stillworkstoday.Thoughthepaper

addressedtwospecificformats,WebCGMandScalarVector

Graphics(SVG),theconceptcanalsoincludeVectorMarkup



Language(VML),inadditiontothethree-dimensionalformats

suchasVirtualRealityModelingLanguage(VRML)andX3D.

InthischapterI'mgoingtospendabrieftimecoveringsomeof

theformatsjustmentionedaswellasproprietaryformsof

vectorgraphics.Then,therestofthechapterisdevotedtoan

introductiontooneofmyfavoritewebgraphicsformats:SVG.



6.1.WebCGM

HaveyoueverheardofWebCGM?Unlessyoufollowallthe

specificationscomingoutoftheW3Corareheavilyintothe

worldofwebgraphics,chancesareyouhaven't.TheCGMinthe

namestandsforComputerGraphicsMetafile,andtheWebCGM

1.0specificationhasbeenaW3Crecommendationsince1999.

There'salsoaWebCGM2.0specificationthatreached

recommendedstatusin2007.

TheW3CURLforWebCGMis

http://www.w3.org/Graphics/WebCGM/.

WebCGMisbasedonanearliernon-web-basedspecification,

CGM,anISOstandardinusesince1987.Withallthis

background,though,WebCGMhasneverreachedpopular

supporttothepointwhereanybrowserI'mawareofprovides

nativesupportfortheformat,thoughtherearebrowserpluginsandtoolstocreateWebCGMcontent.

SVG,whichI'llbecoveringlater,isalsoaW3Cvectorgraphics

recommendation,leadingtothequestion:whytwoformats?

Oddlyenough,attheXMLEurope2004conference,another

paperwaspresentedbyLoftonHendersonandDieter

Weidenbrüeck(see

http://idealliance.org/papers/dx_xmle04/papers/02-02-03/0202-03.html;I'massumingthisisthesameWeidenbrüeck

mentionedatthebeginningofthechapter).Intheirabstract,

theywrote:



In2003,theauthorssetouttoprovideanobjectiveanswer

tothepersistentquestion:whytherearetwoW3C

standards,WebCGMandSVG,forWeb-basedgraphics?Ina

nutshell,thereasonhasbeensummarizedas"WebCGMfor

Web-basedtechnicalgraphics,SVGforgraphicartsand

creativegraphics."

WebCGMisnotatrivialformat.Evenattemptingtofind

examplesandabetterunderstandingofhowitworksproved

surprisinglydifficult.Sinceitisaformatgearedmoretoward

complex,technicalspecifications;usedprimarilybythe

automotive,aerospace,andoilindustries;andnotnecessarily

deliveredinabrowser,I'mnotgoingtocoveritbeyondthis

briefintroduction.Ifyouhaveextratime—lotsofextratime—

andwanttolearnmore,IsuggestyoustartattheW3Csite,

andbesuretohaveplentyofcoffeeoranotherhighly

caffeinatedbeverageonhand.



6.2.The3Ds

BeforeXMLwasbig,whiletheWebwasjustayoungpup,Iwas

workingwithVRML.Itstillamazesmetothisdaythatthis

three-dimensionallanguagefadedoutintorelativeobscurity—

especiallyconsideringhowsurprisinglysophisticateditwas.

Today'spopular3Dworldconsistsofcommunityforumssuchas

SecondLife.YettheideaofsomethinglikeaSecondLife—

wherepeoplecouldenterathree-dimensionalworldwith

avatarsandinteractwithoneanother—wasconceivedwellover

10yearsago,andVRMLwasgoingtogiveittous.Itwasan

excitingtechnologythatgeneratedintenseearlyinterestand

then,suddenly,seemedtohavefallenalmostcompletelyoffthe

radarasaviablewebgraphicsformat.Why?Severalreasons,

really.Performanceissues,browsersupport(orlackthereof),

andthefactthatataboutthattimeMacromediaintroducedits

specificationkiller,Flash.

AmajordisconnectwithVRML,though,hadtodowiththe

VRMLspecificationitself.TheVRMLspecificationleftalotof

implementationdetailsuptothebrowsermakersand,aswe've

seenovertheyearsinregardstoscripting,CSS,andHTML,this

isneveragoodidea:wherethemakerscandiffer,theywill

differ.Irememberhowdifficultitwasatonepointtotrytoget

mylittleVRML1.0lavalamptoworkformorethanoneVRML

client.

IwillsaythatunlikeWebCGM,thereisgrowingsupportfor

moremainstreamaccessofthe3Ds,aidedinpartbyasmall

butviablecommunityof3Denthusiasts.Theireffortsare

focusedprimarilyontheoriginalVRML,(version1.0),thelater

release(VRML97),andtoday'sreplacement,X3D.

Agoodplacetostartlearningabouttheolder

VRMLandthenewerX3DistheWeb3D

Consortium,athttp://www.web3d.org/.



WhereX3DdiffersfromVRMLisgreaterprecisioninhowthe

syntaxisimplemented.Additionally,VRMLspecifiesobject

declarationsusingacurlybracesyntax,whereasX3Dcanbe

specifiedinproperXMLsyntaxinadditiontothe"VRMLclassic"

encoding.

AnexampleoftheVRMLencodingofX3Disshowninthe

followingcodesnippet,whichdefinesbothatransform,which

controlstheoveralllightingandorientationoftheobject,and

theobject(inthiscase,acone):

Transform{

rotation0013.14159

translation02.40

children

Shape{

appearanceAppearance{

materialMaterial{

diffuseColor111

transparency0.2

}

}

geometryCone{

bottomRadius0.4

height0.5

}

}

}



TheXMLsyntaxisshowninExample6-1,takenfromthe

Web3Dwebsiteexamples.Itdescribesaworldconsistingofa

redsphereandablueboxagainstablackbackdrop.

Example6-1.X3DasXMLdescribingabluecubeandred

sphere

CodeView:






"http://www.web3d.org/specifications/x3d-3.0.dtd">





xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'

xsd:noNamespaceSchemaLocation='http://www.web3d.org/specificati






includingdifferentmaterialsandgeometry'/>







X3DEncodings-XML-ClassicVRML/Part01/examples.html#'/>


X3DSpecification/RedSphereBlueBox.x3d'/>


Edit.html'/>











































































Theexample,asrenderedbytheMediaMachinesFluxplug-inin

Firefox,isshowninFigure6-1.

Figure6-1.Bluecubeandredsphereexamplerendered

byFirefox'sMediaMachinesFluxplug-in



WhatmakestheXMLencodingattractiveisthatX3D,unlike

VRML,canbeincorporateddirectlyintoXHTML.Thisabilityto

incorporateacompletelynewspecificationdirectlyintoaweb



pageisakeyusabilityitem,andonethatwe'lllookatmore

closelyasitrelatestoSVGlaterinthischapter.

Thoughthereiscurrentlynobuilt-insupportforX3DorVRMLin

themainbrowsers,thereisaVRML97plug-inforFirefox,the

CortonaVRMLclientforboththePCandtheMac.Another

Windows-basedbrowserplug-inforInternetExplorerand

MozillaisSwirlX3D.Accessanyoftheexamplesatthesite,and

thecontrolwillbeautomaticallyinstalled.Athirdplug-inand

associatedgalleryisMediaMachines,withaFluxplug-inthat

workswithbothIEandFirefoxonWindows.

TheCortonaVRMLclientisavailableat

http://www.parallelgraphics.com/products/cortona/.

SwirlX3Dcanbedownloadedfrom

http://www.pinecoast.com/swvdownload.htm.The

MediaMachinesFluxplug-incanbeaccessedat

http://www.mediamachines.com/developer.php.



Therearealsoadecentnumberofexamplesonline,aswellas

tutorialsforbothspecifications.Agoodplacetocheckfor

examplesistheexamplepageattheWeb3DConsortium.Most

oftheexamplesaregiveninX3D,butthere'susuallyalinkfor

aVRML97fileinadditiontoexamplesshowingX3Dembedded

inXHTML.

Figure6-2showsaFirefoxbrowserwithonesuchfileloaded,

thisoneofafish.Noticethecontrolsthatallowfor"fly,""walk,"

and"study."Thefirsttwoallowustochangeourviewpoint

relativetotheobject,whilethelastitemallowsustotwistand

turntheitemabout,asdemonstratedinFigure6-3.

Figure6-2.VRMLFishopenedintheCortonaplug-inin

Firefox



Duetothelackofbuilt-insupportforthe3Dspecificationsin

anyofthemainbrowsers,nottomentionthecomplexityof

workingwiththespecificationsandconcepts,Iwon'tbe

coveringitinmoredetailinthisbook.Idosuggest,though,

thatyouconsidertryingouttheFirefoxplug-inandthe

examplesatthesitesIpointedout.Ittakeslittletimetoget

thebrowsersetup,andit'safunwaytospendanhourortwo.

Then,ifyoucontinuetobeinterested,checkoutanyofthe

tutorialsavailabletotrythetechnologyforyourself(my

suggestedstartingpointisSwirlX3D,at

http://www.swirlx3d.com/).Nocompilerisrequired,justa

viewercapableofreadingVRMLorX3D.Ataminimum,you'll

beabletoplayRubik'sCubeonline,asshowninFigure6-4.

Figure6-3.VRMLFishmanipulatedinaviewerto

demonstratethe3Dnatureoftheobject



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Chapter 6. Vector This: Early Days and Markup

Tải bản đầy đủ ngay(0 tr)

×