I'm still pretty new to GLGraphics and I just wanted to ask what the best way to create a semi-transparent shape was. I have rendered a sphere based on the globe example, but need to be able to see through it to an extent.
Should I then just apply colours with an alpha value to each vertex, or do I need to use a sprite or texture or something which is semitransparent? I'm after a very basic example or explanation. This sphere must be a GLModel.
And then how should I combine rendering that sphere with rendering other lines/point/shape GLModels which surround the sphere which may or may not be semi-transparent themselves? Blending modes and depth masking etc
I'm sure there's a simple solution to this, but I have a series of shapes involving a bunch of matrix transformations (translate, rotateX, rotateY and rotateZ, pushMatrix and popMatrix) which draw fine outside of the beginGL() / endGL() block, and I then draw a GLModel on top of that which is inside beginGL() / endGL(). But if I put beginGL() / endGL() around everything in the draw function then suddenly everything goes c-rrazy.... though you'll notice the red dots (the GLModel) are in the same spot
I tried changing everything to renderer.translate(), renderer.rotateX(), renderer.pushMatrix() etc, but no help.
I'm working on a project at the moment with lots and lots of data, reading from a text file. The problem I'm having is really low framerates and then a slowdown - starting on 9fps and then getting slower and slower, tending towards 0fps. The points are being plotted with an opengl vertex buffer object (but this isn't the problem, the framerate was the same before I switched to opengl calls).
VisualVM blames my function drawData(). The code for the entire class that function is in is below. Is there a gaping problem here? Is a slowdown a sign of a bad loop or something, or does it just happen if it's all too much?
//This is GOD, the class for a Geospatially Overlaid Dataset.
PVector outputPVector = new PVector(int(pX), int(pY), int(pZ));
return outputPVector;
}
datasetSize is about 2,000,000 for one of the datasets (20 for the only other one currently in there). Is that just too much for a loop to run every frame? But then why does it get slower and slower? Or is it just graphics? surely 2,000,000 points should be able to render faster than this, especially when I'm using a vertex buffer object?
I have a csv file with rows of data, some of it numbers, some of it text. I'm trying to store this data in a String[][], access it later and then convert it into a useful format.
There is another question with a similar problem/title, except their problem was solved by converting the entire String array into a float array. However, my String array does not contain only floats. It has text in it as well. I can access an individual value from my String[][] and print it fine, but converting it to a float produces this error:
Exception in thread "Animation Thread" java.lang.NullPointerException
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:989)
at java.lang.Float.valueOf(Float.java:388)
at java.lang.Float.<init>(Float.java:489)
at processing.core.PApplet.parseFloat(PApplet.java:6566)
at processing.core.PApplet.parseFloat(PApplet.java:6561)
at GESUS$Planet.visualise(GESUS.java:526)
at GESUS$Planet.plot(GESUS.java:364)
at GESUS.draw(GESUS.java:105)
at processing.core.PApplet.handleDraw(PApplet.java:1631)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)
The code is below.
// Welcome to GESUS
// Geospatial Earth Simulation Using Sound (SuperCollider)
import processing.opengl.*;
import javax.media.opengl.*; //use this elsewhere, but removed that code.
import tomc.gpx.*; //maybe there are conflicts with the libraries I am using?
import java.util.Calendar;
import java.util.TimeZone;
import java.lang.Math;
import java.io.File;
GL gl;
PGraphicsOpenGL pgl;
//Equator equator; //class used for solving equations, used elswhere but code removed
Planet earth;
public GPX planetGeography;
XMLElement godDirectory;
void setup() {
size(1600,1000,OPENGL);
background(0);
frameRate(300);
earth = new Planet();
getDataPaths();
}
void getDataPaths() {
godDirectory = new XMLElement(this,"godDirectory.xml");
int godCount = godDirectory.getChildCount();
for(int i=0;i<godCount;i++) {
XMLElement godLayer = godDirectory.getChild(i);
GOD GODLayer = new GOD(godLayer);
}
}
//This is GOD, the class for a Geospatially Overlaid Dataset.
//It takes a data input, parses it and is then called by the Planet to which it is assigned.
int datasetSize = int(godMetaData.get("datasetSize").toString());
for(int j=0;j<datasetSize;j++) {
String latitude = godLayerData[j][int(godMetaData.get("latitude").toString())];
println(latitude); //this works absolutely fine!
//float latitudeFloat = float(latitude);
//why can i not convert this string into a float???
}
}
}
}
The weirdest part is that if you run this code as is, it prints latitudes out no problem. However, as soon as you uncomment the "float latitudeFloat = float(latitude);" line, it prints NULL followed by the error!!! Huh? How can handling a variable LATER affect it earlier in the program? Am I making a dumb mistake or is there something sinister going on?
Thanks in advance for the help, and if there are any other tips on how to make this work better I'd love to hear them!
I'm creating a program which requires millisecond precision. It maps realtime global events, so I also need that time in UTC/GMT time. I created some bloated class which converted my system time into UTC (but I had to manually input my timezone - and this program will eventually be running on the web so that's not workable) with milliseconds from millis() minus the milliseconds after a second change that the program started... blah blah ... its basically crap...
...so long story short, how can I use java's date format/simple date format/calendar/whatever? I read some stuff about parts of it being outdated, plus I don't understand some of the terminology. Does anyone know how to just simply query the current UTC time with millisecond precision?