Jump to content

  • Log In with Google      Sign In   
  • Create Account

Dave

Member Since 22 Mar 2004
Offline Last Active Yesterday, 03:42 PM

#5298999 DirectX C++ Engine and C# WPF Editor/GUI

Posted by on 04 July 2016 - 06:11 AM

My advice would actually be not to go this way because of the complexities. Some of the problems you're going to have to solve with a C# editor are:

 

- What represents your objects in your C# editor?

- How are you going to get your editor to tell your C++ runtime what to do?

   - If you do it over the network you're going to have to have some way of packing up data and sending it over and then unpacking it on the other side.

   - If you do it with a C++/CLI you can end up wrapping alot of C++ classes with C++/CLI equivalents leading to duplication of code and a lot of maintenance.

- What do you do if the C++ engine crashes, how does the editor handle this case?

- WPF is not beginner friendly, i personally detested it when i was using it, but this is purely a personal opinion.

- Its more difficult to get fancy editor features like asset previews working, at a later date.

- I've seen projects using this approach get extremely complex.

 

 

I'd like to propose that you do what Unreal does which is to write your editor UI in C++ using your rendering API to draw it. This has the following good and bad points:

 

+ There is no duplication of classes for the interop with C#.

+ There is no need for network communication or data packing and unpacking.

+ If it crashes you're in the same process and can therefore debug it more easily. With the C# approach this can be trickier depending on your setup.

+ No WPF, again personal.

+ You can do all of the fancy editing features you want because you're in full control.

+ It can still be complex but in my experience less so.

 

- Alot of work to write a custom UI solution, will take a little while to see the fruits of your labor. Its totally worth it IMO though.

- Don't have the reliability of established frameworks like .net.

- If it crashes the whole editor goes down but generally you shouldnt be crashing anyways.

 

So in summary I'm personally not an advocate of wrapping C++ libraries for use in C# unless absolutely necessary and having worked on several different types of editors that have done it in various ways, the most flexible and exciting approach is as i've recommended here but it is quite a bit of work up front.

 

Hope that gives you some ideas, 




#5298998 Normal Map / Bump Map generation in C++

Posted by on 04 July 2016 - 05:58 AM

You could use this for generating your normal maps offline http://cpetry.github.io/NormalMap-Online/




#5295209 when do you load new shaders?

Posted by on 06 June 2016 - 01:04 AM

Yep thats basically it.

 

The cost of switching shaders like this is generally non-free so be wary of doing thousands of shader switches per frame. It's best to batch them, for example.




#5293167 How to implement Cascaded Shadow Map technique ( simply )?

Posted by on 24 May 2016 - 02:35 AM

Have you implemented basic shadow mapping yet?




#5291090 A Brain Dump of What I Worked on for Uncharted 4

Posted by on 11 May 2016 - 03:18 AM

That's very cool, cheers for sharing. Are you allowed to share information on the tech used? I'm curious to know about what language(s) and framework(s) were used for the level editor and so on.




#5290074 Considering two methods of lighting

Posted by on 04 May 2016 - 09:34 AM

I'd suggest looking up "Shadow Mapping" first, it's a basic approach that gives rough results but is a great starting point for learning about it.




#5290036 The best way to render text in D3D12

Posted by on 04 May 2016 - 02:37 AM

In my immediate mode GUI I achieve some pretty nice font rendering, dynamic geometry for the whole UI is created each frame:

 

chessboard.png

 

I create quad lists for the text and update a vertex and index buffer each frame. I originally looked at using distance field fonts but i found it hard to achieve the same quality of rendering. The bitmap font sheet was rendered with the Angel Code bitmap font tool. I've added in some GUI elements that use the different font effects such as italic and drop shadow.




#5283363 In Game Console window using DirectX 11

Posted by on 25 March 2016 - 06:38 AM

Thanks for the links ocornut, it's interesting to see what people have done with IMGUI.


#5283095 In Game Console window using DirectX 11

Posted by on 24 March 2016 - 03:54 AM

The quickest solution would be IMGUI as suggested. I was never convinced it looked that great though and had limited skinning possibilities. I could be wrong though. If my understanding is correct and you wanted to ship the console with your game, it might be better to roll your own.




#5279977 How do you go about a Property System for an Editor?

Posted by on 07 March 2016 - 02:56 AM

My editor is built in the engine so I just have:

void Scn_TransformComponent::GetProperties(Cor_PropertyCollection& collection)
{
	collection.PushGroup("Transform");
	collection.AddBool("Enabled", Cor_PropertyBool::GetDelegate(this, &Scn_TransformComponent::GetEnabled), Cor_PropertyBool::SetDelegate(this, &Scn_TransformComponent::SetEnabled));
	collection.AddVector3("Trans.", Cor_PropertyVector3::GetDelegate(this, &Scn_TransformComponent::GetTranslation), Cor_PropertyVector3::SetDelegate(this, &Scn_TransformComponent::SetTranslation));
	collection.AddVector3("Rot.",	Cor_PropertyVector3::GetDelegate(this, &Scn_TransformComponent::GetRotation), Cor_PropertyVector3::SetDelegate(this, &Scn_TransformComponent::SetRotation), Cor_PropertyAttributes("Degrees"));
	collection.AddVector3("Scal.",	Cor_PropertyVector3::GetDelegate(this, &Scn_TransformComponent::GetScaling), Cor_PropertyVector3::SetDelegate(this, &Scn_TransformComponent::SetScaling));
	
	collection.AddBool("Uniform Scale", Cor_PropertyBool::GetDelegate(this, &Scn_TransformComponent::GetUniformScreenScale), Cor_PropertyBool::SetDelegate(this, &Scn_TransformComponent::SetUniformScreenScale));
	if (m_params.m_uniformScreenScale)
	{
		collection.AddFloat32("Scale Fac.", Cor_PropertyFloat32::GetDelegate(this, &Scn_TransformComponent::GetUniformScaleFactor), Cor_PropertyFloat32::SetDelegate(this, &Scn_TransformComponent::SetUniformScaleFactor));
	}
	collection.PopGroup();
}



It's great because it's immediate, I don't have to convey the information about what properties I want in the property control using attributes (as in the style of C#) because I just do or don't give them in the GetProperties() method. I also don't have complicated macros because I just don't need a reflection system.




#5277855 Integrating Bullet into an entity-component system

Posted by on 24 February 2016 - 04:17 AM

Are you actually making a game or a demo that requires these non-trivial entity hierarchies and multiple components of the same type? I integrated bullet into my entity-component system the most simple way which was one rigid body component per entity and one collision shape per component and i've yet to require anything else. Point being, just do what you need to do. There shouldn't really be any of these what-if scenarios until you actually need them and then the become scenarios and not what-ifs.




#5277277 Correct way of doing Mouse Picking

Posted by on 21 February 2016 - 06:55 AM

You might also consider using a pick buffer which is a render target where each pixel contains an ID that is the object that covers that pixel. Therefore sampling the pick buffer under the cursor gives you the object the mouse is over. This doesn't solve box selection though, but is a simple way of doing it that doesnt involve alot of projection/unprojection. Note also that its particularly good for picking terrain, where typically you don't want to be doing ray triangle intersection.




#5265449 entity system implementation

Posted by on 08 December 2015 - 10:11 AM

A reasonable compromise is to store a set of 1-bit flags on each entity, which tells you which components are attached to this entity. If you need to retrieve the component you'll still need to search for it in the relevant component array, but at least testing for it's presence is now cheap.

Sure that would work. I can't think of any occurrences where i've wanted to see if it has a specific component without actually wanting to do something with it though, not personally.

 

EDIT: I just did a quick google search and found this article again http://bitsquid.blogspot.co.uk/2014/09/building-data-oriented-entity-system.html. Under the heading 'accessing data' it talks about having a much smaller table of indices that provide an indirection to the components at their respective indices. So it looks like you'd use:

 

MAX_ENTITIES * sizeof(int) * MAX_COMPONENT_TYPES bytes for the indirection table and then a trimmed down component table.

rather than:

MAX_ENTITIES * MAX_COMPONENT_TYPES * AVERAGE_COMPONENT_SIZE and no indirection table (as I currently have).

 

So you'd save a tonne of memory that way.




#5265397 entity system implementation

Posted by on 08 December 2015 - 12:43 AM

Sure, I declared that issue up front. I'm yet to find a balance between minimal memory consumption and 'very fast' lookup of components that doesnt involve storing the components on the entity.




#5265335 entity system implementation

Posted by on 07 December 2015 - 03:22 PM

Have you tried the MAX_ENTITIES before BeerNutts, i'm curious what harm comes of it in your experience?






PARTNERS