Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  ASE group support completed - *beta available*  (Read 1450 times)
0 Members and 1 Guest are viewing this topic.
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Posted 2003-12-06 13:01:23 »

Full geom and group node pivot support has been added to the Ase loader as proposed.

What does this mean?  Well if you choose to, you can access individual groups or objects in your model and translate or rotate them around their individual pivot points (which can be specified in MAX).  Previous support only allowed transformations around the origin.

The output of the pre-existing methods has NOT been changed - getModel _should_ work exactally how it used to (although I encourage your to test to make sure my claim is valid).

How can you use this new feature?  Well the most useful way is by the
TransformGroup getTransformGroupTree (HashMap namedNodes) method of AseFile.

That returns the root TransformGroup, plus it maps the node names to their TransformGroups in the passed HashMap.

For example, if you have a model of a human with the body parts "Body" (group of the body geom, arm geom and hand), "Arm" (group of the arm geom and hand geom) and "Hand" (the hand geom), you would add the returned TransformGroup to the root BranchGroup in your scene.  Then you can easily get the Hand or Arm groups from the HashMap and rotate them around their pivot points (the bone joints).

An example of the code in action is given in the demo com.xith3d.test.Xith3DAseGroupTest.

There are two cubes in a group.  Each cube spins in place around their respective pivot points.  The group also spins around it's pivot point (between the two groups), and the group spins around the origin.  This demonstrates the new rotate abilities using three different pivots.  Press the keys "1", "2" and "3" to toggle the rotations of the respective TransformGroups.

The model data is in the files "rotatingcubetext.ASE" and "rotatingcubetest.max".

I have uploaded an "experimental" build for beta testing here:
http://xith.org/download/builds/2003-12-07_experimental-aseloader/

Please run that test to see the new functionality.  Anyone who currently uses the getModel() method in their code, please test my changes with your project and inform me of any problems.

I would like to commit those changes within a few days so long as no issues arise.

Will.

Offline Jens

Senior Member




Java for games!


« Reply #1 - Posted 2003-12-06 19:01:39 »

The demo works fine. I think these improvements will be very important for a lot of us. Keep up the good work.  Smiley

Xith3D Getting Started Guide (PDF,HTML,Source)
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #2 - Posted 2003-12-08 10:11:19 »

Thanks Jens Smiley

NEW BETA RELEASED

This is hopefully the final version before I commit the changes in.

Just repeating, my changes should NOT change existing behaviour but I would like help testing that (so people who use the Ase loader - please download it and make sure nothing crazy happens).

I have also created a tutorial for the GSG about the new methods and functionality.  It's not in there officially yet and my Java example is still being created but I have uploaded it.

The build (and source) can be downloaded from here:
http://xith.org/download/builds/2003-12-08_experimental-aseloader

The GSG PDF is also there if you want some more info on the changes and how they work.  Code is fully commented and javadocumented.

Run the Xith3DAseGroupTest demo from within the demo/ directory to see the new features in action.

1  
java -cp ../libs/xith3d.jar -DXITH3D_USE_VERTEX_BUFFER_CACHING=FALSE com.xith3d.test.Xith3DAseGroupTest


Cheers,

Will.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline aNt

Senior Member




AFK


« Reply #3 - Posted 2003-12-08 10:55:05 »

nice one dude
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #4 - Posted 2003-12-10 11:12:23 »

code has been committed

JWS demos:

From the Getting Started Guide
http://www.xith.org/jws/jws-org.xith3d.gsg.AseTransformGroup.jnlp

Xith3D test case
http://www.xith.org/jws/jws-com.xith3d.test.Xith3DAseTransformGroupTreeTest.jnlp

I am going to upload the tutorial in the near future (it's already in xith-tk CVS for those who can't wait).

Cheers,

Will.

Offline vold_by

Junior Newbie




Java & Rock never dead


« Reply #5 - Posted 2003-12-10 11:21:02 »

Was normal indices parsing aded to new version? I'v realised it earlier forself but waited for ASE group finishig.

Vladimir Al. Vernikovski
JProof Group
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #6 - Posted 2003-12-10 20:59:01 »

Quote
Was normal indices parsing aded to new version? I'v realised it earlier forself but waited for ASE group finishig.


Normal's have always been parsed - since alpha1 that is.

Look at the code:
src/com/xith3d/loaders/ase/AseMesh.java

in particular the 'getTriangleArray' method.

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  
 // convert the normals coordinates.  For each face we have
           // three normal vertices, each of which has 3 floats
           if (normals != null) {
                n = 0;

                float[] norms = new float[nFaces * 3 * 3];

                for (int f = 0; f < numFaces; f++)
                    if ((faceMat[f] == matID) || (matID < 0)) {
                        for (int v = 0; v < 3; v++) {
                            if (convertMeshCoordinates) {
                                norms[(((n * 3) + v) * 3) + 0] = -normals[(((f * 3) +
                                    v) * 3) + 2]; // x
                               norms[(((n * 3) + v) * 3) + 1] = normals[(((f * 3) +
                                    v) * 3) + 1]; // y
                               norms[(((n * 3) + v) * 3) + 2] = normals[(((f * 3) +
                                    v) * 3) + 0]; // z
                           } else {
                                norms[(((n * 3) + v) * 3) + 0] = normals[(((f * 3) +
                                    v) * 3) + 0]; // x
                               norms[(((n * 3) + v) * 3) + 1] = normals[(((f * 3) +
                                    v) * 3) + 1]; // y
                               norms[(((n * 3) + v) * 3) + 2] = normals[(((f * 3) +
                                    v) * 3) + 2]; // z
                           }
                        }

                        n++;
                    }

                a.setNormals(0, norms);


Of course, one must instruct MAX to export normals.

If normals arn't working for your then it would be a bug (somewhere) - not a missing feature Smiley

Maybe I'll whip up a demo in the next day or two.

Hope that helps,

Will.

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #7 - Posted 2003-12-11 00:14:23 »

Normals are definitally in there Smiley

The below diff file contains the changes I made to get the Xith3DAseGroupTest test case to add lighting.

The changes are in three parts:

* Adding lights to the scene
* Creating a material and recursivly adding it to all Shape3D's
* a method to do said recursion.

Note that I am not generating normals - they are loaded in from the ase file!

[edit] The JWS link is here: http://xith.org/jws/jws-com.xith3d.test.Xith3DAseGroupTest.jnlp[/edit]

Will.

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  
Index: Xith3DAseGroupTest.java
===================================================================
RCS file: /cvs/xith3d/src/com/xith3d/test/Xith3DAseGroupTest.java,v
retrieving revision 1.2
diff -u -r1.2 Xith3DAseGroupTest.java
--- Xith3DAseGroupTest.java     9 Dec 2003 12:33:32 -0000       1.2
+++ Xith3DAseGroupTest.java     11 Dec 2003 03:09:34 -0000
-85,7 +85,11 @@
                // Sets the texture path.
               TextureLoader.tf.registerPath("./");
 
-
+               // Adds lights to the scene
+               AmbientLight light = new AmbientLight(true,new Color3f(0.4f,0.4f,0.4f));
+               DirectionalLight dlight = new DirectionalLight(true,new Color3f(0.75f,0.75f,0.75f),new Vector3f(-1,-1,-1));
+               objRoot.addChild(light);
+               objRoot.addChild(dlight);
 
                /*
                 * Loads the ASE file
-132,7 +136,16 @@
                // Adds the entire geometry using the old getModel() method
                objRoot.addChild(af.getModel());
 
-
+               // Creates a material able to accept lighting
+               Material mat2 = new Material();
+               mat2.setEmissiveColor(0f,0f,0f);
+               mat2.setSpecularColor(0.5f,0.5f,0.5f);
+               mat2.setAmbientColor(0.75f,0.0f,0.0f);
+               mat2.setDiffuseColor(0.75f,0.0f,0.0f);
+               mat2.setLightingEnable(true);
+
+               // Recursivly applies material to root BG
+               addMaterial(objRoot, mat2);
 
                return objRoot;
        }
-235,6 +248,27 @@
                }
        }
 
+       /**
+        * Recursivly adds the given material to all Shape3D objects
+        * in the passed group and all of its subgroups.
+        */

+       public static void addMaterial(Group group, Material mat) {
+
+               java.util.List nodes = group.getChildren();
+
+               for (int i = 0; i < nodes.size(); i++) {
+                       SceneGraphObject obj = (SceneGraphObject) nodes.get(i);
+
+                       if (obj instanceof Shape3D) {
+                               Shape3D sh = (Shape3D) obj;
+                               sh.getAppearance().setMaterial(mat);
+
+                       } else if (obj instanceof Group) {
+                               addMaterial( (Group) obj, mat);
+                       }
+               }
+       }
+
        public static void main(String[] args)
        {
                System.out.println("Hit ESC to exit\nPress 3 to stop/start rotation");

Pages: [1]
  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.

BurntPizza (21 views)
2014-09-19 03:14:18

Dwinin (35 views)
2014-09-12 09:08:26

Norakomi (62 views)
2014-09-10 13:57:51

TehJavaDev (87 views)
2014-09-10 06:39:09

Tekkerue (42 views)
2014-09-09 02:24:56

mitcheeb (65 views)
2014-09-08 06:06:29

BurntPizza (47 views)
2014-09-07 01:13:42

Longarmx (35 views)
2014-09-07 01:12:14

Longarmx (40 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

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

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

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!