So, I finally got around to playing with the 3d commands for AGK.
I thought the FPSC characters might make a good place to start.
FPSC models are really easy to get into AppGameKit, just change the DDS textures to PNG.
Here is a
// Project: testing_3d
// Created: 2016-08-15
// set window properties
SetWindowTitle( "AGK 3D Tests" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
// create a temp timer for stepping frames input
temptime# = Timer()
mesh_toggle = 1011
// Create the environment
Create3DPhysicsWorld()
// Load the X file 3D model
LoadObjectWithChildren( 101, "aiko.x" )
anim_name$ = GetObjectAnimationName(101,1)
SetObjectPosition(101, 30, -90, 100)
SetObjectAnimationSpeed( 101, 20 )
PlayObjectAnimation( 101, anim_name$, 1, -1, 1, .5 )
// Texture our model
LoadImage(1011, "aiko_1_D2.png")
LoadImage(1012, "aiko_2_D2.png")
LoadImage(1013, "aiko_3_D2.png")
LoadImage(1014, "aiko_4_D2.png")
LoadImage(1015, "aiko_5_D2.png")
SetObjectMeshImage( 101, 1, 1011, 0)
do
// Print model data on screen
Print(" ")
Print("FPS = " +str(ScreenFPS()))
Print(" ")
Print("Bones = " +str(GetObjectNumBones(101)))
Print(" ")
Print("Meshes = " +str( GetObjectNumMeshes( 101 )))
Print(" ")
Print("Animation Name = " + anim_name$ )
Print(" ")
Print("Total")
Print( "Frames = " + str( GetObjectAnimationDuration( 101, anim_name$)))
Print(" ")
Print("Current")
Print( "Frame = " + str(GetObjectAnimationTime( 101)) )
if GetRawKeyPressed(38)
temptime#=Timer()
ourcurrentframe = GetObjectAnimationTime( 101 )
StopObjectAnimation( 101 )
SetObjectAnimationFrame(101, anim_name$, ourcurrentframe,0)
endif
if GetRawKeyPressed(37)
temptime#=Timer()
SetObjectAnimationFrame( 101, anim_name$, GetObjectAnimationTime( 101 ) -1, 0 )
endif
if GetRawKeyState(37) and (Timer() - temptime#) > .15
temptime#=Timer()
SetObjectAnimationFrame( 101, anim_name$, GetObjectAnimationTime( 101 ) -1, 0 )
endif
if GetRawKeyPressed(39)
temptime#=Timer()
SetObjectAnimationFrame( 101, anim_name$, GetObjectAnimationTime( 101 ) +1, 0 )
endif
if GetRawKeyState(39) and (Timer() - temptime#) > .15
temptime#=Timer()
SetObjectAnimationFrame( 101, anim_name$, GetObjectAnimationTime( 101 ) +1, 0 )
endif
if GetRawKeyPressed(40)
PlayObjectAnimation( 101, anim_name$, GetObjectAnimationTime( 101 ), -1, 1, 0 )
endif
if GetRawKeyPressed(13)
PlayObjectAnimation( 101, anim_name$, 1, -1, 1, 0 )
endif
if GetRawKeyPressed(9)
mesh_toggle = mesh_toggle + 1
if mesh_toggle > 1015
mesh_toggle = 1011
endif
SetObjectMeshImage( 101, 1, mesh_toggle, 0)
endif
Sync()
loop
that might help someone else when importing X file 3D models.
That snippet was written using AppGameKit 2.0.19, so it is untested with later releases.
I couldn't remember the frame ranges for each action, so this helped me list the models moves.
I love the fact that we can change textures on the fly during animations, as that opens a lot of doors for illusions.
UP arrow key = Stop Animation
RIGHT arrow key = Step frames forward
LEFT arrow key = Step frames back
DOWN arrow key = Resume animation, then loop to that frame at end
ENTER key = Play animation from start to end then loop.
TAB key = Cycle through textures
I'll be doing a lot of 3d stuff now, so I started this thread to hold all of my 3d work.
I hope the snippet helps someone.
Below is an earlier test with some freaks made by Mark Blosser (Bond1).
The chainsaw chain had some issues, but that can be resolved.
Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1