rosenkro
30-10-2006 09:46:00
Hi,
i'm working on creating all of the examples in vb.net. At the moment i'm trying BezierPatch, but the following
MeshManager.Singleton.createBezierPatch(...)
is not working, because createBezierPatch is missing.
Roland
Bekas
30-10-2006 09:58:34
Actually it's not missing, the problem is that the method accepts a void* pointer and VB.NET doesn't support pointers.
I can make it IntPtr to make it accessible but isn't it difficult to handle pointers through VB ? How are you creating and passing the control points (patchCtlPoints in the Ogre demo) ?
rosenkro
30-10-2006 15:45:19
I tried to make a "PatchVertex" class (like the structure in the c++ example) with all required fields. Then I want to make an array of this class with the data (this is the patchCtlPoints data) and pass it to the createBezierPatch like
patch = MeshManager.Singleton.createBezierPatch("Bezier1", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, patchCtlPoints, patchDecl, 3, 3, 5, 5, PatchSurface.VS_BOTH)
BTW the PatchSurface.VS_BOTH isn't recognized.
It looks like
Public Class PatchVertex
Public x As Double
Public y As Double
Public z As Double
Public nx As Double
Public ny As Double
Public nz As Double
Public u As Double
Public v As Double
End Class
' Make a 3x3 patch for test
patchCtlPoints(9) = New PatchVertex
' Patch data
patchCtlPoints(0).x = -500.0
patchCtlPoints(0).y = 200.0
patchCtlPoints(0).z = -500.0
patchCtlPoints(0).nx = -0.5
patchCtlPoints(0).ny = 0.5
patchCtlPoints(0).nz = 0.0
patchCtlPoints(0).u = 0.0
patchCtlPoints(0).v = 0.0
.
.
.
Bekas
31-10-2006 00:26:27
BTW the PatchSurface.VS_BOTH isn't recognized.
It's PatchSurface.VisibleSide.VS_BOTH (the enum class name is required in .NET)
PatchVertex should be a Structure, not a class; the array should not contain references but the actual values so that they can be passed to unmanaged code.
I'm considering adding a custom overload method CreateBezierPatch<T> that will accept an array (instead of a pointer), the type T of which will be provided using generics:
PatchVertex[] controlPoints = new PatchVertex[10];
MeshManager.Singleton.CreateBezierPatch<PatchVertex>(name, groupName, controlPoints, decl, 0, 0);
T will also be restricted only to structs.
Does this seem "intuitive"? Has anyone any other idea?