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 - fireside

Pages: 1 ... 37 38 [39] 40 41
571
Support / Re: animation
« on: February 22, 2008, 08:08:47 pm »
Well, I just went through this in blender.  You make your animation.  Then you save key frames of the animation.  Like, legs apart, lifting left leg, lifting right leg, other legs apart.  You save them as 3ds.  I have a character that is a mouse.  So this is the code I did for the animation.  First you need code that loads the model and turns it the right way and builds it:
Code: [Select]
private Object3D loadModel(String filename, float scale)
{
Object3D[] model = Loader.load3DS(filename, scale);

Object3D o3d = new Object3D(0);
 
Object3D temp = null;
     
  for (int i=0; i<model.length; i++)
{
temp=model[i];
temp.setCenter(SimpleVector.ORIGIN);
  temp.rotateX((float)-Math.PI);
  temp.rotateMesh();
  temp.setRotationMatrix(new Matrix());
  o3d=Object3D.mergeObjects(o3d, temp);
  o3d.build();
  }
return o3d;           
}


I have to build the model in the y up positon in blender for that to work.

Then I use this code to load the animation:
Code: [Select]
    Mouse = loadModel("data/stand.3ds",1); 
  Mouse.translate(0, -5, 0);
TextureManager tm = TextureManager.getInstance();
    Texture tex=new Texture("data/fur.jpg");
    tm.addTexture("fur", tex);    
    tex = new Texture("data/red.jpg"); 
    tm.addTexture("red", tex);    
    Mouse.setTexture("fur");
world.addObject(Mouse);
  Animation mouse = new Animation(10);
  mouse.createSubSequence("walk");
  mouse.addKeyFrame(loadModel("data/walk2.3ds",1).getMesh());
  mouse.addKeyFrame(loadModel("data/walk3.3ds",1).getMesh());
  mouse.addKeyFrame(loadModel("data/walk4.3ds",1).getMesh());
  mouse.addKeyFrame(loadModel("data/walk1.3ds",1).getMesh());
 
  mouse.createSubSequence("stand");
  mouse.addKeyFrame(loadModel("data/stand.3ds",1).getMesh());
  mouse.addKeyFrame(loadModel("data/stand2.3ds",1).getMesh());
 
  mouse.createSubSequence("jump");
  mouse.addKeyFrame(loadModel("data/stand.3ds",1).getMesh());
mouse.addKeyFrame(loadModel("data/jump.3ds",1).getMesh());
mouse.addKeyFrame(loadModel("data/jump2.3ds",1).getMesh());

  Mouse.setAnimationSequence(mouse);
  Mouse.rotateY(3.1416f/2f);
    Mouse.setCollisionMode(Object3D.COLLISION_CHECK_SELF);
    Mouse.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);

Then you animate as was explained earlier in this thread.  The index starts with one so, in this case, walk is 1, stand is 2, jump is 3.

572
Support / Re: animation problem
« on: February 21, 2008, 07:15:50 pm »
Yeah, it's working better with an extra frame in the jump. 

573
Support / animation problem
« on: February 21, 2008, 06:03:18 pm »
I've just used a walk and stand animaton with sub sequences up till now and everything was working fine.  However I set up a jump, where the characters size is quite a bit different.  He's scrunched down now getting ready to leap.  Jpct makes garbage out of the model.  If I set the default model that loads at the start as the jump model, then it looks all right, but the stand and walk animations turn into garbage.

edit:  I might get that worked out by using more gradual changes, I'm not sure.  But I'm also getting an error for too many key frames defined when I get to the sixth one with this code:

Code: [Select]
    Mouse = loadModel("data/stand.3ds",1); 
// Object3D Mouse;
  Mouse.translate(0, -5, 0);
 // Mouse.createTriangleStrips();
TextureManager tm = TextureManager.getInstance();
    Texture tex=new Texture("data/fur.jpg");
    tm.addTexture("fur", tex);    
    tex = new Texture("data/red.jpg"); 
    tm.addTexture("red", tex);    
    Mouse.setTexture("fur");
world.addObject(Mouse);
  Animation mouse = new Animation(5);
  mouse.createSubSequence("walk");

  mouse.addKeyFrame(loadModel("data/walk2.3ds",1).getMesh());
  mouse.addKeyFrame(loadModel("data/walk3.3ds",1).getMesh());
  mouse.addKeyFrame(loadModel("data/walk4.3ds",1).getMesh());
  mouse.addKeyFrame(loadModel("data/walk1.3ds",1).getMesh());
  mouse.createSubSequence("stand");
  mouse.addKeyFrame(loadModel("data/jump.3ds",1).getMesh());
  mouse.addKeyFrame(loadModel("data/jump2.3ds",1).getMesh());

The last key frame gives me that error.  Doesn't seem like very many.  I was planning on using quite a few more animations.
OH  DUH!!!  I forgot I defined the animation size.  I'll get back on if the more gradual animations helped.

574
Projects / Re: Labyrinth Z
« on: February 21, 2008, 09:38:47 am »
There look like there are some around.  I'm just not ready to check into them yet, though.  Have you tried the Eclipse editor?  That is the nicest editor I've ever used, the way it underlines mistakes and things.  The search on it is kind of complicated, though.

As an update to this game.  I've got most of the game mechanics worked out now with gravity, collision, and jumping.  Although, there is more work to do and animations to add.  It's roughed in anyway.  Pretty soon I'll be playing around with puzzle ideas.  I'm already getting some so I think this is going to be a fun project.  From what I've used of it so far, I'm pretty happy with the animation system.  It seems to allow quite a bit of control.  One complaint I have is with ellipsoidal collision.  It doesn't tell you what you collided with or that you collided at all, so I had to set up another collision to do that.

575
Support / Re: key released
« on: February 21, 2008, 03:49:11 am »
Oh, never mind.  I made a flag equal to the last state of the downPressed value and checked for a change.

576
Support / key released
« on: February 21, 2008, 02:53:13 am »
I'm trying to figure out how to get a key released event.  I'm using code from the helloworld

Code: [Select]
   private void keyAffected(KeyState state) {
      int code=state.getKeyCode();
      boolean event=state.getState();
      switch (code) {

         case (KeyEvent.VK_LEFT): {
            left=event;
            break;
         }
         case (KeyEvent.VK_RIGHT): {
            right=event;
            break;
         }
         case (KeyEvent.VK_DOWN):{
        downPressed = event;
         }

      }
   }

A key released is false, but that's sort of a do nothing state also.

577
Projects / Re: Labyrinth Z
« on: February 20, 2008, 07:15:01 pm »
I think an installer would take care of most problems, but I better worry about having a game to install first.

578
Projects / Re: Labyrinth Z
« on: February 20, 2008, 09:10:34 am »
I don't think a program really needs to bundle the runtime.  I think it just needs to tell you what's wrong when it can't run.  That hardly ever happens for me and java programs.  I just get some java error I don't understand, or I just see the dos box flash for about a half second.

579
Support / Re: Collision not working
« on: February 20, 2008, 09:00:22 am »
Ha, you beat me to it.  I just tried that.  That's what it was.

580
Support / Re: Collision not working
« on: February 20, 2008, 08:36:12 am »
Way in front.  He starts at the middle of the platform.  And I can walk him all the way to the other side, turn around, and he goes through.  I know the block is doing collision.  It's combined, but I can drop the mouse from high up and it will stop on top the block if I move him over to where the block is when the program starts, so the move function isn't working for some reason.

581
Support / Re: Collision not working
« on: February 20, 2008, 08:20:53 am »
He's in front of the block and walks right through it.

582
Projects / Re: Labyrinth Z
« on: February 20, 2008, 08:11:08 am »
Quote
I think it would be nice if you could write generic java code, and then with the FREE jdk distribute a file that could be run way that the user is most used to starting native programs

I agree.  There's some installers around I think, I haven't checked that out, but I don't like all this classpath stuff.  I've downloaded java jars that were supposed to be self executing and double clicked on them and nothing happens.  It's irritating.  If you don't know java, how are you supposed to know what to do with that?  I don't mind a bat file in Windows.  I haven't used it on other systems so I have no idea what they do.  The byte code, though, is a very good idea.  That way a 64 bit system can run it in 64 bit and a 32 can run it in 32 and other platforms can all read it.  In c++, you would actually have to recompile the program on every one of those systems.

583
Support / Collision not working
« on: February 20, 2008, 06:13:02 am »
I tried doing a search for collision and came up with this function for the mouse:
Code: [Select]
private void doGravity()
{
      SimpleVector msPos=Mouse.getTransformedCenter();
      msPos.add(msHgt);
      if(world.checkCollision(msPos, dr, .6f)== Object3D.NO_OBJECT)
      {
    Mouse.translate(gravity); 
      }           
}
private void move()
{
SimpleVector a = Mouse.getZAxis();
a.scalarMul(-.15f);
a = Mouse.checkForCollisionEllipsoid(a, elipse, 2);
Mouse.translate(a);
}

The gravity part works, but the mouse walks through as in this picture:


The elipse is (2,5,2)  The five is the mouse height and works for gravity.

The platform is set for collision with this code:
Code: [Select]
    platform.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
    platform.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);

I tried setting collision for the mouse but it didn't help.  I had to use -.15 in the scalermult or else the mouse went backwards.

584
Support / Re: Cloned object
« on: February 19, 2008, 08:21:24 pm »
O.K.  It wouldn't take much file space to use one object, either.  I can just reuse switches and elevators and things.

585
Support / Cloned object
« on: February 19, 2008, 06:44:47 am »
I thought about using cloned platforms in this game to save file size, etc.  I'm wondering how this will affect performance, or what would be the best way to get good performance from a lot of cloned platforms and walls rather than a larger structure like the castle that is octree.  What do you recommend for that?

Pages: 1 ... 37 38 [39] 40 41