
one.empty3.library.core.script.InterpreteFacade Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of empty3-library-3d Show documentation
Show all versions of empty3-library-3d Show documentation
3D rendering engine. Plus modelling. Expected glsl textures 3d and 2d rendering3D primitives, and a lot of scenes' samples to test.+ Game Jogl reworked, Calculator (numbers and vectors). Java code parser implementation starts (<=1.2)
The newest version!
/*
*
* * Copyright (c) 2024. Manuel Daniel Dahmen
* *
* *
* * Copyright 2024 Manuel Daniel Dahmen
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*
*/
/*
* 2013 Manuel Dahmen
*/
package one.empty3.library.core.script;
import one.empty3.library.*;
import one.empty3.library.Polygon;
import one.empty3.library.core.extra.*;
import one.empty3.library.core.nurbs.BSpline;
import one.empty3.library.core.nurbs.NurbsSurface;
import one.empty3.library.core.tribase.Plan3D;
import one.empty3.library.core.tribase.TRIEllipsoide;
import one.empty3.library.core.tribase.TRISphere;
import one.empty3.library.core.tribase.Tubulaire;
import java.awt.*;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
public class InterpreteFacade {
public final int FILETYPE_MODEL_TO = 0;
public final int BLANK = 0;
public final int LEFTPARENTHESIS = 1;
public final int RIGHTPARENTHESIS = 2;
public final int LEFTSKETCH = 3;
public final int RIGHTSKETCH = 4;
public final int ALPHA_WORD = 5;
public final int POINT3D = 100;
public final int COLOR = 101;
public final int INTEGER = 102;
public final int DOUBLE = 103;
public final int TRIANGLE = 104;
public final int LIST_TRIANGLES = 105;
public final int BSPLINE = 106;
public final int BEZIER = 107;
private String text;
private int pos;
private boolean okay;
private String repertoire;
public InterpreteFacade(String text, int pos) {
super();
this.text = text;
this.pos = pos;
}
public Object getParsedObject() {
return null;
}
public int getPosition() {
return pos;
}
public void setPosition(int pos) {
this.pos = pos;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public AttracteurEtrange intepreteAttracteurEtrange()
throws InterpreteException {
InterpreteAttracteurEtrange interpreteH = new InterpreteAttracteurEtrange();
interpreteH.setRepertoire(repertoire);
AttracteurEtrange t = null;
try {
t = (AttracteurEtrange) interpreteH.interprete(text, pos);
pos = interpreteH.getPosition();
} catch (Exception e) {
throw new InterpreteException(
java.util.ResourceBundle
.getBundle(
"info.emptycanvas.one.empty3.library/scripts/InterpreteLangage")
.getString(
"ATTRACTEUR ETRANGE ERRUER D'ANALYSE SYNTAXIQUE"));
}
return t;
}
Representable intepreteColline() throws InterpreteException {
InterpretesBase interpreteH = new InterpretesBase();
ArrayList pattern;
pattern = new ArrayList();
pattern.add(interpreteH.BLANK);
pattern.add(interpreteH.LEFTPARENTHESIS);
pattern.add(interpreteH.BLANK);
pattern.add(interpreteH.INTEGER);
pattern.add(interpreteH.BLANK);
pattern.add(interpreteH.RIGHTPARENTHESIS);
interpreteH.compile(pattern);
Integer type = (Integer) interpreteH.read(text, pos).get(3);
this.pos = interpreteH.getPosition();
switch (type) {
case 1:
return (Representable) new CollineModele1(1000);
case 2:
return (Representable)new CollineModele2(1000);
case 3:
return (Representable)new CollineModele3(1000);
default:
return (Representable)new CollineModele1(1000);
}
}
/*__
* *
*
* @return segment de droite
* @throws InterpreteException
*/
public LineSegment intepreteSegmentDroite() throws InterpreteException {
InterpreteSegment interpreteH = new InterpreteSegment();
interpreteH.setRepertoire(repertoire);
LineSegment t = null;
try {
t = (LineSegment) interpreteH.interprete(text, pos);
pos = interpreteH.getPosition();
} catch (Exception e) {
throw new InterpreteException(e);
}
return t;
}
/*__
* @return @throws InterpreteException
*/
public SimpleSphere intepreteSimpleSphere() throws InterpreteException {
InterpreteSimpleSphere interpreteH = new InterpreteSimpleSphere();
interpreteH.setRepertoire(repertoire);
SimpleSphere t = null;
try {
t = (SimpleSphere) interpreteH.interprete(text, pos);
pos = interpreteH.getPosition();
} catch (InterpreteException e) {
throw new InterpreteException(
java.util.ResourceBundle
.getBundle(
"info.emptycanvas.one.empty3.library/scripts/InterpreteLangage")
.getString(
"SIMPLE SPHERE: ERREUR D'ANALYSE SYNTAXIQUE"));
}
return t;
}
public Tourbillon intepreteTourbillon() throws InterpreteException {
interpreteBlank();
interpreteParentheseOuvrante();
interpreteBlank();
interpreteParentheseFermante();
interpreteBlank();
return new Tourbillon();
}
public Tubulaire intepreteTubulaire() throws InterpreteException {
InterpreteTubulaire interpreteH = new InterpreteTubulaire();
interpreteH.setRepertoire(repertoire);
Tubulaire t = null;
try {
t = (Tubulaire) interpreteH.interprete(text, pos);
pos = interpreteH.getPosition();
} catch (Exception e) {
throw new InterpreteException(e);
}
return t;
}
public BezierCubique interpreteBezier() throws InterpreteException {
InterpreteBezier interpreteH = new InterpreteBezier();
interpreteH.setRepertoire(repertoire);
BezierCubique b = null;
try {
b = (BezierCubique) interpreteH.interprete(text, pos);
pos = interpreteH.getPosition();
} catch (Exception e) {
throw new InterpreteException(
java.util.ResourceBundle
.getBundle(
"info.emptycanvas.one.empty3.library/scripts/InterpreteLangage")
.getString("ERRUER"));
}
return b;
}
public BezierCubique2D interpreteBezier2d() throws InterpreteException {
InterpreteBezier2D interpreteH = new InterpreteBezier2D();
interpreteH.setRepertoire(repertoire);
BezierCubique2D b = null;
try {
b = (BezierCubique2D) interpreteH.interprete(text, pos);
pos = interpreteH.getPosition();
} catch (Exception e) {
throw new InterpreteException(
java.util.ResourceBundle
.getBundle(
"info.emptycanvas.one.empty3.library/scripts/InterpreteLangage")
.getString("ERRUER"));
}
return b;
}
public String interpreteBlank() {
InterpretesBase ib = new InterpretesBase();
ArrayList pattern = new ArrayList();
pattern.add(ib.BLANK);
ib.compile(pattern);
try {
ib.read(text, pos);
pos = ib.getPosition();
} catch (Exception e) {
return "";
}
return java.util.ResourceBundle.getBundle(
"info.emptycanvas.one.empty3.library/scripts/InterpreteLangage")
.getString(" ");
}
public BSpline interpreteBSpline() throws InterpreteException {
InterpreteBSpline interpreteH = new InterpreteBSpline();
interpreteH.setRepertoire(repertoire);
BSpline b = null;
try {
b = (BSpline) interpreteH.interprete(text, pos);
pos = interpreteH.getPosition();
} catch (Exception e) {
throw new InterpreteException(
java.util.ResourceBundle
.getBundle(
"info.emptycanvas.one.empty3.library/scripts/InterpreteLangage")
.getString("ERRUER"));
}
return b;
}
public Camera interpreteCamera() throws InterpreteException {
InterpreteCamera interpreteH = new InterpreteCamera();
Camera c = null;
try {
c = (Camera) interpreteH.interprete(text, pos);
pos = interpreteH.getPosition();
} catch (InterpreteException ex) {
throw new InterpreteException("CAMERA ???", ex);
}
return c;
}
public StructureMatrix interpreteCameraCollection()
throws InterpreteException {
StructureMatrix cameras = new StructureMatrix(1, Camera.class);
interpreteBlank();
interpreteParentheseOuvrante();
interpreteBlank();
Camera c;
try {
while (true) {
String id = interpreteIdentifier();
Logger.getAnonymousLogger().log(Level.INFO, id);
if ("camera".equals(id == null ? "NULL" : id.toLowerCase())) {
interpreteBlank();
c = interpreteCamera();
cameras.add(1, c);
Logger.getAnonymousLogger().log(Level.INFO, id);
} else {
break;
}
interpreteBlank();
}
} catch (InterpreteException ex) {
}
interpreteBlank();
interpreteParentheseFermante();
interpreteBlank();
return cameras;
}
public Color interpreteColor() throws InterpreteException {
InterpreteCouleur pc = new InterpreteCouleur();
Color c = Color.BLACK;
try {
c = (Color) pc.interprete(text, pos);
pos = pc.getPosition();
} catch (Exception e) {
throw new InterpreteException(
java.util.ResourceBundle
.getBundle(
"info.emptycanvas.one.empty3.library/scripts/InterpreteLangage")
.getString("ERRUER"));
}
return c;
}
public Cube interpreteCube() throws InterpreteException {
InterpreteCube interpreteH = new InterpreteCube();
interpreteH.setRepertoire(repertoire);
Cube c = null;
try {
c = (Cube) interpreteH.interprete(text, pos);
pos = interpreteH.getPosition();
} catch (Exception e) {
throw new InterpreteException(
java.util.ResourceBundle
.getBundle(
"info.emptycanvas.one.empty3.library/scripts/InterpreteLangage")
.getString("CUBE : ERREUR D'ANALYSE SYNTAXIQUE"),
e);
}
return c;
}
public Double interpreteDouble() throws InterpreteException {
InterpretesBase ib = new InterpretesBase();
ArrayList pattern = new ArrayList();
pattern.add(ib.DECIMAL);
ib.compile(pattern);
try {
ib.read(text, pos);
pos = ib.getPosition();
} catch (Exception e) {
throw new InterpreteException(
java.util.ResourceBundle
.getBundle(
"info.emptycanvas.one.empty3.library/scripts/InterpreteLangage")
.getString("ERRUER"));
}
return (Double) ib.get().get(0);
}
public ID interpreteId() throws InterpreteException {
interpreteBlank();
interpreteParentheseOuvrante();
interpreteBlank();
String id = interpreteIdentifier();
interpreteBlank();
interpreteParentheseFermante();
return new ID(id);
}
public String interpreteIdentifier() throws InterpreteException {
InterpreteString is = new InterpreteString();
String s = "";
try {
s = (String) is.interprete(text, pos);
pos = is.getPosition();
} catch (Exception e) {
throw new InterpreteException(
java.util.ResourceBundle
.getBundle(
"info.emptycanvas.one.empty3.library/scripts/InterpreteLangage")
.getString("ERRUER"));
}/*
* while (success) { interpreteBlank(); try { s += (String)
* is.interprete(text, pos); pos = is.getPosition(); } catch (Exception
* e) { throw new InterpreteException("Erruer"); } }
*/
return s;
}
public Integer interpreteInteger() throws InterpreteException {
InterpretesBase ib = new InterpretesBase();
ArrayList pattern = new ArrayList();
pattern.add(ib.INTEGER);
ib.compile(pattern);
try {
ib.read(text, pos);
pos = ib.getPosition();
} catch (Exception e) {
throw new InterpreteException(
java.util.ResourceBundle
.getBundle(
"info.emptycanvas.one.empty3.library/scripts/InterpreteLangage")
.getString("ERRUER"));
}
return (Integer) ib.get().get(0);
}
StructureMatrix interpreteLumiereCollection() throws InterpreteException {
StructureMatrix lumieres = new StructureMatrix<>(1, Lumiere.class);
InterpretesBase ib = new InterpretesBase();
ArrayList pattern = new ArrayList();
pattern.add(ib.BLANK);
pattern.add(ib.LEFTPARENTHESIS);
pattern.add(ib.BLANK);
ib.compile(pattern);
ib.read(text, pos);
setPosition(ib.getPosition());
Lumiere c;
try {
while (true) {
interpreteBlank();
String id = interpreteIdentifier();
interpreteBlank();
if ("lumierepoint".equals(id == null ? "NULL" : id
.toLowerCase())) {
lumieres.add(1, interpreteLumierePoint());
}
interpreteBlank();
}
} catch (InterpreteException ex) {
}
ib = new InterpretesBase();
pattern = new ArrayList();
pattern.add(ib.BLANK);
pattern.add(ib.RIGHTPARENTHESIS);
pattern.add(ib.BLANK);
ib.compile(pattern);
ArrayList
© 2015 - 2025 Weber Informatics LLC | Privacy Policy