forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

LTE 3D Game Engine - One question

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Oby1Chick



Joined: 13 Feb 2010
Posts: 24

PostPosted: Fri Mar 19, 2010 6:06 am    Post subject: LTE 3D Game Engine - One question Reply with quote

Hello folks,

Well, I am still developping my 3D game for PSP and it is called C3D Burning Wheels.Here is a trailer if you want to learn more :

http://www.youtube.com/watch?v=bSGcxFab4rQ

I use the LTE 3D Game Engine patched for 3.XX and my models are in .x (Direct 3D) format, with JPG textures.They render perfectely on a .x viewer but it the LTE game engine does not render them properly.. The object is deformed and the texture is not applied well.Can you help me ? I use the same source code used to render the dwarf in the example "11.Shadows".

Thanks again for your help guys,
Oby.
Back to top
View user's profile Send private message
Oby1Chick



Joined: 13 Feb 2010
Posts: 24

PostPosted: Thu Mar 25, 2010 6:13 am    Post subject: Reply with quote

UP ! You guys don't know how to use the LTE Game Engine ?
I really need help..
Back to top
View user's profile Send private message
Pihas



Joined: 25 Oct 2008
Posts: 60
Location: Lithuania

PostPosted: Thu Mar 25, 2010 3:41 pm    Post subject: Reply with quote

It's an Irrlicht Engine (http://irrlicht.sourceforge.net/) port for PSP. All realeted information about it i think you will easealy find in their wiki, forums...

There is LTE Mod with better perfomance then simple LTE, checkout maybe it would be better choice: http://www.psp-hacks.com/forums/f141/release-lte-lite-mod-t240347/
Back to top
View user's profile Send private message Visit poster's website
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Sun Apr 04, 2010 11:49 am    Post subject: Reply with quote

Hey Oby1chick

Not sure if you've figured your problem out on your own yet or not but if your DirectX model has any joints/animations, you need to set atleast 1 keyframe in your model to that of what it should look like and set the current frame to that frame in-code.

I had problems with dis-formed and stretched out character models when their animation frame was set before the first keyframe.

This also brings up the frame offset for your model, it was a bitch figuring out why my keyframe numbers weren't matching up to the frames in-game. Make sure your exporter allows you to set the frame offset OR you know the frame offset. Milkshape has a great DirectX 8.0 exporter for use with LTE on PSP. So when you're setting the frame number, you'd multiply the frame by that frame offset to truly get the keyframe (1 * FRAME_OFFSET if you only have 1 keyframe, I use an offset of 30, the milkshape exporter lets you choose).

also if you're doing actual animations, make sure to have a root joint at 0,0,0 otherwise the first joint you make will be your root joint and everything animates around it (yet another problem that was a bitch to figure out)

I'm an experienced LTE and Irrlicht user (check my latest PSP vid on youtube or QJ) and I'm quite amazed someone else is using it as well and this late into the scene at that. If you need any more help you can contact me here, email, youtube, msn or on irc.freenode.net at ##psp-programming
Back to top
View user's profile Send private message
Oby1Chick



Joined: 13 Feb 2010
Posts: 24

PostPosted: Tue Apr 06, 2010 6:51 am    Post subject: Reply with quote

Thanks guys.
I am really glad you're helping me SG57, I saw your project named "The world" and it's pretty amazing, good luck !
This problem is weird because my car does not have any animation created.There is only one frame and the .x renders properly on any Direct3D viewer.The back of the car is disformed and diseppaers at some places. I will post pics tomorrow.

You seem very experienced and I would like to ask you a few other questions if it does not bother you, I consider myself as a C++ newbie xD.
- What format did you use for 3D objects in "The world" ?
- How can I set myself how the camera moves and which keys uses the player so the camera is attached to the back of car and both move the same way ?
- I am having problems with objects textured on only one face and becoming transparent if you see them by the other side, any idea about this ?
- I have some textures that render properly if you seem from the top but that look ugly and blur if you look at them from the side, can you help me ?

Please forgive me for my english, I am french lol.Answer when you want to and thanks one million for your help !
Oby.
Back to top
View user's profile Send private message
anmabagima



Joined: 01 Oct 2009
Posts: 96

PostPosted: Tue Apr 06, 2010 4:50 pm    Post subject: Reply with quote

Hi,

I'm not very much familiar with Irrlicht or LTE. However, I could answer one of your questions: Each face will usualy beeing visible only from one side and get "transparent" from the other. This is called back face culling. I'm uncertain how to deactivate it with LTE but with the GU you could simply call sceGuDisable(GU_CULL_FACE); to make sure all faces are visible from either side, but be aware that this may have huge negavite impact on your performance.

Regarding your camera movement question, I guess you should set the camera to be a child of your car to link the movement together.

Best regards,
AnMaBaGiMa
Back to top
View user's profile Send private message
Oby1Chick



Joined: 13 Feb 2010
Posts: 24

PostPosted: Tue Apr 06, 2010 9:30 pm    Post subject: Reply with quote

Thanks for your help anmabagima !
So my problem is named back face culling.. I will see if there is any documentation about this in LTE or Irrlicht.About the camera, I was not looking for anything special, the coordinates or the camera just need to be the same as the car but y+20 as example and the camera needs to be looking at the back of the car during the whole race, that's it.

I have two models that don't render properly : The wheels, and the car itself.They are in .x format, and the textures are 256*256 JPGs.They render perfectely in any DirectX viewer..I can export my models in BSP, MS3D, OBJ, DirectX, 3Ds, BLitz3D and MD2, I just want to know which one is easy to use and render well.

I will test the OBJ format this afternoon.
I hope it will work better x) !

Edit

The format OBJ renders even worse !
I get a white, not textured and twisted object whereas it renders perfectely in any OBJ viewer ! Here are pictures :[/u]

Car (X or OBJ) in any viewer :



Car (OBJ) in game :



Car (X) in game :



Please help me ! I am going to try other formats :(,
Oby.
Back to top
View user's profile Send private message
iceman755



Joined: 21 Jul 2008
Posts: 34

PostPosted: Wed Apr 07, 2010 5:58 am    Post subject: Reply with quote

To show back faces:
Code:
node->setMaterialFlag(EMF_BACK_FACE_CULLING, false);


About wrong rendered models, it's a little strange, at least with .OBJ files, did you try the advices SG57 gave you some posts above???
_________________
"Libera eas de ore leonis, ne absorbeat eas tartarus, ne cadant in obscurum"
Back to top
View user's profile Send private message
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Wed Apr 07, 2010 8:52 am    Post subject: Reply with quote

Hey Oby

Quote:
- What format did you use for 3D objects in "The world" ?

I use DirectX 8.0 (non compressed from Milkshape's exporter) for everything that needs either joints for animations OR normals for lighting. For everything else I use OBJ.

So for example the Terrain and trees and players in my game need lighting so I have it in directx format which I later texture depending on certain conditions (field type, class type, whatever). The portal mesh on the ground in town and the warp mesh for warping in/out and a few others don't need lighting so they are in .OBJ and I simply texture them in-game.

The 3DS importer in LTE while it supports textures doesn't support normals meaning no lighting plus LTE loads each meshbuffer as its own node which is bad so avoid 3DS.

The OBJ importer in LTE doesn't support materials (.mtl file) and doesn't support normals so its only good for completely static meshes that aren't going to be lit with lighting. Only downside is you must texture it yourself in-code which isn't hard so bleh.

I tried MS3D at the start but it crashes upon loading and I didn't care to look into why after DirectX has worked flawlessly for me.

I've tried .DAE once before and didn't have a problem with it though I didn't really test around with it. the rest - BSP, COL, B3D, etc. - I haven't done anything with them really so I can't help you there sorry.

Quote:
- How can I set myself how the camera moves and which keys uses the player so the camera is attached to the back of car and both move the same way ?
You got this on your own I see. Just set the position of the camera behind the car and set the back of the car as it's target. There are other ways of doing this but I would use your method so stick with it for now unless you need more camera control later on in which we can talk then. I've written 2 advanced camera controller classes for use with LTE - one in my game Light Cycle 3D to follow the light cycle as it races around like a chase camera and the other in my RPG which is by far more advanced but gives a lot of control as seen in the videos.


Quote:
- I am having problems with objects textured on only one face and becoming transparent if you see them by the other side, any idea about this ?
Looks like this got answered for you as well. Materials in LTE have a 'BackFaceCulling' flag that is defaulted to true upon loading meaning the backs to each face aren't rendered giving you the transparent backs you talked about. Disable it and it'll show both sides, to disable it entirely for a node, you can:
Code:
node->setMaterialFlag(EMF_BACK_FACE_CULLING, false);

To do it specifically for a material:
Code:
node->getMaterial(0 /* mat #*/).BackFaceCulling = false;


Quote:
- I have some textures that render properly if you seem from the top but that look ugly and blur if you look at them from the side, can you help me ?
ah yup - you have the Mipmapping Texture Creation Flag set to true when you are loading that texture. Turn on/off mipmapping using:
Code:
driver->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, true/false);


Turn it off when loading textures you don't want to have that 'blurry' look (particularly 2D GUI images, backgrounds, skybox images, car model texture, etc.). You will lose some performance but your rendering quality will improve. You might get some weird effects in the distance as detailed textures aren't blurred together so it 'jitters' off in the distance as you move the camera around. You're best bet is to just test creating mip maps on and off for each node to see which looks right. I use mip maps for my Town Walls but not for the Town Floor since it blurrs it way too much. I am going to look into how to only make it 'blurry' if its a certain distance from the camera, this will fix both our problems.

---

Why your car OBJ is like that - I can't say why its all crumpled up but I can say its all white because the OBJ importer doesn't support materials so it has no materials hence its all white.

As for the DirectX model, why its rotated up right like that, it appears you have the 'up' direction being the Z axis, in LTE the Y axis is up.

If you use milkshape I can tell you this is how it should look to look upright in LTE before exporting using the DirectX 8.0 option:


Sorry about the delay in my response, I don't frequent ps2dev much, but you can keep asking questions I'll keep answering. Quite a few LTE users lately I've been helping so it doesn't bother me.

Oh and your english is good enough for me, hope my english is good enough for you ^.^
Back to top
View user's profile Send private message
Oby1Chick



Joined: 13 Feb 2010
Posts: 24

PostPosted: Wed Apr 07, 2010 11:34 pm    Post subject: Reply with quote

Once again, thanks a lot :) SG57 and iceman.
I've fixed my problem of blur objects using filtrers and disabling ETCF_CREATE_MIP_MAPS, this works great !
I will only try formats that I know how to render, because I don't want to waste my time testing other things.I think I will stick to DirectX for most of my objects but I am going to give a shot to OBJ, 3DS and MD2 for the car and the wheels.I don't have Milkshape myslef, I use Blender :).And EMF_BACK_FACE_CULLING works perfectely too, thanks !

I was able to rotate well the car in OBJ format and to apply a texture to it...But its still awfully twisted and disformed :/.I took a look at docs and it says the OBJ format is named "Maya Obj", does this make any difference ?

Your english is very well (At least better than mine) and I ought you a lot ^^ ! Oby.
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Thu Apr 08, 2010 7:37 am    Post subject: Reply with quote

Loading the obj format relies heavily on converting floating point numbers as strings back in to floats. There are some pretty ropey atof/strtod implementations out there - perhaps that's the problem. I'd try dumping out the vertex and face data on the PSP once the model's loaded and comparing it with a dump from my PC code.
Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Thu Apr 08, 2010 8:05 am    Post subject: Reply with quote

I can't tell you why your OBJ is all twisted up, using the Milkshape exporter I haven't had a problem. I am using nice whole numbers though so I don't experience precision loss that Jim is talking about - what are the dimensions of your model Oby?
Back to top
View user's profile Send private message
Oby1Chick



Joined: 13 Feb 2010
Posts: 24

PostPosted: Thu Apr 08, 2010 9:25 pm    Post subject: Reply with quote

Thanks Jim and sg57 but I have finally fixed my problem :D !
All my objects render very well now, and textures too.
The dimensions of my models were not special, no vertice had coordinates higher than 3 or lower than -3.
I've gave up the OBJ format and everything is in DirectX format.I've changed of converter in fact.Here is a link :
http://development.mindfloaters.de/DirectX_Exporter_Mod.8.0.html
Blender directX converter was not 100% compatible with Irrlicht (So LTE) and someone has modded it so it works perfectly now !

I don't have any problems for the moment.. But I have a question for you SG57 :p. A few weeks ago, I could not render all my models and the skybox at the same time because the PSP froze and a log.txt appeared at the root of my memory stick.Inside, there was written :
Code:

*** GL error 0x0505 in __pspgl_teximg_new ***


I had to resize some of my textures slower.It was because I had not enough memory to load all my textures.My textures folder mustn't be bigger than 1 MB, or it freezes because the LTE game engine loads all the textures in the VFPU, which is too small to contain so much textures.Did you find a way to avoid this problem, or do you also need to be careful with your textures ?

Thanks again x),
Oby.
Back to top
View user's profile Send private message
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Fri Apr 09, 2010 8:30 am    Post subject: Reply with quote

hmm what version of LTE are you using? the lite mod?

I ask because I know of a memory leak in PSPGL that siberianstar fixed in the later versions of LTE (and thus in LTE Lite Mod).

Well I am going to doubt that your skybox textures + a few model textures will fill the RAM since I have a lot and have no such problem yet...

How many polys is your car model? The PSP is a low-med poly console meaning no more than 30k polys on-screen at a time or you might experience some real lag. My map and terrain models have ~2,000-3,000 polys where my character is ~1000 and some objects are between 100 to 1,000.

Also, do not put PSP_HEAP_SIZE or any PSP_MODULE_INFO things in your code, LTE does that for you. This might be your problem.

So yea..
- Don't put PSP_HEAP_SIZE
- Make sure your textures have a max width of 512 and a max height of 512, I recommend 256x256 textures for skybox, 128x128 for ground textures, 64x64 for everything else
- Make sure your models are low-mid poly. So for your car, I'd go for 1k-2k polys, for your map, i'd go for 5k polys or so.


If the problem persists, show me some ccde because you might have a memory leak somewhere.

ttys oby
Back to top
View user's profile Send private message
Oby1Chick



Joined: 13 Feb 2010
Posts: 24

PostPosted: Sat Apr 10, 2010 5:26 am    Post subject: Reply with quote

Yeah, I am using LTE lite mod because I want my homebrew to run on any firmware and not only on kernel 1.50 so I needed it. I've fixed this problem a few weeks ago, but I was just wondering if you also had a limit around 1MB or if you found a way to load more textures.

I figured that you can actually set the heap size yourself if you remove it from the audio lib of LTE, because it is declared here.I've set mine to PSP_HEAP_SIZE_MAX().The problem is solved, don't worry :).

But I've an other bug now lol...And I tried many things but I was not able to find a solution.Parts of my objects too close from the camera disppear and become transparent ! I thought this parameter could be disabled but there is nothing written about that in the documentation.The only command I could read was "setAutomaticCulling", but it does not make any difference if I set it to false on my objects or on my camera using :
Code:

node->setAutomaticCulling(false);

Or :
Code:

camera->setAutomaticCulling(false);


And I have an other issue..
When I rotate my car, it still moves using the global axes and not the object relative axes.I increase Z axis when you press R so the car moves forward (I will make it more realistic later xD) and when you press arrows it rotates the car on the Y axis.But if I press R after I've rotated it, the car still moves on its previous Z axis, if you see what i mean.

Once again thanks a lot sg57 ^^,
Oby.
Back to top
View user's profile Send private message
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Sat Apr 10, 2010 8:17 am    Post subject: Reply with quote

Hey Oby

I haven't run into a memory problem yet where I couldn't load any textures. I don't know just how much I am loading but its gotta be more then a megabyte I'd say..

As for your problem - things disappear when they get too close to the camera because they are being culled by the GPU due to two (?) or more of their vertices being outside the view frustrum.

This will happen whenever you view any triangle close up OR the triangle itself is relatively large. The trick to fixing this annoyance is to clip those large triangles into smaller ones. (subdivide each triangle into 3 smaller triangles and repeat if needed).

Now LTE will do this for you, but its software clipping therefore you should ONLY do it to meshes with large triangles - so in your case your Car model doesn't need it where your track/map/terrain/etc. will need it since it will have large faces.

Each material of a mesh has a clipping flag that is disabled by default. If set to true, software clipping will be performed.
Code:
big_model->getMaterial(0).Clipping = true/false;



To set all the materials clipping flag of a node to true, you can do:
Code:
big_model->setMaterialFlag(EMF_CLIPPING, true/false);


I give you both ways since software clipping is slow and should only be used on those big meshes with big triangles. So say you have tires built into your race track Oby, I don't recommend using the setMaterialFlag function since it will clip the tires too automatically which is a waste since they don't have huge triangles. I recommend going through each material and using the first method and manually setting each clipping flag to true or something equivalent if you have material objects in your 3d model that don't need clipping.

Also, if you enable Clipping (or the mesh is animated), you can't have the StaticMesh (DMA) material flag on for that material.
Back to top
View user's profile Send private message
iceman755



Joined: 21 Jul 2008
Posts: 34

PostPosted: Sat Apr 10, 2010 2:06 pm    Post subject: Reply with quote

For rotating and moving always in the object's Z direction do something like this (after setting object's rotation):

this is just taking into account the Y rotation, if you want it for full rotation (all axises) substitute 2nd line with commented one:

Code:
matrix4 m;
vector3df vObjRot = vector3df(0,ObjNode->getRotation().Y,0);
//vector3df vObjRot = ObjNode->getRotation();
m.setRotationDegrees(vObjRot);
vector3df move = vector3df(0.0f,0.0f,1.0f); //here you set the movement you want
m.transformVect(move);
ObjNode->setPosition(ObjNode->getPosition()+move);

_________________
"Libera eas de ore leonis, ne absorbeat eas tartarus, ne cadant in obscurum"
Back to top
View user's profile Send private message
Oby1Chick



Joined: 13 Feb 2010
Posts: 24

PostPosted: Tue Apr 13, 2010 9:18 pm    Post subject: Reply with quote

I'm really sorry I haven't replied earlier guys, I have been busy lately.
So my two problems are named local axis for rotation and camera culling/clipping.. But they are not solved yet :(.

I figured I was not using LTE lite mod SG57 ! I will try to update my engine, it should not be too difficult. I don't really need it for now, I am able to load everything without memory error.

But I can't fix this culling problem easily.My track has only one material and one texture, which is UV-mapped of course.If I set EMF_CULLING boolean to true, there is no more culling, but it lags a lot because it disable culling for the whole track :(. If I let it to false, I see big holes on the floor.. I also tried to find a better position for the camera so it does not cull anything, but it needs to be veerrryyy high, too high in fact.Do you have other ways to do it in mind ? Like disable clipping only for faces which are close to the camera :/ ? Maybe, I can set the size of the bounding box that the camera node uses to perform clipping and render faces that are (almost) behind the camera ? Thanks again.

I was not able to implement this rotation code yet in my program, I understand what it does but I will try it soon.Thanks a lot iceman !
I am going to search more about culling on irrlicht in google,

Oby.

EDIT : I've found a command in Irrlicht which should solve my problem.. But maybe I'm wrong or I don't use it well.It is :

Code:

camera->setNearValue(f32);


It just change the zoom of the camera..
I need to know how to manage well clipping !
Back to top
View user's profile Send private message
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Thu Apr 15, 2010 8:28 am    Post subject: Reply with quote

Hey Oby,

I heard you stopped by IRC, sorry I was still in class ;\

I saw a screenshot of your problem - it is most definitely the triangles being culled so you need to enable software clipping on that specific material.

Code:
track_node->setMaterialFlag(video::EMF_CLIPPING, true);


That will prevent the triangles from disappearing but it will cause a small slowdown, but not a game breaking slow down.

If you DID do this and it was crazy slow, can I ask how many triangles is your track 3D model? I recommend only clipping the ground so you'd have to separate your model into 2 materials - one for the ground and one for the rest. Then you can clip the ground material only and not the rest will solve the slowdown problem i'm sure.

Don't set a new near value (setNearValue) unless you are dealing with small numbers. The default near value is 1.0f so anything within 1 unit of the camera in it's view frustrum will be clipped. The far value is defaulted to 2000.0f so anything within 1 - 2000 units in the camera's view frustrum will be displayed. You might not want to view the ENTIRE map since some of it may be hidden, so you should probably set the farvalue to something less like 1000.0f but remember its totally dependent on your game's scale.

For me, in my game The World, you'll see how I can see all of hte town in the distance:

That is a far value of 3500.0f where the character is 30 width and 30 length. The near value I haven't touched so it is still 1.0.
Back to top
View user's profile Send private message
Oby1Chick



Joined: 13 Feb 2010
Posts: 24

PostPosted: Fri Apr 16, 2010 6:06 am    Post subject: Reply with quote

Thanks again for your help sg57, no problem about the fact I missed you on IRC, I will try to catch you later :).
My track is around 4000 polygons. A_Nub has helped me a lot on IRC and he told me I could try to subdivide the model to reduce the clipping effect, but it lags too much.
He also told me to try to put the camera further and then change the FOV, but it distorts the view..
The whole track is clipped man, so I need to disable it for the whole track model :/. It does not lag THAT MUCH, so I think I will deal with it, if there is no way to set yourself the limit before objects are clipped..

I also owe you a lot iceman.
Your way of dealing with objects rotations by using a matrix and vectors is really nice, thanks a lot man ^^.

I am going to try to continue developping of my project and I will ask you if I get accross some bugs =),

Oby.
Back to top
View user's profile Send private message
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Fri Apr 16, 2010 8:18 am    Post subject: Reply with quote

Oby1,

You don't need to clip 'everything'. A_Nub did say to subdivide but enabling software clipping does that for you most efficiently.

I think you should get your 3D track model down to the lowest you can then just clip the ground. This means you need to separate the ground from the rest of the track using a separate material and just set that material to be clipped:
Code:
your_track_node->getMaterial(GROUND_MATERIAL).Clipping = true;
This will only clip the ground then, not the sides or the sign or anything so your lag shouldn't be too bad. Remember clipping will atleast divide each triangle into 3 smaller triangles so 4,000 polys will turn into 12,000 depending on the size of the triangles.
Back to top
View user's profile Send private message
Oby1Chick



Joined: 13 Feb 2010
Posts: 24

PostPosted: Sat Apr 17, 2010 7:14 am    Post subject: Reply with quote

Thanks sg57 :).
Well, I've enabled clipping only for the parts of my track where it was needed and my game runs at 30 FPS, but it's enough smooth and I may add motion blur so people don't see it to much.
But sometimes, the game FPS increase and goes at 60 FPS.
I've set up a realistic car movement and rotation but it needs to be the same with any FPS.

I've written my speed formula so the speed increases or decrease according to FPS. However, it doesn't work well. I get the FPS framecount using LTE's getFPS function and a lot of people said it was a bad way of computing FPS to use it so movements speed stay the same. Do I need to lock FPS at 30 f/s or is there an other way to compute FPS so it works better ?

Thanks again folks,
Oby.
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sat Apr 17, 2010 8:09 am    Post subject: Reply with quote

Use a timer to get the elapsed time of the previous frame. Use that elapsed time as the input time for the next frame (as it's likely to take a similar time to render).

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Sat Apr 17, 2010 10:07 am    Post subject: Reply with quote

As Jim said Oby.

I developed a Game Class around LTE Lite Mod that I am using for The World. I am doing it something like this - please note I just hacked this out of my game engine class so it won't be very pretty...
Code:
float time_dialation = 1.0f; // skew this from 1.0f and you can achieve 'slow mo' or 'sped up' effects. just make sure collision detection can handle it
u32 timer = 0;
float speed_factor = 0.0f;

const float Speed_Factor() { return speed_factor; }
void RecalcSpeed()
{
  speed_factor = (float) ((device->getTimer()->getRealTime() - timer) / (1000 * time_dialation));
  timer = device->getTimer()->getRealTime();
}

...

int main()
{
  // init engine and whatnot
  // ...

  RecalcSpeed();

  while(device->run())
  {
    // update scene
    // ... 

    // draw scene
    // ...

    RecalcSpeed();
  }

  return 0;
}


Just multiply any speeds by Speed_Factor() in units per. second. So if you want to rotate your model at 120 degrees per second around the Y-axis:
Code:
while (device->run())
{
  // Rotate model 120 degrees p. second
  node_Model->setRotation( node_Model->getRotation() + vector3df(0.0f, 1.0f, 0.0f) * (120.0f*Speed_Factor()) );

  // Draw Scene and everything else
  driver->beginScene(true, true, 0);

  smgr->drawAll();

  driver->endScene();

  RecalcSpeed();
}
Back to top
View user's profile Send private message
MistPhoenix



Joined: 12 Jul 2009
Posts: 23

PostPosted: Sun Apr 18, 2010 4:37 am    Post subject: Reply with quote

Sg57, Iceman and everyone else that is contributing here, you guys are the greatest! I love how you all are teaching us and providing examples of code with explanation is the fastest way of learning.

I am noticing an increase in dev'ing with LTE. There should really be some good tuts on use with various engine implementations, such as game demos and how to do certain things to speed up the speed and gameplay efficiency.
Back to top
View user's profile Send private message
Oby1Chick



Joined: 13 Feb 2010
Posts: 24

PostPosted: Sun Apr 18, 2010 8:32 pm    Post subject: Reply with quote

Thanks Jim and SG57 :) !
I have barely understood what do I need to do to compute this coefficient myself. But I can't get your sample compiled SG57..It keeps giving me errors, wherever I put the function and all the stuff. I've tried the following code :

Code:

#include <engine.h>
#include <pspctrl.h>
#include "../common.h"

...//A few things

setupPSP();

engineDevice *device = createDevice();

float time_dialation = 1.0f;
u32 timer = 0;
float speed_factor = 0.0f;

const float Speed_Factor() { return speed_factor; }
void RecalcSpeed()
{
  speed_factor = (float) ((device->getTimer()->getRealTime() - timer) / (1000 * time_dialation));
  timer = device->getTimer()->getRealTime();
}

...//Few other things

int engineMain(unsigned int argc, void *argv)
{

       ...//Setup everything, load models and textures and all the stuff

     RecalcSpeed();       

   while(device->run())
   {

                ...//Car speed, roation and etc formula

      node->setRotation(core::vector3df(0.0f,1.0f*Speed_Factor(),0.0f));

                ...//Other stuff
      
      driver->beginScene(true, true, 0);

      smgr->drawAll();

      env->drawAll();

        RecalcSpeed();

   }

   device->drop();

   return 0;
}


And I get :
Code:

main.cpp:13: error: expected constructor, destructor, or type conversion before
';' token
make: *** [main.o] Error 1


I really don't know what to do..
I will try to change a few things but I can't compile it for the moment.

MistPhoenix wrote:
Sg57, Iceman and everyone else that is contributing here, you guys are the greatest! I love how you all are teaching us and providing examples of code with explanation is the fastest way of learning.


I agree !
You are really helpful, and I owe you so much.
I learnt a lot of things about LTE !

By the way, I am leaving house tomorrow to go in holidays during a few days, so I won't be back before 23/04. Cya later guys !
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sun Apr 18, 2010 8:43 pm    Post subject: Reply with quote

Looks like you're trying to call functions like setupPSP() at a global scope instead of inside main(). In any event it's just a syntax error. Hard to tell 'cos you snipped the code.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
Oby1Chick



Joined: 13 Feb 2010
Posts: 24

PostPosted: Thu Apr 29, 2010 2:13 am    Post subject: Reply with quote

I'm back from holidays :).
Thanks Jim, you were right, and that was a stupid mistake >.> !
Now it works well, I can compute FPS way more efficiently than with the command getFPS().. However, I still have a weird problem.

Most of the time, FPS stays around 30. But in the turns of the track, it goes up to 60. And when FPS moves from 30 to 60 because I'm beginning to turn, the car "shakes" and "stirs". I really think I had better lock FPS.. do you guys know how to do that ? In documentation, it says I need to use vsync, but I don't know how to do that.

By the way, I had two other questions.
- How am I going to make the other car AI ? Do I need to create a path that the PSP-controlled car will always follow or do I need to set up a lot of points that the car will go through ?
- How can I check if the car has reached the end of the track without cheating and going on the wrong way ?

Thanks again a lot guys :D !
Oby.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group