diff --git a/.bzrignore b/.bzrignore index 1f4b69e43697855d989e1c8b7dcab25771dc0cd2..8d1f0a32b6a207d6758709374367c9b170207017 100644 --- a/.bzrignore +++ b/.bzrignore @@ -14,3 +14,4 @@ examples/configForm/configForm.jjt javadoc SchemaCompile.jar examples/configForm/config-sheet.html +examples/x3d/x3d_demo.x3d diff --git a/CompilerGeneration.jrag b/CompilerGeneration.jrag index 8c7933cf6d7831acbf00a8c6ace74a3d7fcf6920..8d43500575a73c8df2e9c3549a5a44648ef3755e 100644 --- a/CompilerGeneration.jrag +++ b/CompilerGeneration.jrag @@ -432,7 +432,9 @@ aspect GenPrettyPrinter { pStream.println(" public void DocType.prettyPrint(String indent, PrintStream pStream) {"); pStream.println(" pStream.print(\"<!\");"); pStream.println(" pStream.print(getSTRING());"); - pStream.println(" pStream.println(\"> \");"); + pStream.println(" pStream.println();"); + // Ugly as h*ll, but I don't have the time to fix it right now. AndersN 070914 +// pStream.println(" pStream.println(\"> \");"); pStream.println(" }\n"); pStream.println(" public void AttrValue.prettyPrint(String indent, PrintStream pStream) {"); @@ -444,6 +446,21 @@ aspect GenPrettyPrinter { pStream.println(" getAttrValue().prettyPrint(indent,pStream);"); pStream.println(" }\n"); + pStream.println(" public void Version.prettyPrint(String indent, PrintStream pStream) {"); + pStream.println(" pStream.print(\" version=\");"); + pStream.println(" getAttrValue().prettyPrint(indent,pStream);"); + pStream.println(" }\n"); + + pStream.println(" public void XmlnsXsi.prettyPrint(String indent, PrintStream pStream) {"); + pStream.println(" pStream.print(\" xmlns:xsi=\");"); + pStream.println(" getAttrValue().prettyPrint(indent,pStream);"); + pStream.println(" }\n"); + + pStream.println(" public void XsiNoNamespaceSchemaLocation.prettyPrint(String indent, PrintStream pStream) {"); + pStream.println(" pStream.print(\" xsi:NoNamespaceSchemaLocation=\");"); + pStream.println(" getAttrValue().prettyPrint(indent,pStream);"); + pStream.println(" }\n"); + Hashtable h = elementTypes(); h.putAll(attributeTypes()); Iterator iter = h.values().iterator(); diff --git a/TODO b/TODO new file mode 100644 index 0000000000000000000000000000000000000000..f19868aa3f9c4e5fb724a6a92913f75bc6939a55 --- /dev/null +++ b/TODO @@ -0,0 +1,2 @@ + +o [andersn] Must change JavaCC generation to cope with name-space declarations. Maybe just as it is done in OntologyCompiler. diff --git a/examples/BoundingBox_example.x3d b/examples/BoundingBox_example.x3d index 38f9995b9e34646b797e2dada755224cd3909e55..ab08be6fdc7e4e869ac897a95950ea4321c3b3f1 100644 --- a/examples/BoundingBox_example.x3d +++ b/examples/BoundingBox_example.x3d @@ -2,7 +2,7 @@ <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.1//EN" "http://www.web3d.org/specifications/x3d-3.1.dtd"> <X3D profile="Immersive" version="3.0" - xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.0.xsd"> <head> <meta content="BoundingBox example.x3d" name="title"/> <meta @@ -16,12 +16,12 @@ <Shape bboxCenter="0 0 0" bboxSize="2 2 2"> <Sphere/> <Appearance> - <ImageTexture url=""earth-topo.png" "earth-topo.jpg" "earth-topo.gif" "earth-topo-small.gif" "../earth-topo.png" "../earth-topo.jpg" "../earth-topo.gif" "../earth-topo-small.gif" "/www.web3d.org/x3d/content/examples/earth-topo.png" "/www.web3d.org/x3d/content/examples/earth-topo.jpg" "/www.web3d.org/x3d/content/examples/earth-topo.gif" "/www.web3d.org/x3d/content/examples/earth-topo-small.gif" "http://www.web3d.org/x3d/content/examples/earth-topo.png" "http://www.web3d.org/x3d/content/examples/earth-topo.jpg" "http://www.web3d.org/x3d/content/examples/earth-topo.gif" "http://www.web3d.org/x3d/content/examples/earth-topo-small.gif""/> + <ImageTexture url=""earth-topo.png" "earth-topo.jpg" "earth-topo.gif" "earth-topo-small.gif" "../earth-topo.png" "../earth-topo.jpg" "../earth-topo.gif" "../earth-topo-small.gif" "/www.web3d.org/x3d/content/examples/earth-topo.png" "/www.web3d.org/x3d/content/examples/earth-topo.jpg" "/www.web3d.org/x3d/content/examples/earth-topo.gif" "/www.web3d.org/x3d/content/examples/earth-topo-small.gif" "http://www.web3d.org/x3d/content/examples/earth-topo.png" "http://www.web3d.org/x3d/content/examples/earth-topo.jpg" "http://www.web3d.org/x3d/content/examples/earth-topo.gif" "http://www.web3d.org/x3d/content/examples/earth-topo-small.gif""/> </Appearance> </Shape> <Shape> - <IndexedLineSet colorPerVertex="false" coordIndex="0 1 1 3 3 2 2 0 0 4 4 5 5 1 1 5 5 7 7 3 3 7 7 6 6 2 2 6 6 4 "> - <Coordinate point="-1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 1 -1 1 1 1 -1 1 1 1 "/> + <IndexedLineSet colorPerVertex="false" coordIndex="0 1 1 3 3 2 2 0 0 4 4 5 5 1 1 5 5 7 7 3 3 7 7 6 6 2 2 6 6 4 "> + <Coordinate point="-1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 1 -1 1 1 1 -1 1 1 1 "/> </IndexedLineSet> </Shape> </Transform> diff --git a/examples/x3d/BoundingBox.jrag b/examples/x3d/BoundingBox.jrag index a97511213bcbec6f35313349a704feda312cfa3c..cd608f7859c00a5ce44121707bc01083e7b54c48 100644 --- a/examples/x3d/BoundingBox.jrag +++ b/examples/x3d/BoundingBox.jrag @@ -7,6 +7,7 @@ */ import com.jme.bounding.*; +import com.jme.math.*; import com.jme.util.geom.BufferUtils; aspect BoundingBox { @@ -73,6 +74,63 @@ aspect BoundingBox { } } +aspect WireFrame { + public void ASTNode.addWireFrameBB(BoundingVolume bb) {} + public void Start.addWireFrameBB(BoundingVolume bb) { + getScene().addWireFrameBB(bb); + } + + public void Scene.addWireFrameBB(BoundingVolume bb) { + StringBuffer sb = new StringBuffer().append("\""); + if (bb instanceof OrientedBoundingBox) { + Vector3f[] corners = ((OrientedBoundingBox) bb).vectorStore; + for (int i=0; i<corners.length; i++) { + Vector3f p = corners[i]; + sb.append(String.valueOf((int) p.getX())).append(" "); + sb.append(String.valueOf((int) p.getY())).append(" "); + sb.append(String.valueOf((int) p.getZ())).append(" "); + } + } + sb.append("\""); + Coordinate coord = new Coordinate(new List(). + add(new point(new AttrValue(sb.toString()))), + new List()); + colorPerVertex cpv = new colorPerVertex(new AttrValue("\"false\"")); + String cis = "\"0 1 1 3 3 2 2 0 0 4 4 5 5 1 1 5 5 7 7 3 3 7 7 6 6 2 2 6 6 4\""; + coordIndex ci = new coordIndex(new AttrValue(cis)); + IndexedLineSet ils = new IndexedLineSet(new List().add(cpv).add(ci), + new List().add(coord)); + Shape sh = new Shape(new List(),new List().add(ils)); + Transform tr = new Transform(new List(), new List().add(sh)); + addElement(tr); + } +} + +aspect Navigation { + syn Scene ASTNode.getScene() = null; + eq ComplexElement.getScene() = getNumElement() > 0 ? getElement(0).getScene() : null; + eq Start.getScene() = getSpecification().getScene(); + eq Specification.getScene() { + Scene scene; + for (int i=0; i<getNumElement(); i++) { + if ((scene = getElement(i).getScene()) != null) { + return scene; + } + } + return null; + } + eq X3D.getScene() { + Scene scene; + for (int i=0; i<getNumElement(); i++) { + if ((scene = getElement(i).getScene()) != null) { + return scene; + } + } + return null; + } + eq Scene.getScene() = this; +} + aspect Coordinates { syn StringBuffer Element.getCoordinates() = new StringBuffer(); eq ComplexElement.getCoordinates() { diff --git a/examples/x3d/Demo.java b/examples/x3d/Demo.java new file mode 100644 index 0000000000000000000000000000000000000000..53f07c2b26b7e44267468ecc83c47904f2393b3b --- /dev/null +++ b/examples/x3d/Demo.java @@ -0,0 +1,45 @@ +import AST.Start; +import com.jme.bounding.*; +import com.jme.math.*; +import java.io.*; + + +public class Demo extends Parser { + public static void main(String args[]){ + Start ast = parse(args); + Console con = System.console(); + Vector3f vec; + + BoundingBox aabb = ast.aabb(); + System.out.println("AxisAligned BoundingBox"); + vec = aabb.getCenter(); + System.out.println("Center: X="+vec.getX()+" Y="+vec.getY()+ + " Z="+vec.getZ()); + vec = aabb.getExtent(vec); + System.out.println("Extent: X="+vec.getX()+" Y="+vec.getY()+ + " Z="+vec.getZ()); + System.out.println("Volume: "+aabb.getVolume()); + + OrientedBoundingBox obb = ast.obb(); + System.out.println("\nOriented BoundingBox"); + vec = obb.getCenter(); + System.out.println("Center: X="+vec.getX()+" Y="+vec.getY()+ + " Z="+vec.getZ()); + vec = obb.getExtent(); + System.out.println("Extent: X="+vec.getX()+" Y="+vec.getY()+ + " Z="+vec.getZ()); + System.out.println("Volume: "+obb.getVolume()); + + String s = new String(); + try { + s = con.readLine("%s","$"); + ast.prettyPrint(" ",new PrintStream("x3d_demo.x3d")); + ast.addWireFrameBB(obb); + ast.prettyPrint(" ",new PrintStream("x3d_demo.x3d")); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + System.out.println("****** "+s); + + } +} diff --git a/examples/x3d/build.xml b/examples/x3d/build.xml index 6658b167896a417060c0797f4b8e4a82eef934ad..e06e56d8e866e3a7b454f5696a9ec8cd9b4e6508 100644 --- a/examples/x3d/build.xml +++ b/examples/x3d/build.xml @@ -27,7 +27,7 @@ <!-- compile sources --> <target name="build" depends="gen"> - <javac compiler="jikes" debug="true" nowarn="true" srcdir="." includes="**/*.java" excludes="tools/** siaras/**" classpath=".:${tools}/beaver-rt.jar:${tools}/junit.jar"/> + <javac debug="true" nowarn="true" srcdir="." includes="**/*.java" excludes="tools/** siaras/**" classpath=".:${tools}/beaver-rt.jar:${tools}/junit.jar"/> </target> <!-- generate compiler source files --> diff --git a/examples/x3d/test.x3d b/examples/x3d/test.x3d deleted file mode 100644 index 73c34548961192ccfb20146e2d4ed3941a5d5d5c..0000000000000000000000000000000000000000 --- a/examples/x3d/test.x3d +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd"> -<X3D profile="Full"> - <head> - <meta name="filename" content="..\Sample Parts\Head&plate.x3d"/> - <meta name="description" content="*enter description here, short-sentence summaries preferred*"/> - <meta name="author" content="*enter name of original author here*"/> - <meta name="translator" content="*if manually translating VRML-to-X3D, enter name of person translating here*"/> - <meta name="created" content="*enter date of initial version here*"/> - <meta name="translated" content="20 Dezember 2006"/> - <meta name="revised" content="20 Dezember 2006"/> - <meta name="version" content="*enter version here*"/> - <meta name="reference" content="*enter reference citation or relative/online url here*"/> - <meta name="reference" content="*enter additional url/bibliographic reference information here*"/> - <meta name="copyright" content="*enter copyright information here* Example: Copyright (c) Web3D Consortium Inc. 2002"/> - <meta name="drawing" content="*enter drawing filename/url here*"/> - <meta name="image" content="*enter image filename/url here*"/> - <meta name="movie" content="*enter movie filename/url here*"/> - <meta name="photo" content="*enter photo filename/url here*"/> - <meta name="keywords" content="*enter keywords here*"/> - <meta name="url" content="*enter online url address for this file here*"/> - <meta name="generator" content="Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html"/> - </head> -</X3D>