Page 1 of 3

3D FPS Example

Posted: July 10th, 2014, 2:41 pm
by LameGuy64
Yet another 3D related example but with simple texturing and a first-person camera this time.

Image

Re: 3D FPS Example

Posted: July 10th, 2014, 6:17 pm
by Shadow
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

Re: 3D FPS Example

Posted: July 11th, 2014, 3:10 am
by bizarro2011
very good :praise

Re: 3D FPS Example

Posted: July 11th, 2014, 4:04 am
by Shendo
I agree, it's very cool. Tested on SCPH9002 and SCPH102 and works great.
Maybe you should add a widescreen toggle option :P

Re: 3D FPS Example

Posted: December 11th, 2014, 5:13 am
by kirito1910
wow amazing example :o
someone know how he obtained a .c file from a 3d mesh file?

Re: 3D FPS Example

Posted: January 31st, 2016, 10:42 pm
by gwald
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.

Re: 3D FPS Example

Posted: February 1st, 2016, 10:48 pm
by LameGuy64
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!

Re: 3D FPS Example

Posted: February 2nd, 2016, 8:48 am
by gwald
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.

Re: 3D FPS Example

Posted: March 21st, 2016, 1:33 am
by Aquilus
Hi! Can you please upload the "Makefile" i'm using another SDK and without it i can't compile! Thank you very much :)

Re: 3D FPS Example

Posted: March 21st, 2016, 2:58 am
by Shadow
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

Re: 3D FPS Example

Posted: March 22nd, 2016, 7:55 am
by Aquilus
Ah,i'm a stupid xD! Sorry i didn't see the message hahahaha.
PS thanks for the response :)

Re: 3D FPS Example

Posted: January 13th, 2018, 9:16 pm
by NITROYUASH
good stuff, but what about collision between camera and model(s)?

Re: 3D FPS Example

Posted: April 3rd, 2018, 6:49 am
by MrQuetch
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.

Re: 3D FPS Example

Posted: April 3rd, 2018, 6:52 am
by MrQuetch
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. :)

Re: 3D FPS Example

Posted: August 17th, 2018, 4:02 am
by NITROYUASH
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:

Re: 3D FPS Example

Posted: August 17th, 2018, 10:54 pm
by LameGuy64
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

Re: 3D FPS Example

Posted: November 6th, 2018, 4:14 am
by NITROYUASH
So, i think a TMD format is perfect for basic 3D objects (characters, decorations, etc), but not for level geometry, right?

Re: 3D FPS Example

Posted: November 6th, 2018, 8:39 am
by gwald
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]

Re: 3D FPS Example

Posted: November 6th, 2018, 9:34 am
by NITROYUASH
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

Re: 3D FPS Example

Posted: November 6th, 2018, 5:29 pm
by gwald
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.