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.

DarkBASIC Professional Discussion / modifying an object in real time?

Author
Message
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 8th Jul 2009 15:10
Hi,

Is it possible to modify an object in real time using DBPro.

If so, could you post a link to where you seen something like this being done using DBPro.


cheers

Dark Physics makes any hot drink go cold.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 8th Jul 2009 15:30
What do you mean by modify? Do you mean modify it's texture, or it's mesh?

Both can be achieved, but mesh manipulation will probably require memblocks.

Your signature has been erased by a mod because it is way too awesome!
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 8th Jul 2009 15:48
I mean modify the mesh, thinking of making a model lathe, were you can turn your own object.

You start off with a block or rod then cut bits away.

Dark Physics makes any hot drink go cold.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Jul 2009 15:56
Yeah, you should look into the vertex manipulation commands. Basically this involves locking a specified objects limb, then stepping through each vertex and adjusting it. It's possible to change the position, normal, colour, and UV coordinates this way.

If you make a segmented object, so there's a fixed number of vertexes in height - could be round or square, the system won't mind. Anyhoo, just check the lather blade position, find out which vertexes are being cut, and set them to the desired radius. By working out the actual radius of the vertex from centre, it should be easy to adjust it to suit. I think that would work pretty damn nice as long as you have enough vertexes in the lathe. If it's just a lathe and bit of wood, then I guess you can afford a lot of vertexes. People will be carving virtual chess pieces in no time. Really, with enough detail people could lathe out screws, pretty much anything a lathe could do, you could do the same with this technique.

Also, by setting the actual blade of the lathe as a limb, you can very easily return it's exact 3D position using the limb position commands.


Health, Ammo, and bacon and eggs!
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 8th Jul 2009 16:04 Edited at: 8th Jul 2009 16:04
Cheers Van B, so it possible just a lot reading and messing about of vertex manipulation command set.

so it look like I should start at the begining and see how to move vertex points and see if I can get them to move in and out by control of the keyboard.

Now wheres me hands on book?...

Dark Physics makes any hot drink go cold.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Jul 2009 16:29
There's probably an example lying around that'll get you started.

One thing I wanted to mention - if you UV map your wood with a knot image, like when you cut across the grain and your left with concentric circles. Anyhoo if you use that and texture it so it's like a stick of rock, with the texture all the way from one end to the other - well it'll cut just like a piece of wood, it'll have realistic grain and everything.


Health, Ammo, and bacon and eggs!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Jul 2009 18:31 Edited at: 8th Jul 2009 18:32
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Jul 2009 18:56
I'm messing around with this idea right now as it happens, if I get it working I'll post the code of course. If this is the sort of project your into, then learning those vertex commands will give you a lot of freedom. I'd also look at the CSG stuff, which would allow you to cut holes and join pieces. The polycounts can get kinda crazy when you do a lot of CSG, but I think it'll run pretty well.

My lathe might not be super-accurate, but it should be fun .


Health, Ammo, and bacon and eggs!
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 8th Jul 2009 18:59
Thanks BatVink, you must have a good menmory or a good data base of whats where in the newsletters.

Dark Physics makes any hot drink go cold.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 8th Jul 2009 19:04
Van B CGS is something I have worked out how to do, getting a round object to work is the tricky part, it can be done sometimes.

Quote: "then learning those vertex commands will give you a lot of freedom"

Looks like that what I need to do, will be another one ticked off the list to learn.

Dark Physics makes any hot drink go cold.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Jul 2009 22:03
Hehe, this is so cool. Check the download, lets you lathe out a block of wood in realtime.

Could make for quite a cool furniture creation game, like lathe out the legs of a coffee table then router out the top, drill holes with the CSG commands, then sand and polish using PICK OBJECT .

Would be possible to save the meshes too, DBPro can save out .X or .DBO models, although the polycount might be a bit severe.


Health, Ammo, and bacon and eggs!

Attachments

Login to view attachments
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 8th Jul 2009 22:18 Edited at: 8th Jul 2009 22:20
Van B what values where you testing with as I can't seem to make it cut.

edit
just seen the pointy bit, duh! new specs please.

Dark Physics makes any hot drink go cold.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 8th Jul 2009 22:23
Van B I think that demo should be TGC demo files or code snippets, now to spend along time working out how you did it.

Dark Physics makes any hot drink go cold.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Jul 2009 22:53 Edited at: 8th Jul 2009 22:57
Here's a little update, this time you use the up and down keys to control the lathe speed, and the lathe actually cuts into the mesh now, so you can make more complex models like this:



Edit, forgot to say, press SHIFT to move the lathe along automatically. If you set the lathe to full speed it should make a clean line, but at low speed you can cut screw ridges and make spikes, as the lathe goes in either direction.


Health, Ammo, and bacon and eggs!

Attachments

Login to view attachments
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 9th Jul 2009 01:08
If you like what you made then you might want to enter the Wood Workers Apprentice Competition [7/6 - 7/23].

http://forum.thegamecreators.com/?m=forum_view&t=153780&b=3

However write a save routine other wise you won't have it.

Dark Physics makes any hot drink go cold.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 9th Jul 2009 11:11
Thought it would be simple to rotate the object and then cut the end of it, however there must be some I have missed when looking at the code.

Dark Physics makes any hot drink go cold.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Jul 2009 11:54
I was thinking about how to handle it when the blade goes right through. Personally, I'd have a dead zome - so if the blade goes all the way through, all the vertexes after that point should be squished. So when you detect that the remainder needs to come off, store that X value and any vertex beyond that point is gone, maybe this would work - not at my PC so I'm compiling it in my head...



So what that does is it checks to see if the blade has gone through, and if it has, it remembers that X coordinate in the chop_x# variable, then it restarts the vertex modification by setting the For...Next value V to 0, starts from the beginning and squishes any vertexes past that chop_x# variable.


Health, Ammo, and bacon and eggs!
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 9th Jul 2009 12:23
what I did see when I rotated the object was it did cut, but where it would have cut had it not be rotated.

giving the above code a try, post back when tested.

Cheers.

Dark Physics makes any hot drink go cold.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 9th Jul 2009 12:29 Edited at: 9th Jul 2009 12:30
seem to work ok, a picture to see.



Dark Physics makes any hot drink go cold.

Attachments

Login to view attachments
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Jul 2009 22:29
Also, where it says 'if mb=1' in the code, replace that condition code with this:

if mb=1
inc lathe_x#,((mousemovex())*0.001)*lathe_feedback#
inc lathe_z#,((mousemovey())*0.001)*lathe_feedback#
if lathe_z#<0.0 then lathe_z#=0.0
lathe(1)
else
if mb=2 then rotate camera mousey(),mousex(),0
if mb=0 and lastmb=1 then set object normals 1 : set object smoothing 1,70
endif

This recalculates the object normals, and makes it look much better . I've posted this in code snippets and have a new version in progress, so be sure to check that in the next couple of days.


Health, Ammo, and bacon and eggs!
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 10th Jul 2009 09:30
Nice code, now to come up with a game idea using it! lol

Your signature has been erased by a mod because it is way too awesome!
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 10th Jul 2009 11:29
Quote: "Nice code, now to come up with a game idea using it! lol"


you have to trun an object to fit then it opens/works?

Dark Physics makes any hot drink go cold.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 10th Jul 2009 12:01
Yeah, like you might have to whittle a block down to a set width to go through a hole and push a button to open a door.

But what I was thinking last night, is how gnarly you could make your own bludgeon or club with this thing. Imaging playing a zombie survival game, and there's a lathe and a big old block of wood - it would actually be pretty easy to let the player lathe out their own club, as this system doesn't rely on any data. Can't speak for everyone but I'd find that pretty cool, to take time out and relax, making an instrument of death!. Maybe even allow the player to hammer nails into the thing .

My brother has a game idea for it, he tends to visit and watch over my shoulder when I work - he thinks it would be cool to make and sell furniture, like have different tools and mini-games to end up with a piece of furniture, which sells depending on how nice you make it. Then you use the money to buy tools, wood, and anti-depressants. Ok scrub that last one, but I'll certainly consider a game like that, when I have a nice chunk of time spare.

Yesterday I added wood shavings and tonight I think I'll see about adding sound, I just want to take it to the point where it's a fun and interesting thing that people might want to add into their game. It'll most likely end up as a lathe model that can be loaded into a game, then a special function handles it, kinda like Fallout3 with the workbench, except you'd actually be working at the bench . It's just a shame we can't do this sort of stuff with FPSC. If I do get to develop it further, then I'd want a virtual workshop with different tools and stuff laid out, damn I'd spend hours playing with that - hope I get the time.

Any code I come up with and release is completely public domain though, take it and use it however you like - kinda like farting in an elevator, it's for everyone to enjoy!.


Health, Ammo, and bacon and eggs!
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 10th Jul 2009 13:16
Quote: "kinda like farting in an elevator, it's for everyone to enjoy!."

LMAO!

Your signature has been erased by a mod because it is way too awesome!
Juso
21
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: Finland
Posted: 12th Jul 2009 14:00 Edited at: 12th Jul 2009 14:01
@Van B

Nothing happens, the blade is allways too far away to block.
What size the block should be? How to get the blade closer the block?
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Jul 2009 17:05
Hold the left mouse button and move the mouse forward to get it closer to the block.

If you press return at each of the inputs, it'll use defaults of a round block, with a width of 1.0 and a length of 2.0.


Health, Ammo, and bacon and eggs!

Login to post a reply

Server time is: 2024-05-20 17:38:48
Your offset time is: 2024-05-20 17:38:48