MiniB3D

BlitzMax Modules Forums/MiniB3D/MiniB3D

Hi!

Wireframe:
glPolygonMode(Face, GL_LINE)

--------------------------------------

LoaderMatrix:
I think, you must only multiply incomming vertices with this matrix.

--------------------------------------

SetCubeFace:
SetCubeMode:
glEnable(GL_TEXTURE_CUBE_MAP)
glBindTexture(GL_TEXTURE_CUBE_MAP, Self.TextureID)

glEnable(GL_TEXTURE_GEN_S)
glEnable(GL_TEXTURE_GEN_T)
glEnable(GL_TEXTURE_GEN_R)

Reflectivemode:
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB)
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB)
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB)

Projectivemode:
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB)
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB)
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB)


--------------------------------------

CameraProjMode:
Type TFrustum
	Function SetPerspective(Matrix:Float[], Zoom:Float, Aspect:Float, Near:Float, ..
	                        Far:Float)

		Local FPN:Float, NMF:Float

		Rem
			|  Zoom                              |
			| ------   0        0         0      |
			| aspect                             |
			|                                    |
			|   0     Zoom      0         0      |
			|                                    |
			|               Far+Near  2*Far+Near |
			|   0      0    --------  ---------- |
			|               Near-Far   Near-Far  |
			|                                    |
			|   0      0       -1         0      |
		End Rem

		FPN = Far+Near
		NMF = Near-Far

		Matrix[ 0] = Zoom/Aspect
		Matrix[ 1] = 0.0
		Matrix[ 2] = 0.0
		Matrix[ 3] = 0.0

		Matrix[ 4] = 0.0
		Matrix[ 5] = Zoom
		Matrix[ 6] = 0.0
		Matrix[ 7] = 0.0

		Matrix[ 8] = 0.0
		Matrix[ 9] = 0.0
		Matrix[10] = FPN/NMF
		Matrix[11] = 2*FPN/NMF

		Matrix[12] = 0.0
		Matrix[13] = 0.0
		Matrix[14] = -1.0
		Matrix[15] = 0.0
	End Function
	
	Function SetOrtho(Matrix:Float[], Zoom:Float, Left:Float, Right:Float, ..
	                  Bottom:Float, Top:Float, Near:Float, Far:Float)

		Local RML:Float, TMB:Float, FMN:Float

		Rem
			|    2*Zoom                                 |
			|  ----------         0            0      0 |
			|  Right-Left                               |
			|                                           |
			|                   2*Zoom                  |
			|      0          ----------       0      0 |
			|                 Top-Bottom                |
			|                                           |
			|                               -2*Zoom     |
			|      0              0         --------  0 |
			|                               Far-Near    |
			|                                           |
			|   Right+Left    Top+Bottom    Far+Near    |
			| - ----------  - ----------  - --------  1 |
			|   Right-Left    Top-Bottom    Far-Near    |
		End Rem

		RML = Right-Left
		TMB = Top-Bottom
		FMN = Far-Near

		Matrix[ 0] = 2.0/RML
		Matrix[ 1] = 0.0
		Matrix[ 2] = 0.0
		Matrix[ 3] = 0.0

		Matrix[ 4] = 0.0
		Matrix[ 5] = 2.0/TMB
		Matrix[ 6] = 0.0
		Matrix[ 7] = 0.0

		Matrix[ 8] = 0.0
		Matrix[ 9] = 0.0
		Matrix[10] = -2.0/FMN
		Matrix[11] = 0.0

		Matrix[12] = -((Right+Left)/RML)
		Matrix[13] = -((Top+Bottom)/TMB)
		Matrix[14] = -((Far+Near)/FMN)
		Matrix[15] = 1.0
	End Function
End Type


--------------------------------------

CameraProject
ProjectedX
ProjectedY
ProjectedZ

Multiply the coordinates with the inverse transformation matrix of the camera and then multiply it with the viewmatrix of the camera.

--------------------------------------

DeltaYaw / DeltaPitch:
Calculate the worldcoords of the two entities and build a direction vector of it:
V.X = Entity2.WorldX - Entity1.WorldX
V.Y = Entity2.WorldY - Entity1.WorldY
V.Z = Entity2.WorldZ - Entity.WorldZ
Yaw = -ATan2(V.X, V.Z)
Pitch = -ATan2(V.Y, Sqr(V.X*V.X + V.Z*V.Z))

--------------------------------------

GetMatElement:
Calculate the global transformation matrix and then return the needed element of it.

I hope, this will help you! Nice work!
cu olli