* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: c4's 3D Game Engine  (Read 6168 times)

0 Members and 1 Guest are viewing this topic.

Offline c4ooo

  • Pedanticity prevents ambiguity
  • Super User
  • CW Contest II Winner
  • *
  • Join Date: Aug 2015
  • Location: 127.0.0.1
  • Posts: 1020
  • Post Rating Ratio: +12/-4
  • Advanced forumer
  • Gender: Male
c4's 3D Game Engine
« on: July 22, 2016, 07:40:10 pm »
I first did 3D programming in java the summer of 2014, but haven't really made any 3D games. Anyways, i decided to pick it up again, don't really know what type of game to make.
« Last Edit: July 28, 2016, 10:07:19 am by c4ooo »



Offline Juju

  • aka Yuki Kagayaki aka J̵̭͕͇ù̞̭̝̯̦j̴̭̙̗͖͡ù͏͓̲̕
  • CodeWalrus Staff
  • Super User
  • Server Maintenance
  • Moderator
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Inside a walrus
  • Posts: 3140
  • Post Rating Ratio: +33/-2
  • Couch potato
    • jul.savard
    • juju2143
    • @juju2143
    • juju2143
    • @julosoft
    • juju-kun
    • /u/juju2143
    • juju2143
    • @juju2143
    • Juju's shed
  • Gender: Female
  • WalriiPoints: 99999
Re: c4ooo does 3D programming again
« Reply #1 on: July 22, 2016, 07:42:02 pm »
Nice floor.
  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)
  • Consoles, mobile devices and vintage computers owned: A lot
On semi-hiatus until who knows when. CODEWALRUS 2.0 COMING SOON
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron

if you wanna throw money at me and/or CodeWalrus monthly it's here

Offline xlibman

  • Omni founder & CW co-founder
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18905
  • Post Rating Ratio: +100/-5
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: c4ooo does 3D programming again
« Reply #2 on: July 23, 2016, 06:52:29 am »
I'm definitively curious about what you'll come up with. Something themed around calc games would be cool actually (it doesn't have to be advanced, but for example a voxel version of Reuben 1 but with battles replaced with real time action like in Zelda)
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline c4ooo

  • Pedanticity prevents ambiguity
  • Super User
  • CW Contest II Winner
  • *
  • Join Date: Aug 2015
  • Location: 127.0.0.1
  • Posts: 1020
  • Post Rating Ratio: +12/-4
  • Advanced forumer
  • Gender: Male
Re: c4ooo does 3D programming again
« Reply #3 on: July 24, 2016, 05:47:40 pm »
lolz math sucks
Code: [Select]
        longestLength = Math.max((float) Math.sqrt(Math.pow(x3 - x4, 2) + Math.pow(y3 - y4, 2) + Math.pow(z3 - z4, 2)),
                Math.max((float) Math.sqrt(Math.pow(x2 - x4, 2) + Math.pow(y2 - y4, 2) + Math.pow(z2 - z4, 2)),
                        Math.max((float) Math.sqrt(Math.pow(x2 - x3, 2) + Math.pow(y2 - y3, 2) + Math.pow(z2 - z3, 2)),
                                Math.max((float) Math.sqrt(Math.pow(x1 - x4, 2) + Math.pow(y1 - y4, 2) + Math.pow(z1 - z4, 2)),
                                        Math.max((float) Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2) + Math.pow(z1 - z2, 2)),
                                                (float) Math.sqrt(Math.pow(x1 - x3, 2) + Math.pow(y1 - y3, 2) + Math.pow(z1 - z3, 2)))))));
(This is one line broken into 6 for readability, it finds the longest of all lines connecting 4 vertices of a quad.)

Edit: got downwards collision detection working:

It works by testing if a line segment, representing the direction of your movement, intersects with the plane of a face, and then testing if the point of intersection is within that face. I have to make it now so the angle of the face you're interacting with affects your movement (eg if you walk forward a ramp,  your body goes up, if you try walking up a really tall slope, like a wall, you move back. And of course i have to add collision detection in other direction :P
« Last Edit: July 24, 2016, 06:30:52 pm by c4ooo »

Offline xlibman

  • Omni founder & CW co-founder
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18905
  • Post Rating Ratio: +100/-5
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: c4ooo does 3D programming again
« Reply #4 on: July 24, 2016, 06:42:09 pm »
Hm glad you are getting some collision detection to work. :)

Supersonic Ball 3D?
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Snektron

  • Lvl 69 Russian Snake
  • Super User
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3165
  • Post Rating Ratio: +32/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • quantuminfinity
  • Gender: Male
Re: c4ooo does 3D programming again
« Reply #5 on: July 24, 2016, 09:29:10 pm »
lolz math sucks
Code: [Select]
        longestLength = Math.max((float) Math.sqrt(Math.pow(x3 - x4, 2) + Math.pow(y3 - y4, 2) + Math.pow(z3 - z4, 2)),
                Math.max((float) Math.sqrt(Math.pow(x2 - x4, 2) + Math.pow(y2 - y4, 2) + Math.pow(z2 - z4, 2)),
                        Math.max((float) Math.sqrt(Math.pow(x2 - x3, 2) + Math.pow(y2 - y3, 2) + Math.pow(z2 - z3, 2)),
                                Math.max((float) Math.sqrt(Math.pow(x1 - x4, 2) + Math.pow(y1 - y4, 2) + Math.pow(z1 - z4, 2)),
                                        Math.max((float) Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2) + Math.pow(z1 - z2, 2)),
                                                (float) Math.sqrt(Math.pow(x1 - x3, 2) + Math.pow(y1 - y3, 2) + Math.pow(z1 - z3, 2)))))));
(This is one line broken into 6 for readability, it finds the longest of all lines connecting 4 vertices of a quad.)

How about you break that up for readabillity:
Code: [Select]
double distance(float x0, float y0, float z0, float x1, float y1, float z1)
{
     float x = x0 - x1;
     float y = y0 - y1;
     float z = z0 - z1;
     return Math.sqrt(x*x + y*y + z*z);
}

double max(double... values)
{
    // Java 8
   return Arrays.stream(values).max().getAsDouble();

   // Java <= 7
   double max = Double.MIN_VALUE;
   for (double d : values)
       max = Math.max(d);
   return max;
}

(...)
    longestLength = (float) max
    (
        distance(x1, y1, z1, x2, y2, z2),
        distance(x2, y2, z2, x3, y3, z3),
        distance(x3, y3, z3, x4, y4, z4),
        distance(x4, y4, z4, x1, y1, z1),
    );
(...)

instead of the new max() fucntion you could also just use multple Math.max's. This should be a tiny bit faster due to less casting (though you could remove those in your version too). But its a lot more readable ;)
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Offline c4ooo

  • Pedanticity prevents ambiguity
  • Super User
  • CW Contest II Winner
  • *
  • Join Date: Aug 2015
  • Location: 127.0.0.1
  • Posts: 1020
  • Post Rating Ratio: +12/-4
  • Advanced forumer
  • Gender: Male
Re: c4ooo does 3D programming again
« Reply #6 on: July 27, 2016, 12:16:10 pm »
Ok so, i want some volunteers to do some boring testing :)
So here's what to do: download the attachment, extract the zip, and double click on run.bat. The program should start! Don't touch any of the controls yet except the mouse yet! Your player should be falling down. You will either land on the pink thing or fall right through it. It will be nice if you could reply saying whether you fall through or land on it, as well as a copy of the output.txt file that should be created in the folder in which you extracted the zip. Sorry, so far its windows only :(

Offline Snektron

  • Lvl 69 Russian Snake
  • Super User
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3165
  • Post Rating Ratio: +32/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • quantuminfinity
  • Gender: Male
Re: c4ooo does 3D programming again
« Reply #7 on: July 27, 2016, 12:32:22 pm »
I won't be able to test it since im running Linux on this laptop :(
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Offline E37

  • Full User
  • Join Date: Jul 2016
  • Location: Lihilzard Empire
  • Posts: 233
  • Post Rating Ratio: +10/-0
  • I own 2 game consoles, a ti-83 and a ti-84!
    • E37
Re: c4ooo does 3D programming again
« Reply #8 on: July 27, 2016, 12:39:24 pm »
I'll test it this evening!
  • Consoles, mobile devices and vintage computers owned: Ti83,Ti84!
I've never finished a project, there is always a way to improve!
What's my calc's name? Convert $37 to decimal. Look up that element in the periodic table. Then take the abbreviation of that element and you have it!
Look! A slime!    <(^.^)>

Offline Snektron

  • Lvl 69 Russian Snake
  • Super User
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3165
  • Post Rating Ratio: +32/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • quantuminfinity
  • Gender: Male
Re: c4ooo does 3D programming again
« Reply #9 on: July 27, 2016, 12:45:40 pm »
Okay i managed to get it working. You have to download lwjgl 2.9.3 (https://sourceforge.net/projects/java-game-lib/files/Official%20Releases/LWJGL%202.9.3/)
Then extract lwjgl.jar, lwjgl_util.jar and jinput.jar to a folder called 'lib' next to 3D.jar. Then you copy the folder natives/<your platform> to a folder called 'natives' next to 3D.jar.
Then you can run it with
Code: [Select]
java -Djava.library.path="natives" -jar 3D.jar

The first time i landed on the platform, but the second and third time i fell through the world :(
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Offline c4ooo

  • Pedanticity prevents ambiguity
  • Super User
  • CW Contest II Winner
  • *
  • Join Date: Aug 2015
  • Location: 127.0.0.1
  • Posts: 1020
  • Post Rating Ratio: +12/-4
  • Advanced forumer
  • Gender: Male
Re: c4ooo does 3D programming again
« Reply #10 on: July 27, 2016, 01:10:35 pm »
Ohh, i packaged the whole thing into a fat jar so the natives and libs should be inside the farjar?!?!?! ??? But lol i take pride in the fact that you actually got it to work xD (That sentence seems weird <_< )
Well, can you paste the output.txt of several tries please :) ?

Offline xlibman

  • Omni founder & CW co-founder
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18905
  • Post Rating Ratio: +100/-5
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: c4ooo does 3D programming again
« Reply #11 on: July 27, 2016, 03:39:43 pm »
Ok so, i want some volunteers to do some boring testing :)
So here's what to do: download the attachment, extract the zip, and double click on run.bat. The program should start! Don't touch any of the controls yet except the mouse yet! Your player should be falling down. You will either land on the pink thing or fall right through it. It will be nice if you could reply saying whether you fall through or land on it, as well as a copy of the output.txt file that should be created in the folder in which you extracted the zip. Sorry, so far its windows only :(
When I try to run run.bat, I get the following error:

Quote
Error: Unable to access jarfile 3dtest.jar
Press any key to continue . . .

Looks like you got the file name wrong. ANyway I renamed the jar file and now I get this error @c4ooo

Quote
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.privateGetMethodRecursive(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.LWJGLException
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 7 more
Press any key to continue . . .

Windows 10 Pro (64-bits)
Intel Core i7 2.80 GHz
8 GB RAM
Nvidia GeForce GT 710 (2 GB video memory)
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline c4ooo

  • Pedanticity prevents ambiguity
  • Super User
  • CW Contest II Winner
  • *
  • Join Date: Aug 2015
  • Location: 127.0.0.1
  • Posts: 1020
  • Post Rating Ratio: +12/-4
  • Advanced forumer
  • Gender: Male
Re: c4ooo does 3D programming again
« Reply #12 on: July 27, 2016, 04:36:19 pm »
Yea looks like i forgot to add the whole dam library  :-\ Why were you unable to access the jar though ???

Edit: yea, looks like i put the wrong jar file in the zip, hold on i'll fix it.
« Last Edit: July 27, 2016, 04:38:18 pm by c4ooo »

Offline xlibman

  • Omni founder & CW co-founder
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18905
  • Post Rating Ratio: +100/-5
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: c4ooo does 3D programming again
« Reply #13 on: July 27, 2016, 04:58:23 pm »
Ah I see now. And yeah I thought the file name was wrong at first.
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline c4ooo

  • Pedanticity prevents ambiguity
  • Super User
  • CW Contest II Winner
  • *
  • Join Date: Aug 2015
  • Location: 127.0.0.1
  • Posts: 1020
  • Post Rating Ratio: +12/-4
  • Advanced forumer
  • Gender: Male
Re: c4ooo does 3D programming again
« Reply #14 on: July 27, 2016, 05:07:00 pm »
This one should work: http://s000.tinyupload.com/?file_id=40630677022870276995
(File was to big to uploud to CW)

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games