franksisca
16-03-2010, 12:01
private TransformGroup creaPavimento() {
Texture texture = (new TextureLoader("textures/autobloccanti.jpg", this))
.getTexture();
float l = 60f; // (float) lato;
texture.setMagFilter(Texture.NICEST);
texture.setMipMapMode(Texture.BASE_LEVEL);
Appearance apparence = new Appearance();
apparence.setTexture(texture);
Box pavimento = new Box(l, 0.1f, l, Box.GENERATE_TEXTURE_COORDS, apparence);
GeometryArray g = (GeometryArray) pavimento.getShape(Box.TOP)
.getGeometry();
TexCoord2f[] tx = new TexCoord2f[g.getVertexCount()];
for (int k = 0; k < tx.length; k++) {
tx[k] = new TexCoord2f();
}
g.getTextureCoordinates(0, 0, tx);
for (TexCoord2f t : tx) {
t.scale(2f);
}
g.setTextureCoordinates(0, 0, tx);
pavimento.getShape(Box.TOP).setAppearance(apparence);
Transform3D transf = new Transform3D();
TransformGroup tg = new TransformGroup();
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Vector3f posizione = new Vector3f(0, -2.5f, 0);
transf.setTranslation(posizione);
tg.setTransform(transf);
tg.addChild(pavimento);
return tg;
}
con questo codice creo il pavimento della mia applicazione 3d.
solo che non riesco a trovare il codice per "replicare" questa texture, ovvero me ne crea una ma poi tutto il resto è vuoto.
considerando che bene o male io sò la dimensione massima del mio "mondo", come faccio a fargliela replicaer?
Texture texture = (new TextureLoader("textures/autobloccanti.jpg", this))
.getTexture();
float l = 60f; // (float) lato;
texture.setMagFilter(Texture.NICEST);
texture.setMipMapMode(Texture.BASE_LEVEL);
Appearance apparence = new Appearance();
apparence.setTexture(texture);
Box pavimento = new Box(l, 0.1f, l, Box.GENERATE_TEXTURE_COORDS, apparence);
GeometryArray g = (GeometryArray) pavimento.getShape(Box.TOP)
.getGeometry();
TexCoord2f[] tx = new TexCoord2f[g.getVertexCount()];
for (int k = 0; k < tx.length; k++) {
tx[k] = new TexCoord2f();
}
g.getTextureCoordinates(0, 0, tx);
for (TexCoord2f t : tx) {
t.scale(2f);
}
g.setTextureCoordinates(0, 0, tx);
pavimento.getShape(Box.TOP).setAppearance(apparence);
Transform3D transf = new Transform3D();
TransformGroup tg = new TransformGroup();
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Vector3f posizione = new Vector3f(0, -2.5f, 0);
transf.setTranslation(posizione);
tg.setTransform(transf);
tg.addChild(pavimento);
return tg;
}
con questo codice creo il pavimento della mia applicazione 3d.
solo che non riesco a trovare il codice per "replicare" questa texture, ovvero me ne crea una ma poi tutto il resto è vuoto.
considerando che bene o male io sò la dimensione massima del mio "mondo", come faccio a fargliela replicaer?