### Author Topic: Could someone tell me how to use jpct-ae realize the attached car racing game?  (Read 6568 times)

• long
• Posts: 171
##### Could someone tell me how to use jpct-ae realize the attached car racing game?
« on: May 27, 2014, 03:31:52 am »
I want use jpct-ae as 3d engine to realize a car racing game , but i don't know how to use the 3D map , How can i get the  way point  for car to run ?  Could some one tell me or give me some refence code ?  thank s

#### EgonOlsen

• Posts: 12051
##### Re: Could someone tell me how to use jpct-ae realize the attached car racing game?
« Reply #1 on: May 27, 2014, 08:14:46 pm »
I think that you have to define the waypoints yourself. Either in code by using some clever algorithm or by hand...i would revert to the latter...

• long
• Posts: 171
##### Re: Could someone tell me how to use jpct-ae realize the attached car racing game?
« Reply #2 on: May 28, 2014, 02:11:00 am »
Thanks, I add the 3d map into the world ,  I can't control the  car location on the  map ,Do you have some good ideas?

#### rtSJ

• byte
• Posts: 21
##### Re: Could someone tell me how to use jpct-ae realize the attached car racing game?
« Reply #3 on: May 28, 2014, 09:51:54 am »
You can't locate the car on the world ? Why ?

2 ideas about place waypoint :
• Place waypoint into the 3D model of the map with a specific name "way_point_X", and when you place the road on the world, just search model with this name. And memorise positions on the world. It's the waypoint for the car.
• Use XML to write by hand before. With a node correspond to one waypoint and have 3 attributs (Coordinates). With this way, you can write into the file and add some "best time" at each way point for show how is the best time of the player.

And I never do a clever algorithm, so I can't help you.

• long
• Posts: 171
##### Re: Could someone tell me how to use jpct-ae realize the attached car racing game?
« Reply #4 on: May 28, 2014, 12:21:31 pm »
Thanks, If I add waypoint in 3d mode, How can  I search the  "waypoint_1" by jpct-ae?   I use code like this:

try
{
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();

}

saidao.translate(0,10,0);
saidao.build();

Could you give me some refrece code ? Thank you

#### rtSJ

• byte
• Posts: 21
##### Re: Could someone tell me how to use jpct-ae realize the attached car racing game?
« Reply #5 on: May 28, 2014, 01:35:27 pm »
If I was in your situation, I'll do :

Code: [Select]
`Object3D[] obj;try {     obj = Loader.loadOBJ(res.getAssets().open("road.obj");     for(int i = 0; i < obj.length; i++){          world.addObject(obj[i]);          if(obj[i].getName().equalsIgnoreCase("waypoint_1")){               // memoryse informations of coordinate with obj[j].obj[j].getCenter(); in a arraylist or an array          }     }     saidao = Object3D.mergeAll(obj,null,0.8f));//} catch (IOException e) {     Log.w("Loading", "Error while loading object : "+e.getMessage());}TextureManager.getInstance().addTexture("road", new Texture(res.openRawResource(R.raw.road)));saidao.setTexture("road");            saidao.translate(0,10,0);saidao.build();`
I'm not sur if it work because I don't test it. But you can try it and correct it easly. And actually you just search "waypoint_1", but you need to implement a new "for" or a "while" to detect all waypoint you want.

PS : Use the tag [ code ][ /code ] (without spaces) to write code properly. It's more clean.
« Last Edit: May 28, 2014, 03:42:32 pm by rtSJ »

• long
• Posts: 171
##### Re: Could someone tell me how to use jpct-ae realize the attached car racing game?
« Reply #6 on: May 28, 2014, 03:04:53 pm »
Thank  you Very Much !  If  got  all the waypoints ,   I will get the line for car  to transform , so car can run in AI  mode,  Is't it ?
(sorry for my poor english)

#### rtSJ

• byte
• Posts: 21
##### Re: Could someone tell me how to use jpct-ae realize the attached car racing game?
« Reply #7 on: May 28, 2014, 03:48:34 pm »
If you get a lot of waypoints (to make the line very smooth and realistic), you can translate IA car from one to the other waypoint and do like an AI behavior.

I don't know how are programmed AI of car in racing game. Maybe it's not a good solution, but you can do what you want to do with this method.

• long
• Posts: 171
##### Re: Could someone tell me how to use jpct-ae realize the attached car racing game?
« Reply #8 on: May 29, 2014, 03:44:27 am »
HI, I use this mthod ,but i can't get the postion of waypoint , they are all (0,0,0) , Help me ,please

thank you !!

• long
• Posts: 171
##### Re: Could someone tell me how to use jpct-ae realize the attached car racing game?
« Reply #9 on: May 29, 2014, 06:02:07 am »
Object should build before get the position, now  i  can get the waypoint , I wan't to use camera "walk" along the way by way point ,
like this:
Camera cam = world.getCamera();

SimpleVector p = waypoint[WayID];

p.y -= 20;
p.z -= 100;
cam.setPosition(p);

but is  seems mistake , could you help me to modify the code, thank s a lot

• long
• Posts: 171
##### Re: Could someone tell me how to use jpct-ae realize the attached car racing game?
« Reply #10 on: May 29, 2014, 01:59:49 pm »
Anyone help  me?

#### EgonOlsen

• Posts: 12051
##### Re: Could someone tell me how to use jpct-ae realize the attached car racing game?
« Reply #11 on: May 29, 2014, 03:10:53 pm »
Not sure what your exact problem is...? Where do you get your waypoints from?

• long
• Posts: 171
##### Re: Could someone tell me how to use jpct-ae realize the attached car racing game?
« Reply #12 on: May 29, 2014, 03:35:42 pm »

Object3D[] obj;
for(int i = 0; i < obj.length; i++){
if(obj.getName().contains("WP_")){
obj.build();
waypoint[k] = obj.getTransformedCenter();

wayNav[k] = obj;
k++;

}

so the waypoint postion are got

#### EgonOlsen

• Posts: 12051
##### Re: Could someone tell me how to use jpct-ae realize the attached car racing game?
« Reply #13 on: May 29, 2014, 04:11:46 pm »
Have you printed out your waypoints to see if they are what you expect them to be?