private void drawCurve(ICurve3D curve, int color, Vector3 position) { SimpleMaterial lineMaterial = new SimpleMaterial(); lineMaterial.setUseSingleColor(true); Stack<Vector3> points = new Stack<Vector3>(); for (int i = 0; i <= NUM_POINTS; i++) { Vector3 pos = curve.calculatePoint((float) i / (float) NUM_POINTS); points.add(pos); } Line3D line = new Line3D(points, 1, color); line.setMaterial(lineMaterial); line.setPosition(position); getCurrentScene().addChild(line); }
protected void initScene() { RajLog.systemInformation(); setFrameRate(60); LoaderGCode gCodeParser = new LoaderGCode( getResources(), getTextureManager(), R.raw.calibrationcube_404020_psm_pla35); try { Object3D gCode3D = gCodeParser.parse().getParsedObject(); if (null != gCode3D) { Line3D firstPos = (Line3D) gCode3D.getChildAt(0); Line3D lastPos = null; if (gCode3D.getNumChildren() < 2) { lastPos = firstPos; } else { lastPos = (Line3D) gCode3D.getChildAt(gCode3D.getNumChildren() - 1); } getCurrentCamera().setPosition(0, 0, lastPos.getPoint(0).z + 150); getCurrentCamera().setLookAt(0, 0, 0); float scaleFactor = 0.7f; gCode3D.setScale(scaleFactor); gCode3D.setPosition( -firstPos.getPoint(0).x * scaleFactor, -firstPos.getPoint(0).y * scaleFactor, 0); gCode3D.setRotation(360 - 35, 0, 360 - 15); Material mat = new Material(); for (int i = 0; i < gCode3D.getNumChildren(); i++) { gCode3D.getChildAt(i).setMaterial(mat); } addChild(gCode3D); } } catch (Exception e) { RajLog.e( new StringBuilder() .append("error init'ing gcode GL scene:\n") .append(Log.getStackTraceString(e)) .toString()); } }