3D Painter for Objects - Paint right on 'em -Good!

Blitz3D Forums/Blitz3D Beginners Area/3D Painter for Objects - Paint right on 'em -Good!

Mikorians(Posted 2014) [#1]
[LATEST UPDATE - With Copy & Paste]
I wrote this thing- with credit to the brilliant 'Noobody'
for his help with the find uv function.
You can have it, improve it, post it to library, etc.
I've been making a paint program out of it.
Interested parties may post for it.

Here's the latest revision of this program as of 18 Jan 2014





-----Here is the HexRead program to decode the hex .zip file below it-----




RemiD(Posted 2014) [#2]
Take a look at :
http://www.blitzbasic.com/codearcs/codearcs.php?code=2895
http://www.blitzbasic.com/codearcs/codearcs.php?code=369
http://www.blitzbasic.com/codearcs/codearcs.php?code=515


Mikorians(Posted 2014) [#3]
Thank You RemiD!

And-

Thank You Noobody!
Please state your name if you want to for credit in this painter app!


Rick Nasher(Posted 2014) [#4]
@Mikorians: forgive me for being utterly clueless, but what is the whole Hex-file thing supposed to do? Extract media I assume? Cos it's not working for me if I do what you describe above:

1) save top file as "3D Painter for Objects.bb"
2) save bottom file as "PasteMe.Hex"

Run: 3D Painter for Objects.bb

Results:
Error for not putting a ";" in front of the text "and for the .zip file in hex below..." in "3D Painter for Objects.bb".

Now that would make sense if the HEXREAD bit is supposed to be in a separate program called "HEXREAD.bb"?
Either way it's giving me a "File does not exists"error on the line "CloseFile(FileOut)", even when I put my full path into MyPath$= ".\"

Nogo even if I do this straight from the root of my D: drive.
Anyway, hope you can shed a light on this? (or just dump the media files on MediaFire.com?)


Mikorians(Posted 2014) [#5]
Copy just the hex data (include the 'object painter.zip' line) into notepad and save it in the same folder as the hexread.bb program as "pasteme.hex", Run hexread.bb, and it should create the zip file (which already includes the paint.bb program)
I had tried to put the two source listings into separate code windows, but the forum had a bug I think.
I would like to see if we can make it work together.
Inside the zip?
Object Painter.bb
SkyBox.B3D (just a quad)
SkyBox.bmp (just a white 256x256 bitmap)
It should handle any simple 100% scaled, non-hierarchy, single object b3d.
Be sure the object in the b3d file has a brush texture "skybox.b3d" when you save it.


Mikorians(Posted 2014) [#6]
Sometimes bb requires you to double-click the bb program rather than open it from the menu bar since it contains the path when you click the icon.


Rick Nasher(Posted 2014) [#7]
Ok worked now, dunno why didn't before, while I did exactly the same thing. Weird. Anyway it works.

Where are you planning to go with this? 3D game character painting or something?


RemiD(Posted 2014) [#8]
wrong topic


Mikorians(Posted 2014) [#9]
Oh, I've been writing this 3d texturemap editor for the purpose of tidying up the paintjobs on existing objects such as a real nasty skysphere (not a skybox).

The poles on skyspheres are especially pernicious.

But I've done a whole lot more work on this thing and now it has a lot of the same tools paint does (and some it doesn't)

I will be re-releasing the new version soon I think.
I'm just working on the palette selector api thing...


Rick Nasher(Posted 2014) [#10]
That would be great. Indeed the poles on skysphere's are nasty to do properly. Such a tool would be really helpful, especially if it also does customizable gradient fills.


Mikorians(Posted 2014) [#11]
Hm. Gradients. I will work on it, Rick!
I'm almost finished.

Ya know what's most wonderful about it is that basically you have obtained a planar projector for whatever faces are towards the camera.
I've been working hard and now have non-curved lines when you draw across the object in the window- darn cool stuff!
I think people might like this a lot!
I just have double-line-edge blur (toughy) and two other features before I'll consider this an alpha.


Rick Nasher(Posted 2014) [#12]
Sounds really really good.

Btw(offtopic), the HEXREAD.bb thingy has one very positive aspect to it:
The code published on this site will keep having the media available with it, contrary to some previously published stuff that relied on the media to be hosted externally.

Therefore I think it's good practice to include media like this, which brings me to the next part:
Do you also have an HEXSAVE.bb to create the hexfiles?


Mikorians(Posted 2014) [#13]
It IS kind of a neat way to gain persistence, isn't it?
Here's the ap, but hex files take up about 2x the space in text form.
I don't upload ANYTHING above 4K since I don't want to offend the forum operators.
Use it WISELY.

;HEXWRITE
fl=0:mck%=0:pre_ck%=0
NM$="BlitzLevel.Zip":pc=0
FZ=FileSize(NM$)
FileIn=ReadFile(NM$)
While Not Eof(FileIn)
ReadIn=ReadInt(FileIn)
pk=pk+1:If pk<4 Then Print Hex(ck%)
A$=Hex(ReadIn)
o=0:For t=Len(A$)-1 To 1 Step -2
Nib1$=Mid$(A$,t+0,1)
Nib2$=Mid$(A$,t+1,1)
N1=Instr("0123456789ABCDEF",Nib1$)-1
N2=Instr("0123456789ABCDEF",Nib2$)-1
Byt=(N1*16)+N2
pre_ck%=pre_ck%+(Byt*(256^o)) ;Build 8 byte value
o=o+1:If o>3 Then o=0:mck%=mck%+pre_ck%:pre_ck%=0:pc=pc+1 ;Checksumming
Next
Wend
CloseFile(FileIn)
o=1
FileIn=ReadFile(NM$)
FileOut=WriteFile("PasteMe.Hex")
WriteLine(FileOut,NM$)
WriteLine(FileOut,mck%)
While Not Eof(FileIn)
ReadIn=ReadInt(FileIn)
A$=Hex(ReadIn)
b=Asc(Mid$(A$,7,1)):WriteByte(FileOut,b)
b=Asc(Mid$(A$,8,1)):WriteByte(FileOut,b):fl=fl+1:If fl=FZ Then Exit
b=Asc(Mid$(A$,5,1)):WriteByte(FileOut,b)
b=Asc(Mid$(A$,6,1)):WriteByte(FileOut,b):fl=fl+1:If fl=FZ Then Exit
b=Asc(Mid$(A$,3,1)):WriteByte(FileOut,b)
b=Asc(Mid$(A$,4,1)):WriteByte(FileOut,b):fl=fl+1:If fl=FZ Then Exit
b=Asc(Mid$(A$,1,1)):WriteByte(FileOut,b)
b=Asc(Mid$(A$,2,1)):WriteByte(FileOut,b):fl=fl+1:If fl=FZ Then Exit
o=o+8:If o>80 Then o=1:WriteByte(FileOut,13):WriteByte(FileOut,10)
Wend
CloseFile(FileIn)
CloseFile(FileOut)
End



Rick Nasher(Posted 2014) [#14]
Nice one. Thanks a million.


Guy Fawkes(Posted 2014) [#15]
Here's a small update which now includes the ability to delete all the painted parts of the texture simply by holding right mouse button and dragging. I also changed the color of the paint brush to dark green so that we can establish after painting the entire quad, where the quad is instead of a black quad with a black background. I also changed the paint brush from point brush to rectangle brush, this makes it much easier to paint a solid color on to a surface.

PasteMe.hex:

https://www.mediafire.com/?u922sm915345c22

If someone could please modify this and "Hex" me the example, that would be great! Thank You all, and kudos to the creators of this WONDERFUL program! :)


Mikorians(Posted 2014) [#16]
Thank you, but there's a HUGE update coming which includes that very thing and a whole lot more, so please stand by.
My problem is that the PickedUVW function is very slow for even a small array of points because mouse pixels are much smaller than the 'texels' are, but I still have to cover them carefully...
I will post soon... Any fixes to THAT routine would be helpful.
I've been hammering on a masked texture map applicator thingimagigger.
Rick has given me a real headache.
I also have blur and emboss functions that are part of the problem.
It's already become quite a tangled thicket that works sorta good, and if someone wants to help clean it up, PLEASE let me know.


Guy Fawkes(Posted 2014) [#17]
Nice job, Rick XD


Rick Nasher(Posted 2014) [#18]
As always..


Guy Fawkes(Posted 2014) [#19]
It's ALL YOUR fault, Rick XD


Mikorians(Posted 2014) [#20]
The latest version at the top. We're all untangled now, but I've been forced to knock out a few erroneous functions, and instead have left the puzzling function alone, by itself for anyone willing to have a look.

I'm not going to run an executable, Mr. Fawkes.


Rick Nasher(Posted 2014) [#21]
Better safe than sorry ;-)
I'm very curious about this but I'm getting a "Function 'api_choosecolor' not found", even though I've included the latest FastExt.bb from V1.17.

Is there perhaps some other dependency that needs to be installed?


Mikorians(Posted 2014) [#22]
Yes, the comments at the start indicate you need the two .delcs files typed in.
Incidentally, Mr. Fawkes, if you had hosting, why post the .hex file instead of the .zip?
8/


Guy Fawkes(Posted 2014) [#23]
Because I also included the compiled EXE in the hex, and it was too big to paste anywhere else.


Guy Fawkes(Posted 2014) [#24]
@Rick Nasher, the api_choosecolor function is part of the win32 api DECLs file.


Rick Nasher(Posted 2014) [#25]
Pretty cool, can start it now but when tryin to select color then "User lib function not found"
But I'm probably doing something wrong(too tired after work) I'll check later.


Guy Fawkes(Posted 2014) [#26]
You'll need to make sure you have user32.decls (all of it) in your DECLs folder, and make sure your user32.dll system32 DLL file is NOT corrupt.


Mikorians(Posted 2014) [#27]
Wow. Yeah. Be careful folks.
The API is for a color palette selector built into windows xp. I hope it still exists in newer windows.
I had just grabbed it from the codearc. Credit to "MPZ" ? from Berlin.


Rick Nasher(Posted 2014) [#28]
Ok, well I'm on win7, but I'll checkout GF's suggestions..


Kryzon(Posted 2014) [#29]
You should encapsulate the code in {codebox} {/codebox} tags, replacing the braces with brackets.
It generates a text-area box with scrollbars that contains your code and makes it easier to copy and paste it.


Guy Fawkes(Posted 2014) [#30]
Sorry, @Rick Nasher. This one function apparently came from "comdlg32.decls", not "user32.decls". After I made this change, it worked fine for me :)


Mikorians(Posted 2014) [#31]
Thank you Kryzon, Done.
Latest update again. Now blur works - MOST IMPORTANT FUNCTION.
Mr. Fawkes, you found my oopsie. Fixed the comment in the .bb


Guy Fawkes(Posted 2014) [#32]
Hehe, glad I could help, buddy :)


Guy Fawkes(Posted 2014) [#33]
So Mr. Mikorians, when will there be a way to texture splat onto a 3d mesh? :)


Mikorians(Posted 2014) [#34]
Do you mean 'paste' ?

That much seems eminent along with a bitmap floodfill maybe.

If you mean something more complex... Dunno.
I want to help the community. This thing's a lot different from just a paint program!
If you have reasonable ideas... But I will need to return to my engine soon. (Don't we all)
I'd trade a feature (if I can do it) for a really good set of 256x256 skysphere bmps.
I rotate my sky to simulate wind. I already have sun and moon.
Just different skies. Ah well... It's why I wrote this thing.
This program really needs a good mathematician and 2d gfx man.
Text tool sucks right now. Needs a file requester, bla, bla, bla...
A project like this is never really finished.
It will be updated here as I get to it in the months and years ahead.
Over time, I'll need features, and get sick of the lack thereof.


Guy Fawkes(Posted 2014) [#35]
Yea, I mean paste :P


Mikorians(Posted 2014) [#36]
-----Copy the below text, and paste it into notepad, then save it as PasteMe.Hex-----




Guy Fawkes(Posted 2014) [#37]
YAY! =D


Mikorians(Posted 2014) [#38]
I wish everyone luck in finding the math needed to get the pixel-correct drawing we all so badly need, at least the application is ready for the formula.
I thank all contributors!


Rick Nasher(Posted 2014) [#39]
Pretty good, missing that gradient fill for Sky Sphere's still though. That would make it a real winner..


Mikorians(Posted 2014) [#40]
It's just a tool.
I felt pretty lucky to get even the simplest of drawing tools applied to these routines (kindof hammering that finduvw routine real hard - it's of course, very slow)

I was able to correct ALL of my needed skyspheres using this tool to edit the boundaries of the existing bitmaps. I then used another paint program to touch them up (seeing where the errors lay helped).
I wish folks luck.

Anyone who turns this into a new photoshop is an amazing person.


Guy Fawkes(Posted 2014) [#41]
Does this paint a texure map onto a quad?


Mikorians(Posted 2014) [#42]
It was meant to load a small b3d file, but if the quad had uv coords, it would.
It also works on default createsphere and cube objects, I noted.


Guy Fawkes(Posted 2014) [#43]
Is there a way you can edit this to allow painting of textures onto the quad?


Rick Nasher(Posted 2014) [#44]
"Pretty good, missing that gradient fill for Sky Sphere's still though. That would make it a real winner.. "

Was asking cos I've tried to create a SkySphere gradient with Paint.NET(unofficial MSPaint update) but it never gives me fully satisfying results due to fact that it doesn't give full control over the gradient start/middle/end and which colors used.

You could turn this into *THE* kickass SkySphere Application if you could pull that off. Of course I could try adding that myself, painstakingly reverse enginering your code, which you probably know by heart, but I lack the time rightnow cos I'm trying to do an overambitious foliage-to-terrain thingy(which I'm willing to share to all when done) that makes my own head hurt/spin(a lot). ;-)

Here's a very nice, not too large, Color Gradient thingy done by the all famous Krishan(worth taking a look):

http://www.blitzbasic.com/codearcs/codearcs.php?code=2415

Now I don't know if/how easy it would be to implement that, but.. seems very doable. Hope it helps.



Other (perhaps, didn't check) useful links..
Gradient Of a Triangle(dunno if needed):
http://www.blitzbasic.com/codearcs/codearcs.php?code=1093
Radial Gradient:
http://www.blitzbasic.com/Community/posts.php?topic=77285


Mikorians(Posted 2014) [#45]
I've just been getting the sound/media zone triggers/map cell loaders/destroyers up and running (doing great), but I'm really too much in the thick of it right now to do graphic arts stuff yet.
I will examine your link at a later date.
I've been hybernating in this frigid arctic weather!

Last comment: I noted that this program isn't ABLE to be any too precise about where it places pixels over the 3D projection, but if you meant the 2D one, that wouldn't be hard, perhaps the 3D could be used to map out an irregular masked area on the 2D, is this what you had in mind?
Then filling in the mask with a gradient?
Both guy and you have decent ideas. He wanted paste. We've got it.
Hm. I will consider gradient. I hadn't planned on by polygon gradient, but radius (circular) might be easier.


Rick Nasher(Posted 2014) [#46]
Indeed what I had in mind. Would make an excellent SkySphere editor.


RemiD(Posted 2014) [#47]
Take a look at the code in the Blitz3d samples :
Blitz3D\samples\birdie\texpaint

This may help.


Mikorians(Posted 2014) [#48]
Thank you! I will examine it.
This may take a while... I'm cross-converting maps right now.
Hideous...


Guy Fawkes(Posted 2014) [#49]
Is there any progress on this yet?

Thank you! =)


Guy Fawkes(Posted 2014) [#50]
@Mr. Mikorians? Is there any luck with this wonderful project? :)


RemiD(Posted 2014) [#51]
By curiosity, what is the problem exactly ?


Guy Fawkes(Posted 2014) [#52]
Basically, I need to be able to paste a selected texture slowly onto each triangle of the model, Mr. RemiD.


Kryzon(Posted 2014) [#53]
Try Blender:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Textures/Painting/Projection


Guy Fawkes(Posted 2014) [#54]
Sorry, I'm not a fan of blender. It's got a very complex GUI, and I do not like complex. Thanks though for that, Kryzon. :)


Rick Nasher(Posted 2014) [#55]
Hate Blender: does it Blend?? :-)


Guy Fawkes(Posted 2014) [#56]
Yes.. Yes it does. :3


Hotshot2005(Posted 2014) [#57]
Germany Flag :O


Guy Fawkes(Posted 2014) [#58]
LOL!


Guy Fawkes(Posted 2014) [#59]
Any news on slowly "texture splatting" a model?