Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3 ... 5
  ignore  |  Print  
  kev 3ds loaders setBounds  (Read 13094 times)
0 Members and 1 Guest are viewing this topic.
Offline aNt

Senior Member




AFK


« Posted 2004-02-12 10:16:09 »

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

i tryed:

1  
2  
3  
4  
5  
6  
7  
8  
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 Sad - bish bosh dude...
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2004-02-12 10:29:31 »

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

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

Offline aNt

Senior Member




AFK


« Reply #2 - Posted 2004-02-12 11:05:57 »

model names would be cool Smiley 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 Smiley

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...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #3 - Posted 2004-02-12 11:12:55 »

Oddity Smiley 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

Offline Java Cool Dude

Senior Member




Java forever


« Reply #4 - Posted 2004-02-12 13:11:46 »

Do you use IndexedTriangleArray to store your geometry?
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #5 - Posted 2004-02-12 13:18:30 »

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

Kev

Offline Java Cool Dude

Senior Member




Java forever


« Reply #6 - Posted 2004-02-12 13:51:31 »

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
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #7 - Posted 2004-02-12 13:52:39 »

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

Kev

Offline Java Cool Dude

Senior Member




Java forever


« Reply #8 - Posted 2004-02-12 14:03:06 »

^_^
Lemmie see what I can do
Offline aNt

Senior Member




AFK


« Reply #9 - Posted 2004-02-12 14:33:47 »

tip TOP! speedy and with shaders.. sounds sweet!  Grin
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #10 - Posted 2004-02-12 15:42:05 »

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

Kev

Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #11 - Posted 2004-02-12 17:52:25 »

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.

Offline Java Cool Dude

Senior Member




Java forever


« Reply #12 - Posted 2004-02-12 17:57:14 »

Hey man I've used IndexedTriangleArray in PPL and the water demo
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
  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);
  }
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #13 - Posted 2004-02-12 18:00:10 »

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

Offline Java Cool Dude

Senior Member




Java forever


« Reply #14 - Posted 2004-02-12 18:03:23 »

You're really gonna like what I'm putting next in my demos Wink
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #15 - Posted 2004-02-12 18:11:57 »

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

Offline Java Cool Dude

Senior Member




Java forever


« Reply #16 - Posted 2004-02-12 18:18:08 »

Is it the obj loader or the 3Ds?
Both are fine Smiley
Offline aNt

Senior Member




AFK


« Reply #17 - Posted 2004-02-12 18:21:00 »

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 Smiley just ask...
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #18 - Posted 2004-02-12 18:54:17 »

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

Offline aNt

Senior Member




AFK


« Reply #19 - Posted 2004-02-12 19:44:14 »

thanks loads dudes. i will give it a try Smiley top stuff... indeed....  Kiss
Offline aNt

Senior Member




AFK


« Reply #20 - Posted 2004-02-12 20:34:08 »

dudes what version of xith3d are u using? and where did u upload the new loader?

loader i would guess is on yer site kev?

i dont mind rolling back my xith version. just wondered what versions u chaps are using? i updated from the CVS. it didnt work in the older version i had.

i get this error:

java.lang.NoSuchMethodError: com.xith3d.scenegraph.Shape3D.updateBounds(Z)V
     at org.newdawn.xith3d.threeds.SmoothGroupProcessor.process(SmoothGroupProcessor.java:157)
     at org.newdawn.xith3d.threeds.TDSLoader.processChunk(TDSLoader.java:125)
     at org.newdawn.xith3d.threeds.TDSLoader.load(TDSLoader.java:92)
     at ant.xith3d.mod.Building.loadBuildingData(Building.java:58)
     at ant.xith3d.RenderWindow.init(RenderWindow.java:146)
     at ant.xith3d.RenderWindow.<init>(RenderWindow.java:40)
     at ant.xith3d.Main.main(Main.java:Cool

my load code is:

1  
2  
3  
4  
5  
6  
TDSLoader tload = new TDSLoader();
System.out.println("innited the 3ds file: " + tload);
model = tload.load("model/", new FileInputStream(new File(bFileName)), true);
// model.setIsOccluder(true);
// model.setShowBounds(true, true);
System.out.println("loaded the 3ds file: " + tload);
Offline Java Cool Dude

Senior Member




Java forever


« Reply #21 - Posted 2004-02-13 00:15:47 »

Well everything works fine when loading, but you screwed something up BIG time (/me shoots kev for making him waste over 4 hours debugging and doubting his own code, f**** homework)... Grin

new IndexedTriangleArray(context.numberOfFaces * 3,vertexFormat,context.numberOfFaces * 3);

That's totally wrong, the first argument takes the exact number of non-duplicated vertices, and the last one takes the size of the array holding the vertices' indices
corrected
       if (context.indexedGeometryUsed) {
           context.indexedGeometry = new IndexedTriangleArray(context.numberOfVerts ,vertexFormat,context.numberOfFaces * 3);
           
:sad panda:
Offline Java Cool Dude

Senior Member




Java forever


« Reply #22 - Posted 2004-02-13 00:47:13 »

Thank you KevGlass Tongue


Notice the nice bumping on the model Wink
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
  private void proccessShape3D(Shape3D shape){
    IndexedTriangleArray geometry = (IndexedTriangleArray)shape.getGeometry();

    int[]        indices     = geometry.getIndex();
    float[]      texcoords   = new float     [geometry.getValidVertexCount()*2];
    Point3f[]    vertices    = new Point3f   [geometry.getValidVertexCount()];
    Vector3f[]   normals     = new Vector3f  [vertices.length  ];
    TexCoord3f[] tangents    = new TexCoord3f[vertices.length  ],
                 binormals   = new TexCoord3f[vertices.length  ],
                 texcoords3f = new TexCoord3f[vertices.length  ];

    geometry.getTextureCoordinates(0,0,texcoords);

    for(int i = 0; i< vertices.length; i++){
      texcoords3f[i] = new TexCoord3f(texcoords[i*2 + 0],
                                      texcoords[i*2 + 1],0);
      geometry.getCoordinate(i, vertices   [i] = new Point3f ());
      geometry.getNormal    (i, normals    [i] = new Vector3f());
    }

    OjectStructure.generateTBN(indices , vertices , normals,
                               tangents, binormals, texcoords3f);

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

    for(int i=0; i<indices.length; i++){
      newGeometry.setNormal           (  i, normals    [indices[i]]);
      newGeometry.setCoordinate       (  i, vertices   [indices[i]]);
      newGeometry.setTextureCoordinate(0,i, texcoords3f[indices[i]]);
      newGeometry.setTextureCoordinate(1,i, tangents   [indices[i]]);
      newGeometry.setTextureCoordinate(2,i, binormals  [indices[i]]);
    }
    parent.addChild(ShapeFactory.getTexturedShape(newGeometry,
                                                  "Data/chalicebase.png",
                                                  "Data/chalicedot3.png",
                                                  "Data/torusgloss.png",
                                                  .1f,.1f,.1f, 1, 1, 1, 32));
  }
Offline Java Cool Dude

Senior Member




Java forever


« Reply #23 - Posted 2004-02-13 02:10:49 »

Loading the chalice took 2.422 S
Loading the torus took 1.016  S
Loading the angel took 43.5 S

Man you gotta work on dat speed
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #24 - Posted 2004-02-13 04:59:49 »

Quote

Well everything works fine when loading, but you screwed something up BIG time (* Java Cool Dude shoots kev for making him waste over 4 hours debugging and doubting his own code, f**** homework)...  

new IndexedTriangleArray(context.numberOfFaces * 3,vertexFormat,context.numberOfFaces * 3);


Erg, sorry about that, I actually had the right code in originally, but while debugging I ended up changing it to that.

Doh!

New version uploaded..

Speed:

Have to say its not something I tend to worry about too much, these loaders are only convienience. However, if you could send me the "angel" model I'll see if I can use it as a benchmark...

Sorry guys, seems to have caused you more trouble than its worth. See.. this is why I don't do fixes Wink

Not sure when I'm going to get my next free patch.. shouldn't really be posting now.. should be off to werk.. man JGOF is addictive.

Kev

Offline Java Cool Dude

Senior Member




Java forever


« Reply #25 - Posted 2004-02-13 05:05:55 »

sent Smiley
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #26 - Posted 2004-02-13 06:05:19 »

Ant,

I try to be using the latest version from CVS, but I do jar it up, so I might be up to a week behind...

Are you up and working with the new code now, or do I need to check the latest stuff out again?

Kev

Offline aNt

Senior Member




AFK


« Reply #27 - Posted 2004-02-13 08:49:15 »

i get the same error. and i am now testing againt the jeep model. the loader finds and starts loading the model ok. but then hits that exception.

i am also puting my models in my jar so to test it the same way u seem to be- and get the same error.

going to try and roll back xith3d a few weeks and try again.
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #28 - Posted 2004-02-13 09:10:49 »

Na, no worries, I'll get the latest source from CVS tonight and find out what the problem is..

Also noticed that I don't bother reading the contents in the file into memory before processing it, man I was in a rush, this should help the speed a fair bit..

More time tonight, assuming I don't get obsessed over my newly arrived IPOD Wink

Kev

Offline aNt

Senior Member




AFK


« Reply #29 - Posted 2004-02-13 09:23:28 »

sod the iPod! will take a few hours to charge up anyways dude Smiley.
Pages: [1] 2 3 ... 5
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (23 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!