Skip to content

Commit

Permalink
CastorViewerSharp: Added a way to rotate and translate camera node.
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonJoker committed Dec 1, 2022
1 parent 2717764 commit 20b2661
Show file tree
Hide file tree
Showing 13 changed files with 649 additions and 115 deletions.
1 change: 1 addition & 0 deletions include/Core/CastorUtils/Config/BeginExternHeaderGuard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ See LICENSE file in root folder
#pragma GCC diagnostic ignored "-Wfloat-conversion"
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#pragma GCC diagnostic ignored "-Wnull-dereference"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wredundant-decls"
#pragma GCC diagnostic ignored "-Wshadow"
Expand Down
139 changes: 129 additions & 10 deletions include/Interop/ComCastor3D/Castor3D.idl
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,119 @@ typedef enum
eBACKGROUND_TYPE_COUNT
} eBACKGROUND_TYPE;

// eKEYBOARD_KEY
[
uuid( 765FFD8B-E309-4B69-868F-2A67321733AE ),
helpstring( "Castor3D Keyboard keys enumeration." )
]
typedef enum eKEYBOARD_KEY
{
eKEYBOARD_KEY_NONE,
eKEYBOARD_KEY_BACKSPACE = 0x08,
eKEYBOARD_KEY_TAB = 0x0A,
eKEYBOARD_KEY_RETURN = 0x0D,
eKEYBOARD_KEY_ESCAPE = 0x1B,
eKEYBOARD_KEY_SPACE = 0x20,

// values from 0x21 to 0x7E are reserved for the standard ASCII characters
eKEYBOARD_KEY_DELETE = 0x7F,

// values from 0x80 to 0xFF are reserved for ASCII extended characters
eKEYBOARD_KEY_START = 0x100,
eKEYBOARD_KEY_LBUTTON,
eKEYBOARD_KEY_RBUTTON,
eKEYBOARD_KEY_CANCEL,
eKEYBOARD_KEY_MBUTTON,
eKEYBOARD_KEY_CLEAR,
eKEYBOARD_KEY_SHIFT,
eKEYBO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EYBOARD_KEY_F22,
eKEYBOARD_KEY_F23,
eKEYBOARD_KEY_F24,
eKEYBOARD_KEY_NUMLOCK,
eKEYBOARD_KEY_SCROLL,
eKEYBOARD_KEY_PAGEUP,
eKEYBOARD_KEY_PAGEDOWN,
eKEYBOARD_KEY_NUMPADSPACE,
eKEYBOARD_KEY_NUMPADTAB,
eKEYBOARD_KEY_NUMPADENTER,
eKEYBOARD_KEY_NUMPADF1,
eKEYBOARD_KEY_NUMPADF2,
eKEYBOARD_KEY_NUMPADF3,
eKEYBOARD_KEY_NUMPADF4,
eKEYBOARD_KEY_NUMPADHOME,
eKEYBOARD_KEY_NUMPADLEFT,
eKEYBOARD_KEY_NUMPADUP,
eKEYBOARD_KEY_NUMPADRIGHT,
eKEYBOARD_KEY_NUMPADDOWN,
eKEYBOARD_KEY_NUMPADPAGEUP,
eKEYBOARD_KEY_NUMPADPAGEDOWN,
eKEYBOARD_KEY_NUMPADEND,
eKEYBOARD_KEY_NUMPADBEGIN,
eKEYBOARD_KEY_NUMPADINSERT,
eKEYBOARD_KEY_NUMPADDELETE,
eKEYBOARD_KEY_NUMPADEQUAL,
eKEYBOARD_KEY_NUMPADMULTIPLY,
eKEYBOARD_KEY_NUMPADADD,
eKEYBOARD_KEY_NUMPADSEPARATOR,
eKEYBOARD_KEY_NUMPADSUBTRACT,
eKEYBOARD_KEY_NUMPADDECIMAL,
eKEYBOARD_KEY_NUMPADDIVIDE,
} eKEYBOARD_KEY;

interface IRgbaColour;
interface IRgbColour;
interface IHdrRgbaColour;
Expand Down Expand Up @@ -865,16 +978,19 @@ interface IQuaternion
: IDispatch
{
[propget, id( 1 ), helpstring( "The quaternions's rotation matrix" )] HRESULT RotationMatrix( [out, retval] IMatrix4x4 ** pVal );
[id( 2 ), helpstring( "Transforms a vector through this quaternion" )] HRESULT Transform( [in] IVector3D * val, [out, retval] IVector3D ** pVal );
[id( 3 ), helpstring( "Retrieves the quaternion's axis and angle" )] HRESULT ToAxisAngle( [out] IVector3D ** pAxis, [out] IAngle ** pAngle );
[id( 4 ), helpstring( "Defines this quaternion's axis and angle" )] HRESULT FromAxisAngle( [in] IVector3D * axis, [in] IAngle * angle );
[id( 5 ), helpstring( "Retrieves the quaternion's axes" )] HRESULT ToAxes( [out] IVector3D ** pX, [out] IVector3D ** pY, [out] IVector3D ** pZ );
[id( 6 ), helpstring( "Defines this quaternion's axes" )] HRESULT FromAxes( [in] IVector3D * x, [in] IVector3D * y, [in] IVector3D * z );
[id( 7 ), helpstring( "Retrieves the quaternion's magnitude" )] HRESULT GetMagnitude( [out, retval] float * pVal );
[id( 8 ), helpstring( "Retrieves the quaternion's conjugate" )] HRESULT Conjugate();
[id( 9 ), helpstring( "Spherical linear interpolation with another quaternion, takes the shortest path." )] HRESULT Slerp( [in] IQuaternion * quat, [in] float percent, [out, retval] IQuaternion ** pQuat );
[id( 10 ), helpstring( "Spherical linear interpolation with another quaternion." )] HRESULT Mix( [in] IQuaternion * quat, [in] float percent, [out, retval] IQuaternion ** pQuat );
[id( 11 ), helpstring( "Multiplies this quaternion with another one." )] HRESULT Mul( [in] IQuaternion * rhs, [out, retval] IQuaternion ** pQuat );
[propget, id( 2 ), helpstring( "The quaternions's pitch angle" )] HRESULT Pitch( [out, retval] IAngle ** pVal );
[propget, id( 3 ), helpstring( "The quaternions's yaw angle" )] HRESULT Yaw( [out, retval] IAngle ** pVal );
[propget, id( 4 ), helpstring( "The quaternions's roll angle" )] HRESULT Roll( [out, retval] IAngle ** pVal );
[id( 5 ), helpstring( "Transforms a vector through this quaternion" )] HRESULT Transform( [in] IVector3D * val, [out, retval] IVector3D ** pVal );
[id( 6 ), helpstring( "Retrieves the quaternion's axis and angle" )] HRESULT ToAxisAngle( [out] IVector3D ** pAxis, [out] IAngle ** pAngle );
[id( 7 ), helpstring( "Defines this quaternion's axis and angle" )] HRESULT FromAxisAngle( [in] IVector3D * axis, [in] IAngle * angle );
[id( 8 ), helpstring( "Retrieves the quaternion's axes" )] HRESULT ToAxes( [out] IVector3D ** pX, [out] IVector3D ** pY, [out] IVector3D ** pZ );
[id( 9 ), helpstring( "Defines this quaternion's axes" )] HRESULT FromAxes( [in] IVector3D * x, [in] IVector3D * y, [in] IVector3D * z );
[id( 10 ), helpstring( "Retrieves the quaternion's magnitude" )] HRESULT GetMagnitude( [out, retval] float * pVal );
[id( 11 ), helpstring( "Retrieves the quaternion's conjugate" )] HRESULT Conjugate();
[id( 12 ), helpstring( "Spherical linear interpolation with another quaternion, takes the shortest path." )] HRESULT Slerp( [in] IQuaternion * quat, [in] float percent, [out, retval] IQuaternion ** pQuat );
[id( 13 ), helpstring( "Spherical linear interpolation with another quaternion." )] HRESULT Mix( [in] IQuaternion * quat, [in] float percent, [out, retval] IQuaternion ** pQuat );
[id( 14 ), helpstring( "Multiplies this quaternion with another one." )] HRESULT Mul( [in] IQuaternion * rhs, [out, retval] IQuaternion ** pQuat );
}

// IMatrix4x4
Expand Down Expand Up @@ -1303,6 +1419,9 @@ interface IRenderWindow
[id( 9 ), helpstring( "MouseMouseLButtonUp event processing" )] HRESULT OnMouseMButtonUp( [in] IPosition * pos, [out, retval] boolean * pVal );
[id( 10 ), helpstring( "MouseMouseRButtondown event processing" )] HRESULT OnMouseRButtonDown( [in] IPosition * pos, [out, retval] boolean * pVal );
[id( 11 ), helpstring( "MouseMouseRButtonUp event processing" )] HRESULT OnMouseRButtonUp( [in] IPosition * pos, [out, retval] boolean * pVal );
[id( 12 ), helpstring( "KeyboardKeyDown event processing" )] HRESULT OnKeyboardKeyDown( [in] eKEYBOARD_KEY key, [in] boolean isCtrlDown, [in] boolean isAltDown, [in] boolean isShiftDown, [out, retval] boolean * pVal );
[id( 13 ), helpstring( "KeyboardKeyUp event processing" )] HRESULT OnKeyboardKeyUp( [in] eKEYBOARD_KEY key, [in] boolean isCtrlDown, [in] boolean isAltDown, [in] boolean isShiftDown, [out, retval] boolean * pVal );
[id( 14 ), helpstring( "KeyboardChar event processing" )] HRESULT OnKeyboardChar( [in] eKEYBOARD_KEY key, [in] BSTR c, [out, retval] boolean * pVal );
};

// ISceneBackground
Expand Down
3 changes: 3 additions & 0 deletions include/Interop/ComCastor3D/Castor3D/ComRenderWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ namespace CastorCom
STDMETHOD( OnMouseMButtonUp )( /* [in] */ IPosition * pos, /* [out, retval] */ boolean * pVal );
STDMETHOD( OnMouseRButtonDown )( /* [in] */ IPosition * pos, /* [out, retval] */ boolean * pVal );
STDMETHOD( OnMouseRButtonUp )( /* [in] */ IPosition * pos, /* [out, retval] */ boolean * pVal );
STDMETHOD( OnKeyboardKeyDown )( /* [in] */ eKEYBOARD_KEY key, /* [in] */ boolean isCtrlDown, /* [in] */ boolean isAltDown, /* [in] */ boolean isShiftDown, /* [out, retval] */ boolean * pVal );
STDMETHOD( OnKeyboardKeyUp )( /* [in] */ eKEYBOARD_KEY key, /* [in] */ boolean isCtrlDown, /* [in] */ boolean isAltDown, /* [in] */ boolean isShiftDown, /* [out, retval] */ boolean * pVal );
STDMETHOD( OnKeyboardChar )( /* [in] */ eKEYBOARD_KEY key, /* [in] */ BSTR c, /* [out, retval] */ boolean * pVal );

private:
float doTransformX( int x );
Expand Down
5 changes: 4 additions & 1 deletion include/Interop/ComCastor3D/CastorUtils/ComQuaternion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "ComCastor3D/ComCastor3DPrerequisites.hpp"

#include "ComCastor3D/ComAtlObject.hpp"
#include "ComCastor3D/CastorUtils/ComAngle.hpp"
#include "ComCastor3D/CastorUtils/ComMatrix4x4.hpp"

#include <CastorUtils/Math/Quaternion.hpp>
Expand All @@ -22,7 +23,9 @@ namespace CastorCom
: public CComAtlObject< Quaternion, castor::Quaternion >
{
public:
//typedef VariablePutter< castor::Quaternion, castor::Matrix4x4f const & > MtxPutter;
COMEX_PROPERTY_GET( Pitch, IAngle *, &m_internal, &Internal::getPitch );
COMEX_PROPERTY_GET( Yaw, IAngle *, &m_internal, &Internal::getYaw );
COMEX_PROPERTY_GET( Roll, IAngle *, &m_internal, &Internal::getRoll );
STDMETHOD( get_RotationMatrix )( IMatrix4x4 ** /* [out, retval] */ pVal );

STDMETHOD( Transform )( /* [in] */ IVector3D * val, /* [out, retval] */ IVector3D ** pVal );
Expand Down
1 change: 1 addition & 0 deletions include/Interop/ComCastor3D/ComParameterCast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace CastorCom::details
|| areCompatibleV< SrcT, DstT, eMOVABLE_TYPE, castor3d::MovableType >
|| areCompatibleV< SrcT, DstT, eLIGHT_TYPE, castor3d::LightType >
|| areCompatibleV< SrcT, DstT, eVIEWPORT_TYPE, castor3d::ViewportType >
|| areCompatibleV< SrcT, DstT, eKEYBOARD_KEY, castor3d::KeyboardKey >
|| areCompatibleV< SrcT, DstT, eBORDER_COLOUR, VkBorderColor >
|| areCompatibleV< SrcT, DstT, eFILTER_MODE, VkFilter >
|| areCompatibleV< SrcT, DstT, eIMAGE_TYPE, VkImageType >
Expand Down
6 changes: 1 addition & 5 deletions samples/CastorViewerSharp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ if ( MSVC AND ${CASTOR_BUILD_INTEROP_COM} )

include( CSharpUtilities )

# configure_file(
# ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.csproj.in
# ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.csproj
# @ONLY
# )
add_executable( ${PROJECT_NAME}
App.xaml
App.xaml.cs
MainWindow.xaml
MainWindow.xaml.cs
NodeState.cs

Properties/AssemblyInfo.cs
Properties/Resources.Designer.cs
Expand Down
24 changes: 12 additions & 12 deletions samples/CastorViewerSharp/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="CastorViewerSharp.MainWindow"
Title="CastorViewer#" Height="600" Width="800" SizeToContent="WidthAndHeight" MinWidth="800" MinHeight="600" WindowStartupLocation="CenterScreen" SizeChanged="OnSizeChanged" Loaded="OnLoaded">
<Grid Name="MainGrid">
<Grid.RowDefinitions>
<RowDefinition Height="0" />
<RowDefinition />
<RowDefinition Height="0" />
</Grid.RowDefinitions>
<Canvas Name="RenderPanel" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#FFC7C7C7" MouseMove="OnMouseMove" Grid.RowSpan="2"/>
</Grid>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="CastorViewerSharp.MainWindow"
Title="CastorViewer#" Height="600" Width="800" SizeToContent="WidthAndHeight" MinWidth="800" MinHeight="600" WindowStartupLocation="CenterScreen" SizeChanged="OnSizeChanged" Loaded="OnLoaded" KeyUp="OnKeyUp" KeyDown="OnKeyDown">
<Grid Name="MainGrid">
<Grid.RowDefinitions>
<RowDefinition Height="0" />
<RowDefinition />
<RowDefinition Height="0" />
</Grid.RowDefinitions>
<Canvas Name="RenderPanel" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#FFC7C7C7" MouseMove="OnMouseMove" KeyUp="OnKeyUp" KeyDown="OnKeyDown" Grid.RowSpan="2"/>
</Grid>
</Window>
Loading

0 comments on commit 20b2661

Please sign in to comment.