Skip to content

Commit

Permalink
Merge pull request #5 from zetsumi/FEAT_InsertionMultiple
Browse files Browse the repository at this point in the history
insertion multiple
  • Loading branch information
zetsumi authored Jun 21, 2020
2 parents 990dab7 + 6d2a0da commit 38a6b5d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 11 deletions.
5 changes: 5 additions & 0 deletions WorldEditor/EditInfos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ int CMainFrame::GetInsertGapBetweenModel() const
return ui.spinInsertGap->value();
}

int CMainFrame::GetInsertNombreModelCercle() const
{
return ui.spinNombreModelCercle->value();
}

void CMainFrame::GetWaterEditInfos(int& mode, byte& waterHeight, byte& waterTexture, int& size)
{
mode = WTYPE_NONE;
Expand Down
1 change: 1 addition & 0 deletions WorldEditor/MainFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class CMainFrame : public QMainWindow
int GetInsertRectLength() const;
int GetInsertCercleRadius() const;
int GetInsertGapBetweenModel() const;
int GetInsertNombreModelCercle() const;
void GetWaterEditInfos(int& mode, byte& waterHeight, byte& waterTexture, int& size);
void GetTerrainHeightEditInfos(int& mode, bool& rounded, int& radius, int& hardness, bool& useFixedheight, float& fixedHeight, int& attribute);
int GetTerrainHeightEditMode() const;
Expand Down
37 changes: 27 additions & 10 deletions WorldEditor/MainFrame.ui
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@
<number>255</number>
</property>
<property name="value">
<number>255</number>
<number>250</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand Down Expand Up @@ -979,16 +979,16 @@
</widget>
</item>
<item>
<widget class="QRadioButton" name="insertSuffleReset">
<widget class="QRadioButton" name="insertionModeMultiple">
<property name="text">
<string>Multi Suffle</string>
<string>Multiple</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="insertionModeMultiple">
<widget class="QRadioButton" name="insertSuffleReset">
<property name="text">
<string>Multiple</string>
<string>Multi Suffle</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -1108,14 +1108,21 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<item row="1" column="0">
<widget class="QLabel" name="radiusInsertCercle">
<property name="text">
<string>radius: </string>
</property>
</widget>
</item>
<item row="0" column="2">
<item row="1" column="1">
<widget class="QLabel" name="label_26">
<property name="text">
<string>10</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSlider" name="sliderRadiusInsertCercle">
<property name="minimum">
<number>1</number>
Expand All @@ -1131,10 +1138,20 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_26">
<item row="0" column="0">
<widget class="QLabel" name="label_27">
<property name="text">
<string>10</string>
<string>Nombre de model:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QSpinBox" name="spinNombreModelCercle">
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
Expand Down
43 changes: 42 additions & 1 deletion WorldEditor/WorldEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,11 @@ void CWorldEditor::mousePressEvent(QMouseEvent* event)
}
else if (modeInsert == EInsertMode::INSERT_MULTIPLE || modeInsert == EInsertMode::INSERT_SUFFLE)
{
int gap = MainFrame->GetInsertGapBetweenModel();
if (modeGeo == EInsertionGeometry::INSERT_GEO_RECT)
{
int length = MainFrame->GetInsertRectLength();
int width = MainFrame->GetInsertRectWidth();
int gap = MainFrame->GetInsertGapBetweenModel();

int px = obj->m_pos.x - ((gap * length) / 2);
int pz = obj->m_pos.z - ((gap * width) / 2);
Expand Down Expand Up @@ -409,6 +409,47 @@ void CWorldEditor::mousePressEvent(QMouseEvent* event)
}
}
}
else if (modeGeo == EInsertionGeometry::INSERT_GEO_CERCLE)
{
int nombreModel = MainFrame->GetInsertNombreModelCercle();
int radius = MainFrame->GetInsertCercleRadius();
float angle = 360 / nombreModel; // nombre de models

for (unsigned int teta = angle; teta <= 360; teta += angle)
{
double x, z;
if (modeInsert == EInsertMode::INSERT_MULTIPLE)
{
x = qCos(qDegreesToRadians(static_cast<float>(teta)));
z = qSin(qDegreesToRadians(static_cast<float>(teta)));
}
else if (modeInsert == EInsertMode::INSERT_SUFFLE)
{
float tetaX = qrand() % 360;
float tetaZ = qrand() % 360;
x = qCos(qDegreesToRadians(static_cast<float>(tetaX)));
z = qSin(qDegreesToRadians(static_cast<float>(tetaZ)));
}

CObject* newObj = CObject::CreateObject(obj->m_type, obj);
D3DXVECTOR3 newPos = newObj->m_pos;
newPos.x += (radius * (x * 100)) / 100;
newPos.z += (radius * (z * 100)) / 100;
newPos.y = m_world->GetHeight(newPos.x, newPos.z);
newObj->SetPos(newPos);

if (obj->m_type == OT_MOVER || obj->m_type == OT_ITEM || obj->m_type == OT_CTRL)
{
CSpawnObject* dyna = ((CSpawnObject*)newObj);
dyna->m_rect = QRect(QPoint(
(int)(newObj->m_pos.z + 0.5f),
(int)(newObj->m_pos.x + 0.5f)) + dyna->m_rect.topLeft(),
dyna->m_rect.size()
);
}
newObjs.push_back(newObj);
}
}
}

// Add the new objects
Expand Down

0 comments on commit 38a6b5d

Please sign in to comment.