• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
SeanJD

Lattice Deformer (2x2 FFD)

6 posts in this topic

Hi,
could anyone help me to understand how to apply a lattice deformation on a 3D object, like the FFD modifier in 3DS max: http://www.3dmax-tutorials.com/FFD__Free_Form_Deformation__Modifier.html ?

I have found this thread, now closed, which is basically asking the same question but hasn't got enough information for me to understand how it's done - http://www.gamedev.net/topic/628822-lattice-deformer/ it mentions 'plug the value into the parametric equations for the deformed lattice' but doesn't explain what the parametric equations are.

From my limited knowledge I thought it would be a case of setting a weighted value between each lattice handle and each vertex in the model that i want to deform, and then using that weight to affect the x,y,z positions of each vertex in the model when deforming the control lattice. But so far my attempts have failed. Could anyone help explain the equations / algorithm needed to apply a 2x2 box/lattice deformation, similar to Max's FFD modifier, or point me in the direction of an article which would explain.

Many thanks Edited by SeanJD
0

Share this post


Link to post
Share on other sites
I have been looking into this for days and not come across anything that really explains the concept, but have just come across this paper from siggraph 86 which i think explains it nicely.. http://pages.cpsc.ucalgary.ca/~blob/papers/others/ffd.pdf it uses' tensor product trivariate Bernstein polynomials' to find the vector offset from the original vertex position to that of the deformed lattice. However, before going ahead and writing the code to perform these equations could anyone confirm that this would be an adequate approach to deforming a solid geometry within the control lattice so it moves with the control lattice? I'm just so green to this that I could do with some advice of anyone who has more experience with it. Cheers
0

Share this post


Link to post
Share on other sites

Hi! We've recently implemented something similar, so hopefully I can help. That paper looks like it's probably overly complicated for what you want to do - it's designed to handle data in many forms. If you're planning to do something in a vertex shader (or on the CPU) for regular triangle-soup meshes, you can treat the FFD like skinning. Each vertex of the lattice is essentially a bone, with a bind pose (the original lattice), and a skinned pose (wherever you've deformed the lattice to). The important part is figuring out the weights for each vertex. That's actually just based on cubic interpolation across each axis. Assume your lattice is axis-aligned, to simplify things: Normalize your vertex positions so that they're in the range 0 to 1 on each axis of the bind-pose lattice. Now you apply smoothstep (a cubic polynomial) to those positions to get the weights. The weight of each lattice vertex for a particular model vertex is the product of the three directional weights (either the value, or 1 minus the value, depending on which end of the box you're talking about). Basically, every lattice point influences EVERY vertex (except for the extreme case of points on the perimeter of the lattice). This solution also handles the extrapolated deformation that happens with FFD - your cubic polynomial will start returning values outside of [0,1] if your geometry lies outside the original lattice, and those are still your weights. (You can see this effect in 3dsMax, depending on which options you enable on the modifier). I hope that helps - let me know how you make out!

2

Share this post


Link to post
Share on other sites

Hi Osmanb, thanks for the explanation! I think I was close the first time around then, I have written code which can weight each lattice vertex to each model vertex but just didn't get the weights correct. Also I didn't normalize the vertex positions to be in the range 0->1 . I can do that for sure, but I'm still a little uncertain about getting the weights. I've looked at the smoothstep equation, so do i apply that on each model vertex<->lattice vertex for each direction i.e. calculate the distance between each on each axis? And by product of the three directional weights do you mean the cross product? I'm almost there but just need to get this weighting algorithm right.

Cheers

0

Share this post


Link to post
Share on other sites

Sure, I'll see if I can explain it better... (I'm doing this from memory, and I can't really share any code - this was done for my employer). Anyways: Assume that your original lattice has corners at L_000 and L_111 (and all the other corners are at L_001, L_010, etc...). For each vertex, transform them into "lattice space":

 

V_lattice = (V_world - L_000) / (L_111 - L_000)

 

At this point, any vertices that were inside the original lattice will have all three components in [0,1]. Anything outside will be out of that range. You could use those values directly as your weights (see below), but that's not what the FFD does. ... Hmm, actually, I'm not sure what it does in the 2x2 FFD case. For the 3x3 FFD, the weights for each point along one axis are (for example): x^2, 2*x*(1-x), (1-x)^2. For now, you can probably start with the linear weighting (just use the V_lattice from above).

 

To get the full weight for any particular lattice point, you multiply together all three vertex components (or their complement). So the weight for L_111 is (V.x * V.y * V.z). And the weight for L_010 would be ((1-V.x) * V.y * (1-V.z)). 

 

I hope that's some more help - I'm sorry I don't know the exact weighting in the 2x2 case - but if you do the linear version first, you can play with tuning the weights. In any case, the two terms you generate for any particular axis need to sum to one.

2

Share this post


Link to post
Share on other sites

Great, I think I understand now  though I'm fairly new to 3D dev (I thought smoothstep was a type of dance music wink.png )

I'll give it a try later and let you know how I fare with it.

0

Share this post


Link to post
Share on other sites

The above solution does indeed work! I set it up as a 2x2 lattice and didn't use the smoothstep weighting (just V.x or (1-V.x) as mentioned for basic weighting) and it works a treat. I'll try ading the smoothstep when I get a chance.

Thanks for the solution Osmanb.

1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0