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 / Chafari Tricks

Author
Message
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Jan 2019 11:23
Hi there . I open this new thread to put some of my old and new codes that could be useful for someone.

1- Wireframe alternative.







I'm not a grumpy grandpa
puzzler2018
User Banned
Posted: 4th Jan 2019 14:01
Hello


Really nice effects here again

Had to change lines 22 and 23 to

drawbox(0,0,128,128,wt,wt,wt,wt,0)
getimage(1,0,0,128,128)

cause UVWrap doesnt support images that are not Power of 2 - so the next power after 71, 71 your original would be 128

Nice...
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Jan 2019 15:03 Edited at: 4th Jan 2019 15:15
Quote: "Had to change lines 22 and 23 to

drawbox(0,0,128,128,wt,wt,wt,wt,0)
getimage(1,0,0,128,128)"


Thanks for testing ...I know that sould be an image multiple of two, but there was no way to get with code . I was trying to get an image of 64*64 . I normally use the default window resolution and virtual resolution to 1024 * 768 . I red somwhere about this error .
When I draw a box 0,0, 70*70 and get an image of 0,0,71,71 and then I check like this:

Do....
iw=GetImageWidth(1)
ih=GetImageHeight(1)

print("width "+str(iw))
print("height "+str(ih))

It gives me 64*64 ... does it make any sense ?

Edited. I found the way to upload images...so here's one update code



I'm not a grumpy grandpa

Attachments

Login to view attachments
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 4th Jan 2019 18:20
That's Clever
fubar
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Jan 2019 19:22
Thanks mate . Just to not get bored .

2 - Dazzle effect Just aproach to the lights to see the effect


I'm not a grumpy grandpa
puzzler2018
User Banned
Posted: 4th Jan 2019 20:37
Wow chafari - that looks well super cool - i like your methods in creating things like this in such short amount of code.

I would probably try and do this and end up havng 1000 lines of code.

Keep up the good work, your ideas, skillets or programming knowledge is valuable
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Jan 2019 20:59
Thanks puzzler for your comments . I'm learning aswell from your method .

Now , what I come up with, is trying to emulate fubarpk code in his voxel world . Sorry fubarpk for not puttin the code in your thread , that after all it was an idea of yours .

3 - Voxel Terrain






You can use the map attache from puzzler2018
I'm not a grumpy grandpa

Attachments

Login to view attachments
puzzler2018
User Banned
Posted: 4th Jan 2019 21:05
WOW - awesome smoothing effect by joining vertices too.

Just like to say though the original image of that was indeed from Fubarpk.

Awesome - ill let others do a comment or two - im just going to do a little music now and chill
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 4th Jan 2019 21:28
Quote: "Now , what I come up with, is trying to emulate fubarpk code in his voxel world . Sorry fubarpk for not puttin the code in your thread , that after all it was an idea of yours ."

no worries, I like to share, I think that's how we all learn


what is the advantage of SetMeshMemblockVertexNormal(mesh,i,nx#,ny#,nz#)
over SetMeshMemblockVertexPosition( memID, vertexIndex, x, y, z )
fubar
puzzler2018
User Banned
Posted: 4th Jan 2019 21:34
Hello

Positions are positioning Data - where in the world does an object live

Normals are the lighting structures of each vertex. - to help the GPU render and sort the lightings out or where the sun or a light beams down onto it,

fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 4th Jan 2019 21:48
Thanks that makes sence
neat trick by chafari just been examing his code and he uses the height mapy for y positioning of blocks
was wondering if it would be possible to use the same smoothing technique instead of my look at prev
and next image positioning

fubar
puzzler2018
User Banned
Posted: 4th Jan 2019 21:56 Edited at: 4th Jan 2019 21:57
Im sure its acheivable yes - just need to identify the top layer vertex numbers and join them together somehow

You recollect the cross road code one I did - to join two blocks together

Ill do some testing to see what can come up with the code you already have
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Jan 2019 22:01
Quote: "to use the same smoothing technique "


Exactly that was what I thought ..the smoothing method . I don't know if it has any advantage coparing with SetMeshMemblockVertexPosition( memID, vertexIndex, x, y, z ) as my knowledge of memblock are null

Here's a little update of the same map ...Sorry fubarpk I thought the image map.png was from puzzler .

I'm not a grumpy grandpa
puzzler2018
User Banned
Posted: 4th Jan 2019 22:04
Jeeeeze - where you been all my life lol
puzzler2018
User Banned
Posted: 4th Jan 2019 22:14 Edited at: 4th Jan 2019 22:15
I put my head down in my hands and move head from side to side in shame and say to myself why didnt i think of that method...


Your so clever....
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 4th Jan 2019 22:28 Edited at: 4th Jan 2019 22:29
Quote: "Im sure its acheivable yes - just need to identify the top layer vertex numbers and join them together somehow"

I think when we were working on Modifying a mesh height in real time we came close to something that might help thats assuming we can make
the same number of boxes as the height map has vertexs * 4


Quote: "Sorry fubarpk I thought the image map.png was from puzzler ."

all good, the original idea was to use that map.png file as a mesh without all the lower part, ie when you load it the flat areas would be gone,
as this might make loading a map quicker as you could attach a flat plane object to the bottom and be a bit more efficient. When you load
a height map as an object in a program such as blender there are allot of vertices (a grid) which are not needed like there may be thousands of
vertices too slow a process to manually remove them so I was trying to optimise that process. Hahahah but that become more of a obj creation
tool. My smooth function is kinda close but it needs some exceptions added. Il have a think about that I think as that still might be the easiest.
fubar
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Jan 2019 22:34
Thankyou guys for your comments.

we can make the map much quicker if we just create objects where color are more than pure black ...something like this :


I'm not a grumpy grandpa
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Jan 2019 23:24 Edited at: 4th Jan 2019 23:26
Ok .. Let's think in a new method . As you have seen, I took the easiest way to model the boxes with a terrain to take the advantage of the getgroundheight and place all vertex . I suppose ,a good programmer would opt for a more proffesional way to achive that.
The idea could be as we know how the boxes are placed, to start on one side ...let say the left side . We make a bucle and check for every box neighbor on the right , get its height and then move vertex to half position . Then we do the same with the right side , then front and lastly the back side .



I'm not a grumpy grandpa

Attachments

Login to view attachments
puzzler2018
User Banned
Posted: 4th Jan 2019 23:29
Hey - dont knock yourself. your a excellent inspiriationist and a 20 line coded programmer..

There is no such thing as a professional programmer - there are such things like a very messy programmers

Programming always needs optimising, and you seem to be the optimizer

Get yourself a drink cause you have done us all proud

chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 5th Jan 2019 00:00 Edited at: 5th Jan 2019 00:02
@puzzler Your words make me proud, but the truth is that with programming I am sometimes a bit lazy , and I always look for the fastest way to do things ... it does not matter if I resort to tricks that are not proper to a good programmer.


Edit . Ok .. I'll have a couple of beer until I felt asleep .
I'm not a grumpy grandpa
puzzler2018
User Banned
Posted: 5th Jan 2019 00:07 Edited at: 5th Jan 2019 00:07
Your welcome.

We could try and stop the goto and gosubs but all in good time.

Go grab that beer and have a nice day
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 5th Jan 2019 00:46
I think one method the smoothing could be achieved is if the blocks are only drawn every second pixel
and each pixel represents the vertexs positions of each block, I just have to think about how best to achieve this
fubar
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 5th Jan 2019 01:31 Edited at: 5th Jan 2019 01:31
Not sure if reducing blocks is the solution...if all vertex of a box are in the same pixel (height) I suppose its going to do steps up . At the moment, I manage to reduce vertex quantity using simple planes ...if we want to export to Obj then we should writte only 6 vertex from 0 to 5 and we can reduce the final object even more .

Here's my last update .






I'm not a grumpy grandpa

Attachments

Login to view attachments
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 6th Jan 2019 01:55 Edited at: 6th Jan 2019 01:56
Hi there . Today I come up with a funy code with fake reflexes but could be useful in some situation .

4- Reflexes .





I'm not a grumpy grandpa

Attachments

Login to view attachments
puzzler2018
User Banned
Posted: 6th Jan 2019 10:57
Very nice chafari. - nicely acheived without shaders too. you will alwyas give inspiration to non shader peeps - cool..
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 6th Jan 2019 21:19 Edited at: 6th Jan 2019 21:21
Thanks puzzler.

As you have all seen, this first week of the year began with the challenge of creating a voxel world with an image . Fubarpk , puzzler and me have been working more or less on something similar. As you will know, the technique uses a 2D scan to lift a world with a simple image.

What I come up today with, inspired by fubarpk , is try to do the same but in 3D. You will ask how we could do that . I think the best way is using a 3D object and scan in 3D . Here I have an example that works more o less ok for a voxel world . We know already how to save the object in .Obj, so I will obviate this part . If we export to Obj, for the purpose of using it in agk , we could save it without mtl file to get colours. We could use Texture Projection in Agk .

Ok . Here we go .

5- 3D to voxel creator . Here I make the media, but we could load any 3D model to convert to voxel .





Cheers.
I'm not a grumpy grandpa
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 6th Jan 2019 23:16
The main issue I found with creating the materials
If each block had its own material and the voxel/mesh was created from 1000 blocks it created 1000 materials
which worked fine in blender but didn't work well with loading in uv editing programs such as lithunwrap. I believe
the issue is these programs have is with so many materials because they work well with the objects with materials
assigned but with that said the same 1000 blocks if they didn't repeat the same material might only use 50 materials
which would be fine.
fubar
puzzler2018
User Banned
Posted: 6th Jan 2019 23:20
Thats correct. Whats the maximum for an OBJ material do you think - 1 to 254 maybe ?

Materials are for textures not colors


We can have as much as 65536 colors but could only have 7 texture sets on a particular model
puzzler2018
User Banned
Posted: 6th Jan 2019 23:28
Make use of the mesh indexes to apply a different texture to.
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 6th Jan 2019 23:37 Edited at: 6th Jan 2019 23:39
Well ...I think that we can aply the same material to all of boxes . We don't have to make the mtl with tons of material ...just one and this one asigned to all boxes .


My Voxel Creator with something different .

I'm not a grumpy grandpa
puzzler2018
User Banned
Posted: 6th Jan 2019 23:41
I love that man Chafari - great work
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 7th Jan 2019 04:15 Edited at: 7th Jan 2019 04:16
Thanks puzzler I love you too !!

As I suspected, the interior of the objects are hollow . The technique of sphereslidecasting detects the collision only on the outside of the object .This speeds up the process a lot since internal objects would never be seen.


I'm not a grumpy grandpa

Attachments

Login to view attachments
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Jan 2019 05:41
There is this voxel tool that converts an object to voxels
http://www.drububu.com/miscellaneous/voxelizer/index.html?out=obj
very clever I think. It does tend to make high poly objects depending on the settings
but I used it to create https://play.google.com/store/apps/details?id=joust.eggs
which at the time seemed the easiest way to turn spheres into voxels. but the tool is
very good at converting many objects into voxels
fubar
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 7th Jan 2019 11:25
@fubarpk Thakns for the link . It was for me a challenge I had in mind . The high poly or low poly depends on scan steps and cube size .


6- Texture projection

Now that we are making voxel , I tought I could put here an example of how to texture the whole terrain no matter of the uv's that each cube has .



I'm not a grumpy grandpa
puzzler2018
User Banned
Posted: 7th Jan 2019 19:44
Hello

I have been waiting most of the day to try this one.. Dammm You never seem to disappoint..

Wow - great achieved once again

Im going to have to study your code on how you program cause its just marvelous
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 7th Jan 2019 19:55 Edited at: 7th Jan 2019 19:55
@puzzler. Thanks mate.
Yes ...we can really assign projected texture into agk .
I'm not a grumpy grandpa
puzzler2018
User Banned
Posted: 19th Jan 2019 21:44
Hope to see more of your little tricks soon
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 20th Jan 2019 11:24 Edited at: 20th Jan 2019 14:35
Hi there
I started with the conversion of my 3D editor made in Dbpro.I have found some problems with the object normals, but I have already solved it .Meanwhile, here's a little trick...move the vertices of an object without using memblocks.

7- Scaling Rotated Box I made it in timelapse mode in order you can see the transformation
I'm not a grumpy grandpa
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 20th Jan 2019 13:38
One thing I like about all your snippets chafari
Is I can read your code well and follow it, partly because its small chunks of code but its closer to my style
than some of the other code I try and understand on the forums the only thing I like to change is the
goto routines I prefer a void function than a goto. not because I believe it is better practice but because
I reuse code as much as I can. and a void function is much more useful for future reuse than a subroutine.
but no need to change just thought ide coment on your code being easy enough to follow. In the old days
i would print source code out with my ribbon style printer and lay the code on my floor lol but it made it
much easier to trace code that way. Nowadays i have an inkjet which is much dearer to run than the old
ribbon printers hence why im out of ink lol

nice trick for resizing a block


fubar
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 20th Jan 2019 14:41
Thanks fubarpk for your comments. I know what you mean about goto command I know I should use while/endwhile or other bucle. I have used goto only when I know that I will never come back to this part of code....I will try to avoid in future codes .
I'm not a grumpy grandpa
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 21st Jan 2019 17:27 Edited at: 21st Jan 2019 17:29
Hi there . I have converted my robot Dbpro code to Agk ...I have to say I prefer the Dpbro one .

My Robot



Here's the Dbpro code if you want to test .




I'm not a grumpy grandpa

Attachments

Login to view attachments
puzzler2018
User Banned
Posted: 21st Jan 2019 18:44
WOW - NIce one chafari

chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 21st Jan 2019 19:22
Thanks puzzler ...the one I made in Dbpro looks better
I'm not a grumpy grandpa
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 21st Jan 2019 19:58
Nice Robot
fubar
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 22nd Jan 2019 00:49
Thanks fubarpk

Everyone knows how to make a model in our 3D favorite programm . What I come up with, is a body modeling . This shoud be better with a function to select and move vertex but in this example I just show what happens behind the scenes pulling vertex . The code looks a mess and it need to add every thing in a function, but that will come later.

Body modeling


I'm not a grumpy grandpa
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 22nd Jan 2019 05:49
That's kinda neat and I see your making use of memblocks now
fubar
Rick Nasher
6
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 22nd Jan 2019 12:00
War of the worlds!
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 22nd Jan 2019 12:00
Thaks fubarpk .

Quote: "I see your making use of memblocks now"


In most of my codes I use membloks

Here's an update to the body modeling . I add a function to organize better the code . The code is Timelapse.


I'm not a grumpy grandpa
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 23rd Jan 2019 20:38
Hi there

Here's a gun made using the same method .


I'm not a grumpy grandpa
Xaby
FPSC Reloaded TGC Backer
16
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 24th Jan 2019 00:15

Login to post a reply

Server time is: 2024-04-16 17:29:03
Your offset time is: 2024-04-16 17:29:03