Difference between revisions of "ShipEditor"

From SfzWiki
Jump to: navigation, search
 
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== OLM ==
+
(mostly obsolete, will be coded mainly in lua now, some ideas might be used though)
 +
 
 +
>= OLM =
 
* ObjectOriented-Lowpoly-Modeller
 
* ObjectOriented-Lowpoly-Modeller
* Prism Based -> enhanced Interior Detection and Mesh-Management
+
* Prism Based -> enhanced Interior Detection and Mesh-Management
  
=== TODO ===
+
== Headers ==
<pre><nowiki>
+
// TODO : NameSpace for Editor ? (or just for whole project)
+
// TODO : Research : Multiple Inheritance : Con-/Destructor Calling and Order
+
// TODO : Research : Multiple Inheritance : automatic casting ??? or static_cast<Type>(ptr)
+
// TODO : Research : Trac : auto-generate tickers from doxygen TODOs
+
// TODO : Research : Exceptions
+
// TODO : Research : Python for Editor ?
+
// TODO : Research : DesignPattern : Mnemonic/InnerState for Create/Destroy-Command
+
// Todo : Research : DesignPattern : Builder -> ComponentBuilder
+
</nowiki></pre>
+
  
<pre><nowiki>
+
&lt;code&gt;
Interface:iPointable
+
class iSmartPointable&lt;class _T&gt; {
list<SmartPointer>
+
public:
// Destructor calls NotifyDestroy() of all pointers (ListenerPattern)
+
void RegisterSmartPtr (SmartPtr&lt;_T&gt;* p);
 +
void UnregisterSmartPtr (SmartPtr&lt;_T&gt;* p);
 +
SmartPtr&lt;_T&gt;* GetSmartPtr (iSmartPtrListener* listener);
 +
 +
protected:
 +
std::List&lt;SmartPtr&lt;_T&gt;*&gt; smartPointers;
 +
iSmartPointable(); // empty, protected (must inherit)
 +
~iSmartPointable(); // calls NotifyDestroy() of all smartPointers
 +
void NotifySmartPtrChange(const int code); // calls NotifyChange() of all smartPointers (idea)
 +
}
  
SmartPointer<Type>
+
class iSmartPtrListener&lt;class _T&gt; {
iPointable
+
public :
Type operator * ()
+
virtual void NotifySmartPtrDestroy (SmartPtr&lt;_T&gt;* sp);
Type operator -> ()
+
virtual void NotifySmartPtrChange (SmartPtr&lt;_T&gt;* sp,const int code);
void NotifyDestroy (); // DesignPattern:Listener
+
}
// TODO : Research : DesignPattern : SmartPointer
+
</nowiki></pre>
+
  
<pre><nowiki>
+
class SmartPtr&lt;class _T&gt; {
Interface:iEditable
+
public :
list<VertexPtr> listVertices();
+
SmartPtr (_T* target=0,iSmartPtrListener&lt;_T&gt;* listener=0); // target=0 possible !!!  (register)
abstract void Move (Vec3 v);
+
~SmartPtr (); //  (unregister)
abstract void Scale (Vec3 v,Vec3 o);
+
void SetTarget (_T* target) // unregister old + register new
abstract void Scale (Vec3 v);
+
void NotifyDestroy (); // calls listener-&gt;NotifyDestroy()
abstract void Rotate (Quaternion q,Vec3 o);
+
_T&amp; operator = (_T* cmp) // test for equality
abstract void Rotate (Quaternion q);
+
_T&amp; operator = (SmartPtr&lt;_T&gt; cmp) // test for equality
Vec3 GetBoundsMin ();
+
_T&amp; operator * () // todo : lookup syntax for (*smartptr), something like (int dummy)
Vec3 GetBoundsMax ();
+
_T&amp; operator -&gt; ()
Vec3 GetBoundsCenter ();
+
Vec3 GetPivot ();
+
private :
</nowiki></pre>
+
_T* target; // _T must be iSmartPointable, can be 0
 +
iSmartPtrListener* listener; // can be 0
 +
}
 +
&lt;/code&gt;
  
<pre><nowiki>
+
&lt;code&gt;
Component
+
class iEditable {
Vec3 pos;
+
public :
list<Vec3> top;
+
virtual void Move (Vec3 v);  
list<Vec3> bot;
+
virtual void Scale (Vec3 v,Vec3 o = gVec3Zero); //  might not operate on vertices !
int flags;
+
virtual void Rotate (Vec3 v,Vec3 o = gVec3Zero);
ComponentType* type;
+
virtual void Rotate (Quaternion q,Vec3 o = gVec3Zero);
ComponentGroup* parent; // smartptr ?
+
// void transform(matrix m) ? might not operate on vertices (cockpit-component is iEditable)
EditComponent GetEditComponent (); // null or overridden
+
}
</nowiki></pre>
+
&lt;/code&gt;
  
<pre><nowiki>
+
&lt;code&gt;
ComponentType
+
class iMeshLike : public iEditable {
// SteelFrame,TitanFrame,Cockpit...
+
public :
</nowiki></pre>
+
virtual Vec3&amp; EditVertex (const int i); // throws exception if index out of bounds
 +
virtual int CountVertices ();
 +
Vec3 GetBoundsMin ();
 +
Vec3 GetBoundsMax ();
 +
Vec3 GetBoundsCenter ();
 +
Vec3 GetPivot ();
 +
 +
// todo : readonly lists or complete management in this class ?
 +
// usecase :  ship-frame(readwrite) cockpit(readonly:just one dockable side, and move/rotatable for complete object)
 +
list GetLinkedSides(SideNum);
 +
list GetLinkedVertices(VertexNum);
 +
list GetLinkedEdges(EdgeNum);
 +
list GetSideVertices(SideNum);
 +
list GetEdgeVertices(EdgeNum);
 +
vertex,side,edge enumeration and access
 +
editable functions
 +
position+rotation access -&gt; coordinate conversion + align rotation.
 +
flags for lock vertices, lock pos/rot...
 +
cockpit is model with one designated side for docking,
 +
vertices cannot be changed, but position+rotation change is possible
 +
framecomponent does not need to use rotation, as the vertices are usualle freely movable
 +
when docked to cockpit, and moving the docked side, try to rotate/move the cockpit
 +
as closely as possible, then readjust vertices
 +
also otpional &quot;lock form/vertices&quot; for completed frame components (only rotate/position)
 +
-&gt; behave similar to cockpit
 +
// visual feedback(side/edge/face hilighting, gizmos...) implemented in this class ??
 +
}
 +
&lt;/code&gt;
  
<pre><nowiki>
 
EditComponent
 
// lists for selected vertices,edges,sides and whole component
 
</nowiki></pre>
 
  
<pre><nowiki>
+
&lt;code&gt;
Selection
+
class cComponent {
// Selection != Group, as selection can be mutliple vertices/faces/lines...
+
public:
</nowiki></pre>
+
SmartPtr&lt;cComponent&gt; parent; // =0 for top, frame:group,maschine:frame,...
 +
position,rotation
 +
GetBounds()
 +
GenBluePrint(tex,axis,offset,scale,colors)
 +
Cast2Group()
 +
Cast2Frame()
 +
ComponentType* type;
 +
// emissions for sensors....
 +
// blueprint status display : functionality and damage
 +
NotifyDamage(); // Section (groupname) has been hit..
 +
GetDescription();
 +
// also baseclass for inner-maschinery etc...
 +
// coordinate translation ! (rotation)
 +
//intersection,inclusion-calc
 +
}
 +
&lt;/code&gt;
  
  
<pre><nowiki>
 
ComponentGroup
 
list<Component> elements;
 
</nowiki></pre>
 
  
<pre><nowiki>
+
&lt;code&gt;
EditComponentGroup
+
class cFrameComponent : public iMeshLike {
// type of elements = EditComponent, use Component->GetEditComponent()
+
public:
</nowiki></pre>
+
list&lt;Vec3&gt; top;
 +
list&lt;Vec3&gt; bot;
 +
int flags;
 +
EditComponent GetEditComponent (); // null or overridden
 +
}
 +
&lt;/code&gt;
  
  
<pre><nowiki>
+
&lt;code&gt;
Gizmo
+
class cModuleComponent : public iMeshLike {
bool MouseOver(Vec3 o,Vec3 v);
+
public:
// click+drag // TODO : Research : CEGUI click+drag handling
+
list&lt;list&lt;Vec3&gt;&gt; sides;
</nowiki></pre>
+
// throws exceptions on illegal edit
 +
// cockpit, solarpanel...
 +
// ??? iMeshLike -&gt; iEditable outside editor (deform from hit ??)
 +
}
 +
&lt;/code&gt;
  
<graph>digraph G {
+
&lt;code&gt;
Gizmo -> AxisGizmo -> { MoveGizmo, ScaleGizmo };
+
class cComponentType {
Gizmo -> RotateGizmo;
+
public:
}</graph>
+
// SteelFrame,TitanFrame,Cockpit...
 +
}
 +
&lt;/code&gt;
  
<graph>digraph G {
+
&lt;code&gt;
Component -> { Inner, Hull };
+
class cEditComponent {
ComponentBuilder -> Component;
+
public:
}</graph>
+
// lists for selected vertices,edges,sides and whole FrameComponent
 +
}
 +
&lt;/code&gt;
  
 +
&lt;code&gt;
 +
class cSelection : iEditable {
 +
public:
 +
// Selection != Group, as selection can be mutliple vertices/faces/lines...
 +
}
 +
&lt;/code&gt;
  
<graph>digraph G {
 
  
Component;
+
&lt;code&gt;
GameComponent -> Component;
+
class cComponentGroup {
EditComponent -> {Component,iEditable};
+
public:
 +
std::string name;
 +
std::list&lt;Component&gt; elements;
 +
}
 +
&lt;/code&gt;
  
Selection -> iEditable;
+
&lt;code&gt;
 +
class EditComponentGroup {
 +
public:
 +
// type of elements = EditComponent, use Component-&gt;GetEditComponent()
 +
}
 +
&lt;/code&gt;
  
Component;
 
  
ComponentGroup -> Component;
+
&lt;code&gt;
 +
class cMouseMode {
 +
public :
 +
// activate (=constructor),deactivate(=destructor)
 +
// step(=draw gizmos, active child as param ???),
 +
// abort(by rightclick, activates parent if set)
 +
// child-functions ??
 +
// hold SmartPtr to &quot;cGizmo&quot;s, and abort/selfkill on NotifyDestroy ?
 +
}
 +
&lt;/code&gt;
  
EditComponentGroup -> {ComponentGroup,iEditable}
 
}</graph>
 
  
 +
&lt;code&gt;
 +
class cGizmo {
 +
public:
 +
bool MouseOver(Vec3 o,Vec3 v);
 +
// click+drag // TODO : Research : CEGUI click+drag handling
 +
// drawing, scaling from + -
 +
// move,scale,rot : smartptr to iEditable, selfkill on NotifyDestroy
 +
}
 +
&lt;/code&gt;
  
 +
 +
&lt;code&gt;
 +
class cGrid {
 +
public:
 +
// snapping support (iSnappable ??)
 +
//
 +
}
 +
&lt;/code&gt;
 +
 +
== Diagrams ==
 +
 +
&lt;graph&gt;digraph G {
 +
cGizmo -&gt; cAxisGizmo -&gt; { cMoveGizmo, cScaleGizmo };
 +
cGizmo -&gt; cRotateGizmo;
 +
}&lt;/graph&gt;
 +
 +
&lt;graph&gt;digraph G {
 +
cFrameComponent -&gt; cComponent;
 +
cGameComponent -&gt; cComponent;
 +
cGameFrameComponent -&gt; cFrameComponent;
 +
cEditFrameComponent -&gt; {cFrameComponent,iMeshLike};
 +
cSelection -&gt; iEditable;
 +
cComponentGroup -&gt; cComponent;
 +
cEditComponentGroup -&gt; {cComponentGroup,iEditable}
 +
}&lt;/graph&gt;
 +
 +
 +
== use cases ==
 +
 +
=== start first spaceship frame ===
 +
* select create-frame tool
 +
* click and drag from corner A (somewhere on grid) to corner B of the bottom side
 +
* release mouse and move up/down to place the top side
 +
* click to finish
 +
[[Image:sfz_create_frame.jpg]]
 +
 +
=== extrude or bevel single side ===
 +
* select extrude or bevel tool
 +
* click on side (not in selection) and drag to bevel/extrude this one side
 +
* if extrude
 +
** release to finish
 +
* elseif bevel
 +
** release starts scaling the extruded face
 +
** click to finish
 +
[[Image:sfz_bevel_single.jpg]]
 +
 +
=== bevel/extrude selection ===
 +
* select pointer/selection tool
 +
* select face mode from mode tool (vertex/edge/face/component/group)
 +
* click + drag to select everything within rectangular area (rect-gizmo)
 +
* shift : add to selection, ctrl : remove from selection : change cursor
 +
* shift-click on single faces to add them to the selection
 +
* select extrude/bevel tool
 +
* click on side (in selection) and drag to bevel/extrude the selected faces together
 +
* if extrude
 +
** release to finish
 +
* elseif bevel
 +
** release starts scaling the extruded face
 +
** click to finish
 +
[[Image:sfz_bevel_selection.jpg]]
 +
 +
=== docking 2 sides ===
 +
 +
* user choses pinter/selection tool
 +
* user selects a single frame-side A
 +
* there is a tool-panel with 3 buttons : &quot;dock&quot;,&quot;pickA&quot;,&quot;pickB&quot;
 +
* pickA and pickB are of a special button class used for selecting faces
 +
* click on pickA opens popup with choices : &quot;current Selection&quot;,&quot;list with named selections&quot;,&quot;pick by click&quot;,...
 +
* click on current selection chooses frame-side A and marks the &quot;pickA&quot; button as not-empty (change color?)
 +
* user selects a different single frame-side B on a different frame-component
 +
* same procedure as with pickA
 +
* click on &quot;dock&quot; button leaves the frame-side A in its place, and moves frame-side B to its position if possible (throw exception otherwise)
 +
* in data the two frames are now linked to each other, moving one also moves the other, and walking inside is possible (inner side has no hull)
 +
 +
=== quickdock ===
 +
 +
* user pushes quickdock button (enters dock-mode which is a mousemode)
 +
* user clicks on faceA
 +
* while user moves mouse, a line is drawn from the center of faceA and faceA is highlited in some color
 +
* user clicks on faceB, and the dock is executed, dock-mode stays, so multiple docks can be made
 +
* user clicks on faceA2 ..
 +
* user clicks on faceB2 ..
 +
* ...
 +
* rightclick to stop/abort dock-mode
 +
 +
 +
 +
== todo's ==
 +
 +
* NameSpace for Editor ? (or just for whole project)
 +
* Research : Multiple Inheritance : Con-/Destructor Calling and Order
 +
* Research : Multiple Inheritance : automatic casting ??? or static_cast&lt;Type&gt;(ptr)
 +
* Research : Trac : auto-generate tickets from doxygen TODOs
 +
* Research : Doxygen syntax
 +
* Research : Exceptions
 +
* Research : Decorator : editor for cFrameComponent ?
 +
* Research : Python for Editor ?
 +
* Research : DesignPattern : Memento / State for Create/Destroy-Command ?
 +
* SkyBox-Texture using povray
 +
* Explosion-Animation using povray
 +
* Python integration
 +
** editor
 +
** hud
 +
** story:dialog/messages,events(entersystem,grab,destroy,dock,countdown)treasure,rewards,enemies,missions
 +
* chain-of-responsibility pattern for mousemodes, to catch clicks/drags and keystrokes and return true if handled
 +
 +
== notes/ideas ==
 +
 +
=== Intuitive Behavior ===
 +
 +
* esc,rightclick : cancel mousemode
 +
* backspace=back_to_parent, return=show_detail
 +
* remove(delete) : kill/remove/collapse selected
 +
 +
=== StackTracer/Profile ===
 +
 +
* see sfz-wiki : std:uncaught_exception()
 +
* macro : can be declared empty for release-compile
 +
* macro at beginning of function
 +
* creates object, which runs out of scope as the function exits -&gt; exception-safe
 +
* pass &quot;path&quot;(&quot;cBaseClass::MyMethod&quot;),file,line to constructor
 +
* use (const char*)path pointer instead of string compare
 +
* profile : measure time from constructor to destructor
 +
 +
=== Custom-Assert ===
 +
 +
* keep gui intact if possible
 +
* write report to file
 +
* print stacktrace
 +
* offer options : ignore,abort,debug,throw-exception
 +
 +
=== Linking ===
 +
 +
* Link Sides from different components
 +
* throw exception when trying to move/scale/rotate link when locked
 +
* throw exception when trying to change form of link when locked
 +
 +
=== Locking ===
 +
 +
* lock form(edge-count,connections,NOT SIZE/POS), size(rotate allowed ??), position
 +
* beware of linking !
 +
 +
=== Face/Edge/Vertex Indexing ===
 +
 +
* prism based -&gt; use positive for top, negative for bottom
 +
* keep numbering if possible if only one half is changed
 +
* smartptr-change notify usage ? (integrated listener pattern)
 +
 +
=== Symetry ===
 +
 +
* operates on list&lt;component/sides/edges&gt;:mutli-selection?, keeps binding, operator Source.
 +
* mirror-plane + center-merger-plane gizmo :  &lt;[]&gt; &lt;[I]&gt;
  
 
=== Editing ===
 
=== Editing ===
Line 119: Line 349:
 
* Uses Mnemonic/Inner State Pattern for Create/Destroy
 
* Uses Mnemonic/Inner State Pattern for Create/Destroy
 
* Python Support ??
 
* Python Support ??
* Commands bindable to Buttons, MenuItems, Right-Click Menu....
+
* Commands bindable to Buttons, Keys/KeyCombos, MenuItems, Right-Click Menu....
  
 
=== Move,Scale,Rotate ===
 
=== Move,Scale,Rotate ===
Line 139: Line 369:
 
*types/smartpointers for vertex,edge,side
 
*types/smartpointers for vertex,edge,side
 
*Selection managed as (named)list of those types
 
*Selection managed as (named)list of those types
*Selection depends on active "type" (vertex,edge,side,component,group), no mixing
+
*Selection depends on active &quot;type&quot; (vertex,edge,side,FrameComponent,group), no mixing
 
*select gizmo (rectangle)
 
*select gizmo (rectangle)
 
*Toggle select on intersect or only on complete containment
 
*Toggle select on intersect or only on complete containment
Line 146: Line 376:
 
*undo for selection
 
*undo for selection
 
*group select : when group is already selected, click selects subgroup
 
*group select : when group is already selected, click selects subgroup
 
+
*map&lt;smartptr&lt;comp&gt;,list&lt;num&gt;&gt;
  
 
=== Picking ===
 
=== Picking ===
Line 153: Line 383:
 
*named selection,  
 
*named selection,  
 
*hierarchy list (groups)
 
*hierarchy list (groups)
*pick-by-click (current mode : vertex,edge,side,component,group)
+
*pick-by-click (current mode : vertex,edge,side,FrameComponent,group)
  
 
=== Tools ===
 
=== Tools ===
*ToolPanel = view, Tool = model(singleton) -> model/view seperation, change-listener
+
*ToolPanel = view, Tool = model(singleton) -&gt; model/view seperation, change-listener
*Tool->CreatePanel()
+
*Tool-&gt;CreatePanel()
 
*Python Support ??
 
*Python Support ??
*Tools can "pick" current selection, named selection, groups, or pick-by-click  
+
*Tools can &quot;pick&quot; current selection, named selection, groups, or pick-by-click  
  
* Named Selections (depends on current mode (vertex,edge,side,component,group)) + Select/Unselect/Show/Hide/Delete
+
* camera rotation mode : around current selection, world center, around self(firstperson mode)
* Mode Selection (vertex,edge,side,component,group)
+
* Grid Move Gizmo = Axis at left-top
 +
* Grid Centered on Origin, Center of Current Selection, or fixed point
 +
* Grid x,y,z,off (toggle bindable to key)
 +
* Named Selections (depends on current mode (vertex,edge,side,FrameComponent,group)) + Select/Unselect/Show/Hide/Delete
 +
* Mode Selection (vertex,edge,side,FrameComponent,group) [[Image:sfz_mode.jpg]]
 
* Tool Selection (Select,Move,Scale,Rotate,Extrude,Bevel,SpinExtrude,SpinBevel)
 
* Tool Selection (Select,Move,Scale,Rotate,Extrude,Bevel,SpinExtrude,SpinBevel)
 
* Snap (Grid,Vertex,Edge,Face)
 
* Snap (Grid,Vertex,Edge,Face)
Line 169: Line 403:
 
* Hierarchy-List (also for popup)
 
* Hierarchy-List (also for popup)
 
* Change Parent (opens hierarchy-list popup)
 
* Change Parent (opens hierarchy-list popup)
* Later : Change Type (popup : for compatible types, eg titanframe -> steelframe ??)
+
* Later : Change Type (popup : for compatible types, eg titanframe -&gt; steelframe ??)
 
* Later : Change Side (point,line,3up,3down,square,penta,[x]:popup)
 
* Later : Change Side (point,line,3up,3down,square,penta,[x]:popup)
only for top/bottom, autoconvert if top/bottom <= 4
+
only for top/bottom, autoconvert if top/bottom &lt;= 4
 
* Later : Toggle select on intersect or only on complete containment
 
* Later : Toggle select on intersect or only on complete containment
* Later : QuickCut/Slice (component, : DrawLine Gizmo
+
* Later : QuickCut/Slice (FrameComponent, : DrawLine Gizmo
 
* Later : Create Adapter : pick operand a,b
 
* Later : Create Adapter : pick operand a,b
 
* Later : ExtrudeAroundEdge,TurnAroundEdge (pick edge + turn selection)
 
* Later : ExtrudeAroundEdge,TurnAroundEdge (pick edge + turn selection)
 
* Later : SoftSelection (falloff:distance/adjactance,falloff:linear,cubic,curve,falloffdist)
 
* Later : SoftSelection (falloff:distance/adjactance,falloff:linear,cubic,curve,falloffdist)
 
* Later : Dock : move 2 sides together and link them, pick base(not moved) and operand (modifyed)
 
* Later : Dock : move 2 sides together and link them, pick base(not moved) and operand (modifyed)
* Later : Constraints/Links + LockSize (link 2 sides of different components, only move, not scale group)
+
* Later : Constraints/Links + LockSize (link 2 sides of different FrameComponents, only move, not scale group)
 
* Later : Prism-Based Subdivide (height/width)  
 
* Later : Prism-Based Subdivide (height/width)  
 
* Later : Hide/Show Selection/All
 
* Later : Hide/Show Selection/All
Line 191: Line 425:
 
*TODO : Research : CEGUI
 
*TODO : Research : CEGUI
  
*Tool/Mode/Gizmo can activate "MouseMode", abort on esc,rightclick
+
*Tool/Mode/Gizmo can activate &quot;MouseMode&quot;, abort on esc,rightclick
 
and when another MouseMode is activated
 
and when another MouseMode is activated
  
Line 205: Line 439:
 
and enables cheating (ultra compact, multi-dimensional cargo bays)
 
and enables cheating (ultra compact, multi-dimensional cargo bays)
  
<pre><nowiki>
+
&lt;pre&gt;&lt;nowiki&gt;
 
   ---
 
   ---
 
   /\X/\
 
   /\X/\
 
  /  -  \
 
  /  -  \
 
  -------
 
  -------
  </nowiki></pre>
+
  &lt;/nowiki&gt;&lt;/pre&gt;
 +
 
 +
 
 +
 
 +
=== Blinking/Signal lights ===
 +
 
 +
* position on hull, can have limied offset
 +
* choose color, frequency and offset
 +
 
 +
=== Sensors ===
 +
 
 +
* Heat/Temperature, Radioactivity, Electricity, Mass, Radar(metal), Bio
 +
* spectrum analyzer : distinct materials
 +
* active scanning (radar, detailed materials, freight)
 +
* colors can be customized
 +
* hud element for active scanning : modus (off, manual ping, fade display, ping interval)
 +
* hud element for radar : 2 half-spheres (front and back) or single full sphere
 +
** FOF-colors customizable, lines to center : distance...
 +
** alternate : 2d-circle with orthogonal-lines indicating height
 +
 
 +
=== ComponentTypes ===
 +
 
 +
* implement constraints by inheritance or decorator or callback...
 +
* factory for components ??
 +
** (could be used to convert component-type if neccessary : steel-titan-frame)
 +
** editable restraints
 +
 
 +
=== SampleComponents ===
 +
 
 +
* Frame (different materials, eg steel,titan,...)
 +
* Cockpit/Bridge (different models)
 +
* Scalable Thruster/Engine
 +
* Scalable Solar Panel (rotatable?)
 +
* Mountable Thruster ( mount on wing, like jumbo-jet, can mount missile/rocket-launcher instead)
 +
 
 +
=== Naming Scheme ===
 +
* entity : ship,cargo-box,star,planet...
 +
* entity has components
 +
* system (starsystem) contains entities
 +
* entity has course, pos+vel or pos+orbit(center,elliptic-params)
 +
 
 +
----

Latest revision as of 16:48, 9 January 2011

(mostly obsolete, will be coded mainly in lua now, some ideas might be used though)

>= OLM =

  • ObjectOriented-Lowpoly-Modeller
  • Prism Based -> enhanced Interior Detection and Mesh-Management

Headers

<code> class iSmartPointable<class _T> { public: void RegisterSmartPtr (SmartPtr<_T>* p); void UnregisterSmartPtr (SmartPtr<_T>* p); SmartPtr<_T>* GetSmartPtr (iSmartPtrListener* listener);

protected: std::List<SmartPtr<_T>*> smartPointers; iSmartPointable(); // empty, protected (must inherit) ~iSmartPointable(); // calls NotifyDestroy() of all smartPointers void NotifySmartPtrChange(const int code); // calls NotifyChange() of all smartPointers (idea) }

class iSmartPtrListener<class _T> { public : virtual void NotifySmartPtrDestroy (SmartPtr<_T>* sp); virtual void NotifySmartPtrChange (SmartPtr<_T>* sp,const int code); }

class SmartPtr<class _T> { public : SmartPtr (_T* target=0,iSmartPtrListener<_T>* listener=0); // target=0 possible !!! (register) ~SmartPtr (); // (unregister) void SetTarget (_T* target) // unregister old + register new void NotifyDestroy (); // calls listener->NotifyDestroy() _T& operator = (_T* cmp) // test for equality _T& operator = (SmartPtr<_T> cmp) // test for equality _T& operator * () // todo : lookup syntax for (*smartptr), something like (int dummy) _T& operator -> ()

private : _T* target; // _T must be iSmartPointable, can be 0 iSmartPtrListener* listener; // can be 0 } </code>

<code> class iEditable { public : virtual void Move (Vec3 v); virtual void Scale (Vec3 v,Vec3 o = gVec3Zero); // might not operate on vertices ! virtual void Rotate (Vec3 v,Vec3 o = gVec3Zero); virtual void Rotate (Quaternion q,Vec3 o = gVec3Zero); // void transform(matrix m) ? might not operate on vertices (cockpit-component is iEditable) } </code>

<code> class iMeshLike : public iEditable { public : virtual Vec3& EditVertex (const int i); // throws exception if index out of bounds virtual int CountVertices (); Vec3 GetBoundsMin (); Vec3 GetBoundsMax (); Vec3 GetBoundsCenter (); Vec3 GetPivot ();

// todo : readonly lists or complete management in this class ? // usecase : ship-frame(readwrite) cockpit(readonly:just one dockable side, and move/rotatable for complete object) list GetLinkedSides(SideNum); list GetLinkedVertices(VertexNum); list GetLinkedEdges(EdgeNum); list GetSideVertices(SideNum); list GetEdgeVertices(EdgeNum); vertex,side,edge enumeration and access editable functions position+rotation access -> coordinate conversion + align rotation. flags for lock vertices, lock pos/rot... cockpit is model with one designated side for docking, vertices cannot be changed, but position+rotation change is possible framecomponent does not need to use rotation, as the vertices are usualle freely movable when docked to cockpit, and moving the docked side, try to rotate/move the cockpit as closely as possible, then readjust vertices also otpional "lock form/vertices" for completed frame components (only rotate/position) -> behave similar to cockpit // visual feedback(side/edge/face hilighting, gizmos...) implemented in this class ?? } </code>


<code> class cComponent { public: SmartPtr<cComponent> parent; // =0 for top, frame:group,maschine:frame,... position,rotation GetBounds() GenBluePrint(tex,axis,offset,scale,colors) Cast2Group() Cast2Frame() ComponentType* type; // emissions for sensors.... // blueprint status display : functionality and damage NotifyDamage(); // Section (groupname) has been hit.. GetDescription(); // also baseclass for inner-maschinery etc... // coordinate translation ! (rotation) //intersection,inclusion-calc } </code>


<code> class cFrameComponent : public iMeshLike { public: list<Vec3> top; list<Vec3> bot; int flags; EditComponent GetEditComponent (); // null or overridden } </code>


<code> class cModuleComponent : public iMeshLike { public: list<list<Vec3>> sides; // throws exceptions on illegal edit // cockpit, solarpanel... // ??? iMeshLike -> iEditable outside editor (deform from hit ??) } </code>

<code> class cComponentType { public: // SteelFrame,TitanFrame,Cockpit... } </code>

<code> class cEditComponent { public: // lists for selected vertices,edges,sides and whole FrameComponent } </code>

<code> class cSelection : iEditable { public: // Selection != Group, as selection can be mutliple vertices/faces/lines... } </code>


<code> class cComponentGroup { public: std::string name; std::list<Component> elements; } </code>

<code> class EditComponentGroup { public: // type of elements = EditComponent, use Component->GetEditComponent() } </code>


<code> class cMouseMode { public : // activate (=constructor),deactivate(=destructor) // step(=draw gizmos, active child as param ???), // abort(by rightclick, activates parent if set) // child-functions ?? // hold SmartPtr to "cGizmo"s, and abort/selfkill on NotifyDestroy ? } </code>


<code> class cGizmo { public: bool MouseOver(Vec3 o,Vec3 v); // click+drag // TODO : Research : CEGUI click+drag handling // drawing, scaling from + - // move,scale,rot : smartptr to iEditable, selfkill on NotifyDestroy } </code>


<code> class cGrid { public: // snapping support (iSnappable ??) // } </code>

Diagrams

<graph>digraph G { cGizmo -> cAxisGizmo -> { cMoveGizmo, cScaleGizmo }; cGizmo -> cRotateGizmo; }</graph>

<graph>digraph G { cFrameComponent -> cComponent; cGameComponent -> cComponent; cGameFrameComponent -> cFrameComponent; cEditFrameComponent -> {cFrameComponent,iMeshLike}; cSelection -> iEditable; cComponentGroup -> cComponent; cEditComponentGroup -> {cComponentGroup,iEditable} }</graph>


use cases

start first spaceship frame

  • select create-frame tool
  • click and drag from corner A (somewhere on grid) to corner B of the bottom side
  • release mouse and move up/down to place the top side
  • click to finish
Error creating thumbnail: Unable to save thumbnail to destination

extrude or bevel single side

  • select extrude or bevel tool
  • click on side (not in selection) and drag to bevel/extrude this one side
  • if extrude
    • release to finish
  • elseif bevel
    • release starts scaling the extruded face
    • click to finish
Error creating thumbnail: Unable to save thumbnail to destination

bevel/extrude selection

  • select pointer/selection tool
  • select face mode from mode tool (vertex/edge/face/component/group)
  • click + drag to select everything within rectangular area (rect-gizmo)
  • shift : add to selection, ctrl : remove from selection : change cursor
  • shift-click on single faces to add them to the selection
  • select extrude/bevel tool
  • click on side (in selection) and drag to bevel/extrude the selected faces together
  • if extrude
    • release to finish
  • elseif bevel
    • release starts scaling the extruded face
    • click to finish
Error creating thumbnail: Unable to save thumbnail to destination

docking 2 sides

  • user choses pinter/selection tool
  • user selects a single frame-side A
  • there is a tool-panel with 3 buttons : "dock","pickA","pickB"
  • pickA and pickB are of a special button class used for selecting faces
  • click on pickA opens popup with choices : "current Selection","list with named selections","pick by click",...
  • click on current selection chooses frame-side A and marks the "pickA" button as not-empty (change color?)
  • user selects a different single frame-side B on a different frame-component
  • same procedure as with pickA
  • click on "dock" button leaves the frame-side A in its place, and moves frame-side B to its position if possible (throw exception otherwise)
  • in data the two frames are now linked to each other, moving one also moves the other, and walking inside is possible (inner side has no hull)

quickdock

  • user pushes quickdock button (enters dock-mode which is a mousemode)
  • user clicks on faceA
  • while user moves mouse, a line is drawn from the center of faceA and faceA is highlited in some color
  • user clicks on faceB, and the dock is executed, dock-mode stays, so multiple docks can be made
  • user clicks on faceA2 ..
  • user clicks on faceB2 ..
  • ...
  • rightclick to stop/abort dock-mode


todo's

  • NameSpace for Editor ? (or just for whole project)
  • Research : Multiple Inheritance : Con-/Destructor Calling and Order
  • Research : Multiple Inheritance : automatic casting ??? or static_cast<Type>(ptr)
  • Research : Trac : auto-generate tickets from doxygen TODOs
  • Research : Doxygen syntax
  • Research : Exceptions
  • Research : Decorator : editor for cFrameComponent ?
  • Research : Python for Editor ?
  • Research : DesignPattern : Memento / State for Create/Destroy-Command ?
  • SkyBox-Texture using povray
  • Explosion-Animation using povray
  • Python integration
    • editor
    • hud
    • story:dialog/messages,events(entersystem,grab,destroy,dock,countdown)treasure,rewards,enemies,missions
  • chain-of-responsibility pattern for mousemodes, to catch clicks/drags and keystrokes and return true if handled

notes/ideas

Intuitive Behavior

  • esc,rightclick : cancel mousemode
  • backspace=back_to_parent, return=show_detail
  • remove(delete) : kill/remove/collapse selected

StackTracer/Profile

  • see sfz-wiki : std:uncaught_exception()
  • macro : can be declared empty for release-compile
  • macro at beginning of function
  • creates object, which runs out of scope as the function exits -> exception-safe
  • pass "path"("cBaseClass::MyMethod"),file,line to constructor
  • use (const char*)path pointer instead of string compare
  • profile : measure time from constructor to destructor

Custom-Assert

  • keep gui intact if possible
  • write report to file
  • print stacktrace
  • offer options : ignore,abort,debug,throw-exception

Linking

  • Link Sides from different components
  • throw exception when trying to move/scale/rotate link when locked
  • throw exception when trying to change form of link when locked

Locking

  • lock form(edge-count,connections,NOT SIZE/POS), size(rotate allowed ??), position
  • beware of linking !

Face/Edge/Vertex Indexing

  • prism based -> use positive for top, negative for bottom
  • keep numbering if possible if only one half is changed
  • smartptr-change notify usage ? (integrated listener pattern)

Symetry

  • operates on list<component/sides/edges>:mutli-selection?, keeps binding, operator Source.
  • mirror-plane + center-merger-plane gizmo : <[]> <[I]>

Editing

  • All Operations use the Command Pattern, to support Undo/Redo
  • Uses Mnemonic/Inner State Pattern for Create/Destroy
  • Python Support ??
  • Commands bindable to Buttons, Keys/KeyCombos, MenuItems, Right-Click Menu....

Move,Scale,Rotate

  • when Tool is active, show the apropriate gizmo in scene
  • gizmo acts on Current Selection (iEditable)
  • gizmo gives visual MouseOver feedback
  • support snapping

Creation

  • CreateFrameComponent : Activates a Create-Mode :
  • click(first corner) + drag(2d base) + click(3d)
  • gizmo gives visual feedback during creation
  • support snapping

Selection

  • types/smartpointers for vertex,edge,side
  • Selection managed as (named)list of those types
  • Selection depends on active "type" (vertex,edge,side,FrameComponent,group), no mixing
  • select gizmo (rectangle)
  • Toggle select on intersect or only on complete containment
  • manual selection with shift(add) and control(remove)
  • when selection from list, and last selection was manually altered, save last manual selection as named
  • undo for selection
  • group select : when group is already selected, click selects subgroup
  • map<smartptr<comp>,list<num>>

Picking

in popup :

  • current selection,
  • named selection,
  • hierarchy list (groups)
  • pick-by-click (current mode : vertex,edge,side,FrameComponent,group)

Tools

  • ToolPanel = view, Tool = model(singleton) -> model/view seperation, change-listener
  • Tool->CreatePanel()
  • Python Support ??
  • Tools can "pick" current selection, named selection, groups, or pick-by-click
  • camera rotation mode : around current selection, world center, around self(firstperson mode)
  • Grid Move Gizmo = Axis at left-top
  • Grid Centered on Origin, Center of Current Selection, or fixed point
  • Grid x,y,z,off (toggle bindable to key)
  • Named Selections (depends on current mode (vertex,edge,side,FrameComponent,group)) + Select/Unselect/Show/Hide/Delete
  • Mode Selection (vertex,edge,side,FrameComponent,group)
    Error creating thumbnail: Unable to save thumbnail to destination
  • Tool Selection (Select,Move,Scale,Rotate,Extrude,Bevel,SpinExtrude,SpinBevel)
  • Snap (Grid,Vertex,Edge,Face)
  • AngleSnap (edit+on/off button + buttons for 20 30 40 45 60 90)
  • Name+Group / Ungroup
  • Hierarchy-List (also for popup)
  • Change Parent (opens hierarchy-list popup)
  • Later : Change Type (popup : for compatible types, eg titanframe -> steelframe ??)
  • Later : Change Side (point,line,3up,3down,square,penta,[x]:popup)

only for top/bottom, autoconvert if top/bottom <= 4

  • Later : Toggle select on intersect or only on complete containment
  • Later : QuickCut/Slice (FrameComponent, : DrawLine Gizmo
  • Later : Create Adapter : pick operand a,b
  • Later : ExtrudeAroundEdge,TurnAroundEdge (pick edge + turn selection)
  • Later : SoftSelection (falloff:distance/adjactance,falloff:linear,cubic,curve,falloffdist)
  • Later : Dock : move 2 sides together and link them, pick base(not moved) and operand (modifyed)
  • Later : Constraints/Links + LockSize (link 2 sides of different FrameComponents, only move, not scale group)
  • Later : Prism-Based Subdivide (height/width)
  • Later : Hide/Show Selection/All


Gizmos

  • scalable with +/-
  • mouseovereffekt, areas : axis,area-between

Click / Drag Handling

  • TODO : Research : CEGUI
  • Tool/Mode/Gizmo can activate "MouseMode", abort on esc,rightclick

and when another MouseMode is activated

Spawning/ObjectCreation

  • MouseMode
  • Frame/Cockpit :
    • click on side : extrude/bevel
    • click on empty : create in space/ on grid

Inclusion/Intersection Warning

  • not possible for space ships, breaks interior-definition,

and enables cheating (ultra compact, multi-dimensional cargo bays)

<pre><nowiki>

  ---
 /\X/\
/  -  \
-------
</nowiki></pre>


Blinking/Signal lights

  • position on hull, can have limied offset
  • choose color, frequency and offset

Sensors

  • Heat/Temperature, Radioactivity, Electricity, Mass, Radar(metal), Bio
  • spectrum analyzer : distinct materials
  • active scanning (radar, detailed materials, freight)
  • colors can be customized
  • hud element for active scanning : modus (off, manual ping, fade display, ping interval)
  • hud element for radar : 2 half-spheres (front and back) or single full sphere
    • FOF-colors customizable, lines to center : distance...
    • alternate : 2d-circle with orthogonal-lines indicating height

ComponentTypes

  • implement constraints by inheritance or decorator or callback...
  • factory for components ??
    • (could be used to convert component-type if neccessary : steel-titan-frame)
    • editable restraints

SampleComponents

  • Frame (different materials, eg steel,titan,...)
  • Cockpit/Bridge (different models)
  • Scalable Thruster/Engine
  • Scalable Solar Panel (rotatable?)
  • Mountable Thruster ( mount on wing, like jumbo-jet, can mount missile/rocket-launcher instead)

Naming Scheme

  • entity : ship,cargo-box,star,planet...
  • entity has components
  • system (starsystem) contains entities
  • entity has course, pos+vel or pos+orbit(center,elliptic-params)