Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Lobby

Pages: 1 2 3 [4] 5
46
Support / Re: Texture doesn't seem to apply to a sphere
« on: January 06, 2014, 11:12:21 pm »
Nice :)
You may want that the texture isn't wrapped through the sphere two time - you can do this by using this method:
Code: [Select]
/**
* Creates an ellipsoid with given width, height and depth.
* @param size Vector that contains width, height and depth
* @param quads Number of quads that should be used for the sphere. You should seriously not use more quads than
* you need!
* @param uScale texture u scale, default is 2f
* @param vScale texture v scale, default is 1f
* @return the created ellipsoid
*/
public static Object3D createEllipsoid(SimpleVector size, int quads, float uScale, float vScale) {
int yQuads = Math.max(quads / 2 + 1, 3);
Object3D obj = new Object3D(2 * quads * yQuads);

// Prepare vertices
SimpleVector[][] v = new SimpleVector[quads][yQuads];
for (int y = 0; y < yQuads; y++) {
float yAngle = (float) (Math.PI * y / (yQuads - 1));
float yPos = - 0.5f * size.y * (float) Math.cos(yAngle);
float yRadius = (float) Math.sin(yAngle);
for (int x = 0; x < quads; x++) {
float xAngle = (float) (2 * Math.PI * x / quads);
float xPos = 0.5f * size.x * (float) Math.cos(xAngle) * yRadius;
float zPos = 0.5f * size.z * (float) Math.sin(xAngle) * yRadius;

v[x][y] = new SimpleVector(xPos, yPos, zPos);
}
}

// Create quads
float v0 = 0;
float v1 = vScale / (yQuads - 1);
float vStep = v1;
for (int y = 0; y + 1 < yQuads; y++) {
for (int x = 0; x < quads; x++) {
float u0 = uScale * (float) x / quads;
float u1 = uScale * (float) (x + 1) / quads;
if (y > 0) {
obj.addTriangle(v[x][y], u0, v0,
v[x][y + 1], u0, v1,
v[(x + 1) % quads][y], u1, v0);
}
if (y + 2 < yQuads) {
obj.addTriangle(v[(x + 1) % quads][y], u1, v0,
v[x][y + 1], u0, v1,
v[(x + 1) % quads][y + 1], u1, v1);
}
}

v0 = v1;
v1 += vStep;
}

return obj;
}

Now, create your sphere with something like createEllipsoid(new SimpleVector(1,1,1), 32, 1f, 1f) then I think it is perfect ;)

47
Support / Re: Problem loading textures
« on: January 06, 2014, 04:25:39 pm »
The problem isn't the texture but that there are some triangles really close together - such Problems are called z-fighting and are a result of the 16 bit depth buffer (which is not that much).
It should help to set the far clipping plane to a smaller value or make the object bigger. But the best solution is to avoid such triangles in the mesh using a texture that contains such details as different materials (and this should also help to decrease triangle count).

48
According to JavaDoc of setRotationPivot: "Sets the rotation pivot of the object. The rotation pivot is the point in objectspace around which the object will be rotated using its rotation matrix."
So, firstly I think to set the rotation pivot to the center of poi you should call poi.setRotationPivot(new SimpleVector()); und so on. Secondly I'm not sure whether setRotationPivot takes care of current rotation and position - you could try to use rotateMesh() before doing your second rotation.

I'm not sure whether this can solve your problem. Would be nice to see a little bit more code.

49
Support / Re: Texture doesn't seem to apply to a sphere
« on: January 06, 2014, 12:50:15 pm »
Where do you have the sphere mesh from?
The mesh should have so called texture coordiantes which determine how texture is wrapped on it. If you used Primitives.getSphere() to get the sphere then I think you should use another method to get a sphere (even if you used Object3D.calcTextureWrapSpherical() on the sphere).

Here a little class to create a sphere with usable texture coords (use ExtendedPrimitives.createSphere()):
Code: [Select]
public class ExtendedPrimitives {
/**
* Creates a sphere with a specific radius.
* @param radius of the sphere
* @param quads Number of quads that should be used for the sphere. You should seriously not use more quads than
* you need!
* @return the created sphere
*/
public static Object3D createSphere(float radius, int quads) {
float size = 2 * radius;
return createEllipsoid(new SimpleVector(size, size, size), quads);
}

/**
* Creates an ellipsoid with given width, height and depth.
* @param size Vector that contains width, height and depth
* @param quads Number of quads that should be used for the sphere. You should seriously not use more quads than
* you need!
* @return the created ellipsoid
*/
public static Object3D createEllipsoid(SimpleVector size, int quads) {
int yQuads = Math.max(quads / 2 + 1, 3);
Object3D obj = new Object3D(2 * quads * yQuads);

// Prepare vertices
SimpleVector[][] v = new SimpleVector[quads][yQuads];
for (int y = 0; y < yQuads; y++) {
float yAngle = (float) (Math.PI * y / (yQuads - 1));
float yPos = - 0.5f * size.y * (float) Math.cos(yAngle);
float yRadius = (float) Math.sin(yAngle);
for (int x = 0; x < quads; x++) {
float xAngle = (float) (2 * Math.PI * x / quads);
float xPos = 0.5f * size.x * (float) Math.cos(xAngle) * yRadius;
float zPos = 0.5f * size.z * (float) Math.sin(xAngle) * yRadius;

v[x][y] = new SimpleVector(xPos, yPos, zPos);
}
}

// Create quads
float v0 = 0;
float v1 = 1f / (yQuads - 1);
float vStep = v1;
for (int y = 0; y + 1 < yQuads; y++) {
for (int x = 0; x < quads; x++) {
float u0 = 2f * (float) x / quads;
float u1 = 2f * (float) (x + 1) / quads;
if (y > 0) {
obj.addTriangle(v[x][y], u0, v0,
v[x][y + 1], u0, v1,
v[(x + 1) % quads][y], u1, v0);
}
if (y + 2 < yQuads) {
obj.addTriangle(v[(x + 1) % quads][y], u1, v0,
v[x][y + 1], u0, v1,
v[(x + 1) % quads][y + 1], u1, v1);
}
}

v0 = v1;
v1 += vStep;
}

return obj;
}

This methods, together with some others that also create primitives, will be included in jpct.util next time. So you could also wait until next release ;) .

50
Support / Re: setEnvmapped has no effect
« on: January 05, 2014, 04:46:34 pm »
Ok, thanks for your answer, so I'll try to write such a shader. If I'm successful I'll share it here ;) .

51
Support / setEnvmapped has no effect
« on: January 04, 2014, 10:57:17 am »
Hello,

as topic says I have the problem that setEnvmapped seems to have no effect on my 3D objects. Should the command work, yet?
I hope I'm just too dump to use it, but if not will it be implemented? And will it also be possible to have something like cubic environment mapping which is often used for realtime reflections?

Thanks

52
German corner / Re: Texturskalierung für Texturlayer >1 ändern
« on: January 03, 2014, 04:32:02 pm »
Es ist eher zu Testzwecken, beziehungsweise ich entwickle ein paar Klassen die mir später dann hoffentlich einiges an Arbeit abnehmen können. Für den Fall, dass ich mal ein konkretes Projekt habe, irgendwann ;) .

53
German corner / Re: Texturskalierung für Texturlayer >1 ändern
« on: January 03, 2014, 12:46:43 am »
Bin nun endlich dazu gekommen es umzusetzen, zusammen mit einem Shader für die Auswahl der richtigen Textur sieht das Ganze jetzt so aus:

 :D

54
German corner / Re: Terrain Optimierung durch Dreiecksminimierung
« on: January 02, 2014, 02:52:07 pm »
Sehr schön, damit kommt schon einmal keine Fehlermeldung mehr. Aber ich bin mir nicht sicher ob das so aussehen soll:

Das ist zweimal die gleiche Szene, oben ohne, unten mit Wireframe - offenbar werden da beim Quader ein paar Dreiecke nicht richtig eingezeichnet. Muss man bei der Objekterstellung vielleicht etwas Besonderes beachten? Ich habe hier die createBox-Methode der ExtendedPrimitives-Klasse verwendet, die ich dir per pn geschickt habe.

55
German corner / Re: Texturskalierung für Texturlayer >1 ändern
« on: January 02, 2014, 02:40:11 pm »
Oh, das ist mir völlig entgangen *beschämt in eine Ecke stell*  :-[ .

Vielen Dank, ich denke damit lässt sich das auch relativ gut umsetzen.

56
German corner / Re: Texturskalierung für Texturlayer >1 ändern
« on: January 02, 2014, 02:31:53 pm »
Ok, aber wie funktioniert das? Ich meine PolygonManager.getTextureUV hat keinen Parameter für die Ebene und ich konnte bisher auch keine andere Methode finden die etwas in diese Richtung zu können scheint.

57
German corner / Re: Terrain Optimierung durch Dreiecksminimierung
« on: January 02, 2014, 02:25:45 pm »
Gut, wenn es sich geschwindigkeitstechnich ohnehin nicht lohnt hat sich das auch erledigt, danke.

Wegen drawWireframe, ich verwende jpct-ae ;) .

58
German corner / Re: Texturskalierung für Texturlayer >1 ändern
« on: January 02, 2014, 02:10:53 pm »
Dann müsste die Terrainklasse bereits über die Texturinformationen verfügen - stimmt, das wäre eine Lösung, auch wenn es bedeutet, dass man das Terrain neu bauen muss um es anders zu texturieren.

Nachträglich die UV-Koordinaten für verschiedene Layer zu beeinfluss ist nicht möglich, oder?

59
German corner / Terrain Optimierung durch Dreiecksminimierung
« on: January 02, 2014, 04:48:34 am »
Wie in einem anderen Thread schon angemerkt arbeite ich zur Zeit etwas mit Terrains. Dabei kam mir die Frage, inwiefern ich das Ganze optimieren kann um möglichst wenige Dreiecke darstellen zu müssen. Ich habe in den zahlreichen Dokumentationen irgendwo gelesen, dass Dreiecke, die dies zulassen, automatisch zu weniger zusammengefasst werden. Stimmt das, und gilt das auch noch, wenn man im Nachhinein mit einem VertexController die Position von ein paar Vertexen manipuliert? (ich kann das Ganze nicht so recht glauben, weil damit ja eine ganze Menge Berechnungen verbunden wären)

Zu guter Letzt: Lohnt sich die Optimierung überhaupt? Konkret würde ich gerne dafür sorgen, dass Bereiche, die weiter von der Kamera entfernt sind, mit weniger Details dargestellt werden. Dies ist aber nur dann sinnvoll, wenn die Berechnungen für diese Optimierung mehr Zeit beim Rendern einsparen als sie selbst verbrauchen.

PS. Ich hätte mir auch gerne mal das Gerenderte als Wireframe anzeigen lassen um die Dreiecke sehen zu können, aber leider kommt beim Versuch mittels world.drawWireframe() eine Meldung, dass ein glPointSize() nicht implementiert sei (und dabei habe ich den pointMode-Parameter auf false gesetzt).

60
German corner / Texturskalierung für Texturlayer >1 ändern
« on: January 01, 2014, 09:13:33 pm »
Hallo mal wieder,

ich spiele zur Zeit etwas mit der Terrain-Generierung herum. Nun frage ich mich, ob es auch möglich ist für Andere Texturlayer als 1 eine Transformationsmatrix zu setzen.

Möglicherweise gibt es aber auch eine ganz andere Lösung für folgendes Problem:
Ich möchte ein Terrain so darstellen, dass es an manchen Stellen eine Sand, und an anderen Stellen eine Steintextur aufweist. Wo welche dieser Texturen angezeigt werden soll, kann ich mittels einer weiteren Textur bestimmen (das ist ja unter anderem der Sinn von Multitexturing). Das Ganze funktioniert soweit auch problemlos, nur hätte ich gerne, dass die Stein- und die Sandtextur kleiner skaliert angezeigt werden, sodass die Landschaft detailreicher aussieht (das könnte man auch lösen, indem man riesige Texturen verwendet, aber ich denke das ist keine gute Idee).

Pages: 1 2 3 [4] 5