|
Re: C# wrapper 2.2.6 - RELEASE
[Re: jenGs]
#372767
06/04/11 07:52
06/04/11 07:52
|
Joined: Dec 2002
Posts: 616 Austria
Stromausfall
OP
User
|
OP
User
Joined: Dec 2002
Posts: 616
Austria
|
Hi ! From what i can see, there are two types of materials in the shader library : Predefined Materialsand Predefined Surface Shadersfor an example of how to load a Predefined Surface Shader (a shader that uses a .fx file) follow this link to an example (there is also a download link to an example) : shader example If you on the other hand want to assign a Predefined Material, then you only have to assign the corresponding EngVar. Here's an example :
using System;
using System.Collections.Generic;
using AcknexWrapper;
namespace ShaderTest
{
class Program
{
static void Main(string[] args)
{
EngFun.engine_open(null, null);
Scheduler.StartScheduler(MyMainMethod);
}
private static IEnumerable<ScheduleMethod> MyMainMethod()
{
// load an empty level
EngFun.level_load(null);
// create a cube (_CUBE.mdl is a predefined model - CUBE_MDL in lite-c)
ENTITY cube =
ENTITY.ent_create(
"_CUBE.mdl",
new Vector(60, -20, 0),
CubeMethod);
yield break;
}
private static IEnumerable<ScheduleMethod> CubeMethod(IntPtr p)
{
ENTITY cube =
ENTITY.createFromPointer(p);
// now assign the standard metal material
cube.material =
EngVar.mtl_metal;
// change the ambient vector of the standard metal material
EngVar.mtl_metal.ambient_red = 255;
while (true)
{
// rotate the cube
cube.pan += 2 * EngVar.time_step;
cube.tilt += 1.5 * EngVar.time_step;
// wait one frame
yield return 1;
}
}
}
}
Last edited by Stromausfall; 06/04/11 07:53.
|
|
|
Re: C# wrapper 2.2.6 - RELEASE
[Re: Stromausfall]
#372949
06/06/11 02:49
06/06/11 02:49
|
Joined: Jul 2010
Posts: 283 Germany
jenGs
Member
|
Member
Joined: Jul 2010
Posts: 283
Germany
|
Hey, thank you for your help. But I have another problem. I have an embeded engine Window in a form. Now I want to feed my Form with data from the engine thread. Is this possible? I don't now that much about threading in csharp. Another question: How do I pass a parameter value to a Scheduled method? Edit: Ok, the last problem is solved. I should read your examples more carfully . Is the AddEventObject method the only possible way to pass a parameter? So I guess I have to create a data structure with the information I want to pass?
Last edited by jenGs; 06/06/11 03:00.
|
|
|
Re: C# wrapper 2.2.6 - RELEASE
[Re: jenGs]
#372987
06/06/11 14:29
06/06/11 14:29
|
Joined: Dec 2002
Posts: 616 Austria
Stromausfall
OP
User
|
OP
User
Joined: Dec 2002
Posts: 616
Austria
|
Hi! yes the AddEventObject and Scheduler.AddEventObjectThreadSafe methods are the only way to pass an argument ! But passing an argument is often not necessary, because you can of course create an object fore the method, and thus store as many parameters as you want ! for example :
class SomeClass
{
private string storedParameter1;
private int storedParameter2;
public SomeClass(string parameter1, int parameter2)
{
this.storedParameter1 = parameter1;
this.storedParameter2 = parameter2;
Scheduler.AddEventVoid(SomeFun);
}
private IEnumerable<ScheduleMethod> SomeFun()
{
Console.WriteLine(storedParameter1 + storedParameter2);
yield break;
}
}
There are lots and lots of different approaches to solve this ! Putting all arguments into a struct and then pass it as object parameter is most likely not the best one - because it is quite unsafe and involves casting !
|
|
|
Re: C# wrapper 2.2.7 - RELEASE
[Re: Stromausfall]
#375054
06/23/11 12:15
06/23/11 12:15
|
Joined: Dec 2002
Posts: 616 Austria
Stromausfall
OP
User
|
OP
User
Joined: Dec 2002
Posts: 616
Austria
|
a new version was uploaded (for Acknex 7.85.4 AND Acknex 8.10) the update of the wrapper includes: this update includes: - the conversion between acknex Var variables/values and C# double values has been improved signifcantly ! If you now set/get the value of an engine object/variable to 9.493, it IS 9.493 in the acknex engine ! Previously a slight rounding error was always present (this showed when using a panel which displayed a number, or using pixel_ functions). - the scheduler/acknex engine can now be closed and started again, through using the new Scheduler.CloseEngineAndScheduler method and waiting for Scheduler.EngineClosed to become true (after calling the Scheduler.CloseEngineAndScheduler method). After this the engine/scheduler is fully reset and can be started again ! here's the link: AcknexWrapper_2_2_7_FOR_8_10_AND_7_85_4.zip
|
|
|
Re: C# wrapper 2.2.8 - RELEASE
[Re: Stromausfall]
#375203
06/24/11 09:48
06/24/11 09:48
|
Joined: Dec 2002
Posts: 616 Austria
Stromausfall
OP
User
|
OP
User
Joined: Dec 2002
Posts: 616
Austria
|
a new version was uploaded (for Acknex 7.85.4 AND Acknex 8.10) the update of the wrapper includes: this update includes: - reverted ‘improved conversion’ to the old (pre 2.2.7) conversion, because the ‘new conversion’ (2.2.7) is buggy and slow - pixel_for_vec, pixel_to_vec, pixel_for_bmap, pixel_to_bmap – internally no conversion happens anymore – the pixel value now has type ‘int’ not double (thus allows consistent read and write) here's the link: AcknexWrapper_2_2_8_FOR_8_10_AND_7_85_4.zip
Last edited by Stromausfall; 06/24/11 09:48.
|
|
|
Re: C# wrapper 2.2.9 - RELEASE
[Re: Stromausfall]
#375524
06/26/11 09:37
06/26/11 09:37
|
Joined: Dec 2002
Posts: 616 Austria
Stromausfall
OP
User
|
OP
User
Joined: Dec 2002
Posts: 616
Austria
|
a new version was uploaded (for Acknex 7.85.4 AND Acknex 8.10) the update of the wrapper includes: this update includes: - ScheduleMethod.executeEventVoid and ScheduleMethod.executeEventObject improved -> methods added that way, when they end, immediately jump back to the method that called them, not wait 1 frame to jump back ! here's the link: AcknexWrapper_2_2_9_FOR_8_10_AND_7_85_4.zip
|
|
|
|