3D Entity System [EN]

Previous topic - Next topic

Kitty Hello


Moru

So how is work progressing on this code? From what I see on the german thread there is a lot going on, is it stable yet? Should I bother look at it or are you going to change lots of stuff and only deliver german documentation?

Quentin

for me it's working great just as it is. I'm trying to create a simple Space-Shooter with. The basic movements are very simple to realize. Give it a try ;) Perhaps if you work with it, you will have new ideas what's missing.

Moru

Well, one idea would be to announce here (in english) when there is an update instead of having to download and do a file-compare to figure what was done :-)

Kitty Hello

Apologies! The changes are at the top of the T3D.gbas file (or whatever it's called)

Hemlos

Hello,

It did work/compile mid 2008 without problem.
I downloaded the new system and tried to compile it, the program crashes now.
Bing ChatGpt is pretty smart :O

Schranz0r

Work fine....
No Crash :|
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Hemlos

You try it on win xp ?

I will debug the crash if you cant find the problem.
Bing ChatGpt is pretty smart :O

Moru

#8
Is there any way of rendering shadows with the Entity system? Or is there some way I can get shadows anyway?

I tried EntityEnableShadow(new_obj.obj, TRUE) but this just makes all textures darker...

Kitty Hello

Yes, see the demo. Did you put the light source to a proper place?

Hemlos

#10
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()) Select

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]


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]
Bing ChatGpt is pretty smart :O

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) Select

light = EntityCreateLight(RGB(255,255,255))
EntityMove(light, -150, 150, 150)


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) Select
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

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) Select
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

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?