Creating a new renderable object type
From HEWIKI
Revision as of 19:43, 11 November 2011 by Christopher (Talk | contribs)
|
Documentation on this page is intended for use by customers who have access to HeroEngine source code under their license agreement.
Overview
This page explains how to create a new type of renderable object node, and how to add it to the client and server.
This process requires source code access.
Client-side
A new renderable object needs to be added to:
- Filters
- Asset panel category
- Create menu
Tutorial
- Pick a name. For this tutorial, we'll call it :YourRenderableObject".
- Pick a three-letter extension which uniquely identifies your object type. For this tutorial, we'll use ".yor"
- Open the source code file HeroAssetGrid.cs.
- Find AssetTypeEnum.
- Add YourRenderableObject to it.
- Go to the Asset constructor.
- Add the code:
TypeLookup[".yor"] = AssetTypeEnum.YourRenderableObject;
- Go to HeroBlade.cs (e.g. \MAIN\heroblade\heroblade\HeroBlade.cs)
- Drag the newly created element into the "Create" drop down menu.
- Select your element, go to the Properties tab, and change (Name) to "biYourRenderableObject".
- Change "Tag" to "YourRenderableObject"
- Go to the Events tab, find "Click", and assign the handler "biAssetType_Click" to that event.
- Make sure there's a C++ way of rendering a node. That involves having a unique extension (For example, .bon), and an AssetSpec/Node pair (For example, BoneTrackerAssetSpec.cpp/h and BoneTrackerNode.cpp/h)
- Add to the ASSETSPECTYPE enum in AssetSpec.h
- Add the case to CommandParser.cpp AssetSpecTypeToServerClassName
- Add the new AssetSpec to AssetSpec.cpp #include and FactoryAssetSpec
Server-Side
- Create class definitions on the server GOM complete with fields that represent the properties in the node type.
- Open the DOM editor.
- Make sure that it is not set to 'read-only'.
- Go to the list of classes and push the 'New Class' button.
- Name the new class YourRenderableObjectInstance. IMPORTANT: The archetype of your new class must be set to 'Instance'. Press "Create".
- Create a new class that will contain the writable instance properties and name it YourRenderableObjectInstanceWritableInstanceProperties. That class can be set to archetype 'data', but it needs to inherit the class '_SpecializedWritableInstanceProperties'.
- 'YourRenderableObjectInstsance' now needs to inherit from both: 'Instance' and 'YourRenderableObjectInstanceWritableInstanceProperties'.
- Create fields specific to YourRenderableObject to store property values server-side. Example, if you want a property "BoneToTrack", then you need to add a field for it. You don't need to create fields that are already defined server-side.
- To do that, you create a field definition for the property you're trying to create. NOTE: The type of the field definition on the server needs to be compatible with the type of the field on the client. (Match integer to integer, string to string, vector to vector, etc). IMPORTANT: When you're creating the field, "Reflect" must be set to "Yes"
- If the property type on the client is an enumeration, you will need to create that enumeration on the server and then create a field with its type of that enumeration.
- Once you have all the fields, you need to add them to YourRenderableObjectInstanceWritableInstanceProperties using the DOM editor. To do this, go to the "Classes" section, find YourRenderableObjectInstanceWritableInstanceProperties, add a field.
- Create a prototype from YourRenderableObjectInstance. This will store the default values for a new instance of YourRenderableObjectType. As of this writing, the DOM editor doesn't support prototypes. You'll have to create it manually using console commands.
- Step 1) This step creates the prototype. Type:
\CPFC YourRenderableObjectInstance, ProtoYourRenderableObjectInstance; description="<your description>"
- Step 2) This step sets the fields to their default values. Type:
\MP ProtoYourRenderableObjectInstance; Field1=Value1, Field2=Value2, ...
- Step 3) You need to check to make sure the default values are the ones you want. Type:
\SP ProtoYourRenderableObjectInstance
This shows a list of all the fields and default values. Look at "Scale". The default is (0.,0.,0.). That might not be what you want. Go to Step 2 for each field default value you'd like to set.
- Step 1) This step creates the prototype. Type:
- Register the new type with the edit script.
- If you are creating a game specific type, use the following instructions
- This involves typing a CHAT COMMAND, so open the Chat Panel. Panels -> Chat
- Type:
/HEEDIT ADDASSETTYPE assetname="yourrenderableobjectasset" instancetype="YourRenderableObjectInstance" usePrototype="ProtoYourRenderableObjectInstance" fileExtension=".yor" fqn="\engine\yourrenderableobject.yor" isGeneric="true"
- Note: Set isGeneric to true if your object does not require adding art to the library, else false.
- Note: You won't get any feedback if the command succeeds :(
- If you are creating a new type to be distributed with the Clean HeroEngine, use these instructions
- Open the edit script _EditHandlerClassMethods
- In the function _processCommandAddHeroEngineAssets(), add a line that adds your new asset type
- Open the Chat Panel
- Type:
/HEEDIT addheroengineassets
- Note: If this command fails, you will get an error message, but if it successful, there will be no response.
- Go to a new area instance
- Open the asset panel.
- You should see YourRenderableObject as a category. Expand that, and find yourrenderableobject.yor.
- Select it, then click on "Instances Menu", then click on "Add Instance".
- You should see YourRenderableObject as a category. Expand that, and find yourrenderableobject.yor.
- You should see an instance of your new node.
- If you are creating a game specific type, use the following instructions
- You can now make game-specific code changes.