Author Topic: Character movement  (Read 6529 times)

Offline Pan83

  • byte
  • *
  • Posts: 5
    • View Profile
Character movement
« on: January 15, 2007, 01:11:59 pm »
Hi!!!

I have been doing a 3d project during last months.I have been using c++ 3d engines but I don't like c++.

So I found this great engine!!!

My objective is to make two characters move following two splines.In addition I need to make my camera  follow a spline and make it look at a spline path too.

Can it be done with jPCT???

Thanks

Offline halcor

  • byte
  • *
  • Posts: 28
    • View Profile
Character movement
« Reply #1 on: January 15, 2007, 03:29:18 pm »
Sure. Check the documentation and the example programs.

Offline Pan83

  • byte
  • *
  • Posts: 5
    • View Profile
Character movement
« Reply #2 on: January 15, 2007, 05:17:08 pm »
Quote from: "halcor"
Sure. Check the documentation and the example programs.


Thanks for the quick reply!!!

Are there any newbie tutorials available??

Thanks

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Character movement
« Reply #3 on: January 15, 2007, 06:13:29 pm »
Well, there isnt a newbie tutorial, but you can ask whatever you need but be specific, dont say: please can anyone make a tutorial just for me?

but you can ask about specific things like the spilines!

Once I remember a guy that was asking about a tutorial and he was hard to explain things, you may found that thread on which are exaplined some initial stuff about the engine.
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Character movement
« Reply #4 on: January 15, 2007, 07:26:08 pm »
Here's a thread with a simple "Hello World"-application: http://www.jpct.net/forum/viewtopic.php?t=579
I'm not sure if the last version posted is a working one but the one he's linking to should work.

Offline Pan83

  • byte
  • *
  • Posts: 5
    • View Profile
Character movement
« Reply #5 on: January 16, 2007, 07:40:06 pm »
Thanks for info.

The hello world app was very helpful.

I am checking the manual and the javadoc now to learn the engine.

I will be back for questions for sure... :)  :)

Thanks again

Offline Pan83

  • byte
  • *
  • Posts: 5
    • View Profile
Character movement
« Reply #6 on: January 23, 2007, 04:09:22 pm »
I have a md2 character and I will use Animation so it can follow a path.

How can I make the md2 face the direction it's moving?

Thanks

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Character movement
« Reply #7 on: January 23, 2007, 04:26:10 pm »
If you have the direction vector, you can derive a rotation matrix from this and set it as the new rotation matrix to the Object3D. Somehow like this:

Code: [Select]

Matrix tar=dirVec.getRotationMatrix();
enemy.setRotationMatrix(tar);

Offline Pan83

  • byte
  • *
  • Posts: 5
    • View Profile
Character movement
« Reply #8 on: January 27, 2007, 11:44:19 am »
Thanks for help EgonOlsen but I am totally lost  :cry:

I want to make my md2 to follow this simple path

(0, 0,200)->(-200, 0,0)->(0, 0,-200)->(200, 0,0) using a simple spline(there are some types in Animation I have seen) but I can't make it.

Can you help?I would be very gratefull!!!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Character movement
« Reply #9 on: January 27, 2007, 11:55:10 am »
You have to calculate the positions in between, i.e. if you are at (0,0,200)=vt1 at time t1=0 and at (-200,0,0)=vt2 at time t2=1000, you are at (-1,0,199)=vt at time t=10 (for example). So if you are at t=10 in this example and your last position was vt1, your direction vector is vd=vt-vt1=(-1,0,-1). Then you would do (assuming that your last translation placed you at vt1):

Code: [Select]

obj.translate(vd);
obj.setRotationMatrix(vd.getRotationMatrix());


How to get the steps in between?...i don't know much about splines, but it has to be possible somehow... :wink:

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Character movement
« Reply #10 on: January 27, 2007, 12:33:01 pm »
Perhaps you could get the distance form one point to the other,
and create an array of inbetween coords.

You know that x,y,z difference can be found between the two points.

If you divided each one by, for example, 5, then you made an array out of each
coord+(i*5), you could get inbetween points?

Not real code btw...
Code: [Select]

//Need to be filled with start and end point.
Point3D start;
Point3D end;

//Stores the inbetween coordinates?
Point3D inbetweenCoords = new Point3D(5);

//The difference between coords.
float xDiff = start.x - end.x;
float yDiff = start.y - end.y;
float zDiff = start.z - end.z;

//The distance between each inbetween point.
float xInc = xDiff/5;
float yInc = yDiff/5;
float zInc = zDiff/5;

//Loop through, creating inbetween points.
int i=0,num=5;
while(i<num)
{
     inbetweenCoords[i] = new Point3D(start+(xInc*i),start+(yInc*i),start+(zInc*i));
     i++;
}


That might not work right away, but if you need inbetween coords, it seems to be like itis a starting point. I know Ill be looking into this myself:)
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG