in this case i send you a file to test your own Normal maps with 4 mesh types. you can load the texture and normal map and test it with sphere, cube, teapot (you know for all games the importants meshs like in the film "The bloody killer teapot coming on earth") and plane:
Code: Select all
;////////////////////////////////////////////////////////////////
;//
;// Project Title: MP 3D Engine
;// File Title: EarthBumpmap.pb
;// Created On: 2.12.2008
;// Updated On:
;// Author: Michael Paulwitz
;// OS:Windows
;//
;// Demofile Earth Bumpmap
;//
;////////////////////////////////////////////////////////////////
;-
;- ProgrammStart
MP_Graphics3D (640,480,0,3) ; Create Windows #Window = 0
SetWindowTitle(0, "3D Bumpmap Demo, left world / right with created normals") ; Name
If CreateMenu(0, WindowID(0)) ; Menü erstellen/Create Menu
MenuTitle("&File")
MenuItem( 1, "&Load Texture")
MenuItem( 2, "&Load Bumpmap Texture")
MenuBar()
MenuItem( 3, "&End")
MenuTitle("&Mesh")
MenuItem(4, "Sphere")
SetMenuItemState(0,4,1)
MenuItem(5, "Cube")
MenuItem(6, "Teapot")
MenuItem(7, "Plane")
EndIf
camera=MP_CreateCamera() ; Create Camera
x.f=0 : y.f=0 : z.f = -4
MP_PositionCamera(camera,x.f,y.f,z.f) ; Camera position
light=MP_CreateLight(1,90,0,0) ; Light on
earth1=MP_Createsphere(20) ; Sphere 1
earth2=MP_Createsphere(20) ; Sphere 2
Textur=MP_CreateTextureFromFileInMemory (?Earth_map,?Earth_map-?Earth_map_normals)
Textur2=MP_CreateTextureFromFileInMemory (?Earth_map_normals,?Earth_map_normals-?Earth_map_end)
MP_EntityTexture (earth1,textur)
MP_EntityBumpmapTexture (earth1,textur2)
MP_EntityTexture (earth2,textur)
MP_PositionEntity (Earth1,1,0,0) ; Position Earth1
MP_PositionEntity (Earth2,-1,0,0) ; Position Earth2
While Not MP_KeyDown(#PB_Key_Escape) ; ESC
Select MP_WindowEvent() ; WindowsEvent abfrage
Case #PB_Event_Menu
Select EventMenu() ; Welches Menü? / Menuquestion
Case 1 ; Load Texture
Pattern$ = "Image Files (bmp,jpg,tga,png,dds,ppm,dib,hdr,pfm|*.bmp;*.jpg;*.tga;*.png;*.dds;*.ppm;*.dib;*.hdr;*.pfm"
;directory$ = "C:\Programme\PureBasic\media\"
File.s = OpenFileRequester("Load Texture!", directory$, Pattern$, 0)
If File
MP_FreeTexture (Textur)
Texture = MP_LoadTexture(File.s)
MP_EntityTexture (earth1,Textur)
MP_EntityTexture (earth2,Textur)
EndIf
Case 2 ; Load Bumpmap Texture
Pattern$ = "Image Files (bmp,jpg,tga,png,dds,ppm,dib,hdr,pfm|*.bmp;*.jpg;*.tga;*.png;*.dds;*.ppm;*.dib;*.hdr;*.pfm"
;directory$ = "C:\Programme\PureBasic\media\"
File.s = OpenFileRequester("Load Bump Texture!", directory$, Pattern$, 0)
If File
MP_FreeTexture (Textur2)
Texture2 = MP_LoadTexture(File.s)
MP_EntityBumpmapTexture (earth1,textur2)
EndIf
Case 3 ; end
End
Case 4 ; Sphere
SetMenuItemState(0,4,1)
SetMenuItemState(0,5,0)
SetMenuItemState(0,6,0)
SetMenuItemState(0,7,0)
MP_FreeEntity (earth1)
MP_FreeEntity (earth2)
earth1=MP_Createsphere(20) ; Sphere 1
earth2=MP_Createsphere(20) ; Sphere 2
MP_PositionEntity (Earth1,1,0,0) ; Position Earth1
MP_PositionEntity (Earth2,-1,0,0) ; Position Earth2
MP_EntityTexture (earth1,textur)
MP_EntityBumpmapTexture (earth1,textur2)
MP_EntityTexture (earth2,textur)
Case 5 ; Cube
SetMenuItemState(0,4,0)
SetMenuItemState(0,5,1)
SetMenuItemState(0,6,0)
SetMenuItemState(0,7,0)
MP_FreeEntity (earth1)
MP_FreeEntity (earth2)
earth1=MP_Createcube() ; Cube 1
earth2=MP_Createcube() ; Cube 2
MP_PositionEntity (Earth1,1,0,0) ; Position Earth1
MP_PositionEntity (Earth2,-1,0,0) ; Position Earth2
MP_EntityTexture (earth1,textur)
MP_EntityBumpmapTexture (earth1,textur2)
MP_EntityTexture (earth2,textur)
Case 6 ; Teapot
SetMenuItemState(0,4,0)
SetMenuItemState(0,5,0)
SetMenuItemState(0,6,1)
SetMenuItemState(0,7,0)
MP_FreeEntity (earth1)
MP_FreeEntity (earth2)
earth1=MP_CreateTeapot () ; Teapot 1
earth2=MP_CreateTeapot () ; Teapot 1
MP_PositionEntity (Earth1,1,0,0) ; Position Earth1
MP_PositionEntity (Earth2,-1,0,0) ; Position Earth2
MP_EntityTexture (earth1,textur)
MP_EntityBumpmapTexture (earth1,textur2)
MP_EntityTexture (earth2,textur)
Case 7 ; Plane
SetMenuItemState(0,4,0)
SetMenuItemState(0,5,0)
SetMenuItemState(0,6,0)
SetMenuItemState(0,7,1)
MP_FreeEntity (earth1)
MP_FreeEntity (earth2)
earth1=MP_CreatePolygon (1,4) ; Plane 1
earth2=MP_CreatePolygon (1,4) ; Plane 2
MP_PositionEntity (Earth1,1,0,0) ; Position Earth1
MP_PositionEntity (Earth2,-1,0,0) ; Position Earth2
MP_EntityTexture (earth1,textur)
MP_EntityBumpmapTexture (earth1,textur2)
MP_EntityTexture (earth2,textur)
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
MP_TurnEntity (earth1,-0.06,0,0) ; Move Earth1
MP_TurnEntity (earth2,-0.06,0,0) ; Move Earth2
MP_RenderWorld () ; Hier gehts los
MP_Flip () ;
Wend
DataSection
Earth_map:
IncludeBinary "c:\earth_map.jpg" ; Mein MP Bild included
Earth_map_normals:
IncludeBinary "c:\earth_map_normals.jpg" ; Mein MP Bild included
Earth_map_end:
EndDataSection