Skip to content
Snippets Groups Projects
Commit 035eab40 authored by Anders Nilsson's avatar Anders Nilsson
Browse files

First shot at implementing wire frame bounding box in the AST. Works almost.

parent 420eabf3
Branches
No related tags found
No related merge requests found
......@@ -14,3 +14,4 @@ examples/configForm/configForm.jjt
javadoc
SchemaCompile.jar
examples/configForm/config-sheet.html
examples/x3d/x3d_demo.x3d
......@@ -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();
......
TODO 0 → 100644
o [andersn] Must change JavaCC generation to cope with name-space declarations. Maybe just as it is done in OntologyCompiler.
......@@ -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="&quot;earth-topo.png&quot; &quot;earth-topo.jpg&quot; &quot;earth-topo.gif&quot;&#10;&quot;earth-topo-small.gif&quot;&#10;&quot;../earth-topo.png&quot;&#10;&quot;../earth-topo.jpg&quot;&#10;&quot;../earth-topo.gif&quot; &quot;../earth-topo-small.gif&quot;&#10;&quot;/www.web3d.org/x3d/content/examples/earth-topo.png&quot;&#10;&quot;/www.web3d.org/x3d/content/examples/earth-topo.jpg&quot;&#10;&quot;/www.web3d.org/x3d/content/examples/earth-topo.gif&quot;&#10;&quot;/www.web3d.org/x3d/content/examples/earth-topo-small.gif&quot;&#10;&quot;http://www.web3d.org/x3d/content/examples/earth-topo.png&quot;&#10;&quot;http://www.web3d.org/x3d/content/examples/earth-topo.jpg&quot;&#10;&quot;http://www.web3d.org/x3d/content/examples/earth-topo.gif&quot;&#10;&quot;http://www.web3d.org/x3d/content/examples/earth-topo-small.gif&quot;"/>
<ImageTexture url="&quot;earth-topo.png&quot; &quot;earth-topo.jpg&quot; &quot;earth-topo.gif&quot; &quot;earth-topo-small.gif&quot; &quot;../earth-topo.png&quot; &quot;../earth-topo.jpg&quot; &quot;../earth-topo.gif&quot; &quot;../earth-topo-small.gif&quot; &quot;/www.web3d.org/x3d/content/examples/earth-topo.png&quot; &quot;/www.web3d.org/x3d/content/examples/earth-topo.jpg&quot; &quot;/www.web3d.org/x3d/content/examples/earth-topo.gif&quot; &quot;/www.web3d.org/x3d/content/examples/earth-topo-small.gif&quot; &quot;http://www.web3d.org/x3d/content/examples/earth-topo.png&quot; &quot;http://www.web3d.org/x3d/content/examples/earth-topo.jpg&quot; &quot;http://www.web3d.org/x3d/content/examples/earth-topo.gif&quot; &quot;http://www.web3d.org/x3d/content/examples/earth-topo-small.gif&quot;"/>
</Appearance>
</Shape>
<Shape>
<IndexedLineSet colorPerVertex="false" coordIndex="0 1&#10;1 3&#10;3 2&#10;2 0&#10;0 4&#10;4 5&#10;5 1&#10;1 5&#10;5 7&#10;7 3&#10;3 7&#10;7 6&#10;6 2&#10;2 6&#10;6 4&#10;">
<Coordinate point="-1 -1 -1&#10;-1 -1 1&#10;-1 1 -1&#10;-1 1 1&#10;1 -1 -1&#10;1 -1 1&#10;1 1 -1&#10;1 1 1&#10;"/>
<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>
......
......@@ -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() {
......
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);
}
}
......@@ -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 -->
......
<?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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment