2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: C# wrapper 2.3.3 - RELEASE
[Re: Stromausfall]
#381045
08/23/11 15:46
08/23/11 15:46
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
Serious User
|
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
ah...got confused with INVISIBLE^^
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: C# wrapper 2.3.3 - RELEASE
[Re: Rackscha]
#381070
08/23/11 20:45
08/23/11 20:45
|
Joined: Aug 2009
Posts: 1,438 Spain
painkiller
Serious User
|
Serious User
Joined: Aug 2009
Posts: 1,438
Spain
|
eh...your wrapper is using SHOW for entities. But isnt the correct flag VISIBLE ? panels and view entities use SHOW, and world entities use INVISIBLE
3D Gamestudio A8 Pro AMD FX 8350 4.00 Ghz 16GB RAM Gigabyte GeForce GTX 960 4GB
|
|
|
Re: C# wrapper 2.3.3 - RELEASE
[Re: painkiller]
#381216
08/25/11 13:51
08/25/11 13:51
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
Serious User
|
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
mh i have a problem with the partikle example. i wrote this
class MyGraphic
{
private static void ParticleLine(PARTICLE p)
{
}
public static void DrawLine3DEx(Vector AFrom, Vector ATo, Color AColor, int AAlpha, int ASize)
{
PARTICLE.effect(ParticleLine, 1, AFrom, ATo);
}
}
Get the error: "1 argument cannot be converted from ethodgroup to AcknexWrapper.WrapperDelegateParticle" Cant see any differences between my and your particle event in the tutorial. What have i done
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: C# wrapper 2.3.3 - RELEASE
[Re: Rackscha]
#381273
08/25/11 23:07
08/25/11 23:07
|
Joined: Dec 2002
Posts: 616 Austria
Stromausfall
OP
User
|
OP
User
Joined: Dec 2002
Posts: 616
Austria
|
well you're not using the scheduler (at least that's how it seams), thus some small things change ! in this case, the particle functions doesn't have a PARTICLE as argument anymore, but an IntPtr ! thus the correct code should be :
class MyGraphic
{
private static void ParticleLine(IntPtr p)
{
}
public static void DrawLine3DEx(Vector AFrom, Vector ATo, Color AColor, int AAlpha, int ASize)
{
PARTICLE.effect(ParticleLine, 1, AFrom, ATo);
}
}
|
|
|
Re: C# wrapper 2.3.3 - RELEASE
[Re: Stromausfall]
#381285
08/26/11 00:19
08/26/11 00:19
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
Serious User
|
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
ah thanks ANd how do i use it correctly now? ssems i got my first problem with the garbage collector Got a message that WrapperDelegateParticle did a callback(or however i have to translate it o.O), and it needs to be guranteed that objects are still available..etc. A bit tired and fully translating the germantext(wow ms c# really has long messages :D) is a bit to much now. currently i have those 3 Methods for testing:
private static void ParticleLineEvent(IntPtr AP)
{
PARTICLE P = PARTICLE.createFromPointer(AP);
P.lifespan = 0;
}
private static void ParticleLine(IntPtr AP)
{
PARTICLE P = PARTICLE.createFromPointer(AP);
P.lifespan = 1;
P.event_ = ParticleLineEvent;
}
public static void DrawLine3DEx(Vector AFrom, Vector ATo, Color AColor, int AAlpha, int ASize)
{
PARTICLE.effect(ParticleLine, 1, AFrom, (Vector) ATo.vec_sub(AFrom));
}
runs well for some frames, then it jumps out of the program into engine_frame
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: C# wrapper 2.3.3 - RELEASE
[Re: Rackscha]
#381295
08/26/11 06:36
08/26/11 06:36
|
Joined: Dec 2002
Posts: 616 Austria
Stromausfall
OP
User
|
OP
User
Joined: Dec 2002
Posts: 616
Austria
|
yes, that's because when you use no scheduler, you have to do some extra tasks ! The delegates are automatically collected by the garbage collector, that's why the scheduler stores them ! If use no scheduler, you have to store the used delegates yourself ! the following code snippet should work (i guess) :
// create a delegate for the particle method and store it, if you use instance
// methods etc... you have to store them in another way, but using only static
// methods, this should work too !
private static readonly WrapperDelegateParticle StoredDelegateForParticles = ParticleLineEvent;
private static void ParticleLineEvent(IntPtr AP)
{
PARTICLE P = PARTICLE.createFromPointer(AP);
P.lifespan = 0;
}
private static void ParticleLine(IntPtr AP)
{
PARTICLE P = PARTICLE.createFromPointer(AP);
P.lifespan = 1;
P.event_ = ParticleLineEvent;
}
public static void DrawLine3DEx(Vector AFrom, Vector ATo, Color AColor, int AAlpha, int ASize)
{
// call the effect method, already with the stored delegate
PARTICLE.effect(StoredDelegateForParticles, 1, AFrom, (Vector) ATo.vec_sub(AFrom));
}
|
|
|
Re: C# wrapper 2.3.3 - RELEASE
[Re: Stromausfall]
#381331
08/26/11 15:08
08/26/11 15:08
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
Serious User
|
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
a thanks. and executing the drawline3dex method multiple times still works? And just in case: if i want to use it in an instanced object(so no static methods), how do i handle those? edit: and you explain a little bit how your example above in combination with the garbage collector works within your acknexwrapper? just interseted^^ edit2: Little question: even if your scheduler is not running, isnt it possible for the wrapper to catch the delegate? I mean i call PARTICLE.effect. Isnt it possible to catch it inside your effect function? Greets Rackscha
Last edited by Rackscha; 08/26/11 15:42.
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: C# wrapper 2.3.3 - RELEASE
[Re: Rackscha]
#381339
08/26/11 17:16
08/26/11 17:16
|
Joined: Dec 2002
Posts: 616 Austria
Stromausfall
OP
User
|
OP
User
Joined: Dec 2002
Posts: 616
Austria
|
nope shouldn't be a problem because you use the same STATIC method !
well if you use instanced methods, then you should create a member variable that stores the delegate (like the static one in the example, but NOT static) !
well after you pass the delegate the wrapper, a Marshal method allows to get an IntPtr that points to the managed delegate, this delegate is then passed to the C++ API of the acknex.dll, then the acknex.dll calls the IntPtr, which then calls the delegate (this done inside of .net) ! Thus if the delegate was removed by the garbage collector, the IntPtr points to a delegate that has been removed !
In the scheduler, the delegates for particles are stored as long as they are called every frame, if a particle delegate isn't called anymore, it is automatically removed (because particle functions are called every frame !) Other delegates for example in ent_create only have to be stored while the function is called (for example ent_create), because after this they aren't called anymore... Variables that use delgates, store the delegate and simply overwrite it when the value is changed... And the delgates that are used for the panel methods are stored in a dictionary, that removes the delegates, when the panel element is removed..
|
|
|
Re: C# wrapper 2.3.3 - RELEASE
[Re: Stromausfall]
#381353
08/26/11 20:19
08/26/11 20:19
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
Serious User
|
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
ah thanks One last question though: how do i do a basic setup for the particle? The example above only uses ParticleLineEvent. But how can i setup size/color etc only once? Do i have to store the other event in a wrapper delegate too, use this one first and then reassign the event delegate after first execute of the setup function?
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
|