#Entity object number is very high (over 10000).

Just starting out? Need help? Post your questions and find answers here.
User avatar
J@ckWhiteIII
Enthusiast
Enthusiast
Posts: 183
Joined: Fri May 25, 2012 7:39 pm

#Entity object number is very high (over 10000).

Post by J@ckWhiteIII »

Hey,
I know I'm not THAT good at maths, but can someone explain me how i get this error here (see subject)? isn't it 4*4*4? why does the number get higher than 10000? it'd be very nice of anyone of you can explain and maybe correct this. This is going to be a procedure that generates some cube entities (like a world generator, but at the moment only with one type ^^). I really hope someone can help me here.
the Code:

Code: Select all

Procedure Generate ()
  For i = -10 To 10 Step 5
    For j = -10 To 10 Step 5
      For k = -10 To 10 Step 5
        Cube = CreateCube (#PB_Any,5)
        CreateEntity (Cube,MeshID (Cube),LoadTexture (0,"Tetromino Viertel.bmp"))
        EntityLocate (Cube,i,j,k)
      Next k
    Next j
  Next i
EndProcedure
I get the error at line 6.

Thank you in advance :)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: #Entity object number is very high (over 10000).

Post by IdeasVacuum »

.... If you insert a Debug you will see: Cube: 43458536

Can't advise much further because there is too much work required to make a working snippet to test - that's your job Jack!

From the help:
Texture format can be in PNG, TGA or JPG. It's strongly recommended to make the texture dimension square and with power of 2 width/height: 64x64, 128x128, 256x256... Old GFX cards can have limitation, so if possible limit the texture size to 256x256.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Arctic Fox
Enthusiast
Enthusiast
Posts: 609
Joined: Sun Dec 21, 2008 5:02 pm
Location: Aarhus, Denmark

Re: #Entity object number is very high (over 10000).

Post by Arctic Fox »

You shouldn't use the Cube variable as index number for CreateEntity. Dynamically created index numbers (those generated by the use of #PB_Any) tend to be very high, thus resulting in the object number error.
I think you should use #PB_Any for CreateEntity, too, and store the returned index number in another variable (e.g. named Entity) which can be used for EntityLocate.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: #Entity object number is very high (over 10000).

Post by IdeasVacuum »

I think you only need to create 1 Cube Mesh and then make many Entities of that Mesh? Could be totally wrong, just sounds logical.
Something like this:

Code: Select all

InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
InitSound()
UsePNGImageDecoder()
UsePNGImageEncoder()
#Win = 0
#Texture = 1
#Material = 2
#Cube = 3

Procedure Generate()
;-------------------
OpenWindow(#Win,20,30,640,480,"Cubes",#PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget)
OpenWindowedScreen(WindowID(#Win),0,0,WindowWidth(#Win),WindowHeight(#Win),0,0,0)

  Add3DArchive("C:\Textures\",#PB_3DArchive_FileSystem)
 CreateMaterial(#Material, LoadTexture(#Texture,"Texture.png"))
     CreateCube(#Cube,5)

  For i = -10 To 10 Step 5
    For j = -10 To 10 Step 5
      For k = -10 To 10 Step 5
 
              iEntID = CreateEntity(#PB_Any,MeshID(#Cube),MaterialID(#Material))
              EntityLocate(iEntID,i,j,k)

      Next k
    Next j
  Next i
EndProcedure

Generate()
Note that you need to create a material from a loaded texture and apply that to the Mesh.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
J@ckWhiteIII
Enthusiast
Enthusiast
Posts: 183
Joined: Fri May 25, 2012 7:39 pm

Re: #Entity object number is very high (over 10000).

Post by J@ckWhiteIII »

Yep, had to change "Cube" to "Entity". thank you very much, it works perfectly now
Post Reply