Alessandro Borges wrote:
* Unable to get correct texCoords with a non null TexCoordGeneration
(GForce2), but color are good :((
Well, reason is quite simple. Default geometry generated by Sphere
contains {0} map for tex coords. You need {0,0} map - for both texture
units.
Add following code after sphere constructor, and before adding it to graph:
TriangleStripArray orig = (TriangleStripArray)sph.getShape().getGeometry();
int[] strips = new int[orig.getNumStrips()];
orig.getStripVertexCounts(strips);
TriangleStripArray copy = new
TriangleStripArray(orig.getVertexCount(),orig.getVertexFormat(),
1,new int[]{0,0},strips);
float[] temp = new float[orig.getVertexCount()*3];
orig.getCoordinates(0,temp);
copy.setCoordinates(0,temp);
orig.getNormals(0, temp);
copy.setNormals(0,temp);
temp = new float[orig.getVertexCount()*2];
orig.getTextureCoordinates(0,0, temp);
copy.setTextureCoordinates(0,0, temp);
sph.getShape().setGeometry(copy);
This does the trick. Here I copy the geometry, changing only texture
unit map.
Two points I would like to raise:
1) There is an ugly black spot near highlight on the sphere. Aren't you
trying to mix bumpmap with default light effect ? It will not work I'm
afraid...
2) I suppose it is some kind of leftover from underlying APIs, but for
me putting texCoordSetMap inside Geometry (instead of Appearance) is
very bad choice. Geometry is only interested about set of texture
coordinates it provides, not about mapping them inside Appearance. So
far, I had to break nice encapsulation in my methods, to add Appearance
hints inside geometry generation. I wanted to play with different
Appearances switchable at runtime - but this requires actually changing
geometry in shapes (as one of these appearances is 2 and second 3 units
long).
Artur
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".