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 / Is it possible to make a meshmemblock of mutiple indices

Author
Message
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 5th Apr 2018 03:30 Edited at: 12th Apr 2018 20:10
This has been puzzling me but I know a single mesh can have multiple indices and creatememblockobjectmesh
only copies one index so what I want to do is to make one memblock with all of the data of the mesh

below is the function I got atm but it doesn't work so any help would be greatly appreciated


It is supposed to return a memblock which I then use CreateObjectFromMeshMemblock(newMem )
fubar
puzzler2018
User Banned
Posted: 5th Apr 2018 10:33 Edited at: 5th Apr 2018 10:46
Are you sure you mean indices - they are part of the triangle which cuts down the memory to the gpu - shared or non shared points.

Or do you mean mesh index per object mesh?

It looks like your copying per mesh per object there

Am I thinking that if an object has multpile indexes say 6 indexes - you wish to "merge" not copy all of them together into the first index ( 1 )

Or do you wish to copy each mesh index into one memory object joined at the end


<------ Mesh Index 1-------><---------Mesh Index 2-----------><------------MeshIndex 3------------>etc


and write that out to a binary file or something for later use?

note:- Bearing in mind a memblock as a limit of 10000000
puzzler2018
User Banned
Posted: 5th Apr 2018 10:53
This is a very neat idea thinking about it - cause what could do is have many objects - say a cube, a cone, a cylindar, an .obj blenderj file - or just about any object and add them all to a single mesh

This could have a future...

For example -- https://forum.thegamecreators.com/thread/221462
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 5th Apr 2018 11:19 Edited at: 12th Apr 2018 20:11
Quote: " do you wish to copy each mesh index into one memory object joined at the end"


Yes so you have one memblock that could store all of the data
I was even thinking save the object and read the data into a memblock but the save object don't work yet

the main advantage that I want is to have one terrain block (made of multiple meshes) that I could modify on the fly
ie create craters etc, I had a game I desperately wanted to do that with in the past but couldn't

but joining objects could also be very good but may be a bit harder

here is what I have that modifies the texture of a terrain now I want to be able to modify individual vertex positions


It uses the perlin map to create a starter map and texture now I know I could
modify the height map texture save it and recreate the object from the texture
but I want to do it on the fly for explosions etc
fubar
puzzler2018
User Banned
Posted: 5th Apr 2018 11:53
Wow- really nice work

The modification of vertex points is nearly there but crashes cause your using the GetMemblockSize to get the maximum amount of vertices

Maybe retreive the vertice count on the object instead - which is the first byte of the memblock and use that instead of GetMemblocksize


count = GetMemblockInt(msblk, 0)




to




Maybe....
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 5th Apr 2018 12:30 Edited at: 5th Apr 2018 12:38
That prob helps I had it set so many ways that was just a test so I tried just increasing them by 10
but the main issue is that I really only want one terrain memblock but may have to have an array
of memblocks

Which gets me back to my createMapMemblock function which don't work
fubar
puzzler2018
User Banned
Posted: 5th Apr 2018 12:40
Im still trying to get to grips on what your trying to achieve.

Is it this type of thing?

Mesh 1 - terrain
All subsequent meshes uses the same vertex persitions as the Terrain Mesh, so the following can be created on the same vertex heights as Mesh 1

Mesh 2 - roads

Mesh 3 - explosions

Mesh 4 -- buildings

Mesh 5 - Water flow

Etc
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 5th Apr 2018 12:50
Its prob my lack of understanding and explanation

but one terrain object has several indices so
mem1 = CreateMemblockFromObjectMesh(newobj,0)
mem2 = CreateMemblockFromObjectMesh(newobj,1)
mem3 = CreateMemblockFromObjectMesh(newobj,2)
.
.
.
in effect i want mem=mem1+mem2+mem3
unfortunately we cant CreateMemblockFromObjectMesh(newobj,-1)

fubar
puzzler2018
User Banned
Posted: 5th Apr 2018 12:55
I think its my lack of understanding too, so i have just had a quick look at CreateObjectFromHeightMap

The Split value on here indicates how many meshes are involved on the resulting heightmap object

and you potentially want to copy all those 16 splits - so thats 256 meshes

Forgive me for my lack of understanding

Ill have a think this afternoon
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 5th Apr 2018 13:01
Thanks

Image Memblocks are confusing enough
fubar
puzzler2018
User Banned
Posted: 5th Apr 2018 13:10
Or how about make the command

TerrainObjectID=CreateObjectFromHeightMap( "height.png", mapX,mapY, mapZ, 1, 16 )

to

TerrainObjectID=CreateObjectFromHeightMap( "height.png", mapX,mapY, mapZ, 1, 1 )

then can change the vertex positions on the 1st mesh, (1)



Its not doing what I would like to expect it to do, but at least its a step forward to change vertex's
Santman
7
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 5th Apr 2018 16:14
Just as a shout out, set the split to 0 to only have a single mesh.
puzzler2018
User Banned
Posted: 5th Apr 2018 16:45
Nice input

Also, if change code at line 95



Then get something pretty close to what maybe trying to acheive

Its all out of alignment,, so need to figure that out - but at least vertices are flattening around the area...

fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 5th Apr 2018 20:43 Edited at: 12th Apr 2018 20:11
Thanks that's an improvement on what I was getting

I think what I need is something like
ind = xPixel# + (yPixel#*numberIndicesAcrossXplane)
SetMeshMemblockVertexPosition(TerrainMemblock,ind,GetMeshMemblockVertexX(TerrainMemblock,ind),GetMeshMemblockVertexY(TerrainMemblock,ind)+1,GetMeshMemblockVertexZ(TerrainMemblock,ind))

The problem with only one mesh the heightmap lacks height variation
That was just an example code I whipped up to demonstrate with and play with but the actual map
I want to use will be quite large

I tidied up what we have


Picture of what I hope to adventually convert from DBPRO or DARKGDK to AGK

The above was a game I made along time ago refurnished in DARKGDK it had animating menuscreen
a continent selector which highlighted as you moused over a map editor and the final pic shows gameplay
The only thing explosions were an animated movie with transparency placed onto a plane that faced
towards the player I dearly wanted to be able to make craters and modify the texture all on the fly. It was
my attempt at a kind of 3d cannonball where the player selected the angles and held space to control the
power once space was released it fired the missile at the angles and power.
fubar
puzzler2018
User Banned
Posted: 5th Apr 2018 21:36
Cool - a step in the right direction

Although your forumla would work great for images, im not sure for memblocks, i think its something along

Ind=vertexDataOffset+(vertexIndex*vertexSize)

I maybe talkinig cods wallop though - as I been trying most ways most of the day to figure the formula out - and it will come to me soon.

This is a very neat trick and idea once again, and can further develop something similar to Minecraft too and use 1 x 1 block principle to get the world coordinates and add / remove vertices on that point.

Good man!!

PS. You past developments looks really good too - well done.

puzzler2018
User Banned
Posted: 5th Apr 2018 21:42 Edited at: 5th Apr 2018 21:43
Something tells me that a vertice as a number count

Can use this to remember the codes

SetMemblockInt(chk,0,12) // Vertice Count
SetMemblockInt(chk,4,3) // Indices
SetMemblockInt(chk,8,3) // Attributes
SetMemblockInt(chk,12,32) // Vertice Off
SetMemblockInt(chk,16,60) // Vertice size
SetMemblockInt(chk,20,0)
SetMemBlockInt(chk,24,0x0C000300) //float, 3 components, no normalizing, position
SetMemblockString(chk,28,"position")
SetMemblockInt(chk,40,0x08000300) //same as position, but for normals
SetMemblockString(chk,44,"normal")
SetMemblockInt(chk,52,0x08010401) //For color we have byte, 4 components, normalize data
SetMemblockString(chk,56,"color")



So if we use GetMemblockInt(memblock, <number> ) then can get each of those values

Number been 0, 4, 8, 16, 20 etc for the different values we need from the memblock created than this is goood

Hope this guides you well
puzzler2018
User Banned
Posted: 5th Apr 2018 21:52 Edited at: 5th Apr 2018 21:53
Try


Closer..
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 5th Apr 2018 21:52
Quote: "Ind=vertexDataOffset+(vertexIndex*vertexSize)"

Il have to try that lol tried everything else (sometimes I'm sure after trying things I get more confused prob why
my asks get confusing)

Quote: "PS. You past developments looks really good too - well done."

Thanks I would like to do something similar with AppGameKit at the moment but I cant even get the models to load proper
for the time being. Ide go back to my original C++ code with darkGDK and work on that but its a pain and with newer
versions of directX caused the menu screen to not animate and the explosion i did have to lost transparency.

DarkGDK is available free if your looking for another development tool in c++ by TGC. Ide also share my source for
killerskuds to anyone that is interested but i did purchase a 3dmath library which AppGameKit has allot of the functions
already available. The other thing is i cant share the models. But most textures thats a dif story.
fubar
puzzler2018
User Banned
Posted: 5th Apr 2018 21:57
We have to try and figure out how the memblock is constructed,

Quote: " // index of this vertex is (Vertices start back left and go right then down to next line etc...."


Its perfectly ok to be confused - i am stiill confused with 3D,I wouldnt worry, all this is a learning experience and once cracked the code, then we will all be genuises with AGK
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 5th Apr 2018 21:58
Quote: "i=((xpixel#) + (((yPixel#)*mapX)))/512"


Definitely looks closer the modifications on the x of the grid seem right
fubar
puzzler2018
User Banned
Posted: 5th Apr 2018 22:00
Im not sure where the 512 came from - just experimenting, just have to work that formula out - ill post my findings when i have something that resembles a meaning full value - after working out how its constructed in 1st place



All good!!
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 5th Apr 2018 22:53 Edited at: 12th Apr 2018 20:12
yeh definitely need to understand how memblocks are created

Still not there might have to dump the memblock to a textfile to understand a little better
I was thinking if its 2048 * 1024 the xmax must be twice the size of ymax think I'm way off
fubar
puzzler2018
User Banned
Posted: 5th Apr 2018 22:58
Im thinking

print("Per Vertices " + str(Mapx * MaPY / GetMemblockInt(TerrainMemblock,0))) = 25
print("Per Vertices on X " + str((Mapx * MaPY / GetMemblockInt(TerrainMemblock,0)) * MapX)) = 51200
numverts# = (((MapX * MapY) / GetMemblockInt(TerrainMemblock,0)) * MapX)

So, in this case - Vertices is 25 - on the X (numverts = 51200)

all youll see in textfile is lots of numbers or garbage binary data and just be too difficult to fathom out

We have to think these X and Y values been floats and the vertices to the function is an int so maybe need round or floor too

puzzler2018
User Banned
Posted: 5th Apr 2018 23:10
I bet others are *screaming* at us to get the correct formulae lol

We will get it - just need to figure the formula out and understand how and why it works when we've found it and can move onto greater 3D achievements.
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 5th Apr 2018 23:18 Edited at: 5th Apr 2018 23:25
HAHAAHAHA I'm going back to preschool maths that's easier lol

Thanks for your help this should help with minecraft when its done too

I don't see why there would be a different number of vertices on the x as we are thinking
so I'm sure were close anyway I need food lol got up way too early

The SQR of the max of indices so I thought a percentage of that ie
if the Square Root came to 10 total being 100 then 14 & 7 equals 98

fubar
puzzler2018
User Banned
Posted: 5th Apr 2018 23:32 Edited at: 5th Apr 2018 23:35
Lol - bring me 2 + 2 = 5 again that would be so awesome.

All im thinking is

offset=vertexDataOffset+(vertexIndex*vertexSize)

with the following

Vertices = GetMemblockInt(TerrainMemblock,0)
Vertices Size = GetMemblockInt(TerrainMemblock,12)
Vertices Offset = GetMemblockInt(TerrainMemblock,16)
Per Vertices on X = Mapx * MaPY / GetMemblockInt(TerrainMemblock,0)) * MapX)

VertexIndex will be the calculation with the XPixel# and yPixel somehow

VertexIndex = Vertex Data Offset + ( floor((xPixel# + (yPixel# * mapx)) * VertexSize)

Im really not sure why but should work with these values somehow constructed in this way

Mind boggling its making my eyes water, time for a coffee
puzzler2018
User Banned
Posted: 5th Apr 2018 23:45 Edited at: 5th Apr 2018 23:46
But then I dont think need to worry about that

//offset=vertexDataOffset+(vertexIndex*vertexSize)

We would use this formulae when we hard code directly iinto a memblock -

As we using SetMeshMemblockVertexPosition function, it will do it all for us automatically

We just need to worry about Vertices starting at 0

Sorry for leading you up the garden path with that theory
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 6th Apr 2018 00:23 Edited at: 12th Apr 2018 20:12
Theres 40000 vertices
so
maxX=(SQRT(GetMemblockInt(TerrainMemblock,0)))*1.5
maxY=(SQRT(GetMemblockInt(TerrainMemblock,0)))*.75

calculates a maxX=300 and maxY=150
300*150 =45000 closer but no banana

anyway this is what I changed should work no idea why not lol


looks as tho an array may be needed
fubar
puzzler2018
User Banned
Posted: 6th Apr 2018 00:36 Edited at: 6th Apr 2018 00:42
Me think too and a perfect answer!!



Add them in the perlin map creation function with



just need to work out the world position index (verticescounter)

if hit it, then change those values and update the terrain at those positions accordingly

re-write the memblock with the new position variables - but only on that position otherwise fps will sink

so may need to use the .find function on the array somehow
puzzler2018
User Banned
Posted: 6th Apr 2018 00:41
Maybe not .find but maybe now can use

Index = XPixel# + (YPixel# * MapWidth)

Dec Vertices[index].y , 1

ReWriteTerrain ( index )

puzzler2018
User Banned
Posted: 6th Apr 2018 01:09 Edited at: 6th Apr 2018 01:12
Or could reduce the memory allocation by just concentrating on height only



and rewrite function



Im gettig tired
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 6th Apr 2018 01:18 Edited at: 12th Apr 2018 20:13
Yeh you should sleep I'm very thankful for all your help

I'm thinking now the problem with the formula
x=xPixel#/(mapX/maxX):z=(yPixel#)/(mapZ/MaxZ)

is yPixel# increases on the zplane when it should decrease
a very rough work around is as follows


and that's close as now it moves along the z plane correctly

but get some rest I'm going to go do some stuff in real anyway but once again thanks
fubar
puzzler2018
User Banned
Posted: 6th Apr 2018 01:20
No probs - catch up tomorrow

Ill have a really good dream on the original formula

fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 6th Apr 2018 07:11 Edited at: 12th Apr 2018 20:13
anyway this what I got


which is close but still doesn't line with the texture modifying
so may have to do it with arrays during the perlin map creation
fubar
puzzler2018
User Banned
Posted: 6th Apr 2018 09:44 Edited at: 6th Apr 2018 09:52
Ive added height arrays

and adjusted

maxZ=(SQRT(GetMemblockInt(TerrainMemblock,0)))*.75

to
maxZ=(SQRT(GetMemblockInt(TerrainMemblock,0)))*.95

and added a little bit on the X axis from -5 to 5 - to make it look something like terrain height generating



looking promising everytime
puzzler2018
User Banned
Posted: 6th Apr 2018 10:33
Even closer by adding /1.2

yPixel#=screenHeight-yPixel#/1.2




Hope its helps
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 6th Apr 2018 14:05
Thanks Puzzler The height arrays do show it working allot better
fubar
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 6th Apr 2018 14:49 Edited at: 6th Apr 2018 15:56
I Just woke up but I like what I see very impressive

Will be heading back to bed again soon

cant work out why the height field lost its smoothing too late for me

but the example works well
back to the original concept of having multiple meshes with smoothing

I think I will have to read the data to store in a memblock and perhaps use arrays
or if could get the world coordinate some other way

Il think on this as it could allow joining of different objects as one of the other threads
is doing this I'm hoping they are willing to share the how to


fubar
puzzler2018
User Banned
Posted: 6th Apr 2018 15:56
Its perfectly ok and you did most of the hard work.. I wouldnt have had a clue to even start that coordinate style system

Glad i could help to refine it a bit more, I dont feel its 100% but its really close

its learnt me well too
puzzler2018
User Banned
Posted: 7th Apr 2018 02:39
Suggested it isnt perfect - but its something to work with.

I only put in on the X axis -5 to 5

so maybe now add a Z -5 to 5

and use perlin data to bring up or down the heights on perlin

Then it will be perfect!
puzzler2018
User Banned
Posted: 7th Apr 2018 03:23 Edited at: 7th Apr 2018 03:47
My good fellow,

Anything I do do on other thread is shared every single time.

If I get to understand anything - I will share so dont worry for me at least.

I think the long term members dont share too easily cause they would have had a tought time figuring out things back in the day for them. and it seems unfair for Santman / Jambo etc to keep
giving their code away.

Its important that we learn the code we develop - so can build on it and become programmers - it persistantly copy code without understanding it - this leads to failures and asking for help

cause in this original code there are rem statements to suggest dont know what the "maketerrain" function does.

//dont understand this function
//ModifyTerrain (TerrainMemblock,2048,1024,100,xPixel#,yPixel#)

and to me there is lots and lots of remarked \\


Lets re-write this whole code to what now know

I dont really like remarked code - its there for a reason - In this little project, its not for what we need to lets flush it all out
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 7th Apr 2018 05:08
If the greyscale height image is saved and then reloaded with createobjectfromheightmap its quite fast and does allow a smoother way of editing
the terrain and can make a really good crater too which so far seem to be the best for a terrain editor. I just wanted a way of modifying memblocks
knowing it would be much faster and if there was allot going on in the background it would drop frame rates so much. Definitely achieved it better
this time with your help puzzler than I did in my old code and from scratch again lol The thing that DBPRO and DarkGDK did have was editing with
dwords and other nice things. I seem to recall a similar problem when trying to modify the terrain with more than one mesh too and the past efforts
which was many years ago mind you had a similar issue modifying an object with multiple meshes on the fly. AppGameKit simplifies this with some lovely
new commands making object modifications easier. The raycasting i found in the help file im not sure why you multiple by the set ammounts etc I
just understand it calculates its z location based on mouse, camera position, and start and end coordinates. Which if the value is too low it doesnt
return a hit.

For those wanting to just make a terrain editor and not being worried if frame rates drop to 10 fps or less when you are building the writePixelMemblock
function could be called by passing the values of a grayscale memblock image see the mem2 variable in generatePerlinImages function and because the
writepixelmemblock function is passed R G B A values it will only increase the terrain height by these ammounts so if for example you are on the side of
the terrain it will only build a little on the hill side etc Then if you update the grey scale image with CreateImageFromMemblock , save the image and then
finally recreate the terrain with CreateObjectFromHeightMap it will make very nice build modification perhaps with left mouse rasing and right mouse
lowering the land

Quote: "ModifyTerrain (TerrainMemblock,2048,1024,100,xPixel#,yPixel#) "
that was a function I found someone posted on how to modify multi meshed
terrain on the fly I was hoping theyd see it and explain as it just shows a function and not how they use it

Remaking code is one way i like to learn how to from my old code I feel its often one way people learn when they see an old game etc and get a desire to rebuild it
Learnt so much about AppGameKit in last week or so and allot of it was inspired by you wanting to build minecraft puzzler

fubar
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 8th Apr 2018 08:27 Edited at: 8th Apr 2018 08:40
Quote: "Hope its helps"


As Creating height Maps with multiple meshes seems a little out of reach if i want to modify the terrain height on the fly
I will try like in my second example https://forum.thegamecreators.com/thread/222010 combining with what we
worked out here puzzler. Creating the textures should just be a matter of grabbing a portion of the image created with the
perlin map and adjusting the the old arrays and new ones needed accordingly. With some luck the ending result will result
in a never ending terrain that can be modified on the fly. with some good framerates hahah i said with luck

Il have a good think about it perhaps while I sleep lol as if the collision is on the edge of the terrain the raising and lowering will
have to include both side by side meshes and will have to be a minimum of 5*5 terrains
fubar
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 1st May 2018 19:07
Ideally I want to be able to use in a game like Scorched Earth but 3D like this version
http://www.scorched3d.co.uk/
fubar

Login to post a reply

Server time is: 2019-05-21 20:46:54
Your offset time is: 2019-05-21 20:46:54