Code archives/3D Graphics - Misc/.X Viewer
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
| Due to needing a quick reference while designing textures, I had to design a quick, short application so that I could see how my creations were coming along. The viewer currently only looks at the directory in which it is placed, and only loads .x meshes with .bmp textures, though it should be no bother to edit this. Very basic, but quite handy! | |||||
ClearWorld
Graphics3D 1024,768,32,2
SetBuffer BackBuffer()
.go
Cls
a$=" "
dir=ReadDir(CurrentDir$())
Locate 0,0
While a$>""
Color 255,255,255
a$=NextFile$(dir)
If Len (a$)>3
If (Right$(a$,2))=".X" Or (Right$(a$,2))=".x" Then a$=(Left$(a$,(Len(a$)-2))) Print a$
End If
Wend
Locate 0,700
Color 255,0,0
file$=Input$("INPUT MESHNAME To VIEW: ")
Cls
a$=" "
dir=ReadDir(CurrentDir$())
Locate 0,0
While a$>""
Color 255,255,255
a$=NextFile$(dir)
If Len (a$)>4
If (Right$(a$,4))=".bmp" Or (Right$(a$,4))=".BMP" Then a$=(Left$(a$,(Len(a$)-4))) Print a$
EndIf
Wend
Locate 0,720
Color 255,0,0
txt$=Input$ ("INPUT TEXTURE: ")
Cls
AmbientLight 255,255,255
mesh=LoadMesh(file$+".X")
texture=LoadTexture(txt$+".BMP",49)
TextureBlend texture,2
EntityTexture mesh,texture
cam=CreateCamera()
CameraViewport cam,0,0,1024,768
MoveEntity cam, 120,120,120
MoveEntity mesh, 40,120,40
PointEntity cam,mesh
MoveMouse 512,360
While Not KeyDown(1)
If MouseX()<512 Then MoveMouse 512,MouseY() TurnEntity mesh,0,10,0
If MouseX()>512 Then MoveMouse 512,MouseY() TurnEntity mesh,0,-10,0
If MouseY()<360 Then MoveMouse MouseX(),360 TurnEntity mesh,-10,0,0
If MouseY()>360 Then MoveMouse MouseX(),360 TurnEntity mesh,10,0,0
If MouseDown(1) Then MoveEntity cam,0,0,1
If MouseDown(2) Then MoveEntity cam,0,0,-1
RenderWorld
Flip
Wend
ClearWorld
Goto go
End |
Comments
None.
Code Archives Forum