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 / Make an object bigger

Author
Message
Math89
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: UK
Posted: 8th Jul 2006 12:19 Edited at: 8th Jul 2006 12:19
Yesterday, I tried to make a simple lightmapping effect using a clone of my object with a lightmapped texture, but, in ATI cards, there were a big zfinghting problem (worked fine on nvidia cards ) so I've made this little function to make my objects bigger (and avoid the zfighting 'bug'). This is not a scaling, it moves all the faces on its normal.



Attachments

Login to view attachments
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 8th Jul 2006 12:25 Edited at: 8th Jul 2006 12:26
But, when you move each face on it's normal uniformly, technically yes, its a scale . Actually I think that's how the scale command works, except you've got a bit more control over which normals are moved at what rate.

Good programming practise though.

<EDIT>

Unfortunately you havent provided any code

Math89
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: UK
Posted: 8th Jul 2006 12:29 Edited at: 8th Jul 2006 12:30
Quote: "Unfortunately you havent provided any code"

The code is at the bottom of the picture

Quote: "Actually I think that's how the scale command works"

Actually, it's not


This is the same object with scale object (110%)

Attachments

Login to view attachments
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 8th Jul 2006 12:37 Edited at: 8th Jul 2006 12:37
o.O, there's no code at the bottom of the picture...

Strange how the results differ so much, doesn't make sense to me why that'd be. Ohwell still good job.

<EDIT>

Ah I see it now, sorry stupid me.

Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 8th Jul 2006 12:50
Can ya make this possible for seperate axis now?

Platformer Compo!
WHITEKNUCKLE IS BACK! Check the wip boards for more info
Math89
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: UK
Posted: 8th Jul 2006 12:53 Edited at: 8th Jul 2006 12:53
I think a picture may help you a bit.



With the scaling, the vertices positions will juste be multiplied (the blue dot is the pivot of the box), so, a vetrex will always be on the same green line (the scaled box is the grey one).

With my function, all faces will move in the direction of its normal, the pivot don't matter.

Attachments

Login to view attachments
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 12th Jul 2006 02:40
Does it also works with complex 3d models?

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 12th Jul 2006 03:27
I think if you over-scale complex 3D models in that way then some faces will start to overlap - but prolly yeah, mostly.

Math89
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: UK
Posted: 12th Jul 2006 13:30


Now, you can change the size for each axis .

Quote: " Does it also works with complex 3d models?"

Yes it does
Quote: "some faces will start to overlap"

Sure, but I don't think it's really important .
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 12th Jul 2006 16:27
@Zoto/Math: In Wings3D it's scaling system uses that method, of moving each face outwards uniformly, and in my experience weather it's a character, a map, anything, no faces end up overlapping. It would seem that way assuming some faces wouldnt move outwards, but when you think about it the outer vertx move out allowing the inner verts to move in, it all fits nicely.

Great job Math,
- RUC'

Mr Tank
21
Years of Service
User Offline
Joined: 25th Nov 2002
Location: United Kingdom
Posted: 28th Jul 2006 05:13
Interesting stuff. My memblocks are almost as rusty as my French, but i understand what you are getting at.

Using such a method to "inflate" objects as a modelling tool i'd like to think more about. But for circumventing "z-fighting" there is a method that is arguably better.

What you can do instead is to move the "clone" object slightly along the path from the object to the camera- say 1% of the vector, and scale it appropriately (about the object position)- in this case to 99%. This is equivalent to scaling the object by 99% about the camera. I used just such a method when using ghosted objects on top of the base objects in dbp for a reflection effect, and it worked fine. BTW make sure that culling is on.


You'll be able to click on this someday.

Login to post a reply

Server time is: 2024-11-23 03:59:09
Your offset time is: 2024-11-23 03:59:09