Código:
#include ninfa3d, bi.
Dim shared Camera as ncamera.
Dim as nlight light01.
Dim shared as nmesh objeto.
Dim as nsprite sprite.
Dim shared as byte lanzar=0.
Dim shared as single posx=0,Posy=5,posz=-200.
Dim shared as single vectorx=100,vectory=100,vectorz=100.
Dim shared as single orientación, inclinación.
Dim shared as single tiempo=0.001, tiempo2=0.001.
Enable vertical synch.
Enablevsync().
Starts the ninfa3d engine.
Initengine (640,480,32,0) tbackgroundcolor(128,128,12 background color tambientlight(32,32,32)ambient color.
Include the file samplefuntions, bi.
It contains useful features, such as drawing the interfaz and create the test área.
#include samplefunctions, bi.
Create a Camera.
Camera = createcamera ().
Positionentity(Camera,0,64,-280) position.
Creates the lights.
Light01 = createlight(lgt_point) tpositionentity(light01,0,128,12 position tlightradius(light01,256) Radius of the light tlightcastshadow(light01).
Sprite = loadsprite (media/Glow.bmp) tentityparent(sprite, light01) tscalesprite (sprite,30,30).
Createground()creates the test área.
Load Mesh.
Objeto=createmeshsphere (.
Scalemesh(objeto,5,5,5).
Positionentity(objeto,posx,Posy,posz).
Sub moverobjeto ().
Moveentity(objeto,vectorx*cos(orientación)*tiempo,vectory*sin(inclinación)*tiempo-4.9*(tiempo22),vectorz*sin(orientación)*tiempo).
Tiempo2+=tiempo.
If entityy(objeto)<0 then lanzar=0:positionentity(objeto,posx,Posy,posz).
End sub.
Sub actualizarraton().
If mousedown(mouse_left) then vectorx+=mousex()-320+mousey()-240.
If mousedown(mouse_right) then vectory+=mousex()-320+mousey()-240.
If mousedown(mouse_midle) then vectorz+=mousex()-320+mousey()-240.
Movemouse (320,240).
End sub.
Movemouse (320,240).
Hidemouse ().
While (enginerun)returns 1 if the engine is running tbegins scene tbeginscene ().
If keyhit(key_space) then.
Posx=entityx(objeto):Posy=entityy(objeto):posz=entityz(objeto).
Orientacion=atn(vectorz/vectorx)*sgn(vectorx)*sgn(vectorz).
Inclinacion=atn(vectory/(sqr(vectorx*vectorx+vectorz*vectorz)))*sgn(vectory).
Lanzar=1.
Tiempo2=tiempo.
End if.
If (lanzar) then moverobjeto () else moveentity(objeto,-keydown(key_left)+keydown(key_right),keydown(key_control)*(-keydown(key_down)+keydown(key_up)),-keydown(key_down)+keydown(key_up)):actualizarraton() tby pressing the escape closes the engine tif keyhit(key_escape) then closeengine () tupdate the engine tchanging the value (only afects the physics) that Will update the tphysical faster or slower tupdateengine (0) tdisplays the interfaz (fps and triangles) tinterface ().
Text(15,80,Vector:,0,0)displays on the screen.
Text(15,90, x: +str$(vectorx),0,0)displays on the screen.
Text(15,100, y: +str$(vectory),0,0)displays on the screen.
Text(15,110, z: +str$(vectorz),0,0)displays on the screen tend the scene tendscene ().
Wend.
Ends ninfa3d engine.
Endengine ()
Espero que puedas aprovechar algo del código anterior en tu proyecto.