Codesnippets > 3D-snippets
3D Entity System [EN]
Hemlos:
Definetly some bug, i redownloaded, and recompiled, the demo crashes on startup. (see screenshot)
I think its an issue with the arrays....i find this is typical, it is what usually causes a program to crash.
I tried different ways of solving it, but i have not succeeded.
This is the source of the crash:
--- Code: (EntityInternSetCamera()) ---X_CAMERA o.Mg[12], o.Mg[13], o.Mg[14], o.Mg[12]+o.Mg[8], o.Mg[13]+o.Mg[9], o.Mg[14]+o.Mg[10]
--- End code ---
If i REM this out, the program starts , but as i move the entity with the arrow keys, it crashes again.
[attachment deleted by admin]
Moru:
The demo runs just fine for me as long as I don't press the [ and ] buttons.
Light is placed above and to the side, like this:
--- Code: (glbasic) --- light = EntityCreateLight(RGB(255,255,255))
EntityMove(light, -150, 150, 150)
--- End code ---
also, if I activate the bumpmap with just a plain white .png the program just exits without errors when I add the second type of objects. One type is fine but the second (in whatever order) I add just gets me thrown out.
When I add a camera with this code:
--- Code: (glbasic) --- RESTORE cameras
FOR n = 0 TO 4
READ cam.x, cam.y, cam.z
READ cam.rx, cam.ry, cam.rz
cam.obj = EntityCreateCamera()
EntitySetCameraRange(cam.obj, 1, MAX_RANGE)
EntitySetPosition(cam.obj, cam.x, cam.y, cam.z)
EntitySetRotation(cam.obj, cam.rx, cam.ry, cam.rz)
DIMPUSH camera[], cam // Add the camera to the array of cams
DEBUG "obj:"+camera[n].obj+"\n"
NEXT
--- End code ---
The entity ID I get back is as follows:
obj[0]:0
obj[1]:1
obj[2]:0
obj[3]:1
obj[4]:0
When I try to activate those cameras nothing happens except the skybox disappears. Is there some problem with creating the skybox as in the tutorial?
Quentin:
hmm the entity id should never be 0. In this case something went wrong when creating the entity. Is it possible you post your complete project?
Moru:
I have cut out everything except for this part of the project, the rest is not used:
CreateSphere() is from the samples.
--- Code: (glbasic) ---Init3d()
END
TYPE OBJECT // The 3D objects
obj // Object ID
x; y; z // Position
dx; dy; dz // delta for movement
rx; ry; rz // rotation
ENDTYPE
FUNCTION Init3d:
LOCAL cam AS OBJECT
// Load textures
gfx.brick1 = DynLoadSprite("texture/brick1.png")
gfx.concrete1 = DynLoadSprite("texture/concrete1.png")
gfx.concrete2 = DynLoadSprite("texture/concrete2.png")
gfx.concrete3 = DynLoadSprite("texture/concrete3.png")
gfx.concrete4 = DynLoadSprite("texture/concrete4.png")
gfx.concrete_purple = DynLoadSprite("texture/concrete_purple.png")
gfx.cracks = DynLoadSprite("texture/cracks.png")
gfx.diagonal = DynLoadSprite("texture/diagonal.png")
gfx.sand = DynLoadSprite("texture/sand.png")
gfx.sunrise = DynLoadSprite("texture/sunrise2.png")
gfx.white = DynLoadSprite("texture/white.png")
RESTORE cameras
FOR n = 0 TO 4
READ cam.x, cam.y, cam.z
READ cam.rx, cam.ry, cam.rz
cam.obj = EntityCreateCamera()
EntitySetCameraRange(cam.obj, 1, MAX_RANGE)
EntitySetPosition(cam.obj, cam.x, cam.y, cam.z)
EntitySetRotation(cam.obj, cam.rx, cam.ry, cam.rz)
DIMPUSH camera[], cam // Add the camera to the array of cams
DEBUG "obj:"+camera[n].obj+"\n"
NEXT
active_cam = 4 // The last added camera is the active camera
light = EntityCreateLight(RGB(255,255,255))
EntityMove(light, -150, 150, 150)
// Skybox (or ball in this case)
CreateSphere(0, 2, 35, RGB(255,255,255))
ENDFUNCTION
//! Load sprites. Animations and sprites seems to share ID's
FUNCTION DynLoadSprite: file$
LOCAL free_texture
free_texture = EntityGetFreeTexture()
LOADSPRITE file$, free_texture
RETURN free_texture
ENDFUNCTION
--- End code ---
Quentin:
its hard fo find an error in this snippet. Is not running without several edits.
a few remarks:
- did you define variable MAX_RANGE ?
- your function DynLoadSprite is not needed, use EntityLoadTexture instead, it does what you want
perhaps you could post the complete code without graphics?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version