tags:

views:

58

answers:

1

Hi, i wanted to know how to edit 3d models' vertices in XNA at runtime, i wana do something like the 3d max subtract feature where u put 2 models together and delete the intersecting vertices of 1 of them, more like carving one mesh with the other.

see this if i wasn't clear

anyway so any pointers on how to edit vertices at runtime or any help is really really appreciated.

thanks

A: 

You can't do that.

AFAIK, OpenGL, DirectX and XNA have no utility functions for boolean operations on triangulated meshes (if they had those, we would be seeing fully destructible environments in every game on the market). If you want to do that, you'll have to implement boolean operations yourself. It will be EXTREMELY difficult (especially dealing with topology), and I mean it (tried to do that, will implement them someday (as exercise) when I have more time).

Or you could try adapting/using source code from blender or libgts. BOth of them have implemented boolean operations, but they are written in C/C++, not in C#, so it will be "fun" no matter how you look at it. Also, be careful about licenses if you decide to use their code. Both use flavors of GPL, and GPL is "viral" license.

SigTerm
okay seriously? talk about complexity!i found thishttp://forums.xna.com/forums/t/16614.aspxit has some ready made code but i'm more interested in algorithms which is what i found in a reply that mentioned a published paper...http://www.inf.usi.ch/hormann/papers/Greiner.1998.ECO.pdfwhich looks nice, this is gonna be super funnnnnn
OSaad
@OSaad: As you wish. This is seriously difficult, don't say I didn't warn you. It can be done, but it is a complex procedure with many places where you can easily screw up everything. The basic of boolean op is pretty simple: A - B equals side of A which is outside of B plus inverted side of B which is inside A. This is simple. The problem will arise when you'll start cutting geometry, find out that you'll need triangulation, and realize that standard DirectX mesh doesn't have enough info, which means you'll have to generate it and recalculate it back.
SigTerm
@OSaad: The realtime boolean OP was done in Red Faction 1's GeoMod engine (Guerialla uses completely different technology), but it operated on primitives (sphere/cube - CSG), not on triangles. If I recall correctly, it took about 6 months to develop the technology for a programmer. The booleans on triangulated meshes are the most complex thing (I know of) to be implemented in realtime 3D. Before trying to do the real booleans, try cutting a simple indexed mesh with multiple materials using a plane, and cap the hole with polygons. When you can do that - you are qualified to try real booleans.
SigTerm
@OSaad: "ready made code" Oh, and before I forget it... cutting one polygon by another one is incredibly simple and you should really be able to do it yourself. Cutting entire model is not - there will be many other problems to deal with.
SigTerm