Creating custom object classes in Unity

Hey guys, I’m a professional game developer (going on 15 years now) who’s getting a little tired of running the rat race, and thinking about doing some indie work.

There are a couple of things I’m looking for in a development environment, and scanning through the forums I’m not finding the info I need, so I’ll ask here:

  1. For the kind of project I’d like to work on, I would need access to including new classes of game objects. Many of these would need to compute custom vertex structures for submission to the draw hardware (and also allow code to set graphics hardware register constants from the app side). Does Unity give programmatic access to creating this type of object without getting a source code license?

  2. My tools licenses are all on the PC side… is it possible to network the MAC dev environment to a data creation PC over a network, and transfer useable files from one to the other (for example, native maya .mb or .ma files).

  3. Would I need to pick up a Mac at G5/Intel core duo class or better? (high performance macs are pricey!)…

  4. Is it possible without source code to modify the organization of the render pipeline? Can I pull a framebuffer copy at any point in the pipeline (to use as a reference texture for distortion effects for example)?

Really appreciate any help that can be offered on the subject, regards!

Tz

Couple of issues I can’t seem to find answers about in the forums… apologies if these have been answered before.

It sounds like you want to check out the Mesh interface. Unity does allow you to modify or create meshes to your heart’s content.

Yes, I’ve seen some users doing that with 3DS Max or Visual Studio on Windows.

Depends on what you’re doing. If your other software (modeling, Photoshop, etc) is running on a PC, there’s no good reason to buy a super-high-end Mac. Just buy an iMac and load it down with plenty of RAM - shouldn’t run you more than $1500 or so.

sorry, I wasn’t clear.

I’m referring to procedurally/code generated meshes in this case. In most systems I’ve used, you can derive a new object class off of an existing class, and then override the object’s member functions. In this case, I would probably generate a procedural mesh in the objects ::init() call (let’s say a water surface, or a rain field around the camera, etc), then update it every frame in the object’s ::update() function, and finally submit constant register updates and the modified vertex stream in the object’s ::draw() call.

Without source code, I’m guessing this is unlikely, but I was kind of hoping there’s some interface in the C++ plugin mechanism that allows this kind of extensibility (although, to be honest, I can’t see this working since it appears that plugins are referenced by the scripting language only, which would make them a run-time, not a tool-time interface).

The data side would then need to allow you to populate these objects either by making them reference the new class, then placing them directly into the scene or by spawning them with a script call.

That’s exactly what the mesh interface does, although the example of rain for example would be much better with a particle effect than actully using the mesh interface. Water is generally just a flat surface with bumpmaps.

But check out the documentation for the mesh scripting interface - it should offer all the functionality it sounds like you need.

And I mean, really, there’s a 30-day trial… just try it! :slight_smile:

You either read an object’s mesh data into several arrays (vertices, triangles, UVs, normals, tangents, some of which is optional depending on what you’re doing) and do stuff with it, or create it procedurally, then assign the data to an object. You do it with the scripting language, not using plugins; it’s really fast. (Agreed that rain is more easily handled with the particle system, but some people have done rolling ocean waves this way; I’ve used the mesh interface lots.)

Well, you can’t get a new Mac that’s Core Duo; they’re all Core 2 Duo, or Xeons in the case of the Mac Pro. No need to get the high end though; an iMac would be fine, or a refurb G5 if you want to go that route.

–Eric

Cool, so you can modify meshes on the fly with a scriptable interface.

Do you guys happen to know about creating custom shaders then, and passing in app side members with the vertex stream into the constant registers?

Hi Tz,
You wont be able to use native Maya files unless you have Maya installed on your Mac, as Unity uses Maya batch conversion to convert to fbx on import to the engine. If your still keen on going down this road, I believe you can have maya installed but not actually activated in order to get to the batch converter. Best you check with Joachim on this, and if its a road you want to go down, possibly autodesk will support it as you’ve already brought a hefty license and you are still only activating your pc version. You just need their permission and access to the installer file.

If you jumped through all those hoops, you’d be sweet. Or, get used to exporting to fbx, or buy a cheap app like cheetah 3d which is similar to maya in workflow, and use a combination, as Maya has some fairly extensive and diverse features…

Hardware? Well I’ve got by on a dinosaur, and its really frustrating waiting for it to do its tasks, but on the other hand, I’ve now been in game development for 1.5 years+, and thats really freakin cool.

G4 733mhtz/512ram/128vram

Welcome, I hope you stick around, sounds like you’ve got a fair bit of deep experience, It will be good to pick your brains sometime Im sure…

AaronC

You can do all of this from a script.

Using the mesh interface you can create new meshes and render them either using immediate mode rendering using Graphics.DrawMesh or by assigning them to a mesh renderer.
You can set up shaders materials and thus any opengl state prior to calling Graphics.DrawMesh using Material.SetPass

You can set shader constants using material.SetFloat or material.SetVector and friends.

If you want to use C++ for performance reasons you can pass some data from C# to C++ and modify them there. However there is usually no reason to do that, on a 3 year old G5 i can modify 4mio vertices per second uses C# and upload them to the graphics card each frame. At that point you are bound by agp vertex upload speed quickly anyway so the extra 50% performance you get from C++ doesn’t buy you much.

Since you can call them from anywhere, you can also call them from the tool. That is you could make a menu item, and call into C++ code. That said, unless you are accessing some devices or need to interface with loads of existing code, using C# or JavaScript is the highly recommended way.

Outstanding, thanks for the replies everyone…

So it looks like the only roadblock for me will be the Mac side of things (worked with Macs for years, and I’m a big fan, so no issues there.)

Appreciate all the feedback!

Regards,

Tz