static geometry vs grouped entities in a node
static geometry vs grouped entities in a node
iam still exploring the possibilities with the Ogre engine. if iam wrong with the next questions please explain.
what is faster?
- static geometry what needs to rebuild every time if there's a new object?
- or grouped entities in a node. and than few 100 of those nodes with several entities?
i want to make a building game, with different shapes and forms.
see: Construction sandbox
i made this in another, very slow, engine. so i want it rebuild it in this engine, but now the good way.
so it means i have alot of objects, how do i group them nicely so the fps stays good?
can you point me in the good direction with commands what i can use to achieve this?
i saw a few attempts on this forum already but i tried the code and they all gave me a polink fatal error.
any help is appreciated!
what is faster?
- static geometry what needs to rebuild every time if there's a new object?
- or grouped entities in a node. and than few 100 of those nodes with several entities?
i want to make a building game, with different shapes and forms.
see: Construction sandbox
i made this in another, very slow, engine. so i want it rebuild it in this engine, but now the good way.
so it means i have alot of objects, how do i group them nicely so the fps stays good?
can you point me in the good direction with commands what i can use to achieve this?
i saw a few attempts on this forum already but i tried the code and they all gave me a polink fatal error.
any help is appreciated!
Re: static geometry vs grouped entities in a node
hi thanks for the clarification. the number of entities i cant say how much that would be in the end. its like minecraft, an always expanding world with objects.
if not possible, whats the way to build a grouped mesh with different objects?
yes its based on different pieces.If it's based on different pieces,
final? cant i update the static mesh from time to time? because if iam building something i want it added to that current static mesh. is that even possible?you could generate a static mesh on the final construction
if not possible, whats the way to build a grouped mesh with different objects?
Re: static geometry vs grouped entities in a node
Hi , just i want to play the rule of the Librarian, until someone provide more info
static geometry you can't update it : the help file said :"But once created, the geometry can't be moved anymore." you can use FreeStaticGeometry() and begins again.
look my post Plotting data with Static Geometry, and display 300000 cubes:
http://purebasic.fr/english/viewtopic.php?f=36&t=56894 the data are fixed.
or use AttachEntityObject , i havn't tried before to expand something with this function but i will try, look to its help file, and using search and replace utility i found it in several examples in the examples\3D
but it has some limitations with physics look:
How apply physic on AttachEntityObject:
http://purebasic.fr/english/viewtopic.p ... tityobject
Updating physics parameters:
http://purebasic.fr/english/viewtopic.p ... tityobject
there is also a semi bug with AttachEntityObject , and it is fixed for the next release: http://purebasic.fr/english/viewtopic.php?f=4&t=57304
also look this important thread by Samuel http://purebasic.fr/english/viewtopic.p ... 9&p=419669 you may find it useful if the concern with physics.
always there are maneuvers , alternatives and going around things and bugs
as the poet Albert Camus quotes Pindar, "O my soul, do not aspire to immortal life, but exhaust the limits of the possible.
regards
static geometry you can't update it : the help file said :"But once created, the geometry can't be moved anymore." you can use FreeStaticGeometry() and begins again.
look my post Plotting data with Static Geometry, and display 300000 cubes:
http://purebasic.fr/english/viewtopic.php?f=36&t=56894 the data are fixed.
or use AttachEntityObject , i havn't tried before to expand something with this function but i will try, look to its help file, and using search and replace utility i found it in several examples in the examples\3D
Code: Select all
c:\purebasic\examples\3d\AttachEntityObject.pb
c:\purebasic\examples\3d\AttachEntityObject2.pb
c:\purebasic\examples\3d\AttachEntityObject3.pb
c:\purebasic\examples\3d\CameraTrack.pb
c:\purebasic\examples\3d\CheckObjectVisibility2.pb
c:\purebasic\examples\3d\EnableManualEntityBoneControl.pb
c:\purebasic\examples\3d\Text3D.pb
c:\purebasic\examples\3d\Demos\Character.pbHow apply physic on AttachEntityObject:
http://purebasic.fr/english/viewtopic.p ... tityobject
Updating physics parameters:
http://purebasic.fr/english/viewtopic.p ... tityobject
there is also a semi bug with AttachEntityObject , and it is fixed for the next release: http://purebasic.fr/english/viewtopic.php?f=4&t=57304
also look this important thread by Samuel http://purebasic.fr/english/viewtopic.p ... 9&p=419669 you may find it useful if the concern with physics.
always there are maneuvers , alternatives and going around things and bugs
as the poet Albert Camus quotes Pindar, "O my soul, do not aspire to immortal life, but exhaust the limits of the possible.
regards
Re: static geometry vs grouped entities in a node
so if i understand right, if i use AttachEntityObject to a for example a node. i can make several groups of pieces. the engine renders that faster than having all those objects not attached to each other.
iam just finding a way to group all those objects into 1 object, or more objects. so i can delete parts of it or attach parts of it.
iam just finding a way to group all those objects into 1 object, or more objects. so i can delete parts of it or attach parts of it.
Re: static geometry vs grouped entities in a node
If you use AttachEntityObject the rendering speed will still be the same as if they were all separate entities.
Every entity creates at least one draw call (batch) for Ogre.
The only way to cut down on draw calls is to group the entities together. Either by using StaticGeometry or fusing the entities into a larger entity.
Every entity creates at least one draw call (batch) for Ogre.
The only way to cut down on draw calls is to group the entities together. Either by using StaticGeometry or fusing the entities into a larger entity.
Re: static geometry vs grouped entities in a node
how many staticgeometry's can i make? and if i make that can i still delete single objects from it? and add single objects to it? so i need to rebuild the staticgeometry on realtime, is that possible?The only way to cut down on draw calls is to group the entities together. Either by using StaticGeometry
how can i do that?or fusing the entities into a larger entity.
is it done with addsubmesh?
if i do that does the fps drop, or is it rendered as 1 single mesh, which the fps goes up?
Re: static geometry vs grouped entities in a node
i will show you this 10000 entities attached to one parent. it is acceptable on my system and may be too slow for who don't have a dedicated graphics card. but more something like 20000 entities will degrade the system too much. if we press 2 the 10th cube will detached, if we press w it will be attached again. i find this extremely amusing. mixing large static geometry scenes with such smaller constructs using AttachEntityObject can do the job in making huge cities.
Code: Select all
; PureBasic - Text3D
;
; (c) 2012 - Fantaisie Software
;
; ------------------------------------------------------------
;
IncludeFile "Screen3DRequester.pb"
If InitEngine3D()
Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive("Data/fonts", #PB_3DArchive_FileSystem)
Parse3DScripts()
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
CreateCube(0, 2)
CreateCube(1, 2)
CreateMaterial(0, LoadTexture(0, "Caisse.png"))
CreateMaterial(1, LoadTexture(1, "Wood.jpg"))
CreateEntity(0, MeshID(0), MaterialID(0), 0,-7,0)
For i=1 To 10000
CreateEntity(i, MeshID(1), MaterialID(1),i+1,i+Sin(i+2),i+1)
;ScaleEntity(0, 1/5, 1/5, 1/5)
AttachEntityObject(0, "", EntityID(i))
Next
CreateText3D(0, "Hello world")
Text3DColor(0, RGBA(255, 0, 0, 255))
Text3DAlignment(0, #PB_Text3D_HorizontallyCentered)
AttachEntityObject(0, "", Text3DID(0))
AttachEntityObject(0, "", EntityID(1))
;AttachEntityObject(0, "", EntityID(1) , 6, 5, 6, 45, 0, 0)
;ScaleEntity(1, 1, 5, 1)
MoveText3D(0, 0, 2, 2)
RotateEntity(0, 0, -70, 0)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 0, 40, #PB_Absolute)
Repeat
Screen3DEvents()
ExamineKeyboard()
If KeyboardReleased(#PB_Key_1)
DetachEntityObject(0, Text3DID(0))
ElseIf KeyboardReleased(#PB_Key_2)
DetachEntityObject(0, EntityID(10))
ElseIf KeyboardReleased(#PB_Key_W)
AttachEntityObject(0, "", EntityID(10),0,0,0,0,0,0)
ElseIf KeyboardReleased(#PB_Key_Q)
AttachEntityObject(0, "", Text3DID(0))
EndIf
RotateEntity(0, 0, 1, 0, #PB_Relative)
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
EndRe: static geometry vs grouped entities in a node
i should add a reference to the brilliant example by DK_PETER :Another simple Static geometry example http://www.purebasic.fr/english/viewtop ... 36&t=55981
it is an example of building a whole city instantaneously. once it is built we can't change it unless we free it and build it again almost instantaneously.
use the mouse and the keys W_A_S_D for move and rotate
i should do more testing with static geometry
regarding addsubmesh i think it is possible, i will search more.
it is an example of building a whole city instantaneously. once it is built we can't change it unless we free it and build it again almost instantaneously.
use the mouse and the keys W_A_S_D for move and rotate
i should do more testing with static geometry
regarding addsubmesh i think it is possible, i will search more.
Re: static geometry vs grouped entities in a node
thank you for your reply!
i did some tests with your code and indeed it doesnt improve the fps with AttachEntityObject:
with AttachEntityObject --> 10.000 objects = 30fps. 7500 = 40 fps. 5000 = 60fps. takes a few seconds to load
without AttachEntityObject --> 10.000 objects = 30fps. 7500 = 41 fps. 5000 = 60fps. and instant to load
so theres no fps gain with using AttachEntityObject
but its very useful when iam going to make for example: if they can make cars, and moving things.
i tested the example from DK_PETER and thats a really wonderful example. and i think thats the way to go.
if i can really rebuild it if a add pieces to it, and maybe have more than one static geometry in one world (so i can limit the pieces in one static geometry, so i need only rebuild that static geometry instead of the whole world)
can i build more than 1 static geometry in one world? because it is crazy to rebuild something what has 50.000 objects in it.
and can i select one single object in a static geometry to change it?
my best scenario would be, that the objects are sort of single pieces, grouped in a static geometry and that i can 'grab' a single piece to delete or add them. (with mousepick?)
i think thats not possible with static geometry (because its now one object right?).
to solve that i thought to have more than 1 static geometry's and if you get close to that sector its getting build up in loose pieces, than you can build whatever you want, and if you go away from it, its getting rebuild in static geometry again. is this a good approach?
i did some tests with your code and indeed it doesnt improve the fps with AttachEntityObject:
with AttachEntityObject --> 10.000 objects = 30fps. 7500 = 40 fps. 5000 = 60fps. takes a few seconds to load
without AttachEntityObject --> 10.000 objects = 30fps. 7500 = 41 fps. 5000 = 60fps. and instant to load
so theres no fps gain with using AttachEntityObject
but its very useful when iam going to make for example: if they can make cars, and moving things.
i tested the example from DK_PETER and thats a really wonderful example. and i think thats the way to go.
if i can really rebuild it if a add pieces to it, and maybe have more than one static geometry in one world (so i can limit the pieces in one static geometry, so i need only rebuild that static geometry instead of the whole world)
can i build more than 1 static geometry in one world? because it is crazy to rebuild something what has 50.000 objects in it.
and can i select one single object in a static geometry to change it?
my best scenario would be, that the objects are sort of single pieces, grouped in a static geometry and that i can 'grab' a single piece to delete or add them. (with mousepick?)
i think thats not possible with static geometry (because its now one object right?).
to solve that i thought to have more than 1 static geometry's and if you get close to that sector its getting build up in loose pieces, than you can build whatever you want, and if you go away from it, its getting rebuild in static geometry again. is this a good approach?
Re: static geometry vs grouped entities in a node
you can make more than one static geo just add another line CreateStaticGeometry(??,...)
here the example staticGeometry.pb from the examples\3D
CreateStaticGeometry(0, 1000, 1000, 1000, #True)
CreateStaticGeometry(1, 1000, 1000, 1000, #True)
regarding picking a building by a mouse, thats i think not possible.
but in general picking and selecting object is possible , there is an example somewhere in the 3d examples.
regarding the physics with static geo there are some issues look this thread http://www.purebasic.fr/english/viewtop ... 36&t=56002
there is physics possible with static geo if we haven't freed the entities
and as PMV said "StaticGeometry() is from OGRE3D .. for the render-process .. The complete physic stuff is not OGRE, as it is called bullet"
you can use a model made by modeling software and scale it in xyz if you want good collision physics : look my example about stonehenge
here is the official StaticGeometry.pb with 2 worlds of static Geometry.
here the example staticGeometry.pb from the examples\3D
CreateStaticGeometry(0, 1000, 1000, 1000, #True)
CreateStaticGeometry(1, 1000, 1000, 1000, #True)
regarding picking a building by a mouse, thats i think not possible.
but in general picking and selecting object is possible , there is an example somewhere in the 3d examples.
regarding the physics with static geo there are some issues look this thread http://www.purebasic.fr/english/viewtop ... 36&t=56002
there is physics possible with static geo if we haven't freed the entities
and as PMV said "StaticGeometry() is from OGRE3D .. for the render-process .. The complete physic stuff is not OGRE, as it is called bullet"
you can use a model made by modeling software and scale it in xyz if you want good collision physics : look my example about stonehenge
here is the official StaticGeometry.pb with 2 worlds of static Geometry.
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - Static Geometry
;
; (c) 2012 - Fantaisie Software
;
; ------------------------------------------------------------
;
IncludeFile "Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
Define nx.f, nz.f, Boost.f = 10, Yaw.f, Pitch.f
If InitEngine3D()
Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive("Data/Scripts",#PB_3DArchive_FileSystem)
Parse3DScripts()
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
WorldShadows(#PB_Shadow_Additive)
AmbientColor(0)
; node for Light and Billboard (Sun)
CreateNode(0, 0, 3000, 0)
;Create light
CreateLight(0, RGB(90, 105, 132), 0, 3000, 0)
AttachNodeObject(0, LightID(0))
; Create flare
GetScriptMaterial(0, "Scene/burst")
CreateBillboardGroup(0, MaterialID(0), 2048, 2048)
AddBillboard(0, 0, 0, 3000, 0)
AttachNodeObject(0, BillboardGroupID(0))
; Static geometry
;
; Create Entity
CreateCube(0, 1)
CreateEntity(0, MeshID(0), #PB_Material_None)
; Create Static geometry
CreateStaticGeometry(0, 1000, 1000, 1000, #True)
For z = -10 To 10
For x = -10 To 10
AddStaticGeometryEntity(0, EntityID(0), x * 1000, 0, z * 1000, 1000, 10, 1000, 0, 0, 0)
Height.f = 200 + Random(800)
AddStaticGeometryEntity(0, EntityID(0), x * 1000, Height/2, z * 1000, 200, Height, 200, 0, Random(360), 0)
Next
Next
; Build the static geometry
BuildStaticGeometry(0)
CreateStaticGeometry(1, 1000, 1000, 1000, #True)
For z = 10 To 30
For x = 10 To 30
AddStaticGeometryEntity(1, EntityID(0), x * 1000, 10, z * 1000, 1000, 10, 1000, 0, 0, 0)
Height.f = 200 + Random(800)
AddStaticGeometryEntity(1, EntityID(0), x * 1000, Height/2, z * 1000, 200, Height, 200, 0, Random(360), 0)
Next
Next
; Build the static geometry
BuildStaticGeometry(1)
FreeEntity(0)
; Camera
;
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 2000, 2000, 2000, #PB_Absolute)
;CameraLookAt(0, 0, 0, 0)
RotateCamera(0,0,-110,0,#PB_Relative)
CameraRange (0, 2, 5000)
CameraFOV (0, 90)
CameraBackColor(0, RGB(90, 105, 132))
Repeat
Screen3DEvents()
If ExamineMouse()
Yaw = -MouseDeltaX() * 0.05
Pitch = -MouseDeltaY() * 0.05
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Up)
MoveCamera(0, 0, 0, -2 * Boost)
ElseIf KeyboardPushed(#PB_Key_Down)
MoveCamera(0, 0, 0, 2 * Boost)
EndIf
If KeyboardPushed(#PB_Key_Left)
MoveCamera(0, -2 * Boost, 0, 0)
ElseIf KeyboardPushed(#PB_Key_Right)
MoveCamera(0, 2 * Boost, 0, 0)
EndIf
EndIf
; Sun
nx = 10000 * Cos(ElapsedMilliseconds() / 2500)
nz = 10000 * Sin(ElapsedMilliseconds() / 2500)
MoveNode(0, nx, 3000, nz, #PB_Absolute)
RotateCamera(0, Pitch, Yaw, 0, #PB_Relative)
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
EndRe: static geometry vs grouped entities in a node
ah okay, thank you for the example. the reason i asked about the creating more than one static geometry was that i read somewhere it was not possible. or that was a bug. but it seems solved.
but if i come close to that static geometry, and i delete the static geometry, and replace it for loose pieces (than i can use the normal mouse picking) and after that i rebuild the static geometry. that should do the trick right?regarding picking a building by a mouse, thats i think not possible.
Re: static geometry vs grouped entities in a node
in fact i was about to post an edit about this resembles your idea , ie making a static geometry as a fake construct for the geometry graphics only rendering, then overlapping it with a real entities such as 1000 will not harm the performance, consider it the important buildings such as hospitals, schools, cinemas, etc. then you can pick it as normal saying this is a cinema ... etc.
you can give it physics and weight, and at the ground of the static geometry put a plane or better a big cube scaled down on the y coordinate and add physics to it such as EntityPhysicBody(0,#PB_Entity_StaticBody,1,0,5.0) so it will not fall by the gravity.
now to surround object with a box look the example EntityBoundingBox.pb , and to pick a point in 3d space look example PointPick.pb, also the example MousePick.pb will show you whats is the entity number if you click on it. so cooking all these ideas i think you can click on a cinema building and then surrounding it by a box.
use extensively some search utility to search the examples which contains some function.
you can give it physics and weight, and at the ground of the static geometry put a plane or better a big cube scaled down on the y coordinate and add physics to it such as EntityPhysicBody(0,#PB_Entity_StaticBody,1,0,5.0) so it will not fall by the gravity.
now to surround object with a box look the example EntityBoundingBox.pb , and to pick a point in 3d space look example PointPick.pb, also the example MousePick.pb will show you whats is the entity number if you click on it. so cooking all these ideas i think you can click on a cinema building and then surrounding it by a box.
use extensively some search utility to search the examples which contains some function.
Re: static geometry vs grouped entities in a node
iam gonna experiment with the new info. i have now a good picture in my head how to do it and with what i need to do it. it takes some time for me to build it, because its gonna be the first 3D project in this engine 
thank you for your replys!
thank you for your replys!
Re: static geometry vs grouped entities in a node
T4r4ntul4 wrote:iam gonna experiment with the new info. i have now a good picture in my head how to do it and with what i need to do it. it takes some time for me to build it, because its gonna be the first 3D project in this engine
thank you for your replys!
ApplePi has brought forth some good pointers and it sounds like a good project.
I've been messing around with static geos on and off.
My current wishlist for Static geometry would be:
1. The ability to move the entire static geometry in 3D space. (StaticGeometry::Region?)
2. the ability to 'unlock' the geometry for adding and removing..
I believe, that these wishes are already in the feature request...
Have fun with your project
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
Re: static geometry vs grouped entities in a node
What is needed is not "static geometry" ... it is "instanced geometry" that
is not implemented in PB-OGRE until now.
http://www.purebasic.fr/english/viewtop ... =3&t=55995
Or maybe "paged geometry":
http://www.purebasic.fr/english/viewtop ... =3&t=55996
The batch-count will just be one for all duplicated meshes!
For entities, that are using different mesh-files, it will not help.
So you can make one static geometry per "mesh-file" and
maybe thats how you can remove and add a complete
static geometry without to much performance lags.
Btw. there was a bug in PB implementation of static geometry,
that prevented us to create more then one, but it should be
fixed already and you can create as much as you want.
MFG PMV
is not implemented in PB-OGRE until now.
http://www.purebasic.fr/english/viewtop ... =3&t=55995
Or maybe "paged geometry":
http://www.purebasic.fr/english/viewtop ... =3&t=55996
The batch-count will just be one for all duplicated meshes!
For entities, that are using different mesh-files, it will not help.
So you can make one static geometry per "mesh-file" and
maybe thats how you can remove and add a complete
static geometry without to much performance lags.
Btw. there was a bug in PB implementation of static geometry,
that prevented us to create more then one, but it should be
fixed already and you can create as much as you want.
MFG PMV

