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

Added v 3.1 of the X3D standard as well as a few new examples.

Wire-frame is generated correctly on teapot for OBB but not for AABB
where there is an offset.
parent 7b32ce33
No related branches found
No related tags found
No related merge requests found
...@@ -99,7 +99,7 @@ aspect JavaCCChunks { ...@@ -99,7 +99,7 @@ aspect JavaCCChunks {
pStream.println(" >"); pStream.println(" >");
pStream.println(" |"); pStream.println(" |");
pStream.println(" < STRING_LITERAL:"); pStream.println(" < STRING_LITERAL:");
pStream.println(" \"\\\"\""); pStream.println(" (\"\\\"\"");
pStream.println(" ( (~[\"\\\"\",\"\\n\",\"\\r\"])"); pStream.println(" ( (~[\"\\\"\",\"\\n\",\"\\r\"])");
// pStream.println(" ( (~[\"\\\"\",\"\\\\\",\"\\n\",\"\\r\"])"); // pStream.println(" ( (~[\"\\\"\",\"\\\\\",\"\\n\",\"\\r\"])");
// pStream.println(" |"); // pStream.println(" |");
...@@ -112,7 +112,11 @@ aspect JavaCCChunks { ...@@ -112,7 +112,11 @@ aspect JavaCCChunks {
// pStream.println(" )"); // pStream.println(" )");
// pStream.println(" )"); // pStream.println(" )");
pStream.println(" )*"); pStream.println(" )*");
pStream.println(" \"\\\"\""); pStream.println(" \"\\\"\")");
pStream.println(" | (\"\\\'\"");
pStream.println(" ( (~[\"\\\'\",\"\\n\",\"\\r\"])");
pStream.println(" )*");
pStream.println(" \"\\\'\")");
pStream.println(" >"); pStream.println(" >");
pStream.println("}// LITERALS"); pStream.println("}// LITERALS");
} }
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.1//EN" "http://www.web3d.org/specifications/x3d-3.1.dtd">
<X3D version='3.1' profile='CADInterchange' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.0.xsd'>
<head>
<meta content='IndexedQuadSetExample.x3d' name='title'/>
<meta content='Simple IndexedQuadSet example.' name='description'/>
<meta content='Andrew Grieve, Don Brutzman' name='authors'/>
<meta content='15 October 2005' name='created'/>
<meta content='14 November 2005' name='modified'/>
<meta content='Under development: untested.' name='warning'/>
<meta content='http://www.web3d.org/x3d/content/examples/Basic/CAD/IndexedQuadSetExample.x3d' name='identifier'/>
<meta content='X3D-Edit, http://www.web3d.org/x3d/content/README.X3D-Edit.html' name='generator'/>
<meta content='../../license.html' name='license'/>
</head>
<Scene>
<NavigationInfo type='EXAMINE'/>
<!-- <Background skyColor='1 1 1'/> -->
<Viewpoint DEF='Side' description='IndexedQuadSet side view' position='0 0 10'/>
<Viewpoint DEF='Front' description='IndexedQuadSet front view' orientation='0 1 0 1.57' position='10 0 0'/>
<Viewpoint DEF='Top' description='IndexedQuadSet top view' orientation='1 0 0 -1.57' position='0 10 0'/>
<!-- <Transform scale='2 2 2'> -->
<Transform>
<Shape>
<Appearance>
<Material diffuseColor='1 1 1'/>
</Appearance>
<IndexedQuadSet containerField='geometry' index='0 3 2 1, 4 5 6 7, 2 7 9 8, 2 3 4 7'>
<Coordinate point='-1.5 0 0, -1.5 1 -1, -.5 1 -1, -.5 0 0, 0.5 0 0, 1.5 0 0, 1.5 1 -1, 0.5 1 -1, -0.5 2 -1, 0.5 2 -1,'/>
</IndexedQuadSet>
</Shape>
</Transform>
</Scene>
</X3D>
This diff is collapsed.
This diff is collapsed.
...@@ -29,13 +29,17 @@ aspect BoundingBox { ...@@ -29,13 +29,17 @@ aspect BoundingBox {
eq Scene.obb() { eq Scene.obb() {
OrientedBoundingBox obb = new OrientedBoundingBox(); OrientedBoundingBox obb = new OrientedBoundingBox();
StringBuffer sb = getCoordinates(); StringBuffer sb = getCoordinates();
String s = sb.toString().replace('\"',' ').replace(',',' '); String s = sb.toString().replace('\"',' ').replace('\'',' ').replace(',',' ');
// String s = sb.toString().replace('\"',' ').replace(',',' ').replace(" "," ");
String[] sa = s.split(" ",0); String[] sa = s.split(" ",0);
float[] fa = new float[sa.length]; float[] fa = new float[sa.length];
for (int i=0,j=0; i<sa.length; i++) { for (int i=0,j=0; i<sa.length; i++) {
if (!sa[i].equals("")) { try {
fa[j++] = Float.parseFloat(sa[i]); float f = Float.parseFloat(sa[i]);
fa[j++] = f;
} catch (NumberFormatException e) {
// If it couldn't be parsed, let's just hope it
// shouldn't.
// System.out.println(sa[i]+" is not a float");
} }
} }
obb.computeFromPoints(BufferUtils.createFloatBuffer(fa)); obb.computeFromPoints(BufferUtils.createFloatBuffer(fa));
...@@ -60,13 +64,17 @@ aspect BoundingBox { ...@@ -60,13 +64,17 @@ aspect BoundingBox {
eq Scene.aabb() { eq Scene.aabb() {
BoundingBox aabb = new BoundingBox(); BoundingBox aabb = new BoundingBox();
StringBuffer sb = getCoordinates(); StringBuffer sb = getCoordinates();
String s = sb.toString().replace('\"',' ').replace(',',' '); String s = sb.toString().replace('\"',' ').replace('\'',' ').replace(',',' ');
// String s = sb.toString().replace('\"',' ').replace(',',' ').replace(" "," ");
String[] sa = s.split(" ",0); String[] sa = s.split(" ",0);
float[] fa = new float[sa.length]; float[] fa = new float[sa.length];
for (int i=0,j=0; i<sa.length; i++) { for (int i=0,j=0; i<sa.length; i++) {
if (!sa[i].equals("")) { try {
fa[j++] = Float.parseFloat(sa[i]); float f = Float.parseFloat(sa[i]);
fa[j++] = f;
} catch (NumberFormatException e) {
// If it couldn't be parsed, let's just hope it
// shouldn't.
// System.out.println(sa[i]+" is not a float");
} }
} }
aabb.computeFromPoints(BufferUtils.createFloatBuffer(fa)); aabb.computeFromPoints(BufferUtils.createFloatBuffer(fa));
...@@ -148,7 +156,6 @@ aspect WireFrame { ...@@ -148,7 +156,6 @@ aspect WireFrame {
add(new point(new AttrValue(sb.toString()))), add(new point(new AttrValue(sb.toString()))),
new List()); new List());
colorPerVertex cpv = new colorPerVertex(new AttrValue("\"false\"")); 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\"";
String cis = "\"0 1 2 3 0 4 5 1 5 6 2 6 7 3 7 4\""; String cis = "\"0 1 2 3 0 4 5 1 5 6 2 6 7 3 7 4\"";
coordIndex ci = new coordIndex(new AttrValue(cis)); coordIndex ci = new coordIndex(new AttrValue(cis));
IndexedLineSet ils = new IndexedLineSet(new List().add(cpv).add(ci), IndexedLineSet ils = new IndexedLineSet(new List().add(cpv).add(ci),
......
...@@ -32,11 +32,14 @@ public class Demo extends Parser { ...@@ -32,11 +32,14 @@ public class Demo extends Parser {
String s = new String(); String s = new String();
try { try {
s = con.readLine("%s","1$");
ast.prettyPrint(" ",new PrintStream("x3d_demo.x3d")); ast.prettyPrint(" ",new PrintStream("x3d_demo.x3d"));
s = con.readLine("%s","2$"); System.out.println("Generated X#D with original model");
s = con.readLine("%s","Press enter to include OBB wire-frame");
ast.addWireFrameBB(obb); ast.addWireFrameBB(obb);
ast.prettyPrint(" ",new PrintStream("x3d_demo.x3d")); ast.prettyPrint(" ",new PrintStream("x3d_demo.x3d"));
s = con.readLine("%s","Press enter to include AABB wire-frame");
ast.addWireFrameBB(aabb);
ast.prettyPrint(" ",new PrintStream("x3d_demo.x3d"));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment