PDA

View Full Version : creating a procedural mesh


cwiebe
03-17-2008, 03:29 PM
hi there, i'm fairly new to xsi development (but highly experienced in 3dsmax and other development) so i'm just wondering if something like this is possible...

i want to create a procedural mesh object that changes based on the time. mesh topology need not be consistent so i can't just animate the verts.

basically, a new mesh is built at each whole frame from a mesh file. at half frames, the mesh verts are offset based on velocity (this is to preserve motion blur, etc.)

we've written a tool like this for 3dsmax, but now need an equivalent one for xsi.

i've tried using a time callback on my plugin that destroys the mesh and creates a new one, but this is no good for motion blur, plus there has to be a proper way.

any help would be appreciated.

CiaranM
03-17-2008, 05:24 PM
i've tried using a time callback on my plugin that destroys the mesh and creates a new one, but this is no good for motion blur, plus there has to be a proper way.
any help would be appreciated.
Hi,
I'm writing a similar tool myself. The only difference being that my geometry is generated on the fly, rather than reading from a file.
What exactly do you mean by "destroy the mesh"? This sounds unnecessary.
Have you considered implementing your plugin as an operator that evaluates during playback?
Such an approach with the polygonMesh.Set method of the Object Model would allow you to build your mesh every n frames based on input vertices data. I expect the data could be imported from external sources or perhaps more interestingly, generated procedurally within the update context of the operator.
Also, since the operator is time-based, it is easy to add translation on a per-point level (see Point.PositionArray).

I don't know if this helps you at all, but this the approach that jumped to my mind, when reading your problem. :)

cwiebe
03-17-2008, 05:37 PM
thanks, actually that's pretty helpful. I've been reading docs and looking at source code of other people that are doing similar things. for example, what i'm going to try next (sort of like you suggested) is to create an operator that you apply to a polygon mesh. what the operator does is basically ignore the original state of the mesh and just create one based on my file at the correct time.

does it seem reasonable to implement it as an operator? even if is destroying the initial topology of the mesh?

i'm just used to 3dsmax where scene objects are themselves evaluated based on time. is there some way in xsi to make a 3d scene object that evaluates based on time?

scaron
03-17-2008, 05:46 PM
changing the topology (adding and removing components)...

http://softimage.wiki.avid.com/sdkdocs/cf448413.htm

CMeshBuilder Class...

http://softimage.wiki.avid.com/sdkdocs/sicppsdk/html/classXSI_1_1CMeshBuilder.html

CiaranM
03-17-2008, 05:59 PM
what i'm going to try next (sort of like you suggested) is to create an operator that you apply to a polygon mesh. what the operator does is basically ignore the original state of the mesh and just create one based on my file at the correct time.
does it seem reasonable to implement it as an operator? even if is destroying the initial topology of the mesh?

Yes, this is perfectly fine. I do this myself and it is actually recommended in the SDK Docs (see What is a Custom Operator?). When referencing time in your operator, for more reliable evaluation, you might want to call the 'Time' or 'CurrentFrame' property of the operator context (depending on whether you write a custom operator or a SCOP).

i'm just used to 3dsmax where scene objects are themselves evaluated based on time. is there some way in xsi to make a 3d scene object that evaluates based on time?
mmm...not quite sure what you mean by that. If you mean is there a connection between the geometry object and scene time, then no I don't believe so (only object parameters, I believe). I think that's what operators come in useful.

cwiebe
03-17-2008, 06:10 PM
thank you all, this is very helpful. i should be able to make this work now that i understand a little bit better how xsi deals with geometry.

what i meant about the 3dsmax thing is that, in max, all geometry objects have a BuildMesh(TimeValue t) function that gets called whenever the time changes. so the meshes they produce can be deforming over time regardless of user parameters. it appears that in xsi, this is the job of the operators.

cwiebe
03-20-2008, 05:16 PM
could i not use a Generator Operator to make such a mesh? i have yet to be able to get a GenOp working. if there's some sample code out there, i haven't been able to find it.

CiaranM
03-20-2008, 06:50 PM
Here's an interesting thread that might be informative regarding the limitations of generator ops, which may or may not be relevant to your problem: http://www.xsibase.com/forum/index.php?board=14;action=display;threadid=28603;s tart=0#msg185822

From what I can surmise GenOps can be called from commands only, and are limited in support, and your best bet is to use Geometry.Set().
Please someone correct me if this is wrong.

cwiebe
03-20-2008, 07:31 PM
ahh, so this is why my mesh builder is failing without telling me why:
"UDEV00196841 CMeshBuilder - Cannot be used from within a custom operator"

PolygonMesh.Set() should work.

i suppose i don't really understand how generator operators work. i figured they'd be basically the same as a topological operator, except there is no "input" topology--they are always at the bottom of the operator stack.

so, for example, i was looking at XSI's "MeshMerge" generator operator. that makes a new object with a polygon mesh. its polygon mesh operator stack has a "Mesh Merge" as a generator operator. so basically, i want to make something like MeshMerge. but i haven't been able to get something like that working.

if it turns out i need to implement it as a topological operator, that's fine. it just seems much more natural to do it as a generator, and i'll probably get less complaints :) if anyone has any insight on this topic, let me know.