January 22, 2019, 06:04:13 PM

Author Topic: curious about what AGK allows for surfaces (verticescount, trianglescount)  (Read 6132 times)

Offline RemiD

  • Hero Member
  • *****
  • Posts: 800
Hello,

Since some of you guys have a good experience using AGK, can you please give me some infos :

Is it possible to create surfaces, vertices, triangles ?

If yes,
how many vertices, and how many triangles are allowed in a surface ?

With Blitz3d, there is a limit, which is apparently arbitrary, around 32000 vertices and 32000 triangles in a surface, or you can get a "memory access violation" at renderworld().

And this is really really annoying when trying to build 3d environments by assembling premade parts (or generating the parts) with code.

Just curious...

Thanks,
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 1374
Re: curious about what AGK allows for surfaces (verticescount, trianglescount)
« Reply #1 on: February 24, 2018, 11:28:53 PM »
AGK can do this with a mix of memblock mesh commands. I don't know of any limits as the docs make no reference ( that I can see ) to limits.

The is this from one of updates :

Quote
Removed the 2 million vertex limit on meshes, now only limited by memory

https://www.appgamekit.com/documentation/Reference/Memblock.htm

AddObjectMeshFromMemblock
CreateMemblockFromObjectMesh
CreateObjectFromMeshMemblock
GetMeshMemblockVertexAlpha
GetMeshMemblockVertexBlue
GetMeshMemblockVertexGreen
GetMeshMemblockVertexNormalX
GetMeshMemblockVertexNormalY
GetMeshMemblockVertexNormalZ
GetMeshMemblockVertexRed
GetMeshMemblockVertexU
GetMeshMemblockVertexV
GetMeshMemblockVertexX
GetMeshMemblockVertexY
GetMeshMemblockVertexZ
SetMeshMemblockVertexColor
SetMeshMemblockVertexNormal
SetMeshMemblockVertexPosition
SetMeshMemblockVertexUV
SetObjectMeshFromMemblock
Until the next time...

Offline GaborD

  • Full Member
  • ***
  • Posts: 172
Re: curious about what AGK allows for surfaces (verticescount, trianglescount)
« Reply #2 on: February 25, 2018, 01:53:00 AM »
I haven't done much with mesh generation yet, but my first tests worked great.
Can tell you more soon, planning on playing around more with it. Will see if I can reach the limits. :p

Offline RemiD

  • Hero Member
  • *****
  • Posts: 800
Re: curious about what AGK allows for surfaces (verticescount, trianglescount)
« Reply #3 on: February 25, 2018, 07:46:16 AM »
Quote
Removed the 2 million vertex limit on meshes, now only limited by memory
oh ! that would be good  :o
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline Rick Nasher

  • Hero Member
  • *****
  • Posts: 605
Re: curious about what AGK allows for surfaces (verticescount, trianglescount)
« Reply #4 on: February 25, 2018, 09:24:53 AM »
@RemiD

I knew you couldn't resist the 'Dark' side.  ;D
May the source be with you.

Enjoy buddy.
_______________________________________
 B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________

Offline RemiD

  • Hero Member
  • *****
  • Posts: 800
Re: curious about what AGK allows for surfaces (verticescount, trianglescount)
« Reply #5 on: February 25, 2018, 09:34:47 AM »
@Rick>>i am still a BB coder, i am just curious ;)
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline Kronos

  • Jr. Member
  • **
  • Posts: 9
Re: curious about what AGK allows for surfaces (verticescount, trianglescount)
« Reply #6 on: February 25, 2018, 12:38:01 PM »
Could someone do a quick demo of creating a mesh from scratch in AGK because I can't figure it out.

Offline RemiD

  • Hero Member
  • *****
  • Posts: 800
@Kronos>>AGK is apparently the new great language / engine, but still no example to create a simple 3d mesh, you know what i mean ?

a simple mesh in blitzbasic (1 surface, 3 vertices, 1 triangle)
Code: [Select]
Mesh = CreateMesh()
Surface = CreateSurface(Mesh)
V0% = AddVertex(Surface,-0.5,0.0,-0.5)
V1% = AddVertex(Surface,0.0,0.0,0.5)
V2% = AddVertex(Surface,0.5,0.0,-0.5)
AddTriangle(Surface,V0,V1,V2)
UpdateNormals(Mesh)
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline Rick Nasher

  • Hero Member
  • *****
  • Posts: 605
I know what you mean.  :P
But it's a bit of a different philosophy; I guess they figure everyone even remotely serious about game making is using external tools for 3d models, not primitives, in code built meshes etc anyway, and in that light it's working great.

However.. for a people who like to tinker and wanna go down the road of exploration or do things differently then you might have to make a few mind leaps.

Basically afaik everything is possible but you'd use memory blocks to make things in. Similar as banks I guess?

Code examples [deleted due to objection by the original creator]:

Random Texture Creator
Code: [Select]


Or:

Generator Audio
Code: [Select]

So basically you can make use and create all you like, however you can also make requests for commands you find are missing as it is very much in development still.



_______________________________________
 B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________

Offline RemiD

  • Hero Member
  • *****
  • Posts: 800
Thanks for the example to create a texture, can you show us what it outputs ? (or describe it)

In blitzbasic it would be something like :
Code: [Select]
Texture = CreateTexture(width,height,flags) ;flags -> 1: color , 2 : alpha , 4 : mask
SetBuffer(TextureBuffer(Texture))
 ClsColor(000,000,000) : Cls() ;put a black background
 WritePix(X,Y,R,G,B,A) ;write a texel at X,Y of the R,G,B color with A transparency


Quote
I guess they figure everyone even remotely serious about game making is using external tools for 3d models, not primitives
Where have you seen that i use primitives in my games ?
It can be useful to be able to analyze the surface(s), material(s), texture(s), joints/bones, of a mesh and then to create surfaces, vertices, triangles, materials, textures, joints/bones, depending on the datas gathered, and even "serious" unity / unreal users understand that :
->if you want to merge all surfaces which share the same material/texture in one surface one texture (faster to render)
->if you want to merge premade parts in one surface one material one texture (a custom character is made of several premade parts like body, head, hair, clothes, armors...)
->if you want to create a texture atlas and change the vertices uvs (several textures put in one big texture)
->if you want to create meshes made of premade parts, proceduraly (to have different environments, more diversity)
->if you want to add some effects like scratches / blood on the texture of a character or scratches / damages on the texture of a vehicle.
->if you want to create custom effects like volumetric glow, volumetric light rays, glow rects (ala doom3), texels emitting particles...

Really it can be useful...


( i am still waiting for an example to create a simple 3d mesh (1 surface, 3 vertices, 1 triangle) in AGK :P )
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 1374
Quote
( i am still waiting for an example to create a simple 3d mesh (1 surface, 3 vertices, 1 triangle) in AGK :P )
Here's something to shut you up :P - It creates a cube in code.

Written by puzzler2018 on the AGK forums :

Code: [Select]
function createobjectOurOwn()
 
    objfile = OpenToWrite("cube.obj")
    WriteLine(objfile,"v -0.500000 -0.500000 0.500000")
WriteLine(objfile,"v 0.500000 -0.500000 0.500000")
WriteLine(objfile,"v -0.500000 0.500000 0.500000")
WriteLine(objfile,"v 0.500000 0.500000 0.500000")
WriteLine(objfile,"v -0.500000 0.500000 -0.500000")
WriteLine(objfile,"v 0.500000 0.500000 -0.500000")
WriteLine(objfile,"v -0.500000 -0.500000 -0.500000")
WriteLine(objfile,"v 0.500000 -0.500000 -0.500000")
WriteLine(objfile,"vt 0.000000 0.000000")
WriteLine(objfile,"vt 1.000000 0.000000")
WriteLine(objfile,"vt 0.000000 1.000000")
WriteLine(objfile,"vt 1.000000 1.000000")
WriteLine(objfile,"vn 0.000000 0.000000 1.000000")
WriteLine(objfile,"vn 0.000000 1.000000 0.000000")
WriteLine(objfile,"vn 0.000000 0.000000 -1.000000")
WriteLine(objfile,"vn 0.000000 -1.000000 0.000000")
WriteLine(objfile,"vn 1.000000 0.000000 0.000000")
WriteLine(objfile,"vn -1.000000 0.000000 0.000000")
WriteLine(objfile,"s 1")
WriteLine(objfile,"f 1/1/1 2/2/1 3/3/1")
WriteLine(objfile,"f 3/3/1 2/2/1 4/4/1")
WriteLine(objfile,"s 2")
WriteLine(objfile,"f 3/1/2 4/2/2 5/3/2")
WriteLine(objfile,"f 5/3/2 4/2/2 6/4/2")
WriteLine(objfile,"s 3")
WriteLine(objfile,"f 5/4/3 6/3/3 7/2/3")
WriteLine(objfile,"f 7/2/3 6/3/3 8/1/3")
WriteLine(objfile,"s 4")
WriteLine(objfile,"f 7/1/4 8/2/4 1/3/4")
WriteLine(objfile,"f 1/3/4 8/2/4 2/4/4")
WriteLine(objfile,"s 5")
WriteLine(objfile,"f 2/1/5 8/2/5 4/3/5")
WriteLine(objfile,"f 4/3/5 8/2/5 6/4/5")
WriteLine(objfile,"s 6")
WriteLine(objfile,"f 7/1/6 1/2/6 5/3/6")
WriteLine(objfile,"f 5/3/6 1/2/6 3/4/6")
 
CloseFile(objfile)
cube=LoadObject("cube.obj")
endfunction cube
[/quote]
Until the next time...

Offline RemiD

  • Hero Member
  • *****
  • Posts: 800
@Qube>>thanks, but that's not what i have asked, your code example shows how to write datas in an obj file. :P

I will try to search the AGK forum, there must be an example somewhere !

Oups, apparently no result for AGK... ;)

1 result for darkbasic here : https://forum.thegamecreators.com/thread/115155#msg1309221
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline TomToad

  • Sr. Member
  • ****
  • Posts: 346
For creating a mesh, you start by creating a memblock.  You then fill the memblock with all the information about the mesh.  Then you use CreateObjectFromMeshMemblock() to create the 3d object.  You can use SetObjectMeshFromMemblock() to modify an existing object.

More complicated than B3D, but doable.  I'll see if I can knock up an example for you, if I can figure out how to properly fill out the fields :)
Here is an example of modifying an existing mesh.
Code: [Select]
box = CreateObjectBox(10,10,10)
meshmemblock = CreateMemblockFromObjectMesh(box,1)
direction as float = 1.0
time as float
wait as float = 5.0
vertex as integer[2] = [1,19,20]

do
time = GetFrameTime()
RotateObjectLocalX(box,.1)
RotateObjectLocalY(box,.2)
RotateObjectLocalZ(box,.3)
for i = 0 to 2
SetMeshMemblockVertexPosition(meshmemblock,vertex[i],
GetMeshMemblockVertexX(meshmemblock,vertex[i])+direction*time,
GetMeshMemblockVertexY(meshmemblock,vertex[i])+direction*time,
GetMeshMemblockVertexZ(meshmemblock,vertex[i])+direction*time)
next
wait = wait - time
if wait <= 0.0
wait = 5.0
direction = -direction
endif
SetObjectMeshFromMemblock(box,1,meshmemblock)
sync()
loop
------------------------------------------------
8 rabbits equals 1 rabbyte.

Offline Rick Nasher

  • Hero Member
  • *****
  • Posts: 605
@RemiD:
Quote
( i am still waiting for an example to create a simple 3d mesh (1 surface, 3 vertices, 1 triangle) in AGK :P )
I knew of course you were gonna say that..  :D
But if you're waiting for me to do it then it's gonna take a loooong time for I'm far too busy to delve into that.

Quote
Really it can be useful...
No doubt about that.

I'd like to see a few commands like that. Someone said the current approach has to do with opengl/es??



Here are some other interesting threads(unrelated)..

Making a simple Old School Style FPS Game in AppGameKit 2

https://forum.thegamecreators.com/thread/221520?page=2

Landscape shader
https://forum.thegamecreators.com/thread/221599?page=1#msg2619814





@TomToad:
Now there's a nice demonstration of the concept.
This deserves to also be posted on the AGK and also on their Online Commands Help, right here I'd say:
https://www.appgamekit.com/documentation/Reference/Memblock/SetMeshMemblockVertexPosition.htm


_______________________________________
 B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________

Offline RemiD

  • Hero Member
  • *****
  • Posts: 800
@TomToad>>thanks, but apparently your code example shows how to change the positions of the vertices of an existing surface/mesh, but not how to create a new mesh / surface, vertices, triangles.

And from what i understand in the code, a "memblock" in agk, is what we call a "surface" in blitzbasic / unity.
Oh no ! apparently it is different, a memblock is more like a bank, isn't it ? What a mess !  ;D

From what i can read here : https://www.appgamekit.com/documentation/Reference/Memblock.htm

I don't see a command to create a vertex or a triangle, you can get some vertex properties or set some vertex properties, but that's all...

Oh well, back to blitzbasic !
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0