TGC Codebase Backup



3D model viewer by Mark Garrett

9th Sep 2019 2:31
Summary

..3D model viewer.



Description

3D model viewer to examine your 3D models.
Just get one of your 3D models, and load it in there, and you can examine it from all angles.
It Rotates the 3D model along it's X and Y axis, and you can zoom in and out.
Works on PC.
Load your own 3D object by substituting on line 44 ..... Box = LoadObject("My object.obj")



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    // Project: 3D Object VIewer 
 
  
 
// Created: 2019-09-08
 
// show all errors
 
  
 
SetErrorMode(2)
 
// set window properties
 
SetWindowTitle( "AGK Object Viewer" )
 
SetWindowSize( 1024, 768, 0 )
 
SetWindowAllowResize( 1 ) // allow the user to resize the window
 
  
 
    
 
// set display properties
 
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
 
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
 
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
 
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
 
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
 
  
 
 
    
Box = CreateObjectBox( 7,7, 11 )
 
 
`Or load your own object with :   Box = LoadObject("My object.obj")
 
sync()
 
  
 
    
 
  
 
AddVirtualJoystick( 1, 945,100, 150 )
 
  
 
do
 
 Gosub Move_Object
 
  
 
 print ("Use 'mouse wheel' to zoom object in and out")
 
  
 
 print ("Use 'Virtual Joystick' to move the object to different angles")
 
  
 Sync()
 
  
 
loop
 
  
 
Move_Object:
 
  
`Virtual Joystick:
 
 
If GetVirtualJoystickY(1) < 0  `RotateObjectLocalX
 
RotateObjectLocalX( Box, 2 )
 
endif
 
  
 
If GetVirtualJoystickY(1) > 0 
 
RotateObjectLocalX( Box,  -2 )
 
endif
 
  
 
    
 
If GetVirtualJoystickX(1) > 0  `RotateObjectLocalY
 
RotateObjectLocalY( Box, -2 )
 
endif
 
  
 
If GetVirtualJoystickX(1) < 0 
 
RotateObjectLocalY( Box, 2 )   
 
endif
 
  
`Mouse  Wheel:
    
 
  
if GetRawMouseWheelDelta() <0  then  MoveCameraLocalZ(1,-5)
 
if GetRawMouseWheelDelta() >0  then  MoveCameraLocalZ(1, 5)
 
SetCameraLookAt( 1, GetObjectX(Box),  GetObjectY(Box), GetObjectZ(Box), 0 )
 
  
 
 
Return