Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Vertex and Surface commands?

Author
Message
Rick Nasher
7
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 3rd Mar 2018 10:06 Edited at: 3rd Mar 2018 10:14
Hi guys,

Apparently some Blitz3/Max users feel reluctant to step over to AppGameKit for it's missing some features they like, especially things like this:

Quote: "
CreateMesh([parent])
Parameters
parent (optional) - This optional parameter allows you to specify another entity which will act as the parent to this mesh.

Description
Create a 'blank' mesh entity and returns its handle.

When a mesh is first created it has no surfaces, vertices or triangles associated with it.

To add geometry to this mesh, you will need to:

CreateSurface() ; To make a surface
AddVertex ; You will need to add at least 3 to make a Triangle
AddTriangle ; This will add a triangle by connecting the Vertices (points) you added to the mesh.
"

Example:


Is there an equivalent in AppGameKit that we can use to simulate this? From what I've seen there are of course the Memblock commands such as:

•CopyMemblock ( memSrcID, memDstID, srcOffset, dstOffset, size )
•CreateMemblock ( memID, size )
•DeleteMemblock ( memID )
•GetMemblockByte ( memID, offset )
•GetMemblockByteSigned ( memID, offset )
•GetMemblockExists ( memID )
•GetMemblockFloat ( memID, offset )
•GetMemblockInt ( memID, offset )
•GetMemblockShort ( memID, offset )
•GetMemblockSize ( memID )
•GetMemblockString ( memID, offset, length )
•SetMemblockByte ( memID, offset, value )
•SetMemblockByteSigned ( memID, offset, value )
•SetMemblockFloat ( memID, offset, value )
•SetMemblockInt ( memID, offset, value )
•SetMemblockShort ( memID, offset, value )
•SetMemblockString ( memID, offset, value )
•CreateFileFromMemblock ( filename, memID )
•CreateMemblockFromFile ( filename )
•CreateImageFromMemblock ( imageID, memID )
•CreateMemblockFromImage ( imageID )
•AddObjectMeshFromMemblock ( objID, memID )
•CreateMemblockFromObjectMesh ( objID, meshIndex )
•CreateObjectFromMeshMemblock ( memID )
•GetMeshMemblockVertexAlpha ( memID, vertexIndex )
•GetMeshMemblockVertexBlue ( memID, vertexIndex )
•GetMeshMemblockVertexGreen ( memID, vertexIndex )
•GetMeshMemblockVertexNormalX ( memID, vertexIndex )
•GetMeshMemblockVertexNormalY ( memID, vertexIndex )
•GetMeshMemblockVertexNormalZ ( memID, vertexIndex )
•GetMeshMemblockVertexRed ( memID, vertexIndex )
•GetMeshMemblockVertexU ( memID, vertexIndex )
•GetMeshMemblockVertexV ( memID, vertexIndex )
•GetMeshMemblockVertexX ( memID, vertexIndex )
•GetMeshMemblockVertexY ( memID, vertexIndex )
•GetMeshMemblockVertexZ ( memID, vertexIndex )
•SetMeshMemblockVertexColor ( memID, vertexIndex, red, green, blue, alpha )
•SetMeshMemblockVertexNormal ( memID, vertexIndex, x, y, z )
•SetMeshMemblockVertexPosition ( memID, vertexIndex, x, y, z )
•SetMeshMemblockVertexUV ( memID, vertexIndex, u, v )
•SetObjectMeshFromMemblock ( objID, meshIndex, memID )

These can be used to manipulate an existing mesh, but can we also build one from scratch in a simple fashion as we could in the Blitz3D example?
(if not, then perhaps this should become a feature request, for would win potential users/customers)
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 3rd Mar 2018 10:35
In theory you could build one from scratch by just creating the memblock and then writing all the data, but I've never managed to get anywhere with this given the tutorial. I can get the vertex count etc, but they don't match modelling apps. Would live to see someone manage to decipher an object memblock.
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 3rd Mar 2018 12:57 Edited at: 3rd Mar 2018 15:50
In the Minecraft clone thread for example I posted code to create separate faces for cubes from memblock it can also be used to generate all sorts of models.
This is the important part:

In the CreateFace() function I set the vertex position, normal an uv coordinate for every vertex of one side of the cube.

You need these steps:
1. MemblockID=CreateMeshMemblock() // generate the mesh
2.
- SetMemblockVec3(MemblockID,VERTEX_OFFSET+0,0,0,0) // set Vertex position (you can also use SetMeshMemblockVertexPosition() here)
- SetMemblockVec3(MemblockID,VERTEX_OFFSET+3*4,0,1,0) // Normals
- SetMemblockVec2(MemblockID,VERTEX_OFFSET+6*4,0,0) // UV
3. SetMemblockInt(MemblockID,IndexOffset+0*4,0) // (optional) set the indices
4. ObjectID=BuildMeshMemblock(MemblockID) // finish and return the object ID

[Edit] I wonder how we are supposed to remove a mesh from an object previously added with AddObjectMeshFromMemblock[/Edit]
Rick Nasher
7
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 3rd Mar 2018 20:51
Many thanks for the replies Santman and janbo.

Quote: "[Edit] I wonder how we are supposed to remove a mesh from an object previously added with AddObjectMeshFromMemblock[/Edit]"

You've got a good point there. No delete options in memblock commands, except DeleteMemblock, which makes it kinda difficult.
TomToad
6
Years of Service
User Offline
Joined: 6th Jan 2018
Location:
Posted: 5th Mar 2018 21:01
Here's some code for creating a simple triangle.


the only way I can see to delete a mesh is to delete the entire object, then rebuild it from scratch.
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 5th Mar 2018 23:04 Edited at: 6th Mar 2018 09:25
Id say that hardcoding in the float offsets is not a great idea for readability of code.

Id recommend using the Vertex functions (even if it is maybe slightly slower)
SetMeshMemblockVertexPosition( )
SetMeshMemblockVertexNormal( )
SetMeshMemblockVertexUV( )




Its not that hard really once you get round all the attributes and layout of the memblock.

You can use the memblock functions to set a mesh to just have a single triangle in it with zero area (all vertices to be 0.0) so nothing is shown on screen. Ok, its not a true mesh delete (which we should have) but its close. Unfortunately setting the number of triangles in the memblock to zero causes an error so cant be used to effectively delete the mesh. The command to do it would be good.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 6th Mar 2018 10:13
Quote: "Blitz3D"

i agree to this, some simple 3d functions will be a good improvement.


AGK (Steam) V2017.12.12 : Windows 10 Pro 64 Bit : NVIDIA (390.65) GeForce GTX 1050 Ti : Mac mini OS High Sierra (10.13)
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Mar 2018 11:00
One thing that was added to DBPro I really liked was the vertex locking commands. You could take an object, lock its vertices then modify them, then unlock the object. It was even possible to do vertex modifications with animated models.

I do use the memblock mesh commands for a terrain, allows realtime modifications, digging etc - but it would be great to be able to quickly modify a mesh without having to rebuild it.
The code is dark and full of errors
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 6th Mar 2018 11:26
Quote: "I do use the memblock mesh commands for a terrain, allows realtime modifications, digging etc - but it would be great to be able to quickly modify a mesh without having to rebuild it."


You don't have to rebuild it from scratch every time...you can just create a memblock from the mesh after loading then do multiple changes to the memblock and apply the changes while keeping the memblock around for future changes

Locking (similar to)= CreateMemblockFromMesh() - You dont have to do this every single time...you can hang on to this memblock and modify it again and again....

Unlock (similar to)= SetObjectMeshFromMemblock() - call it after each change that you want to commit.


It wouldnt be hard to wrap functions for createsurface, addvertex & addtriangle if people wanted it.
I like the memblock system as it allows you to control vertex attributes and potentially use some amazing shaders rather then the older fixed function system/pipeline.
Rick Nasher
7
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 6th Mar 2018 17:45
@Bengismo:
Quote: "You don't have to rebuild it from scratch every time...you can just create a memblock from the mesh after loading then do multiple changes to the memblock and apply the changes while keeping the memblock around for future changes
"


Wouldn't this mean keeping the block in memory and wasting (a bit of) space?
puzzler2018
User Banned
Posted: 6th Mar 2018 19:01
How about:-

- Build a map from a type array with offset / vertices / normals/ uv data into an expanding array

- create the object mesh from that array

- if add / remove any objects in game play, then adjust the data in the array and only adjust the memblock for that particular object only with the offset/vertices/normal/uv in the array

- Save the whole data array on a load/save game


If this makes any sense then great - if not, then back to the learning



puzzler2018
User Banned
Posted: 6th Mar 2018 20:39 Edited at: 6th Mar 2018 20:42


Thats a theory anyway.
TomToad
6
Years of Service
User Offline
Joined: 6th Jan 2018
Location:
Posted: 6th Mar 2018 22:11
Here is a start on something. Save this as "mesh.agc"

Example of usage. Copy the file "mesh3-1.jpg" from the "AppGameKit\Samples\3D\3D-FirstPersonExample\media" folder to the project media folder for the texture to work, or use your own texture amd change line 78 accordingly.
puzzler2018
User Banned
Posted: 6th Mar 2018 22:17
Top man!!
Rick Nasher
7
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 6th Mar 2018 23:52 Edited at: 6th Mar 2018 23:54
Really great stuff.

Login to post a reply

Server time is: 2024-11-27 14:36:20
Your offset time is: 2024-11-27 14:36:20