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.

Code Snippets / RealTime Object Painting

Author
Message
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 8th Apr 2007 21:55
I wipped this up today. Its a snippet to paint on an a cube rotated at 0 degrees in realtime.

The method it uses is just simple math.

Enjoy




The fps drops when your painting, but thats only because of all the stuff that I have going on while you paint.

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 8th Apr 2007 22:03
I like it Any chance of making the paint dots a little smaller so I can make a picture?

Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 8th Apr 2007 22:10
Oh sure!



It comes up a little dotty though

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Apr 2007 22:25
Accuracy of the mouse is a little off.

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 8th Apr 2007 23:21
Wow Xenocythe that was quick I drew a picture (it was horrible, lol) Now... the only thing left to do is make it connect the boxes with lines or something! MWAHAHAHAHA!

Bah, no need to do that. That's a pretty cool snippet though.

Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 8th Apr 2007 23:27
Thanks

I made another version. This time, if you draw a little slower, the boxes are connected. But, the only problem is that they are bigger.



Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 9th Apr 2007 01:11
Nice one

Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 9th Apr 2007 03:12
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 10th Apr 2007 12:08
If you could adapt this so that it only drew on the polygon you were actually drawing on (rather than all the other faces of the cube as well), and at different camera angles, it would be very useful for creating bullet holes, blood splatters, etc. Not saying that would be easy, though!!

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 10th Apr 2007 20:40
I think that would be pretty much impossible.

You would have to convert the mesh to a memblock and check every single UV data of each vertex (well, every 3 verteces anyway).
Then you have to change the color on the exact spot on the original texture, probably using memblocks too (get image would be a little too slow I think).

And then there are the complications when the blood spatter actually are part of 2 or more verteces...
Even if it could be done, I sincerely doubt the speed that it can be processed whilst the game running...

So basically, this is a basic algorithm for a square surface. Nevertheless, it's quite useful.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 10th Apr 2007 23:54
Sven, I could just make a cube out of plain objects myself then use sparky's collision DLL

But I'm too busy to attempt that right now

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 11th Apr 2007 10:23
Well that would be possible in some way. But I was talking about a completely irregular object you loaded from whoknowswhere...

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
TEH_CODERER
21
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 11th Apr 2007 11:42
Yeah, Sven B has the right end of the stick! Lol! Would be much cooler to work on a loaded .x or .dbo model. I do think also that memblocks are the way to go. Ig it is possible within DB then memblocks are the only way.

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 12th Apr 2007 03:43
Well I had a brief look at the code, if I'm not mistaken are you redrawring the whole image every time some new data is added? because this is a very inefficient method, your best bet would be to have the texture in a memblock and you edit that then convert it back into an image, also having 2 Do/Loops and transitioning between them using goto is very bad practice, you should just stick to one loop and not use goto at all.

Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 12th Apr 2007 03:49
I'll make sure I do all that in the future Thanks for the good advice.

But for now it was just a mere snippet that I felt like making, and I tried one way and it worked, so I posted it hehe


But did I really use a goto

OMGerz I did!

Alquerian
18
Years of Service
User Offline
Joined: 29th Mar 2006
Location: Reno Nevada
Posted: 12th Apr 2007 07:04
Nice work Xeno! Really cool snippet!

Terrain Generation has a whole new face.

Login to post a reply

Server time is: 2024-11-22 18:33:05
Your offset time is: 2024-11-22 18:33:05