Jump to content

.NET Headers 2.0


L B
 Share

Recommended Posts

Wow! Great job! Everything is very polished and professional. Thanks to all who contributed!!

AMD Phenom II X6 Black Edition, 8GB, 120 GB SSD, 2TB HDD, nVidia GTX 570 1.2GB, Win 7 x64

Intel Core i5, 4GB, 120GB SSD, NVidia 360M 1GB, Win 7 x64

Link to comment
Share on other sites

So how complete is this latest version with regard to the LE engine? Can I do everything with the C# headers as can be done with the C++?

 

Can and more! A lot more...

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

cube.Position.X += sphere.Rotation.Y;
Framework.Effects.Bloom.Enabled = !Framework.Effects.Bloom.Enabled;

 

Many getters are only available in C#, such as Framework effects.

Here's the equivalent of the first line in C. Notice how longer it is.

 

PositionEntity(cube, EntityPosition(cube).X +
EntityRotation(sphere).Y, EntityPosition(cube).Y,
EntityPosition(cube).Z);

 

You simply can't do the first line in another language.

Link to comment
Share on other sites

You don't have dynamic, per-component get/set accessors in any other language except Blitzmax.

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

Can you elaborate on what dynamic, per-component get/set accessors is? I'm hard pressed to think C++ can't do this in one form or another. The line that was posted can be done in C++, so I'm interested in this dynamic, per-compoennt get/set accessors.

 

I do understand that if reflection is used C++ has issues with (but can still use libraries to set reflection up), but I can't see why reflection would be used in the given example, so I'm not following what you mean.

Link to comment
Share on other sites

After a little googling I was able to come up with the following that seems to gives the same behavior. More operator overloading can be done in the properties class to handle other operations if needed.

 

template<class _Prop_t, class _ObjClass_t>
class Property
{
// typedef the callback methods
   typedef _Prop_t (_ObjClass_t::* _pmGet_t)() const;
   typedef void (_ObjClass_t::* _pmSet_t)(_Prop_t);

   _ObjClass_t& m_objInstance;
   _pmGet_t     m_pmGet;
   _pmSet_t     m_pmSet;

public:
   Property(_ObjClass_t& objInstance, _pmGet_t pmGet, _pmSet_t pmSet) :  m_objInstance(objInstance), m_pmGet(pmGet), m_pmSet(pmSet)
   {}
   operator _Prop_t() { return (m_objInstance.*m_pmGet)(); }
   void operator =(_Prop_t value) { (m_objInstance.*m_pmSet)(value); }
_Prop_t operator +=(_Prop_t value) 
{ 
	(m_objInstance.*m_pmSet)((m_objInstance.*m_pmGet)() + value);
	return (m_objInstance.*m_pmGet)();
}
};


class Sample 
{
private:
       int m_length; 
public: 
       int GetLength( ) const
       { 
               return m_length ; 
       } 

       void SetLength (int nInputData )
       { 
		// do whatever you want here
               if ( nInputData < 0 ) 
                       m_length = 0 ; 
               else 
                       m_length = nInputData ; 
       }

       Property<int, Sample> Length;

       Sample() : m_length(0), Length(*this, &Sample::GetLength, &Sample::SetLength)
       {}
};


int main(int argc, char* argv[])
{
   Sample obj;
   obj.Length = 100;

int a = obj.Length;
obj.Length += 50;
a = obj.Length;

   return 0;
}

Link to comment
Share on other sites

At first congrats for releasing it and thx for the hard work you both have done so far.

 

I have found some small additions/bugs:

 

Missing functions

-- CreateSurface | Declared only in Core but not in Mesh or Surface

-- Get/SetVertexColor | Not declared in Core

 

Small bug:

-- TriangleVertex returns void, but should return int.

 

Hope this will be fixed soon ;) Currently I have a small workaround for this (Klepto.CoreAdditions).

Otherwise it seems very complete and nice.

 

[Edit]

found out that you can use mesh.surfaces.add([material]) as CreateSurface

the standard functions should still be accessable IMHO

 

@Rick: I believe he means extra getter / setter which are not available in the other languages because the engine.dll provided with LE doesn't offer these. The C# header uses a modified dll with much more functions. When using this sll with c++ or other languages, they can provide these features as well.

  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

@Rick: Please don't be aggressive on language comparison, as it isn't our intention to compete: we're simply proud of the time we invested in the wrapper that, to us, paid off.

 

Dynamic Vectors

Indeed, all languages can provide the given functionality - however, as far as it goes now, only C# implements it. This means you *can* do it in C/C++, but you'll have to make the headers yourself. And believe me, it's a tedious task. Also, we do not use reflection (hard to maintain), but delegates.

 

The line that was posted was this:

cube.Position.X += sphere.Rotation.Y;

 

The simplest and natural translation to C/C++ would therefore be:

EntityPosition(cube).X += EntityRotation(sphere).Y;

 

However, trying that, you will realize that it has no effect. This is because the Vector3 returned by EntityPosition isn't dynamic, and therefore, changes applied to it do not apply engine commands. You will merely store a variable and increment it, but not set its value back.

 

Simplified Casts

Of course, you'll still be able to increment the cube's X position in a longer manner. But version 2 was all about usability. For instance, you can declare a whole vector by a float or integer, due to an extensive set of operators and casts we created. Example:

 

sun.Rotation = 45;

 

This will set the sun's rotation to 45 degrees in all directions.

 

Advanced Accessors

What do we mean by "advanced accessors"? Have a look at this page: Unified Get/Set accessors. Our custom engine DLL and headers fully implement them, giving you much more flexibility and control.

 

 

 

 

@klepto2: Sorry for the vertex stuff, many things are bugged in this sector. We'll look into it very soon.

Link to comment
Share on other sites

@Rick: Please don't be aggressive on language comparison, as it isn't our intention to compete: we're simply proud of the time we invested in the wrapper that, to us, paid off.

 

Sorry, I didn't mean to come across as aggressive. I was just trying to get an accurate understanding of why this is special in the LE C# implementation. Thanks for the explanation.

Link to comment
Share on other sites

Wow guys, this is looking great!

Can we use Leadwerks in conjunction with Windows Forms (e.g. render to a picturebox)? This would be the way to go then certainly for Leadwerks GUI tools.

desktop: Quad core Q6600 + 4GB + ATI HD4890 + XP

laptop: Dual core T6400 + 4 GB + NVidia 9600M GT + Vista 32

Link to comment
Share on other sites

Wow guys, this is looking great!

Can we use Leadwerks in conjunction with Windows Forms (e.g. render to a picturebox)? This would be the way to go then certainly for Leadwerks GUI tools.

 

I have succesfully converted my LEControl yesterday and i will contribute it as soon as it is tested and works stable.

  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

Ok, some more things i have found.

 

-- ScaleMesh isn't included in the OOP header.

-- How to retrieve global or local vectors?

-- GetPreferedMaterialName isn't defined in the Engine.dll !! Critical !! Cant use the Surface object

-- Color cast from float[] to Color doesn't multiply with 255 (backcast from color to float[] devides by 255)

  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

Ok, some more things i have found.

 

-- ScaleMesh isn't included in the OOP header.

-- How to retrieve global or local vectors?

-- GetPreferedMaterialName isn't defined in the Engine.dll !! Critical !! Cant use the Surface object

-- Color cast from float[] to Color doesn't multiply with 255 (backcast from color to float[] devides by 255)

 

  1. Object scaling (as seven mentioned, it didn't work on meshes as entities): Fixed. Give me some time to upload the next revision. Done.
  2. Mesh scaling: use the following snippet:
    using (Mesh.Editing)
    {
       example.Scale = new Vector3(5, 9, 1);
    }


    Use the same for "Translate" and "Rotate".

  3. GetPreferredMaterialName: Far from being a critical command, I asked Tyler to add it to our DLL for Middlewerks. It should be there when I get to talk to Tyler again.
    Why can't you access the surface object? This should do for most uses:
    example.Surfaces[0].Material.Path


  4. Retrieving global and local vectors? Specify please.
  5. Color cast: This is normal. Try the following code to test by yourself:
    Color test = new float[] { 0.5f, 1f, 0.5f, 1f };
    Debug.Alert(test.ToString());
    
    float[] casted = (float[])test;
    Debug.Alert(string.Format("{0}f, {1}f, {2}f, {3}f", casted[0], casted[1], casted[2], casted[3]));


    This is because the internal constructor uses floats. Please do not assume it's wrong then, you shouldn't be messing with a reflector and looking into our methods anyway :lol:

Link to comment
Share on other sites

Get/Set PreferredMaterialName have been added to the DLL.

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

First thx for the fast fix.

 

1. GetPrefferedMaterialName was critical for me because I wasn't able to access surface properties at all. This was due an internal Entrynotfound exception and causes the running program to stop.

2. Global/Local Vectors (ok bad description) Position and Rotation of an entity have a global and a local value. How to get them?

3. I don't use a reflector, but i have tried to implement SetVertexColor/GetVertexColor to my CoreAdditions as I need them for highlighting selected surfaces. And by doing this i have noticed this issue. If i have used a reflector i might have seen that this is wanted behaviour :).

 

Why are you making the mesh.Scale so complicated? Why don't you just renew the mesh.Scale property with MeshScale and then you can access them like this:

m.Scale ; ScaleMesh

((Entity)m).Scale ; ScaleEntity

  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

2: Use this using block:

 

using (Engine.Globality)

{

// Get/Set position, rotation, scale, etc.

}

 

If you use that, it is global, otherwise everything is local.

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...