Von04 Posted August 24, 2010 Share Posted August 24, 2010 I'm trying to create an emitter using c# 2010 without any luck. To create a mesh you would use Mesh cube = Mesh.CreateCube(), but their doesn't seem to be a function like that for an emitter. I've tried using Emitter fire = new Emitter(IntPtr.Zero) which doesn't give me an error, but as soon as I try to manipulate the emitter the program crashes likes it was never created. Am I doing something wrong or is the c# wrapper not working with emitters right now. Any help would be appreciated. Quote 3d world studio. 3ds Max 8. GTX 260. Visual Studio 2010. Dual Core 2.6 Mhz processor. Link to comment Share on other sites More sharing options...
klepto2 Posted August 24, 2010 Share Posted August 24, 2010 Emitter fire = new Emitter() use the standard constructor. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Von04 Posted August 24, 2010 Author Share Posted August 24, 2010 Emitter fire = new Emitter() use the standard constructor. When I use that line of code I get the "Object reference not set to an instance of an object" error. Here is the Emitter class I am using: using System; namespace Leadwerks { public class Emitter : Entity { public Emitter(IntPtr pointer); public Emitter(int intensity = 100, int lifetime = 1000, Vector3 velocity = null, EmitterCycleMode cycleMode = EmitterCycleMode.Loop, Entity parent = null); public Vector3 Acceleration { set; } public Vector3 Area { set; } public bool Paused { get; set; } public float RotationSpeed { set; } public Vector3 Velocity { set; } public float Waver { set; } public void Pause(); public void Resume(); public void SetRadii(float inner, float outer); } } Emitter fire = new Emitter() use the standard constructor. If I use Emitter fire = new Emitter(100, 100, new Vector3(0,0,0), EmitterCycleMode.Loop, Entity.NullPointer), then I get an "Object reference not set to an instance of an object" error also. Quote 3d world studio. 3ds Max 8. GTX 260. Visual Studio 2010. Dual Core 2.6 Mhz processor. Link to comment Share on other sites More sharing options...
klepto2 Posted August 24, 2010 Share Posted August 24, 2010 Don't use Entity.NullPointer, these Pointers are needed if you use the standard Pointer functions and not the OOP classes. Replace it with null or don't use it at all, it is an optional parameter. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
L B Posted August 24, 2010 Share Posted August 24, 2010 You are using outdated headers. "SetRadii" doesn't exist anymore in version 2, and is replaced by the "Radii" member with dynamic get and set accessors. Has anybody noticed this link? http://www.middlewerks.com/headers/ I posted it many times with barely no comment, which is surprising since people had been waiting on it for over 2 months. Now onto the fix: Vector comparison didn't support null checks, which is now fixed. I'm uploading the new revision. Should be on in 5 minutes at most. Quote Link to comment Share on other sites More sharing options...
Von04 Posted August 24, 2010 Author Share Posted August 24, 2010 Thanks Lazlo, while waiting I figured out this workaround. [DllImport("Engine.DLL", EntryPoint = "CreateEmitter", CallingConvention = CallingConvention.StdCall)] public static extern IntPtr CreateEmitter(int Intensity, int Lifetime, Vector3 Acceleration, int CycleMode, IntPtr Parent); IntPtr emitter = CreateEmitter(100, 1000, new Vector3(0, 5, 0), 0, IntPtr.Zero); Emitter fire = new Emitter(emitter); Quote 3d world studio. 3ds Max 8. GTX 260. Visual Studio 2010. Dual Core 2.6 Mhz processor. Link to comment Share on other sites More sharing options...
L B Posted August 24, 2010 Share Posted August 24, 2010 Good, but feel free to use the latest version of the headers, with the following parameters: Emitter fire = new Emitter(velocity: new[3] { 0, 5, 0 }); It's less than a quarter of the previous code in terms of characters. Quote Link to comment Share on other sites More sharing options...
CopperCircle Posted August 30, 2010 Share Posted August 30, 2010 How do you paint the emitter in C#? Thanks. Quote Link to comment Share on other sites More sharing options...
L B Posted August 30, 2010 Share Posted August 30, 2010 emitter.Material = Material.Load("abstract::leaf.mat"); Quote Link to comment Share on other sites More sharing options...
CopperCircle Posted August 30, 2010 Share Posted August 30, 2010 Great, thanks. Quote Link to comment Share on other sites More sharing options...
CopperCircle Posted August 30, 2010 Share Posted August 30, 2010 Sorry, another question! I can't figure out how to use Framework.Layer to create the emitter in the transparency world? and then switch back to the main world? Quote Link to comment Share on other sites More sharing options...
L B Posted August 30, 2010 Share Posted August 30, 2010 emitter.World = Framework.Layers.Transparency.World; That will only work in C# though. Don't expect it in another language. Quote Link to comment Share on other sites More sharing options...
CopperCircle Posted August 31, 2010 Share Posted August 31, 2010 Brilliant, thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.