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.

Newcomers AppGameKit Corner / CreateObjectfromMeshMemblock produce a Ghost Plane

Author
Message
SomeBasics
User Offline
Joined: 25th Apr 2024
Location: Germany
Posted: 25th Apr 2024 14:13
Hello, this is my first posting. I have now more then 700 hours counted on steam in Classic and start now with the studio. In hope for regularly Updates.

I have testet around with creating objects via code and found a strange behavior. Creating the object via the CreateObjectFromMeshMemblock produce a single ghosting plane. I set a texture to the first mesh of the object and this ghost plane got the same texture. Don't know if it is a bug in my code or i do understand something wrong of the function. I have created a new simple code example to reproduce this and same happens.

the reason: I try to create clusters of objects with multiple meshes of planes because it doubles the fps to 85. Creating a map with poor planes result in 30 fps and the graphics card don't help and sleeps. This because I want to assign diffrent textures to each plane. Don't if there is a better way to do this.

additional Question: How mush meshes can added to one object? Is it the same count like with highmap creation? 255?

I have compiled it with Studio. First I create a tempory plane for a memblock as template. This plane will immediately deleted after create the memblock of this plane. Then I change the vertex coordinates for each potential mesh of the cluster object in a loop. At first I create the Object with CreateObjectFromMeshMemblock and then add the other meshes with AddObjectMeshFromMemblock. Additional I set a texture for each mesh and the cullmode to 0 for testing.

Is it a bug in my code or in the interpreter? I have no idea what i have done wrong.

SomeBasics
User Offline
Joined: 25th Apr 2024
Location: Germany
Posted: 26th Apr 2024 09:03
After slept a night over the problem, I found out that a plane consists of 12 vertecies and not 6. So a plane is everytime visible from both sides and cull mode have no effect normaly. I only set the verticies for the top side and the cullmode made the bottom side visible from this camera position.

To test I set up the vertex count from memblock after creation and place spheres for every vertex at position of the memblock.

I have no use for this bottom side, so I should create the memblock from scratch instead of using a plane as template. Don't know if this brings fps. On the other hand I could use this 12 verticies for one plane with 4 polygons. But it make no differnce for precision of view. It uses only cpu power. It were good if the graphics card would do something to relieve the cpu usage. Because it's only one Core used for the app with 20 % of the full power.

SomeBasics
User Offline
Joined: 25th Apr 2024
Location: Germany
Posted: 27th Apr 2024 12:17
I search the forum for input and tried to set up a simple plane with only 4 verticies memblock from scratch since yesterday. But I fail for unknown reason. Also the help textwall is very hard to read for me. Don't know why but it crashes at line 144 MultiMeshObject = CreateObjectFromMeshMemblock(MeshMemblock) without a error message. I use the standard methods to set the vertex data,, so it only can be a problem in the header block. Bad that no error message popup. It's like poking in the fog. I have not tried to copie the examples from the old forum threads. Because the header had not the attributes I think I need.

Some simple object creation methods would be nice. I think I rember that the old blitz had such functions to add vetices to blank created objects. So if I get control over this memblock thing, it would work enough for me and I could test further to create map with this method.

I don't know how to find the error if there is no real indication.

ando
4
Years of Service
User Offline
Joined: 21st Feb 2020
Location: Australia
Posted: 27th Apr 2024 21:26
Hi SomeBasics, I had a play with your first code snippet but could not find a solution.

I tried replacing object = createobjectplane(15,15) with object = CreateObjectQuad() which
got rid of the ghost plane but the texture was not working.

I also tried adding some code to see where the verts are and could not find all of the verts. Very strange.

Sorry, not much help.

BASIC appeared in May 1964. Lightning flashed, the wind roared and the Earth moved.
And nine months later I was born.
So here I am.
I am Basic.
Code is in my genes.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 28th Apr 2024 23:12
AGK has a lot of helper function for memblock objects;
Search the commands for GetMeshMemblockVertex and SetMeshMemblockVertex
https://www.appgamekit.com/documentation/search.html
SomeBasics
User Offline
Joined: 25th Apr 2024
Location: Germany
Posted: 29th Apr 2024 02:26
Thx for the comments.

@Ando Hm, I thought quads were only for fullscreen shaders. No Problem, all fine.

@blink0k Yes, I found the helper functions and use them for the attribute settings like position, normal, uv, and color. I found the main error of the last code: I had set the indices as float. But they are Integer. So the hole app crash without warning.

I try now to attach a main file from todays work, because it have > 1400 lines. It works and I have testet it. So it should out of bugs now. If anyone is interested in the code for FPS testing. It creates a clustered map (x,y,z) where each cluster is an object with multiple meshes. I build the Memblock for the mesh from scratch without a template primitive. I hope it's not hard to read. A help is written after the window creation.

It seems so that memblock created objects can have much more then 255 meshes, except the heighmaps. At least it has worked with a 20 x 20 cluster. Or it's an illusion. If some one have an idea how I can get more FPS in this test app, my eyes are wide open to read some ideas to optimize. I target a map of (250,5,250).

So have all a nice day or night.

The typ I need for the mesh memblock to pass by ref.


This function works to create a mesh memblock header. The attributes become added dynamic if they were enabled in TMesh.


The payload functions of the memblock to set the planes and cliffs in the cluster.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-04 22:57:18
Your offset time is: 2024-05-04 22:57:18