Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ToddMcF2002

Pages: 1 ... 4 5 [6] 7
76
Just a note on what you are looking at:

The lightning bolt is using 2 Object3D's each with two triangles.  One is on the X/Z plane and the other is on the Y/Z plane (a long "plus").  Obviously they are rendering textures with transparency.  The textures are toggled with every paint cycle so it looks very dynamic.  I also allocate a number of Light objects along its length which gives it a strobe effect you can't see in the screenshot. 

Because you can set the tiling properties for the texture placement you can easily add more "bolts".  Here there are only 2 - ie. no tiling and one on the vertical plane and one on the horizontal.  I tested 4 and 5 on each plane. 

Anyway - it looks great animated and doesnt hit the framerate at all really.  The "node" system uses the same math for vector origin and target but only works on the X/Z plane.  Its surprisingly smooth when you draw the lines realtime - they "chase" the mouse very smoothly elongating and pivoting.





 

77
Thanks Egon...

I'll mail them now.  Just FYI folks - those are TEST models I downloaded from who knows where - placeholders.  Not trying to take credit for them....  Also that blit image in the corner is just another test.

Also for some reason my hardware rendered custom cursors don't show up.  Too bad - neat gauntlet and sword...

Here are the pics I'm sending:
- Lightning bolt
- Setting up the nodes
- Running the nodes

78
I forgot to report back (in case anyone cares  :D) that the Temple of Elemental Evil walking the user defined path nodes worked perfectly.  All that struggle with the lightning bolt math payed off.

Also I how have a "NWN" style camera that pans, zooms, and is height adjustable - meaning the angle to the x/z plane goes from near 0 (over the sholder) to 90 degrees (strait overhead).

Do all screenshots have to be linked or can you upload them here?  My fireball sort of stinks but the lightingbolt and the path nodes look pretty good.




79
Support / Re: 3DS Animated Model Error
« on: April 16, 2007, 08:30:03 pm »
I was able to create and animate a character model with a sword in 3DSMax and get him in the game.  The sword is a seperate mesh and works just like the MD2s.  The only thing I noticed is that my sword seems to get distorted - the hilt is too wide on one sword and the blade too long on a different attempt.  I'm starting to think its not the engine causing the problem though.

One thing is for sure - I have a renewed appreciation for how much work character modeling entails.  I'm a heck of alot better at Java  :P
 

80
Support / Re: RotateMesh() and addChild()
« on: April 12, 2007, 08:02:36 pm »
If I don't rotate the mesh it lines up perfectly.  Like I said though - its a minor inconvenience since I just assume the parent rotation and adjust x/z on the sword until it looks right and write down the translation.  I'm loading from XML so I'm just putting the translation in there along with a bunch of other attributes.

81
Support / RotateMesh() and addChild()
« on: April 12, 2007, 03:48:36 am »
Just trying to verify something:

I have to rotate my MD2's in order to orient them properly on the X/Z plane otherwise they run sideways.
Code: [Select]
         
          // build character
          build()

          // fix mesh alignment on xz plane
  yRot = (float)Math.PI*1.5f;
  rotateY(yRot);
  rotateMesh();

          // this calls addChild() for weapons...
          checkLoadWeapons(c, w);
No matter what sequence combination I use of checkLoadWeapons(), build() and rotateMesh() I always end up having to manually adjust the weapon orientation since rotateMesh() seems to "break" the MD2's origin for the weapon.  In the sequence above I end up cloning the character's rotationMatrix for the weapon and then adjusting X and Z until the weapon matches the hand.  After that all is well.

This is hardly a showstopper since its pretty easy to translate the adjustment.  But - is this expected or am I doing something wrong?

Thanks!


82
Support / Re: 3DS Animated Model Error
« on: April 12, 2007, 02:00:41 am »
I'm afraid you are losing me.  How can I strip() a cloned mesh before a build?  It won't have a bounding box and I'll be back were I was initially.

Here is the working code - maybe I'm just missing something. 

Code: [Select]
private void testLoad3DS(){
try{
Loader.setVertexOptimization(false);

TextureManager tm = TextureManager.getInstance();
Texture t = new Texture("models/3ds/monster.jpg");
tm.addTexture("monster2", t);

Object3D[] animArray=Loader.load3DS("models/3ds/animate/monster_c.3DS", 1f);
monster2=animArray[0];
monster2.build();

monster2.setTexture("monster2");

monster2.rotateX((float)-Math.PI/2);
              monster2.setRotationMatrix(new Matrix());

monster2.translate(new SimpleVector(0, -30, 0));
     
              monster2.createTriangleStrips(2);
              monster2.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
              monster2.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);

theWorld.addObject(monster2);


//0-30  walk
//0-120 walk
//150-190 run
//150-210 run
//250-333 attack-01
//320-400 attack-02
//390-418 death-01
//478-500 growl
//500-550 death-02
//565-650 death-03

System.out.println("MoveTest::testLoad3DS() array size is: " + animArray.length);


Animation anim=new Animation(animArray.length);
int iseq = anim.createSubSequence("walk");
for (int i=0; i<animArray.length; i++) {
Object3D o = animArray[i];
o.build();
o.rotateX((float)-Math.PI/2);
Mesh m = o.getMesh().cloneMesh(true);
m.strip();

anim.addKeyFrame(m);
}
System.out.println("MoveTest::testLoad3DS() setting animation sequence...");
monster2.setAnimationSequence(anim);
System.out.println("MoveTest::testLoad3DS() sequence id is: " + iseq);


}catch(Exception e){
System.err.println("MoveTest::testLoad3DS() " + e.getMessage());
e.printStackTrace();
}
   }


83
Support / Re: 3DS Animated Model Error
« on: April 11, 2007, 07:52:16 pm »
OK.

One thing I'm confused about though - If I strip() I have to do cloneMesh() or I get a null pointer.

If I'm cloning, isnt that using memory that offsets the benefit of strip()?

I also noticed that without cloneMesh() there is an extra frame (or a pause) at the end of the frame sequence.


84
Support / Re: 3DS Animated Model Error
« on: April 11, 2007, 02:40:36 am »
Alright so I found a free 3DS and got it working.  Here is the download for anyone else interested.

http://www.turbosquid.com/FullPreview/Index.cfm/ID/312341

A few things.  There are 650 frames of animation.  That translates to about 19MG as a 3DS export.  Say goodbye to your heap!

I started messing around with selecting the short walk sequence (frames 0-30) in 3DS max and exporting that.  900KB.
I then used the handy "Select Objects" button to thin out the selection to every other frame and then finally every 3rd frame.
Selecting every 3rd frame gave me my target 300KB and the animation was surprising smooth - equivalent to my MD2 animations I downloaded somewhere.

So in case this will help anybody:

I could not find any definitive forum posts validating this for certain - you can use a single 3DS file for your animations just like an MD2.  Works exactly the same.  You could surely export it frame by frame but you don't need to.  Is there some advantage or something?  I like the single file thing because it is consistent with the MD2 approach. 

To export the single 3DS file: 
1.  Tools->Snapshot...
     select 0 - 30 and 30 copies (for the model above that is). 
2.  Edit->Select By->Name
     Select the items you want in the export file - for me it was "monster01", "monster04"..."monster28".  Every 3rd
     frame resulting in a 10 frame animation sequence.  Hit the Select Button before leaving!
3.  File->Export Selected

Here is the working code:

Code: [Select]
   private void testLoad3DS(){
try{
Loader.setVertexOptimization(false);

TextureManager tm = TextureManager.getInstance();
Texture t = new Texture("models/3ds/monster.jpg");
tm.addTexture("monster2", t);

Object3D[] animArray=Loader.load3DS("models/3ds/animate/monster_c.3DS", 1f);
monster2=animArray[0];
monster2.build();

monster2.setTexture("monster2");

monster2.rotateX((float)-Math.PI/2);
              monster2.setRotationMatrix(new Matrix());

monster2.translate(new SimpleVector(0, -30, 0));
     
              monster2.createTriangleStrips(2);
              monster2.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
              monster2.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);

theWorld.addObject(monster2);

System.out.println("MoveTest::testLoad3DS() array size is: " + animArray.length);


Animation anim=new Animation(animArray.length);
int iseq = anim.createSubSequence("walk");
for (int i=0; i<animArray.length; i++) {
animArray[i].build();
Object3D o = animArray[i];
o.rotateX((float)-Math.PI/2);
anim.addKeyFrame(o.getMesh().cloneMesh(false));
}
System.out.println("MoveTest::testLoad3DS() setting animation sequence...");
monster2.setAnimationSequence(anim);
System.out.println("MoveTest::testLoad3DS() sequence id is: " + iseq);


}catch(Exception e){
System.err.println("MoveTest::testLoad3DS() " + e.getMessage());
e.printStackTrace();
}
   }


And then the game loop calls this (I know I need to use a better timer - its just a test!)

Code: [Select]
private void checkAnimate3DS(){
   

try{
long ltime = System.currentTimeMillis();
    if((ltime - _last3DSms) > 60){
_last3DSms = ltime;

if(_anim3DS > 1)
_anim3DS=0;
else
_anim3DS+=0.05f;
monster2.animate(_anim3DS, 1);
}

}catch(Exception e){
System.err.println("MoveTest::checkAnimate3DS() " + e.getMessage());
e.printStackTrace();
}
   }



85
Support / Re: 3DS Animated Model Error
« on: April 10, 2007, 09:51:55 pm »
Yup that was at the top of the routine.  Oh well.  Thanks for the help though.

I don't suppose anyone has any simple animated test 3DS files???

I really don't want to buy one just to test the loader.
   

86
Support / Re: 3DS Animated Model Error
« on: April 10, 2007, 07:54:49 pm »
That got rid of the errors, but now I think I'm still doing something wrong.

[ Tue Apr 10 13:38:21 EDT 2007 ] - ERROR: The sizes of the Animation's Meshes (611) and the object's Mesh (553) don't match!

87
Support / 3DS Animated Model Error
« on: April 10, 2007, 03:18:47 pm »
Can't seem to get this working.  Every time I add a mesh for an animation frame I get an error such as:

Object 'object_1_jPCT20' created using 570 polygons and 558 vertices.
[ Tue Apr 10 08:38:30 EDT 2007 ] - ERROR: Bounding box missing in this mesh!

The model does appear in the world.  He's lying on his back but I know how to fix that.  When I call
Code: [Select]
_monster.setAnimationSequence(anim);
I get:

[ Tue Apr 10 08:38:30 EDT 2007 ] - ERROR: This Animation is empty!


Which is expected given the other errors on each Mesh.

BTW I didn't create the model - its from the book "Killer Java Game Programming" and it was created with Poser
I can't seem to find a basic animated 3DS file anywhere for testing.  Could someone upload one??? 

Here is the underlying code.

Code: [Select]
private void testLoad3DS2(){
try{
Loader.setVertexOptimization(false);

Object3D[] animArray=Loader.load3DS("models/3ds/skel_stand.3ds", 100f);
_monster=animArray[0];
_monster.build();

_monster.rotateX((float)-Math.PI/2);
              _monster.rotateMesh();
              _monster.setRotationMatrix(new Matrix());
     
              _monster.createTriangleStrips(2);
              _monster.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
              _monster.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);

_monster.setTexture("select");
_monster.setVisibility(true);

_monster.translate(new SimpleVector(0, -50, 0));

theWorld.addObject(_monster);



Animation anim=new Animation(5);
Object3D [] o = null;

anim.createSubSequence("stand");
o = Loader.load3DS("models/3ds/skel_stand.3ds", 100f);
anim.addKeyFrame(o[0].getMesh().cloneMesh(false));

anim.createSubSequence("walk");
o = Loader.load3DS("models/3ds/skel_walk1.3ds", 100f);
anim.addKeyFrame(o[0].getMesh().cloneMesh(false));
o = Loader.load3DS("models/3ds/skel_walk2.3ds", 100f);
anim.addKeyFrame(o[0].getMesh().cloneMesh(false));

anim.createSubSequence("punch");
o = Loader.load3DS("models/3ds/skel_punch1.3ds", 100f);
anim.addKeyFrame(o[0].getMesh().cloneMesh(false));
o = Loader.load3DS("models/3ds/skel_punch2.3ds", 100f);
anim.addKeyFrame(o[0].getMesh().cloneMesh(false));

System.out.println("MoveTest::testLoad3DS2() setting sequence...");
_monster.setAnimationSequence(anim);

}catch(Exception e){
System.err.println("MoveTest::testLoad3DS2() " + e.getMessage());
e.printStackTrace();
}
   }




    private void checkAnimate3DS(){
    // CALLED IN GAME LOOP...

try{
long ltime = System.currentTimeMillis();
    if((ltime - _last3DSms) > 60){
_last3DSms = ltime;

if(_anim3DS > 1)
_anim3DS=0;
else
_anim3DS+=0.05f;
_monster.animate(_anim3DS, 2); // walk sequence...
}

}catch(Exception e){
System.err.println("MoveTest::checkAnimate3DS() " + e.getMessage());
e.printStackTrace();
}
   }


88
Support / Re: what happened to paradroidz ?
« on: April 06, 2007, 03:25:24 pm »
Sad.  Sure its a fun game but also its a valuable technology demo for JPCT.

What a litigious society  :'(


89
You need pills to be stupid? I can do it naturally! :D

Mind you, I have thought it would be nice to have a method like addQuad(x,y,z,x1,y1,z1,u,v,u1,v1) purely for convenience...

I just finished the lightning bolt implementation. 

It is basically two rectangular planes casted from source to target, one vertical and one horizontal (a very long "plus").  I then apply a zig zag texture on both and set transparency.  At each paint I toggle a few textures back and forth and play with lighting.  I did this years ago in the Unreal 1 Editor and it looks pretty much the same (a good thing).

One thing though - I'm not quite happy with my math (or lack there of).  Its the stupid pills again.

Basically - it is easy to create the long ends of a rectangle for a source and a target (y is constant for me!).  The problem is the width on the x/z plane.  You need a perpendicular to the line between the points to create a width.   

I just could not get my small mind around it.  Initially I was creating this new "Rectangle" primitive totally in place - ie. pre-rotated between the source and target.  To cheese on calculating the perpendicular on my rectangle (ie. the short end widths) I created the Rectangle on the y axis (like a blade on its edge).  I thought hey -  it will be easy to then simply rotate it by PI/2 to create the horizontal Rectangle.  Right?  Rigghhht???  Nope!  The problem is of course the RotationMatrix.  I just couldnt get a decent one on the Rectangle and I tried for hours.  Every rotation was really messed up and the stupid pills where in full effect.

Finally after pulling my hair out, I found another way.  Far easier.  I calculated the length of the line (that math I know!) and built it horizontally at the World origin this time.  That lets me skip the nasty perpendicular calculation since the rectangle is square to the world.  So I just add and subtract some X since there is no rotation.  Then I moved it to the center point between source and target and rotated it to match the source's yRotation. 

I guess that's not too bad.  It looks really nice and now I can use this much lighter weight Rectangle concept elsewhere.

My next hurdle is to apply this same approach to creating a rectangle on the ground that follows the mouse while pivoting on a source at the other end.  If you have ever played Temple Of Elemental Evil you know what I mean.  Its a line indicating the path you are going to walk if you click.  I think I can do the same thing with one exception - I'll need 2 invisible dummy objects.  One will chase the mouse.  The other will track the object by rotating as it moves.  I need to maintain that Y axis rotation so my math works.


90
Ha ha ha ha!!!!

How could I be so stupid?  Oh well its not for the first time.  Creating rectangular plane is only 2 triangles.  Geesh!!!

I guess I need to start creating my own primitives for this kind of activity and lay off the stupid pills.


Pages: 1 ... 4 5 [6] 7