1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef R2_TOOL_DRAW_PRIM_H
21 #define R2_TOOL_DRAW_PRIM_H
24 #include "prim_render.h"
27 #include "nel/misc/vector.h"
40 * Tool to draw / extend a PRIMITIVE (road or zone)
42 class CToolDrawPrim
: public CTool
45 enum { PrimMaxNumPoints
= 16 };
46 enum TPrimType
{ Road
= 0, Region
, PrimTypeCount
};
47 NLMISC_DECLARE_CLASS(R2::CToolDrawPrim
);
49 CToolDrawPrim(TPrimType primType
= Road
, CInstance
*extending
= NULL
);
50 virtual bool init(const CLuaObject
¶meters
);
51 virtual const char *getToolUIName() const;
52 virtual bool isCreationTool() const { return true; }
53 virtual void cancel();
54 virtual void updateAfterRender();
55 virtual void updateBeforeRender();
56 virtual bool onMouseLeftButtonClicked();
57 virtual bool onMouseRightButtonClicked();
58 virtual bool onMouseLeftButtonDown();
59 virtual bool onDeleteCmd();
61 // update the look of an inaccessible primitive
62 static void updateInaccessiblePrimRenderLook(CPrimRender
&dest
);
65 virtual void onActivate();
67 CPrimRender _Prim
; // the primitive being drawn
68 CPrimRender _InaccessiblePrim
; // inaccessible parts for the primitive being drawn (on an invalid pos on heightmap)
70 CPrimLook _PrimLookInvalid
;
71 CPrimLook _PrimLookCanClose
;
72 CPrimLook _PrimLookInaccessible
;
76 bool _PrimInitialized
;
78 bool _InaccessibleParts
;
79 bool _DistinctLastPoint
;
81 std::vector
<NLMISC::CVector
> _Points
;
82 std::vector
<NLMISC::CVector
> _InitialPoints
; // for extending
83 std::vector
<NLMISC::CVector
> _LastPoints
; // last points for validity test
84 std::string _CookieKey
; // cookie to be attached if creation succeed (empty string if no cookie)
85 CLuaObject _CookieValue
;
86 CLuaObject _CancelFunc
;
88 CInstance::TRefPtr _ExtendedPrimitive
; // road being extended (NULL is this tool is used to create a new primitive)
89 uint _StartNumPoints
; // number of points before extend
96 void setPrimLook(bool closed
, bool lastSegmentValid
, bool valid
);
97 void removeFromWorldMap();
98 void updateValidityFlag(bool ignoreLast
);
99 bool canTerminate() const;
100 bool checkRoomLeft();
101 void displayNoMoreRoomLeftMsg();
102 // for closed polygon only : test if the current shape is valid (e.g not intersecting, with at least 3 points)
103 bool isValidPolyShape(bool ignoreLast
, std::list
<NLMISC::CPolygon
> &splitPoly
) const;
104 bool testAccessibleEdges(bool ignoreLast
);
105 void doUpdateBeforeRender();