xamarin / urho Goto Github PK
View Code? Open in Web Editor NEWCode to integrate with the Urho3D engine
License: Other
Code to integrate with the Urho3D engine
License: Other
In sample 08_Decals (Line 294):
PODVector<RayQueryResult> results;
RayOctreeQuery query(results, cameraRay, RAY_TRIANGLE, maxDistance, DRAWABLE_GEOMETRY);
scene_->GetComponent<Octree>()->RaycastSingle(query);
Currently we map all methods as methods, but some of those should be properties.
Steps to reproduce:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
abort() called
*** error for object 0x7f9913965340: pointer being freed was not allocated
From 09_MultipleViewports (line 206):
effectRenderPath->SetShaderParameter(""BloomMix"", Vector2(0.9f, 0.6f));
https://github.com/xamarin/urho/blob/fe6e046dcdba3bcf17b5e3759f828c52731bc663/bindings/src/BillboardSet.cs it doesn't want to marshal return struct. I investigated it and found out that boolean fields (in Rect and the Enabled) cause that. Because the bool type is not blittable (http://msdn.microsoft.com/en-us/library/75dwhxf7.aspx).
So I see two workarounds: replace bool with byte type (in both Billboard and Rect structures) or rewrite the method somehow to not to return a reference to a struct (field accessors?).
Example usage from 24_Urho2DSprite (Line 98):
float halfWidth = graphics->GetWidth() * 0.5f * PIXEL_SIZE;
Steps:
static public UIElement get_UIElement (IntPtr handle, int stringHash)
{
return new UIElement (urho_map_get_ptr (handle, stringHash));
}```
The engine parameters are the mechanism by which the engine is configured at startup, we need to bind and surface these parameters to managed code.
Application::Setup allows the engine to be tuned here:
// Modify engine startup parameters
engineParameters_["WindowTitle"] = GetTypeName();
engineParameters_["LogName"] = GetSubsystem<FileSystem>()->GetAppPreferencesDir("urho3d", "logs") + GetTypeName() + ".log";
engineParameters_["FullScreen"] = false;
engineParameters_["Headless"] = false;
There are lots of typed subscribers defined in UrhoObject\Object.Events such as:
SubscribeToUpdate
SubscribeToPostRenderUpdate
SubscribeToNetworkMessage
But there is no mechanism to unsubscribe from those events. Original samples use the following code:
UnsubscribeFromEvent(E_SCENEUPDATE);
where E_SCENEUPDATE is a StringHash
global methods definin in ProcessUtils.h
From sample 26_ConsoleInput (Line 112)
String input = GetConsoleInput();
BodyType2D in C# (generated):
public enum BodyType2D
{
BT_STATIC,
BT_DYNAMIC, //means 1
BT_KINEMATIC
}
in C++:
enum BodyType2D
{
BT_STATIC = b2_staticBody,
BT_DYNAMIC = b2_dynamicBody, //its value is actually 2
BT_KINEMATIC = b2_kinematicBody,
};
APIs that require no marshaling should be surfaced directly by the P/Invoke, without the extra layer method
36_Urho2DTileMap (Line 101)
const TileMapInfo2D& info = tileMap->GetInfo();
Used by the sample, but also by a sample player.
Currently we do not auto-bind, or surface this API.
From 30_LightAnimation (Line 127)
SharedPtr<ValueAnimation> colorAnimation(new ValueAnimation(context_));
colorAnimation->SetKeyFrame(0.0f, Color::WHITE);
All events of a given type, because Urho does not have an API to remove just the susbscribed event/handler pair.
As we plan to hand bind the structures to match the ABI of urho, it makes sense to have a struct size and offset validator to ensure that changes to urho do not break the interop by accident
In a handful of cases the eventData is sent with SendEvent, but we do not surface that, in particular it is used by the E_CLIENTIDENTITY message.
When an instance of a managed object is passed down, we need a wait to retain it.
So effectively, implementing toggle refs
From 37_UIDrag (Line 206)
TouchState* ts = input->GetTouch(i);
Line 140:
objectNode.Rotation = Quaternion.FromRotationTo(new Vector3(0.0f, 1.0f, 0.0f), terrain.GetNormal(position));
Some samples use it for storing some info (usually it's String or Vector type).
We can avoid using them in samples. But we can also marshal them at least with String argument.
from 32_Urho2DConstraints (Line 538):
pickedNode->RemoveComponent<ConstraintMouse2D>();
From 19_VehicleDemo
From 17_SceneReplication (Line 482)
newConnection->SendRemoteEvent(E_CLIENTOBJECTID, true, remoteEventData);
From 17_SceneReplication (Line 482):
newConnection->SendRemoteEvent(E_CLIENTOBJECTID, true, remoteEventData);
From 13_Ragdolls (Line 109)
Skeleton& skeleton = model->GetSkeleton();
for (unsigned i = 0; i < skeleton.GetNumBones(); ++i)
skeleton.GetBone(i)->animated_ = false;
From 21_AngelScriptIntegration (Line 112)
ScriptInstance* instance = boxNode->CreateComponent<ScriptInstance>();
15_Navigation (Line 292)
navMesh->FindPath(currentPath_, jackNode_->GetPosition(), endPos_);
While we do get four invocations, the "decl.IsCompleteDefinition" is always false
As it turned out,Vector4 and Plane are different types. And the second one is missing.
These methods too:
Camera::SetReflectionPlane(Plane)
Camera::SetClipPlane(Plane)
From 23_Water sample
// Create a mathematical plane to represent the water in calculations
waterPlane_ = Plane(waterNode_->GetWorldRotation() * Vector3(0.0f, 1.0f, 0.0f), waterNode_->GetWorldPosition());
// Create a downward biased plane for reflection view clipping. Biasing is necessary to avoid too aggressive clipping
waterClipPlane_ = Plane(waterNode_->GetWorldRotation() * Vector3(0.0f, 1.0f, 0.0f), waterNode_->GetWorldPosition() -
Vector3(0.0f, 0.1f, 0.0f));
// Create camera for water reflection
// It will have the same farclip and position as the main viewport camera, but uses a reflection plane to modify
// its position when rendering
reflectionCameraNode_ = cameraNode_->CreateChild();
Camera* reflectionCamera = reflectionCameraNode_->CreateComponent<Camera>();
reflectionCamera->SetFarClip(750.0);
reflectionCamera->SetViewMask(0x7fffffff); // Hide objects with only bit 31 in the viewmask (the water plane)
reflectionCamera->SetAutoAspectRatio(false);
reflectionCamera->SetUseReflection(true);
reflectionCamera->SetReflectionPlane(waterPlane_);
reflectionCamera->SetUseClipping(true); // Enable clipping of geometry behind water plane
reflectionCamera->SetClipPlane(waterClipPlane_);
Audio.GetMasterGain(string) => Audio.GetMasterGain(SoundType)
SoundSource.SetSoundType(string) => SoundSource.SetSoundType(SoundType)
it's still string despite of my changes to CxxBinder: c4121a2
From 32_Urho2DConstraints (Line 496)
scene_->SaveXML(saveFile);
From 34_DynamicGeometry (Line 155):
SharedPtr<Model> cloneModel = originalModel->Clone();
Add async support for user code.
For this to work, we need to have a "context" attached to each operation where we want to support async. In my mind, those are Update and SceneUpdate, but there might be others.
So what we would need to do is, when we first subscribe to one of those events, we need to create a SynchronizationContext for them (UpdateContext and SceneUpdateContext), and we need to make sure that when an event is "dispatched" for Update or SceneUpdate, that we save the current context, then set this as the default context for the duration of the event, and we reset it afterwards [1].
Then, we would need to make our synchronization context basically track any queued tasks, and execute any complete tasks on the update/sceneupdate event.
Perhaps to make this work, we could provide a default SceneUpdate/Update event handlers in Application, and we encourage developers to not subscribe manually with SubscribeToSceneUpdate, but instead to set an event handler, something like:
Application.SceneUpdate += MySceneUpdate
That would centralize all of the SceneUpdates, instead of having hundreds of independent SceneUpdates everywhere.
[1] Potential problem: if a game uses a lot of subscriptions to events, say to 100 events, we do not want to have to push/pop the synchronization context 100 times. So we probably want to proxy all scene update notifications into one big group and dispatch them all at once.
From 29_SoundSynthesis
soundStream_.AddData(newData, numSamples * sizeof(signed short));
where newData is a short[]
32_Urho2DConstraints C# (Line 344)
someNode.CreateComponent()
or
someNode.AddComponent(new ConstraintGear2D(Context));
throw AccessViolationException
The enumerations are not very useful.
One optin is to make the enumeration values just constants that we can reference from an actual enumeration, like this:
enum MyCuteEnumeration {
Foo = UrhoEnums.ENUM_FOO_VALUE
}
So we could get the right value, and just prettify without having to manually deal with all the cases and casing that will berequired.
Sample: 09_MultipleViewports (line 202)
SharedPtr<RenderPath> effectRenderPath = viewport->GetRenderPath()->Clone();
The challenge with this binding is that the Clone() return a SharedPtr, so we would need to surface the internal version of this object. Not difficult, but the side effects need to be understood.
Currently we generate the code for it, but it looks like something that should be an internal implementation detail.
Defined in Input.h line 73
e.g.
[DllImport ("mono-urho", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
internal static extern bool Input_GetMouseButtonPress (IntPtr handle, int button);
without it can return true when should return false (and it does it for _11_Physics sample)
see http://stackoverflow.com/a/4621621
Currently we generate the enumeration values as they are surfaced in C, but we need to do enumeration mapping to make those first class .NET names.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.