-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[modelio] Update for iOS 10.2 beta 1 #1126
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#if XAMCORE_2_0 || !MONOMAC | ||
using System; | ||
using XamCore.ObjCRuntime; | ||
using Vector2i = global::OpenTK.Vector2i; | ||
|
||
namespace XamCore.ModelIO { | ||
|
||
public enum MDLNoiseTextureType { | ||
Vector, | ||
Cellular, | ||
} | ||
|
||
public partial class MDLNoiseTexture { | ||
[iOS (9,0), Mac (10,11, onlyOn64 : true)] | ||
public MDLNoiseTexture (float input, string name, Vector2i textureDimensions, MDLTextureChannelEncoding channelEncoding) : this (input, name, textureDimensions, channelEncoding, MDLNoiseTextureType.Vector) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see now that it replace an existing API :) |
||
{ | ||
} | ||
|
||
public MDLNoiseTexture (float input, string name, Vector2i textureDimensions, MDLTextureChannelEncoding channelEncoding, MDLNoiseTextureType type) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. more like |
||
{ | ||
// two different `init*` would share the same C# signature | ||
switch (type) { | ||
case MDLNoiseTextureType.Vector: | ||
Handle = InitVectorNoiseWithSmoothness (input, name, textureDimensions, channelEncoding); | ||
break; | ||
case MDLNoiseTextureType.Cellular: | ||
Handle = InitCellularNoiseWithFrequency (input, name, textureDimensions, channelEncoding); | ||
break; | ||
default: | ||
throw new ArgumentException ("type"); | ||
} | ||
} | ||
} | ||
} | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,8 @@ | |
|
||
namespace XamCore.ModelIO { | ||
|
||
delegate void MDLObjectHandler (MDLObject mdlObject, ref bool stop); | ||
|
||
[iOS (9,0)][Mac(10,11, onlyOn64 : true)] | ||
[BaseType (typeof(MDLPhysicallyPlausibleLight))] | ||
[DisableDefaultCtor] | ||
|
@@ -415,6 +417,10 @@ interface MDLMaterial : MDLNamed, INSFastEnumeration | |
[return: NullAllowed] | ||
MDLMaterialProperty GetProperty (MDLMaterialSemantic semantic); | ||
|
||
[iOS (10,2), Mac (10,12,1)] | ||
[Export ("propertiesWithSemantic:")] | ||
MDLMaterialProperty[] GetProperties (MDLMaterialSemantic semantic); | ||
|
||
[Export ("removeAllProperties")] | ||
void RemoveAllProperties (); | ||
|
||
|
@@ -645,7 +651,11 @@ nuint VertexCount { | |
} | ||
|
||
[Export ("vertexBuffers", ArgumentSemantic.Retain)] | ||
IMDLMeshBuffer[] VertexBuffers { get; } | ||
IMDLMeshBuffer[] VertexBuffers { | ||
get; | ||
[iOS (10,2), Mac (10,12,1), TV (10,1)] | ||
set; | ||
} | ||
|
||
[NullAllowed] | ||
[Export ("submeshes", ArgumentSemantic.Copy)] | ||
|
@@ -763,6 +773,12 @@ NSMutableArray<MDLSubmesh> Submeshes { | |
[MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] | ||
MDLMesh CreateCylindroid (float height, Vector2 radii, nuint radialSegments, nuint verticalSegments, MDLGeometryType geometryType, bool inwardNormals, [NullAllowed] IMDLMeshBufferAllocator allocator); | ||
|
||
[Static] | ||
[iOS (10,2), Mac (12,1,1), TV (10,1)] | ||
[Export ("newCapsuleWithHeight:radii:radialSegments:verticalSegments:hemisphereSegments:geometryType:inwardNormals:allocator:")] | ||
[MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] | ||
MDLMesh CreateCapsule (float height, Vector2 radii, nuint radialSegments, nuint verticalSegments, nuint hemisphereSegments, MDLGeometryType geometryType, bool inwardNormals, [NullAllowed] IMDLMeshBufferAllocator allocator); | ||
|
||
[Static] | ||
[Export ("newEllipticalConeWithHeight:radii:radialSegments:verticalSegments:geometryType:inwardNormals:allocator:")] | ||
[MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] | ||
|
@@ -772,6 +788,11 @@ NSMutableArray<MDLSubmesh> Submeshes { | |
[Export ("newIcosahedronWithRadius:inwardNormals:allocator:")] | ||
MDLMesh CreateIcosahedron (float radius, bool inwardNormals, [NullAllowed] IMDLMeshBufferAllocator allocator); | ||
|
||
[Static] | ||
[iOS (10,2), Mac (12,1,1), TV (10,1)] | ||
[Export ("newIcosahedronWithRadius:inwardNormals:geometryType:allocator:")] | ||
MDLMesh CreateIcosahedron (float radius, bool inwardNormals, MDLGeometryType geometryType, [NullAllowed] IMDLMeshBufferAllocator allocator); | ||
|
||
[Static] | ||
[Export ("newSubdividedMesh:submeshIndex:subdivisionLevels:")] | ||
MDLMesh CreateSubdividedMesh (MDLMesh mesh, nuint submeshIndex, nuint subdivisionLevels); | ||
|
@@ -932,13 +953,20 @@ interface MDLNoiseTexture | |
[MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] | ||
IntPtr Constructor ([NullAllowed] NSData pixelData, bool topLeftOrigin, [NullAllowed] string name, Vector2i dimensions, nint rowStride, nuint channelCount, MDLTextureChannelEncoding channelEncoding, bool isCube); | ||
|
||
[Internal] | ||
[Export ("initVectorNoiseWithSmoothness:name:textureDimensions:channelEncoding:")] | ||
[MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] | ||
IntPtr Constructor (float smoothness, [NullAllowed] string name, Vector2i textureDimensions, MDLTextureChannelEncoding channelEncoding); | ||
IntPtr InitVectorNoiseWithSmoothness (float smoothness, [NullAllowed] string name, Vector2i textureDimensions, MDLTextureChannelEncoding channelEncoding); | ||
|
||
[Export ("initScalarNoiseWithSmoothness:name:textureDimensions:channelCount:channelEncoding:grayscale:")] | ||
[MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] | ||
IntPtr Constructor (float smoothness, [NullAllowed] string name, Vector2i textureDimensions, int channelCount, MDLTextureChannelEncoding channelEncoding, bool grayscale); | ||
|
||
[Internal] | ||
[iOS (10,2), Mac (12,1,1)] | ||
[Export ("initCellularNoiseWithFrequency:name:textureDimensions:channelEncoding:")] | ||
[MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] | ||
IntPtr InitCellularNoiseWithFrequency (float frequency, [NullAllowed] string name, Vector2i textureDimensions, MDLTextureChannelEncoding channelEncoding); | ||
} | ||
|
||
[iOS (9,0), Mac(10,11, onlyOn64 : true)] | ||
|
@@ -986,6 +1014,10 @@ interface MDLObject : MDLNamed | |
[Export ("objectAtPath:")] | ||
MDLObject GetObject (string path); | ||
|
||
[iOS (10,2), Mac (12,1,1), TV (10,1)] | ||
[Export ("enumerateChildObjectsOfClass:root:usingBlock:stopPointer:")] | ||
void EnumerateChildObjects (Class objectClass, MDLObject root, MDLObjectHandler handler, ref bool stop); | ||
|
||
[NullAllowed, Export ("transform", ArgumentSemantic.Retain)] | ||
IMDLTransformComponent Transform { get; set; } | ||
|
||
|
@@ -1304,7 +1336,11 @@ interface MDLSubmesh : MDLNamed | |
MDLMaterial Material { get; set; } | ||
|
||
[NullAllowed, Export ("topology", ArgumentSemantic.Retain)] | ||
MDLSubmeshTopology Topology { get; } | ||
MDLSubmeshTopology Topology { | ||
get; | ||
[iOS (10,2), Mac (12,1,1), TV (10,1)] | ||
set; | ||
} | ||
|
||
[Static] | ||
[Export ("submeshWithSCNGeometryElement:")] | ||
|
@@ -1739,8 +1775,6 @@ interface MDLVertexDescriptor : NSCopying | |
interface MDLVoxelArray | ||
{ | ||
|
||
[Deprecated (PlatformName.MacOSX, 10, 12, message: "Use new MDLVoxelArray (MDLAsset, int, float)")] | ||
[Obsoleted (PlatformName.iOS, 10, 0, message: "Use new MDLVoxelArray (MDLAsset, int, float)")] | ||
[Export ("initWithAsset:divisions:interiorShells:exteriorShells:patchRadius:")] | ||
IntPtr Constructor (MDLAsset asset, int divisions, int interiorShells, int exteriorShells, float patchRadius); | ||
|
||
|
@@ -1929,6 +1963,9 @@ interface MDLVertexBufferLayout : NSCopying | |
[iOS (9,0)][Mac(10,11, onlyOn64 : true)] | ||
[BaseType (typeof (NSObject))] | ||
interface MDLSubmeshTopology { | ||
[Export ("initWithSubmesh:")] | ||
IntPtr Constructor (MDLSubmesh submesh); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing availability attributes |
||
|
||
[NullAllowed, Export ("faceTopology", ArgumentSemantic.Retain)] | ||
IMDLMeshBuffer FaceTopology { get; set; } | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// MDLNoiseTexture Unit Tests | ||
// | ||
// Authors: | ||
// Vincent Dondain <[email protected]> | ||
// | ||
// Copyright 2016 Microsoft | ||
// | ||
|
||
#if !__WATCHOS__ | ||
|
||
using System; | ||
#if XAMCORE_2_0 | ||
using Foundation; | ||
using ModelIO; | ||
using ObjCRuntime; | ||
#else | ||
using MonoTouch.Foundation; | ||
using MonoTouch.ModelIO; | ||
using MonoTouch.ObjCRuntime; | ||
#endif | ||
using OpenTK; | ||
using NUnit.Framework; | ||
|
||
namespace MonoTouchFixtures.ModelIO | ||
{ | ||
|
||
[TestFixture] | ||
// we want the test to be available if we use the linker | ||
[Preserve (AllMembers = true)] | ||
public class MDLNoiseTextureTest | ||
{ | ||
[TestFixtureSetUp] | ||
public void Setup () | ||
{ | ||
TestRuntime.AssertXcodeVersion (8, 2); | ||
|
||
if (Runtime.Arch == Arch.SIMULATOR && IntPtr.Size == 4) { | ||
// There's a bug in the i386 version of objc_msgSend where it doesn't preserve SIMD arguments | ||
// when resizing the cache of method selectors for a type. So here we call all selectors we can | ||
// find, so that the subsequent tests don't end up producing any cache resize (radar #21630410). | ||
object dummy; | ||
using (var obj = new MDLNoiseTexture (1.0f, "texture", Vector2i.Zero, MDLTextureChannelEncoding.Float16)) { | ||
dummy = obj.ChannelCount; | ||
dummy = obj.ChannelEncoding; | ||
dummy = obj.Dimensions; | ||
dummy = obj.IsCube; | ||
dummy = obj.MipLevelCount; | ||
dummy = obj.Name; | ||
dummy = obj.RowStride; | ||
obj.GetTexelDataWithBottomLeftOrigin (); | ||
obj.GetTexelDataWithBottomLeftOrigin (1, false); | ||
obj.GetTexelDataWithTopLeftOrigin (); | ||
obj.GetTexelDataWithTopLeftOrigin (1, false); | ||
} | ||
using (var obj = new MDLTexture ()) { | ||
} | ||
} | ||
} | ||
|
||
[Test] | ||
public void Ctor () | ||
{ | ||
var V2 = new Vector2i (123, 456); | ||
|
||
using (var obj = new MDLNoiseTexture (1.0f, "texture", V2, MDLTextureChannelEncoding.Float16, MDLNoiseTextureType.Cellular)) { | ||
Asserts.AreEqual (V2, obj.Dimensions, "dimensions"); | ||
} | ||
|
||
using (var obj = new MDLNoiseTexture (1.0f, "texture", V2, MDLTextureChannelEncoding.Float16, MDLNoiseTextureType.Vector)) { | ||
Asserts.AreEqual (V2, obj.Dimensions, "dimensions"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif // !__WATCHOS__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add
[iOS (9,0), Mac (10,11, onlyOn64 : true)]