Xith3d progress

would be cool- then some stuff could have hard darker shadows and others softer colour shadows.

note on collision’s… if i have a airplane flying around and what to see if it crashes into the ground. what sort of collision detection should i use? i still want the airplane to fly around the mountains and stuff.

[the airplane and the terrain are both ase files]

also what do u add a Background to? (view i thought but didnt see to work).

Hi
like OrangeTangy said, glBegin can have GL_POLYGON as it’s type, my understanding is that sgi have some algorithm in glu utilities that triangulates it, but the source is closed otherwise I would have pinched it and implemented it :). I was thinking that at some point GemoetryArray in xith3d would accept GEOM_POLY, like it has GEOM_TRI etc, but I guess this isn’t planned for?

Currently i’m playing with using java3d’s GeometryInfo and Triangulator, then extrackign the triangle arrays and triangle strip arrays and creating xith versions of them, but i’m not having much success, the background colour seems grey rather than black, and most of the shapes in my model don’t show up, even though they have been set to do no face culling.

Grrr :slight_smile:

Endolf

cool i thought it was just me- the Background just comes out gray here also.

but its cool it will get there… all top stuff

rats!!! all you people are having fun an I am not. I run the latest (via cvs) xith3d and get a two shades of black empty screen.

The most recent pull has some opengl diags in it an mine shows up as an nvidia cards support opengl 1.2.2, 0 triangles and …wahoo 5 fps. Any ideas???

Basically I have

dell inspiron,
GeForce go with 16mb
running windowz ME.
jdk1.4.1

I am interested in the configurations you all are running that work :-[

Toshiba Laptop
Win XP Home Edition sp1
P4 2.6GHz
1GB RAM
GeForce4 460 Go 64MB
OpenGL Installable client driver 6.12.10.3230

All works bar some little things… All fansastic!

David if i make a triPatch in 3DsMax or a Plain Object (coverted Plain to a Ploy 3 sides). it seems to not load correctly… the polygons seem to be all over the shop.

any ideas? here is my model file:

*3DSMAX_ASCIIEXPORT 200
*COMMENT “AsciiExport Version 2.00 - Sun Aug 10 18:17:25 2003”
*SCENE {
*SCENE_FILENAME “”
*SCENE_FIRSTFRAME 0
*SCENE_LASTFRAME 100
*SCENE_FRAMESPEED 30
*SCENE_TICKSPERFRAME 160
*SCENE_BACKGROUND_STATIC 0.0000 0.0000 0.0000
*SCENE_AMBIENT_STATIC 0.0000 0.0000 0.0000
}
*MATERIAL_LIST {
*MATERIAL_COUNT 1
*MATERIAL 0 {
*MATERIAL_NAME “2 - Default”
*MATERIAL_CLASS “Standard”
*MATERIAL_AMBIENT 0.5882 0.5882 0.5882
*MATERIAL_DIFFUSE 0.5882 0.5882 0.5882
*MATERIAL_SPECULAR 0.9000 0.9000 0.9000
*MATERIAL_SHINE 0.1000
*MATERIAL_SHINESTRENGTH 0.0000
*MATERIAL_TRANSPARENCY 0.0000
*MATERIAL_WIRESIZE 1.0000
*MATERIAL_SHADING Blinn
*MATERIAL_XP_FALLOFF 0.0000
*MATERIAL_SELFILLUM 0.0000
*MATERIAL_FALLOFF In
*MATERIAL_XP_TYPE Filter
*MAP_DIFFUSE {
*MAP_NAME “Map #2
*MAP_CLASS “Bitmap”
*MAP_SUBNO 1
*MAP_AMOUNT 1.0000
*BITMAP “GRASS2.JPG”
*MAP_TYPE Screen
*UVW_U_OFFSET 0.0000
*UVW_V_OFFSET 0.0000
*UVW_U_TILING 1.0000
*UVW_V_TILING 1.0000
*UVW_ANGLE 0.0000
*UVW_BLUR 1.0000
*UVW_BLUR_OFFSET 0.0000
*UVW_NOUSE_AMT 1.0000
*UVW_NOISE_SIZE 1.0000
*UVW_NOISE_LEVEL 1
*UVW_NOISE_PHASE 0.0000
*BITMAP_FILTER Pyramidal
}
}
}
*GEOMOBJECT {
*NODE_NAME “Plane01”
*NODE_TM {
*NODE_NAME “Plane01”
*INHERIT_POS 0 0 0
*INHERIT_ROT 0 0 0
*INHERIT_SCL 0 0 0
*TM_ROW0 1.0000 0.0000 0.0000
*TM_ROW1 0.0000 1.0000 0.0000
*TM_ROW2 0.0000 0.0000 1.0000
*TM_ROW3 -1.1022 2.8036 0.0000
*TM_POS -1.1022 2.8036 0.0000
*TM_ROTAXIS 0.0000 0.0000 0.0000
*TM_ROTANGLE 0.0000
*TM_SCALE 1.0000 1.0000 1.0000
*TM_SCALEAXIS 0.0000 0.0000 0.0000
*TM_SCALEAXISANG 0.0000
}
*MESH {
*TIMEVALUE 0
*MESH_NUMVERTEX 9
*MESH_NUMFACES 8
*MESH_VERTEX_LIST {
*MESH_VERTEX 0 -201.1022 -197.1964 0.0000
*MESH_VERTEX 1 -1.1022 -197.1964 0.0000
*MESH_VERTEX 2 198.8978 -197.1964 0.0000
*MESH_VERTEX 3 -201.1022 2.8036 0.0000
*MESH_VERTEX 4 -1.1022 2.8036 0.0000
*MESH_VERTEX 5 198.8978 2.8036 0.0000
*MESH_VERTEX 6 -201.1022 202.8036 0.0000
*MESH_VERTEX 7 -1.1022 202.8036 0.0000
*MESH_VERTEX 8 198.8978 202.8036 0.0000
}
*MESH_FACE_LIST {
*MESH_FACE 0: A: 3 B: 0 C: 4 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 1 *MESH_MTLID 0
*MESH_FACE 1: A: 1 B: 4 C: 0 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 1 *MESH_MTLID 0
*MESH_FACE 2: A: 4 B: 1 C: 5 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 1 *MESH_MTLID 0
*MESH_FACE 3: A: 2 B: 5 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 1 *MESH_MTLID 0
*MESH_FACE 4: A: 6 B: 3 C: 7 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 1 *MESH_MTLID 0
*MESH_FACE 5: A: 4 B: 7 C: 3 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 1 *MESH_MTLID 0
*MESH_FACE 6: A: 7 B: 4 C: 8 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 1 *MESH_MTLID 0
*MESH_FACE 7: A: 5 B: 8 C: 4 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 1 *MESH_MTLID 0
}
*MESH_NUMTVERTEX 0
*MESH_NUMCVERTEX 0
*MESH_NORMALS {
*MESH_FACENORMAL 0 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 3 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 0 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 4 0.0000 0.0000 1.0000
*MESH_FACENORMAL 1 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 1 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 4 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 0 0.0000 0.0000 1.0000
*MESH_FACENORMAL 2 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 4 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 1 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 5 0.0000 0.0000 1.0000
*MESH_FACENORMAL 3 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 2 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 5 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 1 0.0000 0.0000 1.0000
*MESH_FACENORMAL 4 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 6 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 3 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 7 0.0000 0.0000 1.0000
*MESH_FACENORMAL 5 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 4 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 7 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 3 0.0000 0.0000 1.0000
*MESH_FACENORMAL 6 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 7 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 4 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 8 0.0000 0.0000 1.0000
*MESH_FACENORMAL 7 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 5 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 8 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 4 0.0000 0.0000 1.0000
}
}
*PROP_MOTIONBLUR 0
*PROP_CASTSHADOW 1
*PROP_RECVSHADOW 1
*MATERIAL_REF 0
}

this is what i get in xith3d:

http://www.topresultmate.com/jogl/screenshot.jpg

and this what it should be:

http://www.topresultmate.com/jogl/screenmax.jpg

any ideas fella?

rrrr- ok i sorted it… seems u need more then one object in the file. if u just have like one object it dont work… np… just make a small triangle off to one side. and all is cool…

Bug noted, I will see what I can do to fix it.

dudes one strange thing…

if i:
BranchGroup top_group = new BranchGroup();
BranchGroup hellcat_group = new BranchGroup();

hellcat_group.addChild(hellcat_group_rota);
hellcat_group_rota.addChild(hellcat_group_trans);
hellcat_group_trans.addChild(hellcatModel);

top_group.addChild(hellcat_group);
locale.addBranchGraph(top_group);

it seems when i move and rotate my model:
hellcat_trans.z = hellcat_trans.z + -1f;
hellcat_translation.setTranslation(hellcat_trans);
hellcat_group_trans.setTransform(hellcat_translation);

  hellcat_rotation.rotXYZ(updown, 0f, leftright);
  hellcat_group_rota.setTransform(hellcat_rotation);

the model rotates around the centre point of the VirtualUniverse. and not around itself. i want to rotate the object then move it along its z. so what ever direction the object it pointing after its rotation, it will then fly along its new transformed z direction. like an airplane…

i cant seem to get this to work…

any ideas all?

You need to have your rotate as a transform below your translate or else you will rotate your translation, which is what is happening here.

so it should be:

translate -> rotate -> model

arrr!!! this is doing my head in - and its to HOT 8)

all i get is my object spinning on itself and moving. i have tryed all orders i can think of. i must be getting something realy wrong here.

:’( :’( :’(

Well your example there shows the model being added to the translation transform group. It should be added to the rotation group and the rotation group should be added to the translate group.

That WILL work. I do it all the time.

yer i no it must be a snap… i can do it in GL normal action… maybe i need a book on java3d and stuff?

im probbly doing it all wrong anyways :slight_smile:

if anyone can see where i am going wrong- ring me bell, i havent got to all the cool questions yet:

package ant.xith3dtest;

import com.xith3d.scenegraph.;
import com.xith3d.render.
;
import com.xith3d.render.jogl.;
import com.xith3d.loaders.ase.
;
import javax.vecmath.;
import java.util.Random;
import com.xith3d.image.
;
import java.awt.image.;
import java.io.
;
import com.xith3d.loaders.texture.*;
import java.util.ArrayList;

import net.java.games.input.*;

/**

  • Draws a simple cube on the screen

  • Copyright (c) 2003 David Yazel Copyright (c) 2003

  • Company:

  • @author David Yazel - aNt messing
  • @version 1.0
    */

public class CubeTest3 {
Keyboard kb = null;

public CubeTest3() {
Texture2D textureWood = null;
TextureLoader.tf.registerPath(“c:/xith3d/demo/”);
TextureLoader.tf.registerPath("./");
TextureLoader.tf.registerPath("…/");

BranchGroup landModel = null;
BranchGroup hellcatModel = null;

try {
  hellcatModel = AseFile.getModel("hellcat.ase");
} catch (Exception er) {
  System.out.println("cant load mod: " + er.toString());
}

Transform3D hellcat_translation = new Transform3D();
Transform3D hellcat_rotation = new Transform3D();

Vector3f hellcat_trans = new Vector3f();
Vector3f hellcat_rota = new Vector3f();

// create a transform and rotation for the hellcat.
TransformGroup hellcat_group_trans = new TransformGroup(hellcat_translation);
TransformGroup hellcat_group_rota = new TransformGroup(hellcat_rotation);

// create a branch group to put in the locale
BranchGroup top_group = new BranchGroup();
BranchGroup hellcat_group = new BranchGroup();

hellcat_group.addChild(hellcat_group_trans);
hellcat_group_trans.addChild(hellcat_group_rota);
hellcat_group_rota.addChild(hellcatModel);

// have also tryed.
// hellcat_group.addChild(hellcat_group_rota);
// hellcat_group_rota.addChild(hellcat_group_trans);
// hellcat_group_rota.addChild(hellcatModel);

top_group.addChild(hellcat_group);

VirtualUniverse universe = new VirtualUniverse();
View view = new View();
view.setFieldOfView(35f * 3.14f / 180f);
Locale locale = new Locale();
universe.addLocale(locale);
universe.addView(view);

locale.addBranchGraph(top_group);

RenderPeer rp = new RenderPeerImpl();
CanvasPeer cp = rp.makeCanvas(null, 640, 480, 32, false);
Canvas3D canvas = new Canvas3D();
canvas.set3DPeer(cp);
canvas.setView(new View());

view.addCanvas3D(canvas);

view.getTransform().lookAt(new Vector3f(0, 0, 950f), new Vector3f(0, 0, 0),
                           new Vector3f(0, 1, 0));

view.setTransparencySortingPolicy(view.TRANSPARENCY_SORT_GEOMETRY);
// view.setSceneAntialiasingEnable(true);
// Background bgcolor = new Background(new Color3f(0f, 0f, 1f));
// view.addChild(bgcolor);
ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
Controller[] cont = ce.getControllers();

System.out.println("cont: " + cont.length);
for(int i = 0; i < cont.length; i++) {
  if(cont[i].getType() == cont[i].getType().KEYBOARD) {
    kb = (Keyboard) cont[i];
  }
}

long startTime = System.currentTimeMillis();
long numFrames = 0;
float anum = 0f;

////////////////////////////////////////////////// RENDER!
for (int i = 0; i < 10000; i++) {
  numFrames++;

  keyboardupdate();

  hellcat_trans.z = hellcat_trans.z + -5f;
  hellcat_translation.setTranslation(hellcat_trans);
  hellcat_rotation.rotXYZ(updown, 0f, leftright);

  hellcat_group_trans.setTransform(hellcat_translation);
  hellcat_group_rota.setTransform(hellcat_rotation);

  view.getTransform().lookAt(new Vector3f(0f, 0f, 1000f),
                             new Vector3f(0f, 0f, 1f), new Vector3f(0, 1, 0));

  view.renderOnce();
}


long deltaTime = (System.currentTimeMillis() - startTime) / 1000;

if (deltaTime > 0) {
  System.out.println("done frame speed test at " + (numFrames) / (deltaTime) +
                     " fps");
  System.out.println("there are " + canvas.get3DPeer().getTriangles() +
                     " triangles in scene");
  System.out.println("rendering " +
                     canvas.get3DPeer().getTriangles() * (numFrames) /
                     (deltaTime) + " triangles/sec");

}
System.out.println("   Num frames = " + numFrames);
System.out.println("   Delta ms = " + deltaTime);

System.exit(0);

}

float updown = 0f;
float leftright = 0f;

public void keyboardupdate() {
kb.poll();
Axis[] ax = kb.getAxes();

for (int x = 0; x < ax.length; x++) {
  float num = ax[x].getPollData();
  if (num != ax[x].getDeadZone()) {
    // System.out.println("key: " + ax[x].getName());
    if (ax[x].getName().equalsIgnoreCase("key 113")) {
      // System.out.println("right arrow");
      leftright = (leftright - 0.01f);
    }

    if (ax[x].getName().equalsIgnoreCase("key 112")) {
      // System.out.println("left arrow");
      leftright = (leftright + 0.01f);
    }

    if (ax[x].getName().equalsIgnoreCase("key 110")) {
      // System.out.println("up arrow");
      updown = (updown - 0.01f);
    }

    if (ax[x].getName().equalsIgnoreCase("key 115")) {
      // System.out.println("down arrow");
      updown = (updown + 0.01f);
    }
  }
}

}

public static void main(String[] args) {
CubeTest3 cubeTest1 = new CubeTest3();
}
}

aNt,

I am currently experiancing the exact same problem as you - and it is driving me nuts. I spent countless hours last night trying to get it to work but to no avail. This morning I tried with a simple cube and still no cigar.

This is code that I ported from j3d and was working fine in j3d. I thought I understood this concept. Back when I was using gl4java I encountered and solved (easily) the same problem. And I have a few books on j3d/opengl to assist. I have compiled and run my code so many times that my processor has almost melted.

Seriously though, here is the problem.

Take a small cube, at the position 10, 10, 0. (ie. 10 to the right, and 10 up).


             |             [_]
             |             
             |             
_______________
             |             
             |             
             |             


Now I want to rotate that cube in place.


             |             \_\
             |             
             |             
_______________
             |             
             |             
             |             


How I did it with straight OpenGL calls and j3d was this:
Move the cube to (0,0,0) > rotate it > move back to (10,10,0).
Rotating without that move caused it to rotate (or orbit) around the (0,0,0) “pivot point” which is correct but not wanted in my case.

not wanted:


             |             [_]
             |                 [_]
             |                  
_______________ 
             |                [_]
             |              [_]
             |             etc...


Now no matter what I tried last night and this morning I can not get any object in Xith3D to change it’s “point of rotation”.
move to origin > rotate > move back simply has the same effect as
rotate
move to some place > rotate just moves the whole bloody thing to a different area.
So no matter what I wanted the “Reference point/pivot point/point of rotation” to be for the rotation - I always go the same (see “not wanted” ASCII diagram). It seemed like moving the object moved it’s origin as well and thus I just couldn’t rotate it around an arbitrary reference.

Now, sure - I could simply load the object in relitive to (0,0,0) but this is a work around and I have spent too many hours trying the other way that I must as least know how to do it correctly (and then I won’t mind about applying any work arounds).

This was tested using a Single TransformGroup so no funny stuff is happening with TransformGroup children.

here is a handy method that recursivly prints the contects of a group.


            public static void printGroup (Group g, String offset) {
                  
                  System.out.println(offset + (g.getClass().getName()));
                  
                  for (int i = 0; i < g.numChildren(); i++) {
                        Class c = g.getChild(i).getClass();
                        
                        
                        
                        if (c.getName().lastIndexOf("Group") != -1)
                              printGroup((Group) g.getChild(i), offset + "  ");
                        else
                              System.out.println(offset + "  " + c.getName() + " group");
                  }
            }

This is my very simple cube, so as you can see no funny stuff:


com.xith3d.scenegraph.TransformGroup
  com.xith3d.scenegraph.BranchGroup       
    com.xith3d.scenegraph.Shape3D

I am using Xith3d from CVS and keeping up to date which I am hoping fixes more problems than it introduces however it is a double edged sword.

What am I doing wrong? I thought I understood the transform concept and have managed to do this exact thing fine in OpenGL and j3d. But I am running out of ideas for this one.

I can easily do my work around and I know that will work - but I refuse to believe that it isn’t possbile this way.

Please tell me what you think.

Cheers,

Will.

[edit: formatting, correcting]
[edit: aNt, I wish I had read your posts before hitting the same brick wall myself and trying a similar cube test - it would have saved me some time but at least now there are two case studies :D]

Here is a code snippet from one of my many tries at solving this connundrum.


  // setup rotation transform (angleYAxis is passed).
                  Transform3D angle = new Transform3D();
                  angle.setIdentity();
                  angle.rotAxis(new Vector3f(0f,0f,1f), (float)((angleYAxis) * Math.PI / 180.0));

// apply move transform
                  Transform3D t = new Transform3D();
                  geomRoot.getTransform(t);
                  t.setTranslation(new Vector3f(-10,10,0));
                  geomRoot.setTransform(t);

// apply rotation transform
                  t = new Transform3D();
                  geomRoot.getTransform(t);
                  t.mul(angle);
                  geomRoot.setTransform(t);

// apply move back transform
                  t = new Transform3D();
                  geomRoot.getTransform(t);
                  t.setTranslation(new Vector3f(10,10,0));
                  geomRoot.setTransform(t);


geomRoot is the only TransformGroup in the scene.

I tried several different permetations but not once did the “Reference point” around which the object is rotated change in relation to the placement of the object.

I won’t bother posting all of my code - but suffice to say that in concept is it is just about the same as aNt’s.

[edit]
I have also tried making a tree of TransformGroups, in the order:
rotation > translate to reference point > model

but to no avail
[/edit]

Cheers,

Will.

well i dont no- i have tryed loads of stuff now. even to the stange of pot luck.

i can translate the object and have it rotate around its self in it new translated location. and i can rotate the object and have it rotate around a 0,0,0 Vurtual Univerce. i cant get it to rotate then translate(along z of the new rotated vector) from its new translated location (like a aircraft).

so i can do this:

|
|   [ ]
|      [ ]
|        [ ]

------------------ rotate -> translate -> model
| [ ]
| … move around rotate around the VurtulUni

i can also do this:

|       [ ]
|     ---
|     ---
|  /  /
|[ ]

------------------ translate -> rotate -> model
| move and rotate on itself

what i want to do is this:

|  --- ---
|  --- --- \  \
| /  /       [ ]
|/  /        \  \
|[ ]

------------------ ?? dont no… [translate -> rotate -> translate -> model ? maybe… didnt work :frowning: ]
| fly around the space

The difference between your second and third cases is not clear to me.

Stepping back and thinking of a single frame of animation… you have the location of your jet fighter and the direction that it is facing.

That’s one translate to set the location.
One rotate to set the heading.

Now you have it in the right place facing the right direction… what more do you want?

it seems to reset evey time. the second one is every update… so the cube is just moving out to a point, and rotating on itself. the next draw update it gets moved out more and rotates on its self.

its not heading in the direction of the new rotation tranform. it just keeps heading into z, with the object spining around itself without a care.

[quote]Now you have it in the right place facing the right direction… what more do you want?
[/quote]
i would like it to move in the direction of the rotation. and then on the next update just tell the transform to move in z a little bit more. and because the rotation vector has changed - it heads off in that new changed direction.

at the moment the transform just keeps heading off into z without a care of the rotations change in direction.

OK this could be a bug. Could you e-mail a test program to david@yazel.net and I will look at it tonight.

It sounds like that a change to a parent transform is causing information in a child transform to be ignored. I could see the possibility of a bug here because the optimization I have in the scenegraph for transform chaining are a bit tricky.