Okay,
So, in the manual under
SetObjectMeshImage( objID, meshIndex, imageID, textureStage ) , it says that ...
"Texture stages can be used to assign multiple images to a mesh, for example you might put the base (diffuse) texture in stage 0, a normal map in stage 1, and a light map in stage 2. "
And, when trying to set the Normal map as stage 1 and the light map as stage 2 as per the instructions, I could not get it to work right.
Then, when looking at the manual under
SetObjectNormalMap( objID, imageID ) , it says ...
" The normal map will be placed in texture stage 2, overwriting anything that is already there and will have a shader generated that combines it with any dynamic lighting, to correctly light the object."
So, i used that command and actually got a bump happening with the built in shader!
So, I changed my SetObjectMeshImage stages to Diffuse to 0, Normal to 2 (using the other command), and Specular to 1, and got better results.
If you just want to see the bump, then don't use the specular, because I may still be using it wrong.
I had a couple requests for the code to this simple model viewer, so here is the revised code if anyone want to play around with modifying it...
// Project: model_viewer
// Created: 2017-09-23
// set window properties
SetWindowTitle( "Conjured Model Viewer" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
//splash
temptime#=timer()
createsprite(666, LoadImage("splash/logo.png"))
SetSpritePosition(666, 150,100)
SetSpriteScale(666,2,2)
createsprite(999, LoadImage("splash/agk2.png"))
SetSpritePosition(999, 650,180)
SetSpriteScale(999,2,2)
sync()
do
if timer() - temptime# > 2 then exit
loop
SetSpriteVisible(666,0)
SetSpriteVisible(999,0)
// Create the environment
Create3DPhysicsWorld()
SetClearColor(0,0,0)
SetCameraRange( 1, 1, 100000 )
SetCameraPosition(1,20,100,-100)
// load images for the texture buttons
LoadImage(1, "message_diffuse.png")
LoadImage(2, "message_normal.png")
LoadImage(3, "message_specular.png")
// create the virtual buttons for controls
AddVirtualButton(1, 40, 40 , 80)
SetVirtualButtonImageUp(1,LoadImage("open_folder.png"))
SetVirtualButtonImageDown(1,LoadImage("open_folder_x.png"))
// create buttons for the textures
AddVirtualButton(2, 896, 128 , 256)
SetVirtualButtonImageUp(2,1)
SetVirtualButtonImageDown(2,1)
AddVirtualButton(3, 896, 384 , 256)
SetVirtualButtonImageUp(3,2)
SetVirtualButtonImageDown(3,2)
AddVirtualButton(4, 896, 640 , 256)
SetVirtualButtonImageUp(4,3)
SetVirtualButtonImageDown(4,3)
SetSunActive( 1 )
//CreatePointLight(1, 100,100,100,1000,255,255,255)
//SetPointLightMode(1,0)
object_num = 1
do
// input for opening the x file for the model
if GetVirtualButtonPressed(1)
new_model$ = ChooseRawFile("*.x")
DeleteObject(object_num)
object_num = object_num + 1
if object_num > 3 then object_num = 1
LoadObject(object_num, new_model$)
SetObjectPosition(object_num, 0, 0, 0)
RotateObjectLocalY(object_num, 180)
SetVirtualButtonImageUp(2,1)
SetVirtualButtonImageDown(2,1)
SetVirtualButtonImageUp(3,2)
SetVirtualButtonImageDown(3,2)
SetVirtualButtonImageUp(4,3)
SetVirtualButtonImageDown(4,3)
SetObjectShader( object_num, 0 )
SetObjectLightMode(object_num, 1)
endif
// inputs for opening the textures
if GetVirtualButtonPressed(2)
diffuse_texture$ = ChooseRawFile("*.png")
DeleteImage(100)
LoadImage(100, diffuse_texture$)
SetObjectMeshImage(object_num, 1, 100, 0)
SetVirtualButtonImageUp(2,100)
SetVirtualButtonImageDown(2,100)
endif
if GetVirtualButtonPressed(3)
normal_texture$ = ChooseRawFile("*.png")
DeleteImage(200)
LoadImage(200, normal_texture$)
//SetObjectMeshImage(object_num, 1, 200, 2)
SetObjectNormalMap( object_num, 200 )
SetVirtualButtonImageUp(3,200)
SetVirtualButtonImageDown(3,200)
endif
if GetVirtualButtonPressed(4)
specular_texture$ = ChooseRawFile("*.png")
DeleteImage(300)
LoadImage(300, specular_texture$)
SetObjectMeshImage(object_num, 1, 300, 1)
SetVirtualButtonImageUp(4,300)
SetVirtualButtonImageDown(4,300)
endif
// handle inputs for rotating the object
if GetRawKeyState(69) // E
RotateObjectLocalY(object_num, 1)
endif
if GetRawKeyState(81) // Q
RotateObjectLocalY(object_num, -1)
endif
// handle inputs for camera movement
if GetRawKeyState(13) // Enter
MoveCameraLocalY(1, 1)
endif
if GetRawKeyState(16) // Shift
MoveCameraLocalY(1, -1)
endif
if GetRawKeyState(80) // P
SetCameraPosition(1,20,100,-100)
SetCameraLookAt(1, GetObjectX(object_num), GetObjectY(object_num)+40, GetObjectZ(object_num), 0)
endif
if GetRawKeyState(83) // S
RotateCameraLocalX(1,.2)
endif
if GetRawKeyState(87) // W
RotateCameraLocalX(1,-.2)
endif
if GetRawKeyState(65) // A
RotateCameraGlobalY(1,-.4)
endif
if GetRawKeyState(68) // D
RotateCameraGlobalY(1,.4)
endif
if GetRawKeyState(37)
MoveCameraLocalX(1, -1)
endif
if GetRawKeyState(39)
MoveCameraLocalX(1, 1)
endif
if GetRawKeyState(38)
MoveCameraLocalZ(1,2)
endif
if GetRawKeyState(40)
MoveCameraLocalZ(1,-2)
endif
Sync()
loop
You can ignore that object_num because I had plans to be able to load multiple objects at the same time, but haven't gotten that far yet.
Anyway, I hope this helps, and have fun.
EDIT
I had some old comments and code that was commented out that did not apply which I accidentally left in the first post of the code.
So, I just edited the post to remove those unnecessary sections of code to make it a bit cleaner. (sorry about that sloppy code/post)
Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1