Adding entities to scene in Napkin


#1

Not sure this was asked before.

When creating a new project I want to add entities to the scene object.
I’ve already created some entities and the scene object.
What is the proper way to do this?

In Napkin I select the scene object in the Resources panel, go to Entities in the Inspector, right click and the only option (besides Expand all, Collapse) is “Add nap::RootEntity”.
When I click that Napkin crashes. I could not find any other option.

Assertion failed: (inserted), function arrayAddValue, file /Users/coenklosters/Documents/dev/nap/tools/napkin/src/document.cpp, line 326.

I usually open my app_structure.json in a text editor to add the entities manually, but I was wondering if I’m missing something obvious here.

Thanks.


#2

In true rubber duck debugging fashion I found the answer in the manual.

You have to use the Scene panel to add entities:
https://www.napframework.com/doxygen/da/d34/napkin.html#napkin_doc_management

So it’s rather a little inconvenience, for some reason I expected to be able to do that in the inspector like you can link resources and materials there.


#3

The reason you have to add an Entity to a scene is because an Entity (together with its components) is instantiated. Regular resources are not instantiated. This allows you to spawn multiple entities of the same type (with different) settings when loading a file. It also allows you to spawn an entity at runtime with a specific set of settings based on the same entity resource (blueprint).

This means that when you change a parameter of a component in the resource panel you set the (shared) default setting. When you change a parameter of a component in the scene view you override that default value.

You therefore have to create an entity resource and add it to a scene to spawn it.

To understand the (critical) difference between resources and instances I highly recommend reading up on scene management in NAP. Having a good understanding of this concept will help you during development later on, although it might be a little hard to initially grasp. It’s a common concept used by other engines as well, such as unreal and unity, although implement differenly.


#4

Thanks for the reply.

The role of entities was clear, the question was more about doing it in Napkin.

When I started using Napkin I was able to do every necessary action with only the Resource and Inspector panels. The only thing I wasn’t able to achieve was adding Entities to the Scene, there’s an “Add nap::RootEntity” (which is crashing), but no “Add entity” option.

After reading the manual again I realised that we also have a Scene panel and that’s exactly where I had to do this action.

I was just wondering if there was any reason not to enable “Add entity” in the Inspector panel when the Scene is selected, ex. right clicking the “Entities” property?

That’s where I was expecting it and I guess that would apply to other people new to Napkin as well.

Again, this is just a minor usability thing, nothing cardinal, but I thought this feedback might help you in some way.


#5

Hey!

When I started using Napkin I was able to do every necessary action with only the Resource and Inspector panels. The only thing I wasn’t able to achieve was adding Entities to the Scene, there’s an “Add nap::RootEntity” (which is crashing), but no “Add entity” option.

We should remove that option from the scene resource or fix it. The root entity is implicit now and doesn’t have to be specified anymore. We somehow forgot to remove it from the resource panel. @bas can maybe pitch in here.