3D FPS Example

Programming examples for the Psy-Q SDK
User avatar
LameGuy64
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 388
Joined: Apr 10, 2013
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

3D FPS Example

Post by LameGuy64 » July 10th, 2014, 2:41 pm

Yet another 3D related example but with simple texturing and a first-person camera this time.

Image
You do not have the required permissions to view the files attached to this post.
Last edited by LameGuy64 on December 12th, 2017, 12:05 am, edited 1 time in total.
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

User avatar
Shadow
Verified
Admin / PSXDEV
Admin / PSXDEV
Posts: 2670
Joined: Dec 31, 2012
PlayStation Model: H2000/5502
Discord: Shadow^PSXDEV

Post by Shadow » July 10th, 2014, 6:17 pm

Very impressive. I really need to get that DTL-H2000 out to you. I've sent you a PM.

Oh, for those that want to compile it with Psy-Q, here is the MAKEFILE:

Code: Select all

# -----------------------------------------
#       PlayStation 1 Psy-Q Makefile
# -----------------------------------------

all:
	del fptest.map
	del fptest.sym
	del fptest.exe
	del fptest.cpe
	cls
	
	ccpsx -Xm -Xo$80010000 fptest.c -ofptest.cpe,fptest.sym,fptest.map
	cpe2x /ce fptest.cpe
Here is the compiled PS-EXE by the way with flight inversion (IE: down is up and up is down):
FPTEST.EXE
You do not have the required permissions to view the files attached to this post.
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

User avatar
bizarro2011
Serious PSXDEV User
Serious PSXDEV User
Posts: 118
Joined: Mar 27, 2012
Location: Brazil

Post by bizarro2011 » July 11th, 2014, 3:10 am

very good :praise

User avatar
Shendo
Verified
C Programming Expert
C Programming Expert
Posts: 250
Joined: Mar 21, 2012
I am a: Programmer
Motto: Never settle
PlayStation Model: SCPH-7502
Discord: ShendoXT
Location: Croatia, EU

Post by Shendo » July 11th, 2014, 4:04 am

I agree, it's very cool. Tested on SCPH9002 and SCPH102 and works great.
Maybe you should add a widescreen toggle option :P
Dev console: SCPH-7502, FreePSXBoot, CH340 serial cable.

User avatar
kirito1910
Interested PSXDEV User
Interested PSXDEV User
Posts: 8
Joined: Dec 09, 2014
I am a: Developer
Location: Italy

Post by kirito1910 » December 11th, 2014, 5:13 am

wow amazing example :o
someone know how he obtained a .c file from a 3d mesh file?

User avatar
gwald
Verified
Net Yaroze Enthusiast
Net Yaroze Enthusiast
Posts: 282
Joined: Sep 18, 2013
I am a: programmer/DBA
PlayStation Model: Net Yaroze
Contact:

Post by gwald » January 31st, 2016, 10:42 pm

This is very awesome!!! :praise :mrgreen:
Thanks for sharing the FPS code too :dance

:lol: at the tile popping due to the fixed floating point GTE, I think making the tile a unit bigger fixes it.

kirito1910 wrote:wow amazing example :o
someone know how he obtained a .c file from a 3d mesh file?

I'd say it's just a bin2code conversion.

User avatar
LameGuy64
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 388
Joined: Apr 10, 2013
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

Post by LameGuy64 » February 1st, 2016, 10:48 pm

gwald wrote:I'd say it's just a bin2code conversion.
It actually just contains an array of 3D vertex coordinates for each quad... Thanks for the compliments though!
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

User avatar
gwald
Verified
Net Yaroze Enthusiast
Net Yaroze Enthusiast
Posts: 282
Joined: Sep 18, 2013
I am a: programmer/DBA
PlayStation Model: Net Yaroze
Contact:

Post by gwald » February 2nd, 2016, 8:48 am

LOL,
I actually tried converting it to NetYaroze code :D

I am stuck at :

Code: Select all

	t=0; NumPrims=0;
		for (i=0; i<quad_count; i++) {

			myPrimTempT = (POLY_FT4*)myPrimPtr;


			nclip = RotAverageNclip4(
				&quad_mesh[t], &quad_mesh[t+1], &quad_mesh[t+2], &quad_mesh[t+3],
				(long*)&myPrimTempT->x0, (long*)&myPrimTempT->x1,
				(long*)&myPrimTempT->x3, (long*)&myPrimTempT->x2,
				&p, &OTz, &Flag);


			if ((nclip > 0) && (OTz > 0)) {

				SetPolyFT4(myPrimTempT);
				quad_color[i].cd = myPrimTempT->code;
				OTc = OTz>>(14-OT_LENGTH);

				// High LOD level (subdivided)
				if (OTc < 15) {

					if (OTc > 5) div.ndiv = 1; else div.ndiv = 2;

					DivideFT4(
						&quad_mesh[t], &quad_mesh[t+1], &quad_mesh[t+3], &quad_mesh[t+2],
						(u_long*)&tp[0], (u_long*)&tp[1], (u_long*)&tp[2], (u_long*)&tp[3],
						&quad_color[i],
						myPrimTempT, &myOT[ActivePage][OTc],
						&div);

					// Increment primitive list pointer
					myPrimPtr += POLY_FT4_size*((1<<(div.ndiv))<<(div.ndiv));
					NumPrims += ((1<<(div.ndiv))<<(div.ndiv));

				// Low LOD level (no subdivision)
				} else if (OTc < 48) {

					myPrimTempT->u0 = tp[0].u;	myPrimTempT->v0 = tp[0].v;
					myPrimTempT->u1 = tp[1].u;	myPrimTempT->v1 = tp[1].v;
					myPrimTempT->u2 = tp[2].u;	myPrimTempT->v2 = tp[2].v;
					myPrimTempT->u3 = tp[3].u;	myPrimTempT->v3 = tp[3].v;
					myPrimTempT->clut	= tp[0].page;
					myPrimTempT->tpage	= tp[1].page;

					DpqColor(&quad_color[i], p, &ColTemp);
					setRGB0(myPrimTempT, ColTemp.r, ColTemp.g, ColTemp.b);

					addPrim(&myOT[ActivePage][OTc], myPrimTempT);

					myPrimPtr += POLY_FT4_size;
					NumPrims += 1;

				}

			}

			t+=4;

		}
*/

RotAverageNclip4:
RotAverageNclip4
Perform a coordinate transformation and perspective transformation for four points; find an interpolation
value, average of Z values, and outer product.
Library
libgte.lib
Header File
libgte.h
Introduced
2.x
Syntax
long RotAverageNclip4(
SVECTOR *v0, SVECTOR *v1, SVECTOR *v2, SVECTOR *v3,
long *sxy0, *sxy1, *sxy2, *sxy3,
long *p,
long *otz,
long *flag)
Documentation Date
12/14/98
Pointer to vectors (input)
Pointer to coordinates (output)
Pointer to interpolation value
(output)
Pointer to OTZ value (output)
Pointer to flag (output)
Explanation
A coordinate transformation of four points v0, v1, v2, and v3 is performed using a rotation matrix. Next a
perspective transformation is performed and four screen coordinates sxy0, sxy1, sxy2 and sxy3 are
returned. An interpolation value for depth cueing on v2 to p is also returned. Finally, we also receive 1/4 of
the Z value of the screen coordinates for v2 to otz.
v0, v1, v2, v3 -> vx, vy, vz
sxy0, sxy1, sxy2, sxy3
p
otz
flag
: (1, 15, 0)
: (1, 15, 0), (1, 15, 0)
: (0, 20, 12)
: (0, 32, 0)
: (0, 32, 0)
When the return value is negative, SX, SY, etc., are incorrect. When SX and SY are required, use
RotAverage4().
Return value
Outer product of (sx0, sy0), (sx1, sy1), (sx2, sy2).
See also
RotAverage4(), RotAverageNclip3()
The rest looks familiar.. I'm sure the yaroze SDK can do it.. I remember doing custom TMD stuff.

Aquilus
What is PSXDEV?
What is PSXDEV?
Posts: 2
Joined: Mar 21, 2016

Post by Aquilus » March 21st, 2016, 1:33 am

Hi! Can you please upload the "Makefile" i'm using another SDK and without it i can't compile! Thank you very much :)

User avatar
Shadow
Verified
Admin / PSXDEV
Admin / PSXDEV
Posts: 2670
Joined: Dec 31, 2012
PlayStation Model: H2000/5502
Discord: Shadow^PSXDEV

Post by Shadow » March 21st, 2016, 2:58 am

Aquilus wrote:Hi! Can you please upload the "Makefile" i'm using another SDK and without it i can't compile! Thank you very much :)
Uhm, the MAKEFILE is shown in my first post. It uses CCPSX, but you can get away with using GCC if you know how.

Code: Select all

ccpsx -Xm -Xo$80010000 fptest.c -ofptest.cpe,fptest.sym,fptest.map
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

Aquilus
What is PSXDEV?
What is PSXDEV?
Posts: 2
Joined: Mar 21, 2016

Post by Aquilus » March 22nd, 2016, 7:55 am

Ah,i'm a stupid xD! Sorry i didn't see the message hahahaha.
PS thanks for the response :)

User avatar
NITROYUASH
Verified
Serious PSXDEV User
Serious PSXDEV User
Posts: 124
Joined: Jan 07, 2018
I am a: Game Designer
PlayStation Model: SCPH-5502
Location: Russian Federation
Contact:

Post by NITROYUASH » January 13th, 2018, 9:16 pm

good stuff, but what about collision between camera and model(s)?

User avatar
MrQuetch
Active PSXDEV User
Active PSXDEV User
Posts: 42
Joined: Apr 01, 2018
I am a: Programmer and artist.
Motto: You can accomplish anything.
Location: United States

Post by MrQuetch » April 3rd, 2018, 6:49 am

Hi, Lameguy64.

This is a really cool example of 3D on the PS1 - there is a lot to learn here. I have figured out my texture problem; so, thanks for your help with that.

User avatar
MrQuetch
Active PSXDEV User
Active PSXDEV User
Posts: 42
Joined: Apr 01, 2018
I am a: Programmer and artist.
Motto: You can accomplish anything.
Location: United States

Post by MrQuetch » April 3rd, 2018, 6:52 am

NITROYUASH wrote: January 13th, 2018, 9:16 pm good stuff, but what about collision between camera and model(s)?
There are many methods of getting collision "data". What you can do is use simple trigonometry to check the sides of the camera (player), and check the distance between yourself and the walls, floors, ceilings, and if it is too close - tell it to stop moving. If you can get all of the "boxes" in the scene, you could use AABB collisions to check and see if you are within the bounds of one of those "boxes". AABB is meant for 2D, but if you add the other axis (I'll call it AABBCC), you could get the same variant in 3D.

Hopefully this helps. :)

User avatar
NITROYUASH
Verified
Serious PSXDEV User
Serious PSXDEV User
Posts: 124
Joined: Jan 07, 2018
I am a: Game Designer
PlayStation Model: SCPH-5502
Location: Russian Federation
Contact:

Post by NITROYUASH » August 17th, 2018, 4:02 am

I am here again.
It actually just contains an array of 3D vertex coordinates for each quad... Thanks for the compliments though!
So, i have a test level (TIM, RSD and TMD) and i want to test it with this example code.
Quadmap.c is still confusing me, how i can export 3D data to this type? ._ .

Thanks for the answers c:

User avatar
LameGuy64
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 388
Joined: Apr 10, 2013
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

Post by LameGuy64 » August 17th, 2018, 10:54 pm

quadmap.c just contains an array of quad coordinates and colors. The rendering method I used in this example is a quick and dirty one when I was still learning how to do 3D graphics on the console.

For TMD stuff, here are some examples I made a long time ago: http://www.psxdev.net/forum/viewtopic.php?f=64&t=626
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

User avatar
NITROYUASH
Verified
Serious PSXDEV User
Serious PSXDEV User
Posts: 124
Joined: Jan 07, 2018
I am a: Game Designer
PlayStation Model: SCPH-5502
Location: Russian Federation
Contact:

Post by NITROYUASH » November 6th, 2018, 4:14 am

So, i think a TMD format is perfect for basic 3D objects (characters, decorations, etc), but not for level geometry, right?

User avatar
gwald
Verified
Net Yaroze Enthusiast
Net Yaroze Enthusiast
Posts: 282
Joined: Sep 18, 2013
I am a: programmer/DBA
PlayStation Model: Net Yaroze
Contact:

Post by gwald » November 6th, 2018, 8:39 am

NITROYUASH wrote: November 6th, 2018, 4:14 am So, i think a TMD format is perfect for basic 3D objects (characters, decorations, etc), but not for level geometry, right?
TMD is a dirty word around here :lol:
It's not really perfect for anything apart from a menu or non playable screens, it's way to big of a format!
But if you like using it, that's cool :) level geometry shouldn't be too complex.
The thing with TMD you don't want to have too many calls,
I mean textured quads in a TMD individually draw, is pretty crappy, (Net Yaroze SDK - the FPS on my recording is crap but notice the number of quads on screen and Hlines Vsyncs!) :
[BBvideo=560,315]https://www.youtube.com/watch?v=mkC_L2sHWtY[/BBvideo]

Compared to a single draw:
[BBvideo=560,315]https://www.youtube.com/watch?v=8uCgLuGif5o[/BBvideo]

User avatar
NITROYUASH
Verified
Serious PSXDEV User
Serious PSXDEV User
Posts: 124
Joined: Jan 07, 2018
I am a: Game Designer
PlayStation Model: SCPH-5502
Location: Russian Federation
Contact:

Post by NITROYUASH » November 6th, 2018, 9:34 am

Sooooo, if TMD (oh, sorry for that word :D) isn't nice, what are my other options?

Also, how it looks like (PSY-Q v4.7):
SCR1.png
SCR2.png
You do not have the required permissions to view the files attached to this post.

User avatar
gwald
Verified
Net Yaroze Enthusiast
Net Yaroze Enthusiast
Posts: 282
Joined: Sep 18, 2013
I am a: programmer/DBA
PlayStation Model: Net Yaroze
Contact:

Post by gwald » November 6th, 2018, 5:29 pm

That looks cool!
Like I said, TMD is ok if used in few draw calls, but it's not really good for fast/action games, IMO anyway.

I don't know much about PSY-Q but I think there's a primitive library? ie it doesn't start with GS.
Ie: addPrim mentioned in above ZIP file
Which looks like it uses the TMD's types (POLY_FT4 etc) but without the overhead of the complete TMD/GS bloat.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests