kev 3ds loaders setBounds

seems the bounding area around your loaded is wrong. its got me stuck mate… any chance u could fix that bit?

i tryed:


TDSLoader tload = new TDSLoader();
System.out.println("innited the 3ds file: " + tload);
model = tload.load("model/", new FileInputStream(new File(bFileName)));
model.setIsOccluder(true);
BoundingSphere bs = new BoundingSphere(new Vector3f(0f,0f,0f), 100f);
model.setBounds(bs);
model.setShowBounds(true, true);
System.out.println("loaded the 3ds file: " + tload);

with no joy :frowning: - bish bosh dude…

I might even get some tonight, if the wife lets me ;D

I had thought that Xith would support auto bounds computation like Java3D but if not I guess I can work something out.

Infact, TDSModel simply extends BranchGroup (I suspect, not having the source at work is a pain). BranchGroup must perform some form of bounds computation to support scenegraph culling. Maybe this only happens on the first render of the scene? Check if the bounds have been set after rendering?

Even so, like I said, I might get some chance tonight, so I could take a look at the Transparency issue as well. Is there anything else needs checking out?

Kev

model names would be cool :slight_smile: so the model name in the 3ds files is passed over to xith… simple to look stuff up… -not sure maybe it duss this now… could be my model… all in all just them things :slight_smile:

i have set:

model.setShowBounds(true, true);

and added the model to a Transform3D and thats added to a TransformGroup. seems the bounds just wont have it… it shows the bounds as a small sphear in the middle of the model. not wrapping around the model. This would explane me model popping off the screen…

Oddity :slight_smile: If one of the most intense Xith folks have a moment could you let us know if Geometry objects should be calculating their own bounds? And if so are there any know bugs in that area?

Model Names, good plan, infact wasn’t I going to make it look a lot like Williams’s ASE additions? I’ll try to match up to that as much as possible.

Got to check out some OBJ loader issues aswell…

Kev

Do you use IndexedTriangleArray to store your geometry?

Nope. Its just done with a standard TriangleArray, at least it was last time I checked :slight_smile:

Kev

Sigh…, that means that I’m gonna have to load a model, filter the repeated vertices, treat them and generate TBN matricies, and finally submit them again to the parent shape as well as a new set of TexCoord3f in order to feed more info to my shaders (PS & VS) when it comes to do extra effects…
/me goes and look into loading 3DS models in his latest demos

Or alternatively I could just add support for IndexedTriangleArrays, or better still (from my point of view) you could :slight_smile:

Kev

:slight_smile:
Lemmie see what I can do

tip TOP! speedy and with shaders… sounds sweet! ;D

Ah, minor bug, forgot to register the processor. Got it :slight_smile:

Kev

Ok, just uploaded a new version with transparency support and the bounds thing fixed (at least it seems that way).

I’ve tried to add indexed geometry support, but it seems I don’t know what I’m doing in that area since my stuff doesn’t appear if I used indexed geometry.

Hey ho, got to do some work on the OBJ loader… hopefully get to have a second look at the indexed stuff a bit later…

Kev

PS. Do you actually use indexed geometry in your demos JCDs? I couldn’t find any in your source, was looking for examples.

Hey man I’ve used IndexedTriangleArray in PPL and the water demo


  public Shape3D getJCDTorus(float OuterRadius, float InnerRadius   , int   Slice        ,
                             int   Stack      , float repeatTextureS, float repeatTextureT){


    TexCoord3f texCoords[]      = new TexCoord3f[(Slice + 1)*(Stack + 1)],
               torusTangents[]  = new TexCoord3f[(Slice + 1)*(Stack + 1)],
               torusBinormals[] = new TexCoord3f[(Slice + 1)*(Stack + 1)];

    Vector3f   torusNormals[]   = new Vector3f[(Slice + 1)*(Stack + 1)];

    Point3f    torusVertices[]  = new Point3f[(Slice + 1)*(Stack + 1)];

    float      x                = 0,
               z                = 0,
               temp             = 0,
               sliceStep        = 2f*(float)Math.PI/Slice,
               stackStep        = 2f*(float)Math.PI/Stack,
               sliceAngle       = 0,
               stackAngle       = 0,
               filterTriangles  = 0;

    int        indices[]        = new int[Slice*Stack*6];

    for(int i = 0; i<(Slice + 1); i++){
      if(i ==  Slice )
        sliceAngle = 0;

      x = (float)Math.sin(sliceAngle);
      z = (float)Math.cos(sliceAngle);

      torusVertices[i] = new Point3f(OuterRadius - InnerRadius*x,
                                                 0              ,
                                            InnerRadius*z       );
      torusNormals[i]  = new Vector3f(-x,0,z);

      texCoords[i]     = new TexCoord3f(0, (float)i/Slice*repeatTextureT,0);

      sliceAngle += sliceStep;
    }

    for(int a = 1, p = Slice + 1; a < Stack + 1; a++){
      stackAngle += stackStep;
      if(a == Stack)
        stackAngle = 0;
      for(int i = 0; i< Slice +1 ; i++, p++){

        rotateTupleZ(torusVertices[p] = new Point3f() , torusVertices[i], stackAngle);
        rotateTupleZ(torusNormals[p]  = new Vector3f(), torusNormals[i] , stackAngle);
        texCoords[p] = new TexCoord3f((float)a/Stack*repeatTextureS,
                                       (float)i/Slice*repeatTextureT,0);
      }
    }

    for(int j=0; j<Stack; j++)
      for(int i=0; i<Slice; i++){
        indices[((j*Slice+i)*2)*3+0]  = j*(Slice+1)+i;
        indices[((j*Slice+i)*2)*3+1]  = (j+1)*(Slice+1)+i;
        indices[((j*Slice+i)*2)*3+2]  = j*(Slice+1)+i+1;
        indices[((j*Slice+i)*2+1)*3+0]= j*(Slice+1)+i+1;
        indices[((j*Slice+i)*2+1)*3+1]= (j+1)*(Slice+1)+i;
        indices[((j*Slice+i)*2+1)*3+2]= (j+1)*(Slice+1)+i+1;
      }
    OjectStructure.generateTBN(indices      , torusVertices , torusNormals,
                               torusTangents, torusBinormals, texCoords   );
    createNormalVectorsShape(torusVertices, torusNormals,
                             torusTangents, torusBinormals);

    IndexedTriangleArray torusGeometry = new IndexedTriangleArray(torusVertices.length,
                                                                  GeometryArray.TEXTURE_COORDINATE_3 |
                                                                  GeometryArray.COORDINATES          |
                                                                  GeometryArray.NORMALS,
                                                                  3,
                                                                  new int[]{0,1, 2},
                                                                  indices.length);

    torusGeometry.setIndex(indices);
    torusGeometry.setNormals(0, torusNormals);
    torusGeometry.setCoordinates(0, torusVertices);
    torusGeometry.setValidIndexCount(indices.length);
    torusGeometry.setTextureCoordinates(0,0, texCoords);
    torusGeometry.setTextureCoordinates(1,0, torusTangents);
    torusGeometry.setTextureCoordinates(2,0, torusBinormals);

    polygonAttributes = new PolygonAttributes();
    polygonAttributes.setPolygonMode(PolygonAttributes.POLYGON_FILL);

    setTextureAttributes();
    setTextureUnitStateDot3BumpMap();
    torusAppearance.setPolygonAttributes(polygonAttributes);

    vertexShader = new VertexProgram(getShaderCode("Data/ppl.jcd"),lightLocation);
    torusAppearance.setVertexShaderProgram(vertexShader);

    return new Shape3D(torusGeometry,torusAppearance);
  }

Excellent, I’ll give that a try. You’re really going to upset the guy waiting for me to have a look at his problems with the OBJ loader :wink:

Kev

You’re really gonna like what I’m putting next in my demos :wink:

Its official JCD, you rock! Just saved me a bunch of time searching, had missed the setIndex() line which appears to fixed everything…

So…

  • Transparency should now work
  • Bounds should be correct
  • And indexed geometry can be created by passing a “true” as the second parameter the load() method.

The code is still awful and still feels like the code I ported it from. It will get fixed soon as I get some proper time. However, I hear there is a new 3DS loader on the way from a central code base which might be the best bet as and when it arrives.

Cheers again JCD,

Kev

Is it the obj loader or the 3Ds?
Both are fine :slight_smile:

sorry just got home- do u still want that model?

http://www.topresultmate.com/xith3d/test5.3DS

is a model with a transparent base. i can make u anything u like :slight_smile: just ask…

The 3DS loader has all the additons, I must get to the updates to the OBJ loader. However, not the OBJ does not support indexed triangle arrays yet. Hopefully, later.

Kev

thanks loads dudes. i will give it a try :slight_smile: top stuff… indeed… :-*