mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-25 16:26:18 +00:00
Added: Export usefull cursor and shape functions in lua:
getGroundAtMouse getMousePos getMouseDown getMouseMiddleDown getMouseRightDown setMouseCursor setupShape getShapeIdAt addShape moveShape rotateShape getShapePos getShapeScale getShapeRot getShapeColPos getShapeColScale getShapeColOrient deleteShape
This commit is contained in:
parent
18b024f0c7
commit
512d300741
15 changed files with 1910 additions and 528 deletions
|
@ -38,14 +38,17 @@ namespace NLGUI
|
|||
|
||||
void resetPointerPos ();
|
||||
void setPointerDown (bool pd);
|
||||
void setPointerMiddleDown (bool pd);
|
||||
void setPointerRightDown (bool pd);
|
||||
void setPointerDownString (const std::string &s);
|
||||
|
||||
void getPointerPos (sint32 &x, sint32 &y);
|
||||
void getPointerDispPos (sint32 &x, sint32 &y);
|
||||
|
||||
void getPointerOldPos (sint32 &x, sint32 &y);
|
||||
void getPointerDownPos (sint32 &x, sint32 &y);
|
||||
bool getPointerDown ();
|
||||
bool getPointerDown (sint32 &x, sint32 &y);
|
||||
bool getPointerMiddleDown (sint32 &x, sint32 &y);
|
||||
bool getPointerRightDown (sint32 &x, sint32 &y);
|
||||
std::string getPointerDownString ();
|
||||
bool getPointerDrag ();
|
||||
|
||||
|
@ -70,6 +73,12 @@ namespace NLGUI
|
|||
bool _PointerDown; // Is the pointer down ?
|
||||
sint32 _PointerDownX; // Pointer down position
|
||||
sint32 _PointerDownY;
|
||||
bool _PointerMiddleDown; // Is the middle pointer down ?
|
||||
sint32 _PointerMiddleDownX; // Pointer middle down position
|
||||
sint32 _PointerMiddleDownY;
|
||||
bool _PointerRightDown; // Is the right pointer down ?
|
||||
sint32 _PointerRightDownX; // Pointer right down position
|
||||
sint32 _PointerRightDownY;
|
||||
std::string _PointerDownString; // What is under the pointer at the down position
|
||||
bool _PointerDrag; // Is the pointer down and we have moved ?
|
||||
bool _PointerVisible; // Is the pointer visible or hidden ?
|
||||
|
|
|
@ -76,16 +76,39 @@ namespace NLGUI
|
|||
{
|
||||
_PointerDown = pd;
|
||||
|
||||
if (_PointerDown == true)
|
||||
if (_PointerDown)
|
||||
{
|
||||
_PointerDownX = _PointerX;
|
||||
_PointerDownY = _PointerY;
|
||||
}
|
||||
|
||||
if (_PointerDown == false)
|
||||
else
|
||||
_PointerDrag = false;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::setPointerMiddleDown (bool pd)
|
||||
{
|
||||
_PointerMiddleDown = pd;
|
||||
|
||||
if (_PointerMiddleDown)
|
||||
{
|
||||
_PointerMiddleDownX = _PointerX;
|
||||
_PointerMiddleDownY = _PointerY;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::setPointerRightDown (bool pd)
|
||||
{
|
||||
_PointerRightDown = pd;
|
||||
|
||||
if (_PointerRightDown)
|
||||
{
|
||||
_PointerRightDownX = _PointerX;
|
||||
_PointerRightDownY = _PointerY;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::setPointerDownString (const std::string &s)
|
||||
{
|
||||
|
@ -116,16 +139,30 @@ namespace NLGUI
|
|||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
void CViewPointerBase::getPointerDownPos (sint32 &x, sint32 &y)
|
||||
bool CViewPointerBase::getPointerDown (sint32 &x, sint32 &y)
|
||||
{
|
||||
x = _PointerDownX;
|
||||
y = _PointerDownY;
|
||||
|
||||
return _PointerDown;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
bool CViewPointerBase::getPointerDown ()
|
||||
bool CViewPointerBase::getPointerMiddleDown (sint32 &x, sint32 &y)
|
||||
{
|
||||
return _PointerDown;
|
||||
x = _PointerMiddleDownX;
|
||||
y = _PointerMiddleDownY;
|
||||
|
||||
return _PointerMiddleDown;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
bool CViewPointerBase::getPointerRightDown (sint32 &x, sint32 &y)
|
||||
{
|
||||
x = _PointerRightDownX;
|
||||
y = _PointerRightDownY;
|
||||
|
||||
return _PointerRightDown;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -55,6 +55,7 @@ CContextualCursor ContextCur;
|
|||
CLFECOMMON::TCLEntityId SlotUnderCursor;
|
||||
uint32 MissionId = 0;
|
||||
uint32 MissionRingId = 0;
|
||||
sint32 InstanceId = 0;
|
||||
UInstance selectedInstance;
|
||||
const UInstance noSelectedInstance;
|
||||
string selectedInstanceURL;
|
||||
|
@ -85,6 +86,7 @@ void contextExtractRM (bool rightClick, bool dblClick);
|
|||
void contextMission (bool rightClick, bool dblClick);
|
||||
void contextWebPage (bool rightClick, bool dblClick);
|
||||
void contextWebIG (bool rightClick, bool dblClick);
|
||||
void contextARKitect (bool rightClick, bool dblClick);
|
||||
void contextRingMission (bool rightClick, bool dblClick);
|
||||
void contextOutpost (bool rightClick, bool dblClick);
|
||||
void contextBuildTotem (bool rightClick, bool dblClick);
|
||||
|
@ -123,6 +125,7 @@ void initContextualCursor()
|
|||
ContextCur.add(true, "MISSION", string(""), 0.0f, checkUnderCursor, contextMission);
|
||||
ContextCur.add(true, "WEB PAGE", string(""), 0.0f, checkUnderCursor, contextWebPage);
|
||||
ContextCur.add(true, "WEBIG", string(""), 0.0f, checkUnderCursor, contextWebIG);
|
||||
ContextCur.add(false, "ARKITECT", string("curs_pick.tga"), 0.0f, checkUnderCursor, contextARKitect);
|
||||
ContextCur.add(true, "OUTPOST", string(""), 0.0f, checkUnderCursor, contextOutpost);
|
||||
ContextCur.add(true, "RING MISSION", string(""), 0.0f, checkUnderCursor, contextRingMission);
|
||||
ContextCur.add(true, "BUILD_TOTEM", string("uimGcmChooseBuilding"), 0.0f, checkUnderCursor, contextBuildTotem);
|
||||
|
@ -526,10 +529,10 @@ void checkUnderCursor()
|
|||
}
|
||||
else
|
||||
{
|
||||
CShapeInstanceReference instref = EntitiesMngr.getShapeInstanceUnderPos(cursX, cursY);
|
||||
sint32 instance_idx;
|
||||
CShapeInstanceReference instref = EntitiesMngr.getShapeInstanceUnderPos(cursX, cursY, instance_idx);
|
||||
|
||||
bool cleanSelectedInstance = EntitiesMngr.instancesRemoved();
|
||||
if (cleanSelectedInstance)
|
||||
if (EntitiesMngr.instancesRemoved())
|
||||
selectedInstance = noSelectedInstance;
|
||||
|
||||
UInstance instance = instref.Instance;
|
||||
|
@ -552,9 +555,16 @@ void checkUnderCursor()
|
|||
selectedInstance.getMaterial(j).setShininess( 1000.0f );
|
||||
}
|
||||
}
|
||||
if (!instref.ContextText.empty())
|
||||
{
|
||||
|
||||
selectedInstanceURL = instref.ContextURL;
|
||||
if (instref.ContextText.empty())
|
||||
{
|
||||
InstanceId = instance_idx;
|
||||
if(ContextCur.context("ARKITECT", 0.f, ucstring()))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ucstring contextText;
|
||||
contextText.fromUtf8(instref.ContextText);
|
||||
if(ContextCur.context("WEBIG", 0.f, contextText))
|
||||
|
@ -875,6 +885,8 @@ void contextWebPage(bool rightClick, bool dblClick)
|
|||
//-----------------------------------------------
|
||||
void contextWebIG(bool rightClick, bool dblClick)
|
||||
{
|
||||
if(rightClick)
|
||||
return;
|
||||
CInterfaceManager *IM = CInterfaceManager::getInstance();
|
||||
CInterfaceElement *pGC = CWidgetManager::getInstance()->getElementFromId("ui:interface:bot_chat_object");
|
||||
CInterface3DShape *el= dynamic_cast<CInterface3DShape*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:bot_chat_object:scene3d:object_1"));
|
||||
|
@ -896,6 +908,24 @@ void contextWebIG(bool rightClick, bool dblClick)
|
|||
}
|
||||
}// contextWebIG //
|
||||
|
||||
//-----------------------------------------------
|
||||
// contextARKitect :
|
||||
//-----------------------------------------------
|
||||
void contextARKitect(bool rightClick, bool dblClick)
|
||||
{
|
||||
string header;
|
||||
if (rightClick)
|
||||
{
|
||||
header = toString("rightClick = true\nSelectedInstanceId = %u\n", InstanceId);
|
||||
} else {
|
||||
header = toString("rightClick = false\nSelectedInstanceId = %u\n", InstanceId);
|
||||
}
|
||||
|
||||
CLuaManager::getInstance().executeLuaScript(string(header)+selectedInstanceURL, true);
|
||||
|
||||
}// contextARKitect //
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// contextOutpost
|
||||
//-----------------------------------------------
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "interface_v3/people_interraction.h"
|
||||
#include "interface_v3/bar_manager.h"
|
||||
#include "interface_v3/group_compas.h"
|
||||
#include "misc.h"
|
||||
// 3D
|
||||
#include "nel/3d/quad_tree.h"
|
||||
// Interface 3D
|
||||
|
@ -65,11 +66,13 @@
|
|||
#include "player_r2_cl.h"
|
||||
#include "r2/editor.h"
|
||||
|
||||
|
||||
///////////
|
||||
// USING //
|
||||
///////////
|
||||
using namespace NLMISC;
|
||||
using namespace NL3D;
|
||||
using namespace NLPACS;
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
@ -400,6 +403,7 @@ CEntityManager::CEntityManager()
|
|||
_NbPlayer = 0;
|
||||
_NbChar = 0;
|
||||
_LastEntityUnderPos= NULL;
|
||||
_LastRemovedInstance = -1;
|
||||
}// CEntityManager //
|
||||
|
||||
//-----------------------------------------------
|
||||
|
@ -522,21 +526,178 @@ void CEntityManager::reinit()
|
|||
initialize(_NbMaxEntity);
|
||||
}
|
||||
|
||||
CShapeInstanceReference CEntityManager::createInstance(const string& shape, const CVector &pos, const string& text, const string& url, bool bbox_active)
|
||||
CShapeInstanceReference CEntityManager::createInstance(const string& shape, const CVector &pos, const string& text, const string& url, bool haveCollisions, sint32& idx)
|
||||
{
|
||||
idx = -1;
|
||||
CShapeInstanceReference nullinstref(UInstance(), string(""), string(""));
|
||||
if (!Scene) return nullinstref;
|
||||
|
||||
UInstance instance = Scene->createInstance(shape);
|
||||
if (text.empty())
|
||||
bbox_active = false;
|
||||
CShapeInstanceReference instref = CShapeInstanceReference(instance, text, url, bbox_active);
|
||||
|
||||
if(!instance.empty())
|
||||
{
|
||||
_ShapeInstances.push_back(instref);
|
||||
UMovePrimitive *primitive = NULL;
|
||||
|
||||
if (PACS && haveCollisions)
|
||||
{
|
||||
primitive = PACS->addCollisionablePrimitive(dynamicWI, 1);
|
||||
primitive->setDontSnapToGround(false);
|
||||
}
|
||||
|
||||
// Put instance in last deleted position if found
|
||||
if (_LastRemovedInstance != -1)
|
||||
{
|
||||
idx = _LastRemovedInstance;
|
||||
nlinfo("OK adding to index : %d", idx);
|
||||
_ShapeInstances[idx].Instance = instance;
|
||||
_ShapeInstances[idx].Primitive = primitive;
|
||||
_ShapeInstances[idx].ContextText = text;
|
||||
_ShapeInstances[idx].ContextURL = url;
|
||||
_ShapeInstances[idx].BboxActive = !text.empty() || !url.empty();
|
||||
_ShapeInstances[idx].Deleted = false;
|
||||
|
||||
_LastRemovedInstance = _ShapeInstances[idx].LastDeleted;
|
||||
_ShapeInstances[idx].LastDeleted = -1;
|
||||
return _ShapeInstances[idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
nlinfo("OK url, text = %s, %s", url.c_str(), text.c_str());
|
||||
CShapeInstanceReference instref = CShapeInstanceReference(instance, text, url, !text.empty() || !url.empty());
|
||||
instref.Primitive = primitive;
|
||||
idx = _ShapeInstances.size();
|
||||
_ShapeInstances.push_back(instref);
|
||||
return instref;
|
||||
}
|
||||
}
|
||||
return nullinstref;
|
||||
}
|
||||
|
||||
bool CEntityManager::deleteInstance(uint32 idx)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size())
|
||||
return false;
|
||||
|
||||
if (!_ShapeInstances[idx].Instance.empty())
|
||||
Scene->deleteInstance(_ShapeInstances[idx].Instance);
|
||||
UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
|
||||
if (primitive)
|
||||
{
|
||||
PACS->removePrimitive(primitive);
|
||||
}
|
||||
_ShapeInstances[idx].Primitive = NULL;
|
||||
_ShapeInstances[idx].Deleted = true;
|
||||
_ShapeInstances[idx].LastDeleted = _LastRemovedInstance;
|
||||
_LastRemovedInstance = idx;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CVector CEntityManager::getInstancePos(uint32 idx)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return CVector(0,0,0);
|
||||
|
||||
UInstance instance = _ShapeInstances[idx].Instance;
|
||||
if(instance.empty())
|
||||
return CVector(0,0,0);
|
||||
|
||||
return instance.getPos();
|
||||
}
|
||||
|
||||
bool CEntityManager::setInstancePos(uint32 idx, CVector pos)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return false;
|
||||
|
||||
UInstance instance = _ShapeInstances[idx].Instance;
|
||||
if(instance.empty())
|
||||
return false;
|
||||
|
||||
UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
|
||||
if (primitive)
|
||||
{
|
||||
primitive->setGlobalPosition(_ShapeInstances[idx].PrimRelativePos + pos, dynamicWI);
|
||||
}
|
||||
|
||||
instance.setPos(pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
CVector CEntityManager::getInstanceRot(uint32 idx)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return CVector(0,0,0);
|
||||
|
||||
UInstance instance = _ShapeInstances[idx].Instance;
|
||||
if(instance.empty())
|
||||
return CVector(0,0,0);
|
||||
|
||||
return instance.getRotEuler();
|
||||
}
|
||||
|
||||
bool CEntityManager::setInstanceRot(uint32 idx, CVector rot)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return false;
|
||||
|
||||
UInstance instance = _ShapeInstances[idx].Instance;
|
||||
if(instance.empty())
|
||||
return false;
|
||||
|
||||
instance.setRotEuler(rot);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CVector CEntityManager::getInstanceScale(uint32 idx)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return CVector(0,0,0);
|
||||
|
||||
UInstance instance = _ShapeInstances[idx].Instance;
|
||||
if(instance.empty())
|
||||
return CVector(0,0,0);
|
||||
|
||||
return instance.getScale();
|
||||
}
|
||||
|
||||
CVector CEntityManager::getInstanceColPos(uint32 idx)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return CVector(0,0,0);
|
||||
|
||||
return _ShapeInstances[idx].PrimRelativePos;
|
||||
}
|
||||
|
||||
CVector CEntityManager::getInstanceColScale(uint32 idx)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return CVector(0,0,0);
|
||||
|
||||
UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
|
||||
if (!primitive)
|
||||
return CVector(0,0,0);
|
||||
|
||||
float width, depth;
|
||||
primitive->getSize(width, depth);
|
||||
float height = primitive->getHeight();
|
||||
|
||||
return CVector(width, depth, height);
|
||||
}
|
||||
|
||||
double CEntityManager::getInstanceColOrient(uint32 idx)
|
||||
{
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return 0.f;
|
||||
|
||||
UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
|
||||
if (!primitive)
|
||||
return 0.f;
|
||||
|
||||
return primitive->getOrientation(dynamicWI);
|
||||
}
|
||||
|
||||
|
||||
bool CEntityManager::removeInstances()
|
||||
{
|
||||
|
@ -546,9 +707,16 @@ bool CEntityManager::removeInstances()
|
|||
{
|
||||
if (!_ShapeInstances[i].Instance.empty())
|
||||
Scene->deleteInstance(_ShapeInstances[i].Instance);
|
||||
|
||||
UMovePrimitive *primitive = _ShapeInstances[i].Primitive;
|
||||
if (primitive)
|
||||
{
|
||||
PACS->removePrimitive(primitive);
|
||||
}
|
||||
}
|
||||
_ShapeInstances.clear();
|
||||
_InstancesRemoved = true;
|
||||
_LastRemovedInstance = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -559,10 +727,165 @@ bool CEntityManager::instancesRemoved()
|
|||
return instRemoved;
|
||||
}
|
||||
|
||||
CShapeInstanceReference CEntityManager::getShapeInstanceUnderPos(float x, float y)
|
||||
|
||||
|
||||
bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const vector<string> &values) {
|
||||
if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
|
||||
return false;
|
||||
|
||||
UInstance instance = _ShapeInstances[idx].Instance;
|
||||
if(instance.empty())
|
||||
return false;
|
||||
|
||||
UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
|
||||
|
||||
for (uint32 i=0; i < keys.size(); i++)
|
||||
{
|
||||
nlinfo("Setup [%s] with [%s]", keys[i].c_str(), values[i].c_str());
|
||||
|
||||
string param = keys[i];
|
||||
if (param == "transparency")
|
||||
{
|
||||
uint t;
|
||||
if( fromString( values[i], t ) ) {
|
||||
t = max(0, min((int)t, 255));
|
||||
makeInstanceTransparent(instance, t, t == 255);
|
||||
}
|
||||
}
|
||||
else if (param == "colorize")
|
||||
{
|
||||
CRGBA c;
|
||||
if( fromString( values[i], c ) )
|
||||
{
|
||||
for(uint j=0;j<instance.getNumMaterials();j++)
|
||||
{
|
||||
instance.getMaterial(j).setShininess( 1000.0f );
|
||||
instance.getMaterial(j).setEmissive(c);
|
||||
instance.getMaterial(j).setDiffuse(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (param == "texture")
|
||||
{
|
||||
if (!values[i].empty())
|
||||
{
|
||||
for(uint j=0;j<instance.getNumMaterials();j++)
|
||||
{
|
||||
sint numStages = instance.getMaterial(j).getLastTextureStage() + 1;
|
||||
for(sint l = 0; l < numStages; l++)
|
||||
{
|
||||
if (instance.getMaterial(j).isTextureFile((uint) l))
|
||||
instance.getMaterial(j).setTextureFileName(values[i], (uint) l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (param == "scale x" || param == "scale y" || param == "scale z")
|
||||
{
|
||||
float v;
|
||||
CVector scale = instance.getScale();
|
||||
|
||||
if( getRelativeFloatFromString( values[i], v ) ) {
|
||||
updateVector(param, scale, v, true);
|
||||
} else {
|
||||
updateVector(param, scale, v, false);
|
||||
}
|
||||
instance.setScale(scale);
|
||||
}
|
||||
|
||||
// Primitive colissions setups
|
||||
|
||||
if (!primitive) continue;
|
||||
|
||||
if (param == "col size x" || param == "col size y" || param == "col size z")
|
||||
{
|
||||
float width, depth;
|
||||
primitive->getSize(width, depth);
|
||||
float height = primitive->getHeight();
|
||||
|
||||
CVector size = CVector(width, depth, height);
|
||||
float v;
|
||||
if( getRelativeFloatFromString( values[i], v ) ) {
|
||||
updateVector(param, size, v, true);
|
||||
} else {
|
||||
updateVector(param, size, v, false);
|
||||
}
|
||||
primitive->setSize(size.x, size.y);
|
||||
primitive->setHeight(size.z);
|
||||
}
|
||||
else if (param == "col pos x" || param == "col pos y" || param == "col pos z")
|
||||
{
|
||||
CVector pos = instance.getPos();
|
||||
float v;
|
||||
|
||||
if( getRelativeFloatFromString( values[i], v ) ) {
|
||||
updateVector(param, _ShapeInstances[idx].PrimRelativePos, v, false);
|
||||
} else {
|
||||
if (param == "col pos x")
|
||||
_ShapeInstances[idx].PrimRelativePos.x = v - pos.x;
|
||||
if (param == "col pos y")
|
||||
_ShapeInstances[idx].PrimRelativePos.y = v - pos.y;
|
||||
if (param == "col pos z")
|
||||
_ShapeInstances[idx].PrimRelativePos.z = v - pos.z;
|
||||
}
|
||||
primitive->setGlobalPosition(pos + _ShapeInstances[idx].PrimRelativePos, dynamicWI);
|
||||
}
|
||||
else if (param == "col orientation")
|
||||
{
|
||||
double orient = primitive->getOrientation(dynamicWI);
|
||||
double v = 0.f;
|
||||
|
||||
if (values[i].empty())
|
||||
continue;
|
||||
|
||||
if (values[i][0] == '+')
|
||||
{
|
||||
fromString(values[i].substr(1), v);
|
||||
orient += v;
|
||||
}
|
||||
else
|
||||
{
|
||||
fromString(values[i], v);
|
||||
orient = v;
|
||||
}
|
||||
|
||||
primitive->setOrientation(orient, dynamicWI);
|
||||
}
|
||||
else if (param == "col mask player")
|
||||
{
|
||||
bool active;
|
||||
fromString(values[i], active);
|
||||
UMovePrimitive::TCollisionMask mask=primitive->getCollisionMask();
|
||||
if (active)
|
||||
primitive->setCollisionMask(mask|MaskColPlayer);
|
||||
else
|
||||
primitive->setCollisionMask(mask&~MaskColPlayer);
|
||||
}
|
||||
else if (param == "col mask door")
|
||||
{
|
||||
bool active;
|
||||
fromString(values[i], active);
|
||||
UMovePrimitive::TCollisionMask mask=primitive->getCollisionMask();
|
||||
if (active)
|
||||
primitive->setCollisionMask(mask|MaskColDoor);
|
||||
else
|
||||
primitive->setCollisionMask(mask&~MaskColDoor);
|
||||
}
|
||||
else if (param == "col obstacle")
|
||||
{
|
||||
bool active;
|
||||
fromString(values[i], active);
|
||||
primitive->setObstacle(active);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CShapeInstanceReference CEntityManager::getShapeInstanceUnderPos(float x, float y, sint32 &idx)
|
||||
{
|
||||
CShapeInstanceReference selectedInstance(UInstance(), string(""), string(""));
|
||||
_LastInstanceUnderPos= NULL;
|
||||
idx = -1;
|
||||
|
||||
// If not initialised, return
|
||||
if (_ShapeInstances.empty())
|
||||
|
@ -583,13 +906,14 @@ CShapeInstanceReference CEntityManager::getShapeInstanceUnderPos(float x, float
|
|||
float bestDist = 255;
|
||||
for(uint i=0; i<_ShapeInstances.size(); i++)
|
||||
{
|
||||
if (_ShapeInstances[i].BboxActive)
|
||||
if (!_ShapeInstances[i].Deleted && _ShapeInstances[i].BboxActive)
|
||||
{
|
||||
H_AUTO(RZ_Client_GEUP_box_intersect)
|
||||
|
||||
// if intersect the bbox
|
||||
NLMISC::CAABBox bbox;
|
||||
//= _ShapeInstances[i].SelectionBox;
|
||||
if(!_ShapeInstances[i].Instance.empty()) {
|
||||
_ShapeInstances[i].Instance.getShapeAABBox(bbox);
|
||||
if (bbox.getCenter() == CVector::Null)
|
||||
{
|
||||
|
@ -599,13 +923,15 @@ CShapeInstanceReference CEntityManager::getShapeInstanceUnderPos(float x, float
|
|||
{
|
||||
bbox.setMinMax((bbox.getMin()*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos(), (bbox.getMax()*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos());
|
||||
}
|
||||
if(bbox.intersect(pos, pos+dir*15.0f))
|
||||
if(bbox.intersect(pos, pos+dir*50.0f))
|
||||
{
|
||||
float dist = (bbox.getCenter()-pos).norm();
|
||||
if (dist < bestDist)
|
||||
{
|
||||
selectedInstance = _ShapeInstances[i];
|
||||
bestDist = dist;
|
||||
idx = (sint32)i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,12 +101,24 @@ public:
|
|||
ContextText = text;
|
||||
ContextURL = url;
|
||||
BboxActive = bbox_active;
|
||||
Deleted = false;
|
||||
LastDeleted = -1;
|
||||
Primitive = NULL;
|
||||
PrimSize = CVector(1.f, 1.f, 1.f);
|
||||
PrimHeight = 1.f;
|
||||
PrimRelativePos = CVector(0.f, 0.f, 0.f);
|
||||
}
|
||||
|
||||
NL3D::UInstance Instance;
|
||||
NLPACS::UMovePrimitive *Primitive;
|
||||
CVector PrimSize;
|
||||
float PrimHeight;
|
||||
CVector PrimRelativePos;
|
||||
string ContextText;
|
||||
string ContextURL;
|
||||
bool BboxActive;
|
||||
bool Deleted;
|
||||
sint32 LastDeleted;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -132,6 +144,7 @@ private:
|
|||
|
||||
/// Shapes Instances caches
|
||||
std::vector<CShapeInstanceReference> _ShapeInstances;
|
||||
sint32 _LastRemovedInstance;
|
||||
bool _InstancesRemoved;
|
||||
|
||||
typedef struct
|
||||
|
@ -213,10 +226,20 @@ public:
|
|||
void reinit();
|
||||
|
||||
|
||||
CShapeInstanceReference createInstance(const string& shape, const CVector &pos, const string &text, const string &url, bool active=true);
|
||||
CShapeInstanceReference createInstance(const string& shape, const CVector &pos, const string &text, const string &url, bool haveCollisions, sint32 &idx);
|
||||
bool deleteInstance(uint32 idx);
|
||||
bool removeInstances();
|
||||
CVector getInstancePos(uint32 idx);
|
||||
bool setInstancePos(uint32 idx, CVector pos);
|
||||
CVector getInstanceRot(uint32 idx);
|
||||
CVector getInstanceScale(uint32 idx);
|
||||
CVector getInstanceColPos(uint32 idx);
|
||||
CVector getInstanceColScale(uint32 idx);
|
||||
double getInstanceColOrient(uint32 idx);
|
||||
bool setInstanceRot(uint32 idx, CVector pos);
|
||||
bool instancesRemoved();
|
||||
CShapeInstanceReference getShapeInstanceUnderPos(float x, float y);
|
||||
bool setupInstance(uint32 idx, const std::vector<std::string> &keys, const std::vector<std::string> &values);
|
||||
CShapeInstanceReference getShapeInstanceUnderPos(float x, float y, sint32 &idx);
|
||||
|
||||
/**
|
||||
* Create an entity according to the slot and the form.
|
||||
|
|
|
@ -271,6 +271,15 @@ void HandleSystemCursorCapture(const CEvent &event)
|
|||
{
|
||||
CEventMouseDown &em = (CEventMouseDown &) event;
|
||||
DownMouseButtons |= em.Button & (leftButton | middleButton | rightButton);
|
||||
|
||||
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
|
||||
if (cursor)
|
||||
{
|
||||
cursor->setPointerDown(em.Button == leftButton);
|
||||
cursor->setPointerMiddleDown(em.Button == middleButton);
|
||||
cursor->setPointerRightDown(em.Button == rightButton);
|
||||
}
|
||||
|
||||
Driver->setCapture(true);
|
||||
}
|
||||
|
||||
|
@ -281,6 +290,13 @@ void HandleSystemCursorCapture(const CEvent &event)
|
|||
DownMouseButtons &= ~(em.Button & (leftButton | middleButton | rightButton));
|
||||
if (DownMouseButtons == 0)
|
||||
{
|
||||
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
|
||||
if (cursor)
|
||||
{
|
||||
cursor->setPointerDown(false);
|
||||
cursor->setPointerMiddleDown(false);
|
||||
cursor->setPointerRightDown(false);
|
||||
}
|
||||
Driver->setCapture(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2520,7 +2520,6 @@ class CAHAddShape : public IActionHandler
|
|||
}
|
||||
|
||||
bool have_shapes = true;
|
||||
bool first_shape = true;
|
||||
while(have_shapes)
|
||||
{
|
||||
string shape;
|
||||
|
@ -2537,8 +2536,8 @@ class CAHAddShape : public IActionHandler
|
|||
have_shapes = false;
|
||||
}
|
||||
|
||||
|
||||
CShapeInstanceReference instref = EntitiesMngr.createInstance(shape, CVector((float)x, (float)y, (float)z), c, u, first_shape);
|
||||
sint32 idx;
|
||||
CShapeInstanceReference instref = EntitiesMngr.createInstance(shape, CVector((float)x, (float)y, (float)z), c, u, false, idx);
|
||||
UInstance instance = instref.Instance;
|
||||
|
||||
if(!instance.empty())
|
||||
|
@ -2558,7 +2557,7 @@ class CAHAddShape : public IActionHandler
|
|||
instance.getMaterial(j).setShininess( 1000.0f );
|
||||
}
|
||||
|
||||
if (!texture_name.empty() && first_shape)
|
||||
if (!texture_name.empty())
|
||||
{
|
||||
sint numStages = instance.getMaterial(j).getLastTextureStage() + 1;
|
||||
for(sint l = 0; l < numStages; l++)
|
||||
|
@ -2571,8 +2570,6 @@ class CAHAddShape : public IActionHandler
|
|||
}
|
||||
}
|
||||
|
||||
first_shape = false;
|
||||
|
||||
if (transparency.empty())
|
||||
::makeInstanceTransparent(instance, 255, false);
|
||||
else
|
||||
|
@ -2605,6 +2602,9 @@ class CAHAddShape : public IActionHandler
|
|||
instance.setPos(CVector((float)x, (float)y, (float)z));
|
||||
instance.setRotQuat(dir.getRot());
|
||||
}
|
||||
|
||||
instance.setTransformMode(UTransformable::RotEuler);
|
||||
|
||||
// if the shape is a particle system, additionnal parameters are user params
|
||||
UParticleSystemInstance psi;
|
||||
psi.cast (instance);
|
||||
|
@ -2637,6 +2637,7 @@ class CAHAddShape : public IActionHandler
|
|||
};
|
||||
REGISTER_ACTION_HANDLER (CAHAddShape, "add_shape");
|
||||
|
||||
|
||||
class CAHRemoveShapes : public IActionHandler
|
||||
{
|
||||
virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -106,6 +106,16 @@ private:
|
|||
static int getCompleteIslands(CLuaState &ls);
|
||||
static int getIslandId(CLuaState &ls);//TEMP
|
||||
|
||||
static int addShape(CLuaState &ls);
|
||||
static int moveShape(CLuaState &ls);
|
||||
static int rotateShape(CLuaState &ls);
|
||||
static int getShapePos(CLuaState &ls);
|
||||
static int getShapeScale(CLuaState &ls);
|
||||
static int getShapeRot(CLuaState &ls);
|
||||
static int getShapeColPos(CLuaState &ls);
|
||||
static int getShapeColScale(CLuaState &ls);
|
||||
static int getShapeColOrient(CLuaState &ls);
|
||||
static int deleteShape(CLuaState &ls);
|
||||
|
||||
///////////////////////////// Standard Lua stuff ends here //////////////////////////////////////////////
|
||||
|
||||
|
@ -202,6 +212,14 @@ private:
|
|||
static sint getCharacterSheetRegionLevel(const std::string &sheet);
|
||||
static std::string getRegionByAlias(uint32 alias);
|
||||
static sint getGroundZ(uint32 x, sint32 y);
|
||||
static int getGroundAtMouse(CLuaState &ls);
|
||||
static int getMousePos(CLuaState &ls);
|
||||
static int getMouseDown(CLuaState &ls);
|
||||
static int getMouseMiddleDown(CLuaState &ls);
|
||||
static int getMouseRightDown(CLuaState &ls);
|
||||
static int getShapeIdAt(CLuaState &ls);
|
||||
static int setupShape(CLuaState &ls);
|
||||
static void setMouseCursor(const std::string texture);
|
||||
// open the window to do a tell to 'player', if 'msg' is not empty, then the message will be sent immediatly
|
||||
// else, current command of the chat window will be replaced with tell 'player'
|
||||
static void tell(const ucstring &player, const ucstring &msg);
|
||||
|
|
|
@ -2502,6 +2502,8 @@ bool mainLoop()
|
|||
|
||||
// R2ED enabled ?
|
||||
R2::getEditor().autoConfigInit(IsInRingSession);
|
||||
if (!IsInRingSession)
|
||||
R2::getEditor().registerLuaFunc();
|
||||
|
||||
CurrSeason = computeCurrSeason();
|
||||
|
||||
|
|
|
@ -1507,3 +1507,44 @@ bool getRyzomModes(std::vector<NL3D::UDriver::CMode> &videoModes, std::vector<st
|
|||
|
||||
return nFoundStringMode > -1;
|
||||
}
|
||||
|
||||
// Get float value from string. Return true if the value is relatif ( src = "+15.5" for example )
|
||||
bool getRelativeFloatFromString(const std::string src, float &dst)
|
||||
{
|
||||
dst = 0;
|
||||
if (src.empty())
|
||||
return false;
|
||||
|
||||
if (src[0] == '+')
|
||||
return fromString(src.substr(1), dst);
|
||||
else
|
||||
fromString(src, dst);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool updateVector(const string part, CVector &dst, float value, bool add /* = false */)
|
||||
{
|
||||
string p = part;
|
||||
if (part.size() > 1)
|
||||
p = part.substr(part.size()-1, 1);
|
||||
|
||||
if (add)
|
||||
{
|
||||
if (p == "x")
|
||||
dst.x += value;
|
||||
else if (p == "y")
|
||||
dst.y += value;
|
||||
else if (p == "z")
|
||||
dst.z += value;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p == "x")
|
||||
dst.x = value;
|
||||
else if (p == "y")
|
||||
dst.y = value;
|
||||
else if (p == "z")
|
||||
dst.z = value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,6 +168,9 @@ std::string getStringCategory(const ucstring &src, ucstring &dest, bool alwaysAd
|
|||
// Get the category from the string (src="&SYS&Who are you?" and dest="Who are you?" and return "SYS"), if no category, return ""
|
||||
std::string getStringCategoryIfAny(const ucstring &src, ucstring &dest);
|
||||
|
||||
bool getRelativeFloatFromString(const std::string src, float &dst);
|
||||
bool updateVector(const std::string part, NLMISC::CVector &dst, float value, bool add = false);
|
||||
|
||||
// Number of shortcut
|
||||
#define RYZOM_MAX_SHORTCUT 20
|
||||
|
||||
|
|
|
@ -893,6 +893,7 @@ public:
|
|||
static NLMISC::CCDBNodeLeaf *getPlotItemSheetDBLeaf(uint index);
|
||||
static bool getIsStartingScenario() { return _IsStartingScenario; }
|
||||
bool isClearingContent() const { return _ClearingContent; }
|
||||
void registerLuaFunc();
|
||||
|
||||
private:
|
||||
void initPlotItems();
|
||||
|
@ -925,7 +926,7 @@ private:
|
|||
void initObjectProjectionMetatable();
|
||||
void registerDisplayers();
|
||||
void registerTools();
|
||||
void registerLuaFunc();
|
||||
|
||||
// add a C++ method in the environement
|
||||
void registerEnvMethod(const char *name, TLuaWrappedFunction func);
|
||||
void registerEnvFunction(const char *name, TLuaWrappedFunction func);
|
||||
|
|
|
@ -165,6 +165,47 @@ void CTool::getMousePos(sint32 &x, sint32 &y)
|
|||
cursor->getPointerPos(x, y);
|
||||
}
|
||||
|
||||
// ***************************************************************
|
||||
void CTool::getMouseDown(bool &down, sint32 &x, sint32 &y)
|
||||
{
|
||||
down = false;
|
||||
//H_AUTO(R2_CTool_getMousePos)
|
||||
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
|
||||
if(cursor == NULL)
|
||||
{
|
||||
x = y = -1;
|
||||
return;
|
||||
}
|
||||
down = cursor->getPointerDown(x, y);
|
||||
}
|
||||
|
||||
// ***************************************************************
|
||||
void CTool::getMouseMiddleDown(bool &down, sint32 &x, sint32 &y)
|
||||
{
|
||||
//H_AUTO(R2_CTool_getMousePos)
|
||||
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
|
||||
if(cursor == NULL)
|
||||
{
|
||||
x = y = -1;
|
||||
return;
|
||||
}
|
||||
down = cursor->getPointerMiddleDown(x, y);
|
||||
}
|
||||
|
||||
// ***************************************************************
|
||||
void CTool::getMouseRightDown(bool &down, sint32 &x, sint32 &y)
|
||||
{
|
||||
//H_AUTO(R2_CTool_getMousePos)
|
||||
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
|
||||
if(cursor == NULL)
|
||||
{
|
||||
x = y = -1;
|
||||
return;
|
||||
}
|
||||
down = cursor->getPointerMiddleDown(x, y);
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************
|
||||
sint32 CTool::getMouseX()
|
||||
{
|
||||
|
@ -331,6 +372,7 @@ bool CTool::raytrace(const NLMISC::CVector &segmentStart, const NLMISC::CVector
|
|||
{
|
||||
if (Landscape)
|
||||
{
|
||||
nlinfo("landscape=%d,%d", segmentStart.x, segmentStart.y);
|
||||
// use a shortest distance for collision manager (for speed)
|
||||
CVector segmentEnd = segmentStart + 100.f * dir;
|
||||
float dist = Landscape->getRayCollision(segmentStart, segmentEnd);
|
||||
|
@ -444,15 +486,26 @@ bool CTool::computeNearestValidSurfaceFromHeightMap(float x, float y, NLMISC::CV
|
|||
const CScenarioEntryPoints::CCompleteIsland *islandDesc = getEditor().getIslandCollision().getCurrIslandDesc();
|
||||
if (!islandDesc) return false;
|
||||
|
||||
nlinfo("have island");
|
||||
|
||||
sint mapX = (sint) (x - islandDesc->XMin);
|
||||
sint mapY = (sint) (y - islandDesc->YMin);
|
||||
|
||||
nlinfo("mapX,mapY=%d,%d island=%d,%d-%d,%d", mapX, mapY, islandDesc->XMin, islandDesc->YMin, islandDesc->XMax, islandDesc->YMax);
|
||||
if (mapX < 0 || mapY < 0 || mapX >= (islandDesc->XMax - islandDesc->XMin) || mapY >= (islandDesc->YMax - islandDesc->YMin)) return false;
|
||||
sint hmZ = heightMap(mapX, mapY);
|
||||
nlinfo("HeightMap = %d", hmZ);
|
||||
if (hmZ >= 0x7ffe) return false; // not an accessible pos
|
||||
|
||||
nlinfo("accessible pos");
|
||||
|
||||
if (!isIslandValidPos(heightMap, *islandDesc, x + 0.5f, y) ||
|
||||
!isIslandValidPos(heightMap, *islandDesc, x - 0.5f, y) ||
|
||||
!isIslandValidPos(heightMap, *islandDesc, x, y + 0.5f) ||
|
||||
!isIslandValidPos(heightMap, *islandDesc, x, y - 0.5f)) return false;
|
||||
|
||||
nlinfo("valid pos");
|
||||
|
||||
float z = 1.f + 2.f * hmZ;
|
||||
// this is a possibly valid position
|
||||
// compute nearest surface from here, and see if not far from the intersection
|
||||
|
@ -471,6 +524,9 @@ bool CTool::computeNearestValidSurfaceFromHeightMap(float x, float y, NLMISC::CV
|
|||
inter1Found = inter1Found && normal1.z >= minAngleSin;
|
||||
inter2Found = inter2Found && normal2.z >= minAngleSin;
|
||||
if (!inter1Found && !inter2Found) return false;
|
||||
|
||||
nlinfo("inter foud");
|
||||
|
||||
if (inter1Found && inter2Found)
|
||||
{
|
||||
// because z in heightmap in usually a 'ceil' of real height, tends to favor surface below
|
||||
|
@ -487,6 +543,7 @@ bool CTool::computeNearestValidSurfaceFromHeightMap(float x, float y, NLMISC::CV
|
|||
{
|
||||
inter = inter2;
|
||||
}
|
||||
nlinfo("inter = %d,%d", inter.x, inter.y);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -516,6 +573,7 @@ CTool::TRayIntersectionType CTool::computeLandscapeRayIntersection(const CWorldV
|
|||
{
|
||||
CVector delta = bias * (cardinals[k].x * worldViewRay.Right + cardinals[k].y * worldViewRay.Up);
|
||||
found = raytrace(worldViewRay.Origin + delta, worldViewRay.Dir, inter);
|
||||
nlinfo("found");
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
|
@ -527,10 +585,12 @@ CTool::TRayIntersectionType CTool::computeLandscapeRayIntersection(const CWorldV
|
|||
const CArray2D<sint16> &heightMap = getEditor().getIslandCollision().getHeightMap();
|
||||
if (!heightMap.empty())
|
||||
{
|
||||
nlinfo("okidoi : %d, %d", inter.x, inter.y);
|
||||
// if heightmap is present, use it because it gives us more reliable information
|
||||
CVector surfPos;
|
||||
if (!computeNearestValidSurfaceFromHeightMap(inter.x, inter.y, surfPos)) return InvalidPacsPos;
|
||||
static volatile float threshold = 2.f;
|
||||
nlinfo("found");
|
||||
return (inter - surfPos).norm() < threshold ? ValidPacsPos : InvalidPacsPos;
|
||||
}
|
||||
|
||||
|
@ -541,6 +601,7 @@ CTool::TRayIntersectionType CTool::computeLandscapeRayIntersection(const CWorldV
|
|||
}
|
||||
else
|
||||
{
|
||||
nlinfo("GR");
|
||||
// see if pacs collisions are ok at that pos
|
||||
NLPACS::UGlobalPosition dummyPos;
|
||||
return getPacsType(inter, 2.f, dummyPos);
|
||||
|
@ -901,5 +962,4 @@ NLMISC::CRGBA CTool::getInvalidPosColor()
|
|||
|
||||
}
|
||||
|
||||
|
||||
} // R2
|
||||
|
|
|
@ -213,6 +213,12 @@ public:
|
|||
static CInterfaceManager &getUI();
|
||||
// Get mouse position
|
||||
static void getMousePos(sint32 &x, sint32 &y) ;
|
||||
// Get if mouse are clicked down and position of last down click
|
||||
static void getMouseDown(bool &down, sint32 &x, sint32 &y);
|
||||
// Get if mouse are middle clicked down and position of last down click
|
||||
static void getMouseMiddleDown(bool &down, sint32 &x, sint32 &y);
|
||||
// Get if mouse are right clicked down and position of last down click
|
||||
static void getMouseRightDown(bool &down, sint32 &x, sint32 &y);
|
||||
// Get mouse x position
|
||||
static sint32 getMouseX();
|
||||
// Get mouse y position
|
||||
|
|
Loading…
Reference in a new issue