###前提・実現したいこと
Processing(3.3.6)で以下のエラーが出て困っています。どなたかお力添え頂けると幸いです。
下から4行目 " g3 = (PGraphicsOpenGL)g;" の箇所が黄色くマークされます。
ソースコードは、エラー文付近より上の行のみ掲載しています。
###発生している問題・エラーメッセージ
ClassCastException: processing.core.PGraphicsJava2D cannot be cast to processing.opengl.PGraphicsOpenGL
###該当のソースコード
JAVA
1import java.io.BufferedReader; 2import java.io.File; 3import java.io.FileReader; 4import java.io.IOException; 5import java.util.ArrayList; 6import java.util.Arrays; 7 8import javax.swing.JFileChooser; 9import javax.swing.JFrame; 10import javax.swing.filechooser.FileFilter; 11import javax.swing.filechooser.FileNameExtensionFilter; 12import javax.vecmath.Point3f; 13import javax.media.opengl.*; 14import javax.swing.*; 15 16import peasy.PeasyCam; 17 18import controlP5.*; 19import processing.opengl.*; 20 21 22private boolean dualExtrusionColoring = false ; 23 24PeasyCam cam; //The camera object, PeasyCam extends the default processing camera and enables user interaction 25ControlP5 controlP5; //ControlP5 object, ControlP5 is a library used for drawing GUI items 26PMatrix3D currCameraMatrix; //By having 2 camera matrix I'm able to switch a 3D pannable area and a fixed gui in relation to the user 27PGraphicsOpenGL g3; //The graphics object, necessary for openGL manipulations 28ControlGroup panButts; //The group of controlP5 buttons related to panning 29private boolean is2D = false; 30private boolean isDrawable = false; //True if a file is loaded; false if not 31private boolean isPlatformed = false; 32private boolean isSpeedColored = true; 33private String gCode; //The path of the gcode File 34private ArrayList<LineSegment> objCommands; //An ArrayList of linesegments composing the model 35private int curScale = 20; 36private int curLayer = 0; 37 38 39////////////ALPHA VALUES////////////// 40private final int TRANSPARENT = 20; 41private final int SOLID = 100; 42private final int SUPERSOLID = 255; 43 44 45////////////COLOR VALUES///////////// 46private final int RED = color(255, 200, 200); 47private final int BLUE = color(0, 255, 255); 48private final int PURPLE = color(242, 0, 255); 49private final int YELLOW = color(237, 255, 0); 50private final int OTHER_YELLOW = color(234, 212, 7); 51private final int GREEN = color(33, 255, 0); 52private final int WHITE = color(255, 255, 255); 53 54 55///////////SPEED VALUES/////////////// 56private float LOW_SPEED = 700; 57private float MEDIUM_SPEED = 1400; 58private float HIGH_SPEED = 1900; 59 60 61//////////SLIDER VALUES///////////// 62private int minSlider = 0; 63private int maxSlider; 64private int defaultValue; 65 66 67/////////Canvas Size/////////////// 68private int xSize = 5*screen.width/6; 69private int ySize = 5*screen.height/6; 70 71//////////////////////////////////// 72private int camOffset = 70; 73private int textBoxOffset = 200; 74 75/* 76 private static String argument =null; 77 78 79 public static void main(String args[]) { 80 PApplet.main(new String[] {"ProcessingGcodeViewer" }); 81 if(args.length >= 1) 82 { 83 argument = args[0]; 84 } 85 } 86 */ 87 88public void settings() { 89 90 size(xSize, ySize, OPENGL); //OpenGL is the renderer; untested with p3d 91 92} 93 94public void setup() { 95 96 //gCode = ("RectangularServoHorn2.gcode"); 97 //gCode = ("C:/Users/noah/Downloads/RoboArm/pig.gcode"); 98 //gCode = ("C:/Users/noah/Dropbox/Rep26Stuff/Example Files/Cupcake/Merged.gcode"); 99 100 frameRate(25); 101 hint(ENABLE_NATIVE_FONTS); //I've found this hint prevents some weird ControlP5 font not in box issues. 102 background(0); //Make background black 103 104 g3 = (PGraphicsOpenGL)g; 105 hint(DISABLE_OPENGL_2X_SMOOTH); //AntiAliasing really hurts performance and I've found it to be distracting when on 106 noSmooth();
###試したこと
###補足情報(言語/FW/ツール等のバージョンなど)
環境は processing 3.3.6
こちらのプログラムを動かそうとした所、つまづきました。
https://www.thingiverse.com/thing:14980
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2017/10/16 03:57 編集