Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (577)
games submitted by our members
Games in WIP (498)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3
1  Java Game APIs & Engines / Engines, Libraries and Tools / Re: How do I use a Matrix4f as a camera? on: 2014-02-19 10:20:17
I don't mind doing things myself, It's just when I don't find any tutorials that explain things clearly for me.

With that code you gave me nothing happens, and with the code I got from the tutorials, nothing happens. I can move the test cube I have with the cubeLocation variable. But not the camera itself.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
while(!Display.isCloseRequested()){
            inputUpdate();
           
            view.setIdentity();
            Matrix4f.translate(location, view, view);
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

            glPushMatrix();
                glTranslatef(cubeLocation.x, cubeLocation.y, cubeLocation.z);
                glBegin(GL_QUADS);
                    /* Lots of glVertex3f calls */
                glEnd();
            glPopMatrix();
           
            System.out.println(location);
            Display.update();
        }
       
        Display.destroy();
    }


I tried with and without glLoadIdentity() but again, whatever I do I cant back away from the cube.

EDIT: I when I tested you code I replaced Matrix4f.translate(location, view, view); with
1  
2  
3  
view.m03 = location.x;
view.m13 = location.y;
view.m23 = location.z;
2  Java Game APIs & Engines / Engines, Libraries and Tools / How do I use a Matrix4f as a camera? on: 2014-02-19 09:21:50
I have just began with LWJGL and have ended up with a problem, I can't get a Matrix4f camera to work, no matter what I'm using. All the tutorials I have seen have loads of other codes with shaders, and calculations for FPS movement, which confuses me. I just want a simple camera that I can move in X, Y, and Z.
3  Game Development / Newbie & Debugging Questions / Re: Vector3f or three floats variables on: 2014-02-17 07:27:12
First i'll just quickly mention that some of the functions you are using are sorta outdated, your just learning tho, so its not a big deal.

Anyway, Matrices are simply a mathematical tool to move points in a certain way. You can think of it this way. You can store rotations and/or translations inside of Matrices. Now Im not sure if you use shaders, but if you do this will be more obvious if you don't ill explain anyway.

A point is multiplied by (usually) multiple matrices in openGL to transform the point. For example a couple of matrix multiplications can turn a random point in 3D/2D space, to a point relative to your camera, to a point taking into account perspective (like changing the point to how it would look like out of a camera lens), and eventually to a point relative to your screen.


[edit: fixed typos]

Thanks, I haven't looked into shaders yet, so far I have trying to get the cameras working, and objects rotating the way I want.

I have seen camera objects in a tutorial ( http://www.java-gaming.org/index.php?topic=30871.0 ) that uses two Matrix4f objects named "projection", and "view". I would have followed that tutorial if It didn't had used the m variables inside the Matrix4f object, m00, m11, m22, m23, m32, m33 makes no sense to me, and I felt like just copy and paste the code wouldn't do me any good.

EDIT: Anyway, I think I'll read up on matrix later, and uses Vector3f for my camera/objects while i learning matrixes.
4  Game Development / Newbie & Debugging Questions / Re: Vector3f or three floats variables on: 2014-02-17 06:59:08
Thanks, and since my question have been answered I'm going to go a bit off topic.

I haven't gotten my head around matrixes yet. So far I just see them as a space in a 2D or 3D environment telling objects inside that environment to render inside the matrixes buffer. I use gluPerspective for my cameras, and glOrtho for the hud. I have used glGetFloat on them so I can use glLoadMatrix to switch between them when I want.
5  Game Development / Newbie & Debugging Questions / Vector3f or three floats variables on: 2014-02-17 06:03:49
I have just began with 3D in java, using LWJGL. I have so far manage to create a camera, and some objects. But after looking around on the internet I noticed that some people uses codes like this

1  
2  
private Vector3f location = new Vector3f(0, 0, 0);
private Vector3f rotation = new Vector3f(0, 0, 0);


and

1  
2  
private float x, y, z;
private float rx, ry, tz;


Is it just a preference thing? whats the advantages, and disadvantages? I personally like the Vector3f method, since then I can use a method that returns the vector and use the variables x y and z instead of using get and set methods. It also allows me to use .set for things like projectiles, and to put the camera where I want it to be.
6  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Start with 3D on: 2014-02-13 14:07:02
Are you thinking of PC's having two or more monitors installed or what? Games usually won't have more than one window. That only window is used to render the game on. In games, some tutorials mention "Screen" as a different term. There, a "Screen" is a stage, or level, or the state of the game. There will be Menu screen, Intro screen, Game screen, Titles screen and more screens, but there will be only one window all the time. There are also a single screen at a time, which is called the "Active Screen". That active screen is displayed on the only window of the game.

Thanks, I'm very well aware of that. My own personal computer have a dual monitor setup, ( http://fav.me/d4ilb43 ) and I want to create games that supports that. It's not a question about getting UI elements to fit in the screen, or what games usually do. It's about creating games I want to play, and if I have to go out of the norm, then so be it. But since you can't answer my question I guess I have to test it out myself.
7  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Start with 3D on: 2014-02-13 13:13:06
So I tested LWJGL, and remember exactly why I hated it. I won't go into detail, for it will just turn into a rant. But if I made a screen object, and write all GL functions in there, they wouldn't mess with each other, right?

I didn't really get your thought..
Just wanted to mention something. You talk as if Display is a bad class. In CPP you need to make the window yourself, which is a lot of tedious work. You should be happy that someone else made it so easy to make a window and start rendering right away. It literally takes few lines of code to get something onto the screen..

One of the main reasons I learned Java instead of C++. I guess I'm going to like it once I understand it. For right now it doesn't make much sense to me.

I mean like this, If I make a class called screen, and write all the GL code there, like the rendering, and display stuff. Will it work, or will it be issues when two of the screen objects tries to render at the same time?
8  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Start with 3D on: 2014-02-13 12:57:39
So I tested LWJGL, and remember exactly why I hated it. I won't go into detail, for it will just turn into a rant. But if I made a screen object, and write all GL functions in there, they wouldn't mess with each other, right?
9  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Start with 3D on: 2014-02-13 08:54:45
After getting some hours of sleep, and reading this thread again, I think I'll wait until LWJGL 3.0 comes out, and test it, I might not like it. But JME sounds worse.

The biggest issue I have is the static Display method, I prefer to have them as objects, it make much more sense to me. I have only programmed in java2D so far, with no other library's attached (a side from those I made myself.), and if I want two windows I just run new Frame() twice, I don't think that's possible in LWJGL.

Also when I try LWJGL, what do I exactly have to give up? Can I just use LWJGL to do the rendering, and keep using java's own listeners, and my own game loops?
10  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Start with 3D on: 2014-02-13 04:39:38
It have worked good so far for me, and i still don't like the static variables/methods, and when you said that it loads all the models for me, then that sets off even more warning signs for me. If i would want things to do that I would have stuck with making games with game maker. I like to feel like I have control over the code, like I'm doing the work, sure if I want that then I could try to code a whole engine myself. But I'm not at that level yet, I just want to be able to use 3D models, set up "cameras", and then have some easier method for hit detection with the 3D models. I don't want a API that takes control away from me, that forces me to abandon working with listeners, objects, and such.

So stop trying to convince me to try out LWJGL, I don't like it, just accept it and move on. If you don't have anything else to suggest, then just leave this thread.

11  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Start with 3D on: 2014-02-13 04:07:22
I'm not disregarding it. But if it's another API that suits me better, then I will take it. For it's not only LWJGL that can run openGL, right? The main reason why I don't want a static Display is because I'm use to have an List with my screen objects, so I can have multi monitor support.
12  Java Game APIs & Engines / Engines, Libraries and Tools / Start with 3D on: 2014-02-13 03:53:36
I would like to start with 3D in java, but I'm not sure what i should use. So far I have only tested lwjgl which I didn't like. Mostly because I was forced to used the global variable "Display" to set options for the window. I prefer to have my windows in a variable, like how I have had it so far with JFrame. Also my friend (who is my graphic designer) uses blender, so it would be great if he could just export the files, and run them in the game without having some obscure file format to convert them to.
13  Game Development / Newbie & Debugging Questions / Re: [Solved] count up to 16 with one digit on: 2014-01-13 23:56:17
@Yemto,

If you want something a little more interesting you should look into alternate numerical systems.  For example, the ancient Mayans had a cool counting system based on base 60(!) and writing a translator could be a lot of fun actually.  You could change the symbols to be more "alieny" as well.  I like the idea of aliens having their own language in general, I think that's pretty cool.

Good luck with your game.

Thanks, I think I stay at base 17, at least for this race. But I will use another font so the alien words looks different, I'm to lazy to come up with a whole new language.
14  Game Development / Newbie & Debugging Questions / Re: count up to 16 with one digit on: 2014-01-13 22:57:31
And your reason behind that is, what exactly? I want to push my boundaries so I can learn something. If I didn't I wouldn't been able to code at all since I don't understand it there for I shouldn't learn it.
It was just a hint that the player might have the same or worse problems. So if its important to the game to be able to get these numbers, almost nobody will be able to. If it's not important, then it doesn't matter...

That's what play testers are for. But I had just planned to use this as a count down in seconds to things like self-destruct. But also have it spread around the game to clew the players that it's numbers.
15  Game Development / Newbie & Debugging Questions / Re: count up to 16 with one digit on: 2014-01-13 22:36:01
Thanks, now I understand how it works. I was so stuck in base 10 that I didn't know what changing to base 17 was going to do ^^
However, if even you as the developer had problems to understand this, maybe it's not such a good idea to put it into the game... Huh

And your reason behind that is, what exactly? I want to push my boundaries so I can learn something. If I didn't I wouldn't been able to code at all since I don't understand it there for I shouldn't learn it.
16  Game Development / Newbie & Debugging Questions / Re: count up to 16 with one digit on: 2014-01-13 21:08:02
Thanks, now I understand how it works. I was so stuck in base 10 that I didn't know what changing to base 17 was going to do ^^
17  Game Development / Newbie & Debugging Questions / Re: count up to 16 with one digit on: 2014-01-13 20:42:43
1  
2  
System.out.println(Integer.parseInt("GGG", 17));
System.out.println(Integer.toString(1111, 17).toUpperCase());


works perfectly fine for me? Why reinvent the wheel?

1. Because I didn't know the well existed
2. That code don't work.

1  
2  
System.out.println(Integer.parseInt("A0", 17)); //170
System.out.println(fromAlienNumber("A0")); //100


if we had a digit for 10, I don't think A0 would be 170, since A means 10, and 0 means 0. I have no clew how a 7 got into the mix
18  Game Development / Newbie & Debugging Questions / [Solved] count up to 16 with one digit on: 2014-01-13 20:24:33
I'm working on a game where the player going to encounter a alien race, which is suppose to have a digit up to 16. I have manage to make the code that can translate Alien to Human. But not Human to Alien. I'm using A-G in the code for the 10-16 digits. How do I make the Human to Alien method?


Just in case someone wants/need to see my code that translate Alien to Human.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
public static int fromAlienNumber(String nr){
        boolean isNegative = nr.contains("-");
       
        //Code to see if the number is compatible with the alien alphabet.
       Matcher m = Pattern.compile("(-?[0-9A-G]+)").matcher(nr);
        if(!m.matches()){
            System.err.println(nr+" is not an alien number");
            return -1;
        }
       
        int result = 0;
        nr = nr.replace("-","");
       
        for(int i=0; i<nr.length(); i++)          
            result += (int)(charToNumber(nr.charAt(i)) * Math.pow(10, nr.length()-(i+1)));              
        return isNegative ? -result : result;
    }
   
    public static int charToNumber(char c){
        switch(c){
            case '0': return 0;
            case '1': return 1;
            case '2': return 2;
            case '3': return 3;
            case '4': return 4;
            case '5': return 5;
            case '6': return 6;
            case '7': return 7;
            case '8': return 8;
            case '9': return 9;
            case 'A': return 10;
            case 'B': return 11;
            case 'C': return 12;
            case 'D': return 13;
            case 'E': return 14;
            case 'F': return 15;
            case 'G': return 16;

        }
       
        //To make the compiler happy, it should never come here.
       return -1;
    }
19  Game Development / Newbie & Debugging Questions / Re: Check if RGB is transparent. on: 2014-01-02 16:46:47
Give a bit more detail, what are you using (Swing,LibGDX,Slick2D,LWJGL)

I'm using java2D, and the variable is a BufferedImage
20  Game Development / Newbie & Debugging Questions / Check if RGB is transparent. on: 2014-01-02 16:33:09
I need to check if a pixel in a buffered image is 100% transparent, no matter the "color", is there any way to do that?
21  Game Development / Newbie & Debugging Questions / Re: Thread spawning or Thread pool on: 2013-12-25 05:18:21
That's about as on topic as you can be. There's obviously no point asking for multithreading solutions if you don't need it in the first place. Multithreading isn't like implementing game mechanics; you don't implement it when you want, you implement it when you need it.

This isn't a topic about which threading i should use. I specifically as for what type of multithreading is best for a game. Even if none of them are better than single threading. Please let me struggle, and fail if I must. At least I learn exactly why it shouldn't be used.
22  Game Development / Newbie & Debugging Questions / Re: Thread spawning or Thread pool on: 2013-12-25 04:17:11
Why do you want to use multiple threads? Any specific reasons? Using multiple threads is a bad idea in games and it leads to many problems.

Please stay on topic, this thread is about what type of mutlithreading I should use, not why I do it.
23  Game Development / Newbie & Debugging Questions / Thread spawning or Thread pool on: 2013-12-25 02:29:01
I'm currently making a RPG game in java, and have been thinking of moving on to multithreading. But I don't know what I should use, thread spawning or thread pool. Which one should I use? and why?
24  Discussions / General Discussions / Re: Sync project via FTP on: 2013-10-24 05:51:18
Looks like I going to stick with messing around with USB, since git is the worst thing I have ever tried. It's no information about it that's up to date.

EDIT: and not it have messed up my computer, I can't open any files or folders...
25  Discussions / General Discussions / Re: Sync project via FTP on: 2013-10-24 05:07:49
I have looked into git, and I can't find a tutorial how I can host it on my home computer. I could use github. But I like to have my project private.
26  Discussions / General Discussions / Sync project via FTP on: 2013-10-24 00:06:31
I'm a software developer, and work on projects at home, and on different computers at work. Lately moving around files have beginning to become a annoyance. So I wonder if it's any way I can automatically sync everything up from a FTP server? Preferably with a NetBeans/Eclipse plugin.
27  Game Development / Newbie & Debugging Questions / Re: Better HashMap keys on: 2013-09-29 19:51:14
Sorry. Maybe I don't simply get it or something... but it doesn't really make sense to me - what You want to do.
HashMap stores key - value pairs, where the key can be any type. So why do You create a String hash in order to use it as a key? It clearly seems that there You have x, y and z coordinates, so why not just use for example Vector3 class as the key type in HashMap? That's what the HashMap is designed for.

No you clearly don't get it, and it's so simple. I created this topic to get help with my keys in HashMap, since I knew I didn't need to use Strings as keys, but I didn't know how to create a good key with numbers, since x + y + z wouldn't work.

Also, The are no Vector3, Vector3d, or Vector3D in java2D, so I couldn't possibly know about it. Now when I do i need something that works in java2D
28  Java Game APIs & Engines / Java 2D / Re: JFrame and BufferStrategy on: 2013-09-28 04:37:28
I manage to think out of a fix, it's was the time it took to run .createCompatibleVolatileImage() that slowed down the rendering. So I just create it once, and it fixed it. it runs around 1200 fps instead of 1300, so it's still totally acceptable.

1  
2  
3  
4  
5  
6  
7  
8  
9  
//Create BufferStrategy
BufferStrategy buffer = this.getBufferStrategy();
if(buffer == null){ this.createBufferStrategy(2); return; }

//Create bufferImage
if(bufferImage == null){
    GraphicsConfiguration gConfig = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
    bufferImage = gConfig.createCompatibleVolatileImage(res.width, res.height); return;
}


code to make the bufferImage stretch
1  
2  
3  
g2.dispose();
buffer.getDrawGraphics().drawImage(bufferImage, 0, 0, getWidth(), getHeight(), null);
buffer.show();
29  Java Game APIs & Engines / Java 2D / Re: JFrame and BufferStrategy on: 2013-09-28 01:04:49
150~ fps
1  
2  
3  
GraphicsConfiguration gConfig = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
BufferedImage img = gConfig.createCompatibleImage(res.width, res.height, Transparency.TRANSLUCENT);
Graphics2D g2 = (Graphics2D)img.getGraphics();


550~ fps
1  
2  
3  
GraphicsConfiguration gConfig = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
VolatileImage img = gConfig.createCompatibleVolatileImage(res.width, res.height);
Graphics2D g2 = (Graphics2D)img.getGraphics();


1300~ fps
1  
Graphics2D g2 = (Graphics2D)buffer.getDrawGraphics();


Here is the whole render method, keep in mind that it's stayed the same for all the above examples.
1  
//Long code
30  Game Development / Newbie & Debugging Questions / Re: Better HashMap keys on: 2013-09-28 00:15:51
Call me crazy...but maybe think about using a hashing function? Tongue

MurmurHash2 is a reasonable choice for speed vs. quality.

What do you mean "speed vs. quality" what I want is generate a unique number from x, y, z.
Pages: [1] 2 3
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (24 views)
2014-04-15 18:08:23

BurntPizza (19 views)
2014-04-15 03:46:01

UprightPath (33 views)
2014-04-14 17:39:50

UprightPath (17 views)
2014-04-14 17:35:47

Porlus (33 views)
2014-04-14 15:48:38

tom_mai78101 (59 views)
2014-04-10 04:04:31

BurntPizza (117 views)
2014-04-08 23:06:04

tom_mai78101 (217 views)
2014-04-05 13:34:39

trollwarrior1 (184 views)
2014-04-04 12:06:45

CJLetsGame (191 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!