Main Menu
Menu

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.

Show posts Menu

Messages - rtSJ

#1
Are you sure that you export is correct ? I try to open your .obj with blender and all the waypoint are in the center of the world. And I don't see the road.

Try to display the position of your waypoint when you search them. Try to display the position of your camera at any moment too. I think your probleme come from your model. Not the librairy jPCT or my alogithm. I'm not sur, but your .obj is not correct.
#2
Okay so, if you want a smooth moving along the different waypoint and "on the road", you need to translate you camera. Or to set a new position on the duration. My solution is if you have a game cycle, you need to update the position of the camera between 2 waypoints.

int wayID;
int wayIDMax = waypoint.lenght;
float percent = 0;

function boolean moveAlongRoad(){
     Camera c = world.getCamera();
     // Adjust it with your duration of your game cycle
     float addPercent= 0.1;
     
     if(wayID < wayIDMax-1){
          c.setPosition(waypoint[wayID].getPosition.add(waypoint[wayID+1].sub(waypoint[wayID])*percent));
          percent += addPercent;
     } else {
          // Run finished
          return true;
     }
     
     if(addPercent >= 1){
          wayID++;
     }

     return false;
}


But for a perfect behavior, you need to apply this to an invisble object in front of your camera (Or just use a fictive position), translate the camera too but with a lower percentage, and do a "lookAt" to your camera on this object juste in front of it.
You camera will follow the path of your waypoint and always look in front of itself, on the road.

If you want to control exactly the view of the camera, you need to create other waypoint only for the invisible object, but it's more complicated to syncronyze both and more long to create a lots of waypoint. But it can work.
#3
I don't understand what your problem is. The position of the camera is never set ? Or it's set, but not at the right position ?
Try to log every single part of your code to identify the part where the error came from, to compare the result log with an expect result.

We can't help you with this informations. We don't understand what's going on and what is the real problem. Sorry. Can you explicit more ?
#4
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.
#5
If I was in your situation, I'll do :

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.
#6
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.
#7
Support / Re: Strange transparency
May 26, 2014, 10:23:03 AM
It's works fine ! Thank you for your work  ;D

Just a little more question, can I know if a texture loaded directly on the 3D model have an alpha value ? Because I know how to check when I load a new texture (With the bitmap image), but when it's load by the librairy, can I check if it have an alpha value ?
#8
Support / Strange transparency
May 23, 2014, 09:49:25 AM
Hello everyone !

I'm coming here today because I have a problem about transparency on my 3D object. I put a transparent texture on one object 3D, and, here's my problem, nothing behinde if display. I have a CameraView on the background and I can see it. But there's is object between my transparent object and my background...

I must enable any Z-order renderer of anything like that ?
#9
Support / Re: Troubles with rotation matrix
May 19, 2014, 03:47:08 PM
Okay, okay It's my fault, I'm sorry. It's work quite well. Thank you ! I'm not very familiar with the 3D mathematics.

Concerning the different coordinate systems and the conversion between them, I make a rotation of the matrix with this line of code :

rotationMatrix = matrixMultiplication(rotationMatrix, myXDegRotationMatrix);

But I'm not sur of what matrix I'm suppose to use. I try to do a rotation of 180 degree with :


my180DegRotationMatrix[0] = 1.0f; my180DegRotationMatrix[1] = 0.0f; my180DegRotationMatrix[2] = 0.0f;
my180DegRotationMatrix[3] = 0.0f; my180DegRotationMatrix[4] = -1.0f; my180DegRotationMatrix[5] = 0.0f;
my180DegRotationMatrix[6] = 0.0f; my180DegRotationMatrix[7] = 0.0f; my180DegRotationMatrix[8] = -1.0f;


And a rotation of 90 degree anti-clockwise :


my90DegRotationMatrix[0] = 1.0f; my90DegRotationMatrix[1] = 0.0f; my90DegRotationMatrix[2] = 0.0f;
my90DegRotationMatrix[3] = 0.0f; my90DegRotationMatrix[4] = 0.0f; my90DegRotationMatrix[5] = 1.0f;
my90DegRotationMatrix[6] = 0.0f; my90DegRotationMatrix[7] = -1.0f; my90DegRotationMatrix[8] = 0.0f;


But that didn't works
#10
Support / Re: Troubles with rotation matrix
May 19, 2014, 01:52:07 PM
Okay, I understand but what is weird is when I apply ma matrix on my camera, the view is deformed. And the camera is not oriented correctly, I'm sur.

When I get the matrix data, I transform it to a 4x4 matrix and I dump to the matrix of the camera :


gyroMatrix = getRotationMatrixFromOrientation(fusedOrientation);
                       
float[] arr4x4 = new float[16];
           
for(int i = 0; i < 9; i++){
    arr4x4[i] = gyroMatrix[i];
}
arr4x4[3] = 0;
arr4x4[7] = 0;
arr4x4[11] = 0;
arr4x4[12] = 0;
arr4x4[13] = 0;
arr4x4[14] = 0;
arr4x4[15] = 1;
           
scene.xyzMatrix.setDump(arr4x4);


And in my cycle of rendering I update the camera with :


Camera worldcam = world.getCamera();

worldcam.setBack(xyzMatrix);


I don't understand what I doing wrong because I think I do everything good...
#11
Support / Re: Troubles with rotation matrix
May 16, 2014, 02:45:22 PM
Thanks for your answer, but it's not what I look for... Sorry ^^'
#12
Support / Troubles with rotation matrix
May 16, 2014, 02:06:32 PM
Hello everyone !

I write it today because I have a problem with the orientation of a jPCT camera. I use the sensor of the device to do augmented reality. I use this tutorial to get the differents values [http://www.thousand-thoughts.com/2012/03/android-sensor-fusion-tutorial/] (Because the easy way is too noisy). I get a rotation matrix and 3 angles (Pitch, roll and Azimuth).

So I want to use the 3 angles with a simple rotateCameraAxis. But I can't because the 3 values ar not independant and when I rotate on 1 axis, others moves and I can't rotate for the 2 others. (I you have a solution, say it, I'm happy to read it !)

The second way to rotate the camera is to use the rotation matrix. I convert it to a 4x4 matrix and fill with 0 and one 1, I base it on cols. But it don't work. And more, my view is totally deformed. My modles are very stranges... Anyone have a solution about it ?

How can I use the 3 angles or the matrix to rotate my camera ?

Thanks ! :)
#13
Support / Re: Use 2 SurfaceView make lag
May 12, 2014, 03:50:22 PM
I mean delayed camera image.

But I think it's the fault of my device because on an other device I haven't any delayed images... So I think you can't do anything for me. But if you have an idea about it, I'm happy to heard it.
#14
Support / Use 2 SurfaceView make lag
May 07, 2014, 02:29:32 PM
Hello everyone !

My problem today is that I use 2 SurfaceView at the same time in my AR software. One is for display the camera of the device. It's a custum class that extends SurfaceView :
public class CameraView extends SurfaceView implements SurfaceHolder.Callback

The second is a GLSurfaceView where I render all my objects with jPCT :

setmGLView(new GLSurfaceView(this.application));
setCameraView(new CameraView(this.context));

setRenderer(new MyRenderer());
getmGLView().setRenderer(getRenderer());
getRenderer().initialize();


But when the both are display, a little lag come. But when I display only one, it's good and very fluent.

Maybe It's not the good solution to display my camera on an other SurfaceView. But I don't understand how to correct the problem and delete the lag. Anyone have an idea ?
#15
Support / Re: Scale many objects together
April 28, 2014, 11:58:09 AM
Okay, so I found a solution and it works. Just when I scale objects, I put this :

model.setRotationPivot(center);

center is a SimpleVector same for all the objects. And it keep the uniformity of the model when I scale any objects.

Thank you all !