Lisp HUG Maillist Archive

Embed Scene Kit View (SCNView) in a capi pane?

Hi,

I am trying to embed a Scene Kit view SCNView in a cap pane. I tried to adapt the movie-view.lisp under objc/examples which embeds an NSMovieView. However I cannot get to display the SCNView.

I have attached the code. (scenekit-view.lisp)

SCNView reference: https://developer.apple.com/Library/mac/documentation/SceneKit/Reference/SCNView_Class/index.html#//apple_ref/occ/cl/SCNView

I also load the Scene Kit framework. 

CL-USER 50 > (objc:ensure-objc-initialized
  :modules
  '("/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation"
    "/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa"
    "/System/Library/Frameworks/SceneKit.framework/Versions/A/SceneKit"
    "/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL"))

I am loading the OpenGL framework as Scene Kit uses OpenGL behind the scenes.

Any help/suggestions really appreciated.

Thanks,
Deepak

--
http://deepaksurti.com
To see a miracle, be the miracle.

Re: Embed Scene Kit View (SCNView) in a capi pane?

Deepak,

Your example works just fine. I think the problem is that the sphere you’re creating is white, as so is the background. :-)

Try adding this to your init-function callback in the interface before returning the view:

(objc:invoke view "setBackgroundColor:" (objc:invoke "NSColor" "blackColor”))

Now run it.

Cheers,

Jeff M.

On Nov 23, 2014, at 11:50 AM, Deepak Surti <dmsurti@gmail.com> wrote:

Hi,

I am trying to embed a Scene Kit view SCNView in a cap pane. I tried to adapt the movie-view.lisp under objc/examples which embeds an NSMovieView. However I cannot get to display the SCNView.

I have attached the code. (scenekit-view.lisp)

SCNView reference: https://developer.apple.com/Library/mac/documentation/SceneKit/Reference/SCNView_Class/index.html#//apple_ref/occ/cl/SCNView

I also load the Scene Kit framework. 

CL-USER 50 > (objc:ensure-objc-initialized
  :modules
  '("/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation"
    "/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa"
    "/System/Library/Frameworks/SceneKit.framework/Versions/A/SceneKit"
    "/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL"))

I am loading the OpenGL framework as Scene Kit uses OpenGL behind the scenes.

Any help/suggestions really appreciated.

Thanks,
Deepak

--
http://deepaksurti.com
To see a miracle, be the miracle.
<scenekit-view.lisp>

Re: Embed Scene Kit View (SCNView) in a capi pane?

Hi Jeff,

Yes, I just checked and that is the reason :-). Sorry for the noise, it is better to go play outside on a Sunday than work :-D.

Thanks,
Deepak

On Mon, Nov 24, 2014 at 12:22 AM, Jeffrey Massung <massung@gmail.com> wrote:
Deepak,

Your example works just fine. I think the problem is that the sphere you’re creating is white, as so is the background. :-)

Try adding this to your init-function callback in the interface before returning the view:

(objc:invoke view "setBackgroundColor:" (objc:invoke "NSColor" "blackColor”))

Now run it.

Cheers,

Jeff M.

On Nov 23, 2014, at 11:50 AM, Deepak Surti <dmsurti@gmail.com> wrote:

Hi,

I am trying to embed a Scene Kit view SCNView in a cap pane. I tried to adapt the movie-view.lisp under objc/examples which embeds an NSMovieView. However I cannot get to display the SCNView.

I have attached the code. (scenekit-view.lisp)

SCNView reference: https://developer.apple.com/Library/mac/documentation/SceneKit/Reference/SCNView_Class/index.html#//apple_ref/occ/cl/SCNView

I also load the Scene Kit framework. 

CL-USER 50 > (objc:ensure-objc-initialized
  :modules
  '("/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation"
    "/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa"
    "/System/Library/Frameworks/SceneKit.framework/Versions/A/SceneKit"
    "/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL"))

I am loading the OpenGL framework as Scene Kit uses OpenGL behind the scenes.

Any help/suggestions really appreciated.

Thanks,
Deepak

--
http://deepaksurti.com
To see a miracle, be the miracle.
<scenekit-view.lisp>




--
http://deepaksurti.com
To see a miracle, be the miracle.

Re: Embed Scene Kit View (SCNView) in a capi pane?

Hi Sangeet,

For SCNVector3, you have to define objc struct, something along these lines, (assuming SceneKit framework has been loaded):

CL-USER 41 > (objc:define-objc-struct (SCNVector3 (:foreign-name "SCNVector3"))
  (x :float)
  (y :float)
  (z :float))

CL-USER 42 > (setf vec3-ptr
      (fli:with-dynamic-foreign-objects ((ptr SCNVector3))
        (setf (fli:foreign-slot-value ptr 'x) 1.0
              (fli:foreign-slot-value ptr 'y) 2.0
              (fli:foreign-slot-value ptr 'z) 3.0)
        ptr))

CL-USER 43 >
(fli:foreign-slot-value vec3-ptr 'x)
1.0

....

Hope this helps,
Thanks,
Deepak

On Tue, Dec 2, 2014 at 6:23 PM, Sangeet Khemlani <skhemlani@gmail.com> wrote:
Hi there,

I’ve been playing with the scenekit-view that Deepak created (thanks Deepak!) and it seems to be working alright, but for some reason I’m not able to change the positions of any of the nodes. The error I’m getting is on this line:

(objc:invoke sphere-node "setPosition:" (objc:invoke "SCNVector3" "SCNVector3" 1.0 1.2 1.3))

and it says that it cannot find the SCNVector3 class. Is this syntax incorrect (as I suspect) or is it an issue of not loading the appropriate libraries? I’ve attached the full script.

Cheers,
Sangeet




> On Nov 23, 2014, at 1:56 PM, Deepak Surti <dmsurti@gmail.com> wrote:
>
> Hi Jeff,
>
> Yes, I just checked and that is the reason :-). Sorry for the noise, it is better to go play outside on a Sunday than work :-D.
>
> Thanks,
> Deepak
>
> On Mon, Nov 24, 2014 at 12:22 AM, Jeffrey Massung <massung@gmail.com> wrote:
> Deepak,
>
> Your example works just fine. I think the problem is that the sphere you’re creating is white, as so is the background. :-)
>
> Try adding this to your init-function callback in the interface before returning the view:
>
> (objc:invoke view "setBackgroundColor:" (objc:invoke "NSColor" "blackColor”))
>
> Now run it.
>
> Cheers,
>
> Jeff M.
>
>> On Nov 23, 2014, at 11:50 AM, Deepak Surti <dmsurti@gmail.com> wrote:
>>
>> Hi,
>>
>> I am trying to embed a Scene Kit view SCNView in a cap pane. I tried to adapt the movie-view.lisp under objc/examples which embeds an NSMovieView. However I cannot get to display the SCNView.
>>
>> I have attached the code. (scenekit-view.lisp)
>>
>> SCNView reference: https://developer.apple.com/Library/mac/documentation/SceneKit/Reference/SCNView_Class/index.html#//apple_ref/occ/cl/SCNView
>>
>> I also load the Scene Kit framework.
>>
>> CL-USER 50 > (objc:ensure-objc-initialized
>>   :modules
>>   '("/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation"
>>     "/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa"
>>     "/System/Library/Frameworks/SceneKit.framework/Versions/A/SceneKit"
>>     "/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL"))
>>
>> I am loading the OpenGL framework as Scene Kit uses OpenGL behind the scenes.
>>
>> Any help/suggestions really appreciated.
>>
>> Thanks,
>> Deepak
>>
>> --
>> http://deepaksurti.com
>> To see a miracle, be the miracle.
>> <scenekit-view.lisp>
>
>
>
>
> --
> http://deepaksurti.com
> To see a miracle, be the miracle.





--
http://deepaksurti.com
To see a miracle, be the miracle.

Re: Embed Scene Kit View (SCNView) in a capi pane?

Unable to parse email body. Email id is 13210

Re: Embed Scene Kit View (SCNView) in a capi pane?

Hi Sangeet,

I have attached the code which shows how to set the position. More importantly, it works ;-). (You can use the same idiom to for SCNVector4 and other struct data types in SceneKit framework).

Thanks,
Deepak

On Tue, Dec 2, 2014 at 11:29 PM, Martin Simmons <martin@lispworks.com> wrote:
>>>>> On Tue, 2 Dec 2014 20:37:05 +0530, Deepak Surti said:
>
> CL-USER 42 > (setf vec3-ptr
>       (fli:with-dynamic-foreign-objects ((ptr SCNVector3))
>         (setf (fli:foreign-slot-value ptr 'x) 1.0
>               (fli:foreign-slot-value ptr 'y) 2.0
>               (fli:foreign-slot-value ptr 'z) 3.0)
>         ptr))

Don't return the ptr from fli:with-dynamic-foreign-objects, because it has
dynamic extent.

--
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/



--
http://deepaksurti.com
To see a miracle, be the miracle.
Updated at: 2020-12-10 08:33 UTC