www.jpct.net
jPCT - a 3d engine for Java => Support => Topic started by: AGP on June 16, 2009, 01:11:06 am
-
This error is produced by
manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getResource("RacerModels/Textures"), "jaguarsk.jpg"));
but not by background = new javax.swing.ImageIcon(this.getClass().getResource("RacerModels/Textures/CLOUDS1.JPG")).getImage();
The same error is true for manager.add(String, new Texture(this.getClass().getResourceAsStream(...)). What gives?
-
manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getResource("RacerModels/Textures"), "jaguarsk.jpg"));
Probably just a typo, but I noticed you didn't include an actual filename:
manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getResourceAsStream("RacerModels/Textures/JAGUARSK.JPG"), "jaguarsk.jpg"));
-
It's neither a typo nor the only way I tried it. This:
manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getResourceAsStream("RacerModels/Textures/jaguarsk.jpg")));
doesn't work either (same security error).
-
Could be because the Swing-stuff is signed by SUN already (or trusted by default) and the methods that i'm using for loading a texture aren't. But i can't use any other to stay compatible with 1.1. You may try to load the images yourself and use the appropriate constructor that takes an image.
-
That did the trick. So simple! Still, I wish it had worked. What is the purpose of 1.1 compatibility, anyway?
-
That did the trick. So simple! Still, I wish it had worked. What is the purpose of 1.1 compatibility, anyway?
The purpose is...being compatible with 1.1... ;D Some users still rely on this.
-
Apart from that: If the files are in the jar, the applet should be able to access them no matter what.
-
But it wasn't able until I loaded them through ImageIcon. I can't explain it either. Anyway, as long as it works I am happy. I will post you a link of that racing game you liked soon. At this point I'm just working out the collision-detection. And here's a question: invisibility won't affect collision-detection, will it (I thought once that it did but I hope I'm wrong)?
Oh, and I was going to write that I think the latest version of Firefox changed the way it handles its cache, because all of a sudden I can run, change, recompile, repackage, and run again without it giving me headaches, which is making it much easier on me to test my stuff.
-
Visibility DOES affect collision detection. You can't collide with something that isn't visible/active. If this is a problem, set all colliders to visible before calling the collision methods and reset them afterwards where needed. I'm always doing it this way, because i usually use completely different meshes for collision than i use for the visuals.
-
Oh, I think I know what the problem might have been. Rather than calling getResource[AsStream]() directly from Class, try using getClassLoader().getResource[AsStream]() instead:
manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getClassLoader().getResourceAsStream("RacerModels/Textures/jaguarsk.jpg"), "jaguarsk.jpg"));
-
Thanks for the suggestion, paulscode. Is your way any faster?
And Egon, how fast is it to make something visible/invisble? Because as I understand, I'm going to have to make my object visible, test for collision, then make it invisible before I draw for every iteration. So is it just flipping an internal boolean or does work get done?
-
Nope, it's just flipping a boolean. As said, i'm doing this constantly.
-
Egon, I really hate showing my stuff to people because I really hate criticism, but here it goes: http://www.agpgames.com (http://www.agpgames.com)
All but the starship game is working to the point of showing it (if maybe not yet bragging!). Check out the racer. And by the way, I didn't do collision between the two cars yet. Thanks a whole lot both to you and to paulscode for the help with the opponent car. Street Fighter was a family joke between me, my wife my brother-in-law and his girlfriend (now wife). I'm still going to add blood and black eyes. All games are meant for an analog joystick, even if they work (badly) with the keyboard.
-
My analog joystick (i've actually never really used it before) seems to suck. When plugged in and calibrated, the screen in Racer spins and doesn't stop. So i tried to play with the keyboard, which works pretty bad...as you've "promised".
I think Racer is a really good start. I like how it looks so far. Here are my suggestions on how to improve it IMHO:
- Scale your textures to power of 2. jPCT does this for you while loading, but it slows down the loading process
- Get rid of the double loading of textures. For some reason, you seem to load them twice
- Fix the transparency. Remember that even the software renderer can do additive blending, which should look nice on the lights
- Improve the keyboards controls. I have to hit UP multiple times to accelerate, which is very annoying
- Fix the steering. It seems to rotate the car even when standing still
- Somehow, the size of the car doesn't really match the rest of the scene. The car is hardly higher than the curb and maybe half as high as a door. That looks pretty strange. Like in some AAA commercial shooter games, where your hero barely reaches the doorknob... ;D
- Add support for the hardware renderer. You are loading LWJGL anyway, so why not use it to fullest if possible!? Albeit i like the look of the software renderer...
- Consider to use raft's MipMapping extension when using the software renderer (if the applet's memory restrictions allow for that)
As said, it's a good start. I think that improving the controls is the most important part because the best game concept fails if the controls suck. I'll try to find one of my semi-analog Competition Pro USB joysticks to see, if they work better....
Keep up the good work!
BTW: I can't load the street fighter applet...the link seems to be wrong.
Edit: Found and tried the Competition Pro...it's better than the other joystick but not much better than the keyboard. How am i supposed to accelerate? No matter what i do, i'm driving very very slow. This is on a P4M @ 2.2Ghz, i.e. a pretty old laptop of mine.
-
Thanks for the suggestion, paulscode. Is your way any faster?
I don't know, but it should eliminate the access control exception problem you were having when loading stuff that is compiled inside the JAR.
-
Egon, I fixed the Street Fighter link. As for the joystick spinning the camera, no one in the lwjgl group seems to have a suggestion about it, so at the beginning of Racer I tell you to move the analog sticks before the car moves. I also find that if I press the accelerator button one or two seconds before the race the analog sticks default to zero value (as it always should).
-
And the joystick uses a button for accelerating and another for braking. as opposed to up and down like the keyboard.
-
But to address your list of suggestions:
- I will rescale the textures later (probably the last thing I do, really, because there's so much more to do).
- I'm not double-loading them, but perhaps the process of loading an image, then making it a texture does that? Your suggestion!
- Some trees for some reason aren't transparent, but fortunately they're further from camera than the trees that work. I'll look into the problem later, but I looked at the textures and I see nothing wrong with them (same as the ones that work).
- Only way I see to improve input is to implement lwjgl's keyboard, which I guess I'll do.
- Are you sure the steering thing isn't your joystick?
- The cars are a little smaller, but believe it or not that's a choice I made for the gameplay. I don't know, if it bothers people too much, I might rescale them.
- Good point about the hardware renderer, I will do that.
- What exactly is MipMapping and how will it improve the game?
Thanks for your suggestions and do read what I wrote in response to your analog stick troubles.
-
I tried to wiggle around with the stick like the onscreen message says, but to no avail. I think it's the stick. I've never really used it, it may be broken.
About the double loading of textures...no, my method doesn't do this. The log messages that i got were, that a texture with the name <namehere> has been added twice to the manager preceded by a rescale message, which i got a bunch of before. So i assumed that they were loaded twice.
About the keyboard: It's possible to create good keyboard controls with the default event listeners. I don't think that LWJGL Keyboard class will work here, because it requires a Display to be created, which is only given in the context of the native OpenGL renderer.
I don't know how you do the keyboard stuff right now, but you may want to have a look at jPCT's KeyMapper-class in the util-package.
-
I will look into the KeyMapper, thanks.
For my other game, I told you about this already: ever since I switched the renderer from the old hardware method to the AWTGLCanvas, I keep getting ArrayIndexOutOfBoundsExceptions. No event threads either draw or change the models, and all the draw() calls are in a single game loop. So what are all the circumstances in which the World.draw(FrameBuffer) method might throw this right after a succesful call to World.renderScene(FrameBuffer)?
-
The only situation that i'm aware of where this could happen, is when some other thread fiddles around with an object while the draw()-call runs. I can't verify this problem in any other situation...i've never experienced it and i have quite a lot of test cases for AWTGLRenderer.
Do you have stack trace of this exception? Or, even better, a test case to reproduce it?
-
I can send you the whole thing if you want to have a look. I find it really weird.
-
If you could provide a version that i can use without much hassle, i'll give it a try.