I'm having a little difficulty and being a complete newbie to using the API
am not sure where to find an answer.

When I apply textures using setTexCoordGeneration everything works fine. I
would like to be able to set the coordinates without this method but the
texture does not render.

I am creating Shape3D objects out of dynamic data. I am using QuadArrays to
define the geometry through GeometryInfo.

The code looks something like this(cut down):

class QuadShape extends Shape3D {

...

        if(sttexurl!=null){

//              stlook.setTexCoordGeneration(sttexgen); //uncommenting this works and
textures applied

                TextureLoader sttexl = new TextureLoader(sttexurl,
TextureLoader.GENERATE_MIPMAP , null);
                sttex = (Texture2D)sttexl.getTexture();
                sttex.setEnable(true);
                TextureAttributes ta = new TextureAttributes();
                stlook.setTextureAttributes(ta);
        }

try{
                sttexurl = new URL(serverpath+texurl1);
}catch(Exception e){
        System.out.println("error loading image in"+this+": "+e+" @url: "+sttexurl);
}

                stmat.setLightingEnable(true);
                stmat.setAmbientColor(1.0f,1.0f,1.0f);
                stmat.setDiffuseColor(1.0f,1.0f,1.0f,0.0f);
                stmat.setEmissiveColor(0.0f,0.0f,0.0f);
                stmat.setSpecularColor(0.0f,0.0f,0.0f);
                stmat.setShininess(0.0f);
                stmat.setLightingEnable(true);

                stlook.setMaterial(stmat);
                stlook.setTexture(sttex);

                TextureAttributes sttexa = new TextureAttributes();
                sttexa.setTextureMode(sttexa.MODULATE);

                stlook.setTextureAttributes(sttexa);

...

//this method takes the data that has been interpreted and sets the geometry

public void compileQuads(Appearance stlook){
        if(stverts.size()>0){
                float[] verts = new float[stverts.size()];
                int n = 0;
                Iterator it = stverts.iterator();
                while(it.hasNext()){
                        Object o = it.next();
                        try{
                                Float ff =(Float)o;
                                float f = ff.floatValue();
                                verts[n++]= f;

                        }catch(Exception e){
                                System.out.println(e + " // on number: '" + 
o.toString());
                        }
                }
                Vector3f[] normals = new Vector3f[stnorms.size()];
                n = 0;
                it = stnorms.iterator();
                while(it.hasNext()) normals[n++]=((Vector3f)it.next());

                int numfaces = normals.length;
                int numpoints = numfaces*4;

                QuadArray tileset = new QuadArray(numpoints,
QuadArray.TEXTURE_COORDINATE_2 | QuadArray.COORDINATES | QuadArray.NORMALS);

                tileset.setCoordinates(0, verts);

                GeometryInfo gitileset = new GeometryInfo(tileset);

                NormalGenerator normilizer = new NormalGenerator();
                normilizer.generateNormals(gitileset);

  //sttexcs is a Vector loaded with a repetition of {TexCoord2f(0.0f,
0.0f), TexCoord2f(1.0f, 0.0f), TexCoord2f(1.0f, 1.0f), TexCoord2f(0.0f,
1.0f)} for each face

                Object[] rtexarr = sttexcs.toArray();
                TexCoord2f[] texarr = new TexCoord2f[rtexarr.length];
                for(int i=0;i<rtexarr.length;i++)texarr[i]=(TexCoord2f)rtexarr[i];

//these lines should set the texture coordinate data
                gitileset.setTextureCoordinateParams(texarr.length,2);
                gitileset.setTextureCoordinates(0, texarr);

                setAppearance(stlook);
                setGeometry(gitileset.getGeometryArray());
}

...

}

I get an error:
  "Missing Texture Coordinate data list"

If anyone would be kind enough to let me know what I need to do to enable
the textures or what I should look out for when trying to make
TexCoodinates I would be most grateful.  I know I am just missing something
simple due to my lack of experience with the API or language.

Matthew Barnes

===========================================================================
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".

Reply via email to