Commit f7094701 authored by Byurrrer's avatar Byurrrer

combination

parent f337bb0e
......@@ -54,6 +54,8 @@ static const half2 g_vTexUVcenter = half2(0.5, 0.5);
static const half g_fUnit256 = 1.0/255.0;
static const half g_fUnit128 = 1.0/127.0;
//! слой непрозрачной геометрии
#define LAYER_OPAQUE 1
......@@ -63,20 +65,14 @@ static const half g_fUnit256 = 1.0/255.0;
@{*/
//! непрозрачные неосвещаемые
#define MTLTYPE_LAYER_OPAQUE_UNLIT 0.0
//! прозрачные неосвещаемые
#define MTLTYPE_LAYER_TRANSPARENT_UNLIT 0.666667
//! непрозрачные освещаемые
#define MTLTYPE_LAYER_OPAQUE_LIGHT 0.333333
#define MTLTYPE_UNLIT 0
//! прозрачные освещаемые
#define MTLTYPE_LAYER_TRANSPARENT_LIGHT 1.0
#define MTLTYPE_LIGHT 1
//! сравнение слоев
#define EQUAL_LAYER(layer1, layer2) (abs(layer1 - layer2) < 0.1)
//#define EQUAL_LAYER(layer1, layer2) (abs(layer1 - layer2) < 0.1)
//!@}
......
......@@ -21,8 +21,11 @@ sampler2D g_sParameters:register(s5);
half4 main(VSO_PP IN):COLOR0
{
half4 vNormal = tex2D(g_sNormals,IN.vTexUV);
half fSort = vNormal.w;
half fLayer = NormalDecodeLayer(vNormal.xyz);
half2 vLayerType = LayerDecode(vNormal.w);
//vLayerType.x *= LAYERS_COUNT_MAX;
//return half4(vLayerType.x, vLayerType.x, vLayerType.x, 1);
//half fSort = LayerDecodeType(vNormal.w);
//half fLayer = LayerDecodeLayer(vNormal.w);
//цвет приводим к sRGB
half4 vColor = tex2D(g_sColor,IN.vTexUV);
......@@ -43,11 +46,11 @@ half4 main(VSO_PP IN):COLOR0
half fAdaptedLum = tex2D(g_sAdaptedLum, g_vTexUVcenter);
// если материал освещаемый то надо вычислить его освещенность
if(!(EQUAL_LAYER(fSort, MTLTYPE_LAYER_OPAQUE_UNLIT) || EQUAL_LAYER(fSort, MTLTYPE_LAYER_TRANSPARENT_UNLIT)))
if(vLayerType.y == MTLTYPE_LIGHT)
vColor.xyz = (vAmbientColor * vAmbient.w * vColor.xyz) + (fSpecular * 0.5 * vAmbient.xyz);
// если слой материала относится к непрозрачной геометрии, тогда не нужна прозрачность
if(int(fLayer * LAYERS_COUNT_MAX) == LAYER_OPAQUE)
if(vLayerType.x == LAYER_OPAQUE)
vColor.a = 1.0;
//применение тонмапинга
......
......@@ -65,8 +65,9 @@ PSO_Lbuffer main(VSO_ResPos IN)
PSO_Lbuffer OUT;
half4 vNormals = tex2D(g_sNormals, IN.vTexUV);
half2 vLayerType = LayerDecode(vNormals.w);
[branch]if(EQUAL_LAYER(vNormals.w, MTLTYPE_LAYER_OPAQUE_UNLIT) || EQUAL_LAYER(vNormals.w, MTLTYPE_LAYER_TRANSPARENT_UNLIT))
[branch]if(vLayerType.y == MTLTYPE_UNLIT)
{
OUT.vAmdient.xyz = 0;
OUT.vAmdient.w = 0;
......@@ -93,7 +94,7 @@ PSO_Lbuffer main(VSO_ResPos IN)
half4 vParam = tex2D(g_sParameters, IN.vTexUV);
half3 vNormalPixel = normalize(/*vNormals.xyz * 2 - 1*/NormalDecode(vNormals.xyz).xyz);
half3 vNormalPixel = normalize(NormalDecode(vNormals.xyz).xyz);
half3 vLigth = normalize(g_vLightPos.xyz - vPosition.xyz);
half3 vVertexToEye = normalize(g_vViewPos.xyz - vPosition.xyz);
half3 vHalfVector = normalize(vVertexToEye + vLigth.xyz);
......@@ -112,7 +113,7 @@ PSO_Lbuffer main(VSO_ResPos IN)
//закрываем баг с отставанием теней
#ifdef IS_SHADOWED
fShadow = saturate(min(fShadow, fAbsDiffuse - 0.02));// + (vNormals.w == 1 ? 0.2 : 0));//+0.01;
fShadow = saturate(min(fShadow, fAbsDiffuse - 0.02));
fAbsDiffuse = fShadow;
#endif
......
......@@ -78,22 +78,22 @@ half GetTextureLod4Scene(half2 vTexUV)
//##########################################################################
//! кодирование xyz нормали в xy
half3 NormalEncode(half3 vNormal, half fLayer)
half3 NormalEncode(half3 vNormal)
{
vNormal.xy = vNormal.xy * 0.5 + 0.5;
/*vNormal.xy = vNormal.xy * 0.5 + 0.5;
[branch]if(vNormal.z >= 0.0)
vNormal.z = 0.5 + fLayer * g_fUnit256;
else
vNormal.z = fLayer * g_fUnit256;
vNormal.z = fLayer * g_fUnit256;*/
return vNormal;
return vNormal * 0.5 + 0.5;
}
//! декодирование нормали xy в xyz
half4 NormalDecode(half3 vNormal)
half3 NormalDecode(half3 vNormal)
{
half fLayer = 0;
/*half fLayer = 0;
if(vNormal.z >= 0.5)
fLayer = (floor((vNormal.z - 0.5) * 255.0 + 0.5)) * g_fUnit256;
......@@ -104,10 +104,44 @@ half4 NormalDecode(half3 vNormal)
vNormal.z = sign(vNormal.z * 2.0 - 1.0);
vNormal.z = sqrt(1 - pow(vNormal.x, 2) - pow(vNormal.y, 2)) * vNormal.z;
return half4(vNormal, fLayer);
return half4(vNormal, fLayer);*/
return vNormal * 2.0 - 1.0;
}
half LayerEncode(half fLayer, int iLighted)
{
half fResult = 0;
[branch]if(iLighted == MTLTYPE_LIGHT)
fResult = 0.5 + fLayer * g_fUnit256;
else
fResult = fLayer * g_fUnit256;
return fResult;
}
half2 LayerDecode(half fCode)
{
half fLayer = 0;
int iLighted = MTLTYPE_UNLIT;
if(fCode >= 0.5)
{
fLayer = /*fCode - 0.5;//*/(floor((fCode - 0.5) * 255.0 + 0.5)) * g_fUnit256;
iLighted = MTLTYPE_LIGHT;
}
else
{
fLayer = /*fCode;//*/floor(fCode * 255.0 + 0.5) * g_fUnit256;
iLighted = MTLTYPE_UNLIT;
}
return half2(int(fLayer * LAYERS_COUNT_MAX), iLighted);
}
#define NormalDecodeLayer(vNormal)(NormalDecode(vNormal).w)
#define LayerDecodeLayer(fCode)(LayerDecode(fCode).x)
#define LayerDecodeType(fCode)(LayerDecode(fCode).y)
//! преобразвоание цвета в нормаль (если конечно цвет содержит нормаль)
half3 Color2Normal(half3 vColor)
......@@ -130,9 +164,13 @@ PSO_Gbuffer CreateGbuffer(half4 vColor, half3 vNormal, half4 vParam, half4 vWVPp
OUT.vColor = vColor;
vNormal = normalize(vNormal);
/*vNormal = normalize(vNormal);
OUT.vNormal.xyz = NormalEncode(vNormal, vNearFarLayers.w);
OUT.vNormal.w = vNearFarLayers.z;
OUT.vNormal.w = vNearFarLayers.z;*/
vNormal = normalize(vNormal);
OUT.vNormal.xyz = NormalEncode(vNormal);
OUT.vNormal.w = LayerEncode(vNearFarLayers.w, vNearFarLayers.z);
OUT.vParam = vParam;
......
......@@ -66,15 +66,20 @@ PSO_UnionAlpha main(VSO_PP IN):COLOR0
aNormal[2] = tex2Dlod(g_sNormal, aTexUV[2]);
aNormal[3] = tex2Dlod(g_sNormal, aTexUV[3]);
aIdLayer[0] = int(NormalDecodeLayer(aNormal[0].xyz) * LAYERS_COUNT_MAX);
aIdLayer[1] = int(NormalDecodeLayer(aNormal[1].xyz) * LAYERS_COUNT_MAX);
aIdLayer[2] = int(NormalDecodeLayer(aNormal[2].xyz) * LAYERS_COUNT_MAX);
aIdLayer[3] = int(NormalDecodeLayer(aNormal[3].xyz) * LAYERS_COUNT_MAX);
half2 vLayerType0 = LayerDecode(aNormal[0].w);
half2 vLayerType1 = LayerDecode(aNormal[1].w);
half2 vLayerType2 = LayerDecode(aNormal[2].w);
half2 vLayerType3 = LayerDecode(aNormal[3].w);
aIsTransparency[0] = (aNormal[0].w >= MTLTYPE_LAYER_TRANSPARENT_UNLIT) ? 1 : 0;
aIsTransparency[1] = (aNormal[1].w >= MTLTYPE_LAYER_TRANSPARENT_UNLIT) ? 1 : 0;
aIsTransparency[2] = (aNormal[2].w >= MTLTYPE_LAYER_TRANSPARENT_UNLIT) ? 1 : 0;
aIsTransparency[3] = (aNormal[3].w >= MTLTYPE_LAYER_TRANSPARENT_UNLIT) ? 1 : 0;
aIdLayer[0] = vLayerType0.x;
aIdLayer[1] = vLayerType1.x;
aIdLayer[2] = vLayerType2.x;
aIdLayer[3] = vLayerType3.x;
aIsTransparency[0] = (aIdLayer[0] > LAYER_OPAQUE) ? 1 : 0;
aIsTransparency[1] = (aIdLayer[1] > LAYER_OPAQUE) ? 1 : 0;
aIsTransparency[2] = (aIdLayer[2] > LAYER_OPAQUE) ? 1 : 0;
aIsTransparency[3] = (aIdLayer[3] > LAYER_OPAQUE) ? 1 : 0;
//в случае если у нас нет ппрозрачных слоев то возвращаем текущий цвет
[branch] if((aIsTransparency[0] == 0 && aIsTransparency[1] == 0 && aIsTransparency[2] == 0 && aIsTransparency[3] == 0))
......
......@@ -926,7 +926,7 @@ struct ISXGUIListView : public virtual ISXGUIComponent
//! установить текст в ячейку
virtual void setItemText(char *szText, int iColumn, int iString) = 0;
virtual void setItemText(const char *szText, int iColumn, int iString) = 0;
//! получить текст из ячейки
virtual void getItemText(char *szText, int iColumn, int iString, int iSizeBuff) = 0;
......
......@@ -68,16 +68,27 @@ int CGUIListView::insertColumn(const char* text, int col, int width)
//delete[] szIStr;
if (col < m_aStrings.size() - 1)
{
m_aStrings[m_aStrings.size()] = m_aStrings[col];
Array<String> aNewStrings;
m_aStrings[col] = aNewStrings;
}
else
m_aStrings[m_aStrings.size()];
return iRes;
}
int CGUIListView::addColumn(const char* text, int width)
{
m_aStrings[m_aStrings.size()];
return insertColumn(text, getColumnsCount(), width);
}
void CGUIListView::deleteColumn(int col)
{
m_aStrings.erase(col);
ListView_DeleteColumn(m_hWindow, col);
}
......@@ -95,6 +106,7 @@ int CGUIListView::addString(LPARAM data)
lvi.iItem = getStringCount();
lvi.iSubItem = 0;
lvi.lParam = data;
m_aStringData.push_back(data);
return ListView_InsertItem(m_hWindow, &lvi);
}
......@@ -108,9 +120,10 @@ int CGUIListView::getStringCount()
return ListView_GetItemCount(m_hWindow);
}
void CGUIListView::setItemText(char* text, int col, int str)
void CGUIListView::setItemText(const char* text, int col, int str)
{
ListView_SetItemText(m_hWindow, str, col, text);
m_aStrings[col][str] = text;
ListView_SetItemText(m_hWindow, str, col, (char*)m_aStrings[col][str].c_str());
}
void CGUIListView::getItemText(char* text, int col, int str, int sizebuff)
......@@ -130,6 +143,7 @@ void CGUIListView::setItemData(int str, LPARAM data)
lvi.iSubItem = 0;
lvi.lParam = data;
BOOL res = ListView_SetItem(m_hWindow, &lvi);
m_aStringData[str] = data;
int qwerty = 0;
}
......@@ -140,7 +154,7 @@ LPARAM CGUIListView::getItemData(int str)
lvi.iSubItem = 0;
BOOL res = ListView_GetItem(m_hWindow, &lvi);
return lvi.lParam;
return m_aStringData[str];// lvi.lParam;
}
int CGUIListView::getSelString(int start)
......@@ -150,7 +164,13 @@ int CGUIListView::getSelString(int start)
void CGUIListView::setSelString(int str)
{
ListView_SetItemState(m_hWindow, str, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
if (str < 0)
{
for (int i = 0; i < this->getStringCount(); ++i)
ListView_SetItemState(m_hWindow, i, 0x0, LVIS_SELECTED | LVIS_FOCUSED);
}
else
ListView_SetItemState(m_hWindow, str, 0xF, LVIS_SELECTED | LVIS_FOCUSED);
this->setFocus();
}
......@@ -179,9 +199,10 @@ void CGUIListView::clearStrings()
{
int countstr = getStringCount();
for (int i = 0; i < countstr; ++i)
{
deleteString(0);
}
//BOOL bf = TabCtrl_DeleteAllItems(m_hWindow);
//int qwerty = 0;
for (int i = 0; i < m_aStrings.size(); ++i)
m_aStrings[i].clear();
m_aStringData.clear();
}
\ No newline at end of file
......@@ -26,7 +26,7 @@ public:
void deleteString(int str);
int getStringCount();
void setItemText(char* text, int col, int str);
void setItemText(const char* text, int col, int str);
void getItemText(char* text, int col, int str, int sizebuff);
void setItemData(int str, LPARAM data);
......@@ -40,6 +40,10 @@ public:
void clear();
void clearStrings();
private:
Array<Array<String>> m_aStrings;
Array<long> m_aStringData;
};
#endif
\ No newline at end of file
......@@ -916,7 +916,7 @@ void CModels::load(const char *szPath)
szStr[iStrLen] = 0;
pTransparency->m_sTex = szStr;
pTransparency->m_sTex += ".dds";
pTransparency->m_idTex = SGCore_MtlLoad(pTransparency->m_sTex.c_str(), MTL_TYPE_GEOM);
pTransparency->m_idTex = SGCore_MtlLoad((pTransparency->m_sTex + ".dds").c_str(), MTL_TYPE_GEOM);
fread(&(pTransparency->m_iCountVertex), sizeof(int32_t), 1, pFile);
fread(&(pTransparency->m_iCountIndex), sizeof(int32_t), 1, pFile);
......@@ -2810,16 +2810,15 @@ void CModels::render(DWORD timeDelta, GEOM_RENDER_TYPE type, ID idVisCalcObj)
for (int k = 0, kl = m_aTransparency.size(); k < kl; ++k)
{
if (m_aTransparency[k] && m_aVisInfo[idVisCalcObj]->m_aVisible4Transparency[k])
renderTransparency(timeDelta, k);
renderTransparency(timeDelta, m_aTransparency[k]);
}
}
else if (idVisCalcObj == SX_GEOM_DEFAULT_VISCALCOBJ)
{
for (int k = 0, kl = m_aSortTransparency.size(); k < kl; ++k)
{
if (m_aSortTransparency[k] && m_aSortTransparency[k]->m_isVisible4Observer)
renderTransparency(timeDelta, k);
renderTransparency(timeDelta, m_aSortTransparency[k]);
}
}
}
......@@ -2969,11 +2968,10 @@ void CModels::renderSegmets(DWORD timeDelta, ID idModel, ID idTex, ID idVisCalcO
}
}
void CModels::renderTransparency(DWORD timeDelta, ID idModelTransparency)
void CModels::renderTransparency(DWORD timeDelta, CTransparencyModel *pTransparencyModel)
{
STATIC_PRECOND_TRANSPARENCY_MODEL_ID(idModelTransparency, _VOID);
CTransparencyModel *pTransparencyModel = m_aTransparency[idModelTransparency];
if (!pTransparencyModel)
return;
g_pDXDevice->SetStreamSource(0, pTransparencyModel->m_pVertexBuffer, 0, sizeof(vertex_static_ex));
......
......@@ -581,7 +581,7 @@ protected:
void renderSegmets(DWORD timeDelta, ID idModel, ID idTex = -1, ID idVisCalcObj = SX_GEOM_DEFAULT_VISCALCOBJ);
//!
void renderTransparency(DWORD timeDelta, ID idModelTransparency);
void renderTransparency(DWORD timeDelta, CTransparencyModel *pTransparencyModel);
};
#endif
\ No newline at end of file
......@@ -2096,20 +2096,25 @@ void CMaterials::render(ID id, const float4x4 *pWorld)
if (pMtrl->m_oMainGraphics.m_isUnlit)
{
if (!(pMtrl->m_oLightParam.m_isTransparent))
fLayer = MTLTYPE_LAYER_OPAQUE_UNLIT;
fLayer = MTLTYPE_UNLIT;
else
fLayer = MTLTYPE_LAYER_TRANSPARENT_UNLIT;
fLayer = MTLTYPE_UNLIT;
}
else
{
if (!(pMtrl->m_oLightParam.m_isTransparent))
fLayer = MTLTYPE_LAYER_OPAQUE_LIGHT;
fLayer = MTLTYPE_LIGHT;
else
fLayer = MTLTYPE_LAYER_TRANSPARENT_LIGHT;
fLayer = MTLTYPE_LIGHT;
}
if (m_useCountSurface && pMtrl->m_oLightParam.m_isTransparent)
++(m_idCurrIdSurface);
{
if (m_idCurrIdSurface == 1)
m_idCurrIdSurface += 2;
else
++(m_idCurrIdSurface);
}
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, pMtrl->m_oMainGraphics.m_idShaderPS, "g_vNearFarLayers", &float4_t(*r_near, *r_far, fLayer, float(m_idCurrIdSurface)));
}
......
......@@ -237,7 +237,7 @@ enum MTLSORT
@{*/
//! непрозрачные неосвещаемые
#define MTLTYPE_LAYER_OPAQUE_UNLIT 0.0f
/*#define MTLTYPE_LAYER_OPAQUE_UNLIT 0.0f
//! прозрачные неосвещаемые
#define MTLTYPE_LAYER_TRANSPARENT_UNLIT 0.666667f
......@@ -246,7 +246,13 @@ enum MTLSORT
#define MTLTYPE_LAYER_OPAQUE_LIGHT 0.333333f
//! прозрачные освещаемые
#define MTLTYPE_LAYER_TRANSPARENT_LIGHT 1.0f
#define MTLTYPE_LAYER_TRANSPARENT_LIGHT 1.0f*/
//! прозрачные неосвещаемые
#define MTLTYPE_UNLIT 0
//! непрозрачные освещаемые
#define MTLTYPE_LIGHT 1
//!@}
......
......@@ -190,9 +190,6 @@ LRESULT SXLevelEditor_RenderWindow_MouseMove(HWND hWnd, UINT uiMsg, WPARAM wPara
//
level_editor::pAxesHelper->onMouseMove(((int)(short)LOWORD(lParam)), ((int)(short)HIWORD(lParam)));
if (level_editor::pAxesHelper->m_bIsDragging == false)
return 0;
//
if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GEOM && level_editor::idActiveElement >= 0)
level_editor::GeomTransformByHelper();
......@@ -357,7 +354,7 @@ LRESULT SXLevelEditor_ButtonGeometryOpen_Click(HWND hWnd, UINT uiMsg, WPARAM wPa
level_editor::FillListBoxGeom();
level_editor::GreenActivateAll(false);
level_editor::GameActivateAll(false);
level_editor::GameVisible4Properties(false);
level_editor::AIGridActivateAll(false);
level_editor::GeomActivateAll(false);
level_editor::GeomActivateCreate(true);
......@@ -371,7 +368,7 @@ LRESULT SXLevelEditor_ButtonGreenOpen_Click(HWND hWnd, UINT uiMsg, WPARAM wParam
level_editor::FillListBoxGreen();
level_editor::GeomActivateAll(false);
level_editor::GameActivateAll(false);
level_editor::GameVisible4Properties(false);
level_editor::GreenActivateAll(false);
level_editor::GreenActivateCreate(true);
......@@ -388,7 +385,7 @@ LRESULT SXLevelEditor_ButtonGameObjectOpen_Click(HWND hWnd, UINT uiMsg, WPARAM w
level_editor::GeomActivateAll(false);
level_editor::GreenActivateAll(false);
level_editor::AIGridActivateAll(false);
level_editor::GameActivateAll(true);
level_editor::GameVisible4Properties(true);
return 0;
}
......@@ -401,7 +398,7 @@ LRESULT SXLevelEditor_ButtonAIGridOpen_Click(HWND hWnd, UINT uiMsg, WPARAM wPara
level_editor::GeomActivateAll(false);
level_editor::GreenActivateAll(false);
level_editor::GameActivateAll(false);
level_editor::GameVisible4Properties(false);
level_editor::AIGridActivateAll(true);
......
This diff is collapsed.
......@@ -26,11 +26,10 @@ LRESULT SXLevelEditor_ButtonGameCreate_Click(HWND hwnd, UINT msg, WPARAM wParam,
//!
void SXLevelEditor_VeldStringGameConnections(
proptable_t *pPropTable, //!< pPropData ( )
propdata_t *pPropData, //!<
int iNumExclude, //!<
char *szStrOut, //!<
int iSize //!< szStrOut ( )
CBaseEntity *pEntity, //!<
propdata_t *pPropData, //!<
int iNumExclude, //!<
char *szStrOut //!<
);
//!
......
......@@ -233,6 +233,9 @@ void level_editor::GreenTransformByHelper()
if (!(level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GREEN && level_editor::idActiveElement >= 0 && level_editor::idActiveGreenSplit >= 0 && level_editor::idActiveGreenObject >= 0))
return;
if (level_editor::pAxesHelper->m_bIsDragging == false)
return;
// ,
if (level_editor::pComboBoxGreenSel->getSel() == 0)
{
......
......@@ -357,14 +357,28 @@ namespace level_editor
//**********************************************************************
void GameActivateAll(bool bf);
void GameSel(int sel);
/*!
\note
*/
void GameVisible4Properties(bool bf);
//!
void GameVisible4Connections(bool bf);
//! listbox
void GameSel(int iSelect);
//!
void GameTraceSetPos();
//!
void GameTraceCreate();
void GameRestoreListViewObject();
//!
CBaseEntity* GameGetObj4Connect(CBaseEntity* pEntity, const char *szName);
//! ( #GameGetObj4Connect)
void GameMessageNotFoundName(const char *szName);
//!
void GameUpdatePosRot();
......@@ -372,12 +386,10 @@ namespace level_editor
//!
void GameVisibleProperties(bool bf);
//!
void GameVisibleConnections(bool bf);
//!
void GameTransformByHelper();
//!
void GameDelete(int iSelected);
//**********************************************************************
......@@ -433,9 +445,9 @@ namespace level_editor
extern CAxesHelper *pAxesHelper;
extern float3 vHelperPos;
/*extern float3 vHelperPos;
extern float3 vHelperRot;
extern float3 vHelperScale;
extern float3 vHelperScale;*/
//**********************************************************************
......@@ -443,7 +455,7 @@ namespace level_editor
extern ID idActiveGreenSplit; //!< ( )
extern ID idActiveGreenObject; //!< ( )
extern ID idActiveElement; //!<
extern ID idActiveElement; //!< listbox
//**********************************************************************
......
......@@ -107,10 +107,10 @@ void level_editor::GeomSel(int iSelected)
float3 vMin, vMax;
SGeom_ModelGetMinMax(iSelected, &vMin, &vMax);
level_editor::vHelperPos = (vMax + vMin) * 0.5f;
level_editor::vHelperScale = *pScale;
/*level_editor::vHelperPos = (vMax + vMin) * 0.5f;
level_editor::vHelperScale = *pScale;*/
level_editor::pAxesHelper->setPosition(level_editor::vHelperPos);
level_editor::pAxesHelper->setPosition((vMax + vMin) * 0.5f);
level_editor::pAxesHelper->setRotation(*pRot);
level_editor::pAxesHelper->setScale(float3(1,1,1));
......@@ -246,13 +246,28 @@ void level_editor::GeomTransformByHelper()
if (!(level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GEOM && level_editor::idActiveElement >= 0))
return;
static float3 vStartScale;
static bool isStartScale = true;
if (level_editor::pAxesHelper->m_bIsDragging == false)
{
isStartScale = true;
return;
}
//
if (level_editor::pAxesHelper->getType() == CAxesHelper::HANDLER_TYPE_MOVE)
{
float3 vCurrPos = *SGeom_ModelGetPosition(level_editor::idActiveElement);
float3 vNewPos = vCurrPos + (level_editor::pAxesHelper->getPosition() - level_editor::vHelperPos);
float3 vMin, vMax;
SGeom_ModelGetMinMax(level_editor::idActiveElement, &vMin, &vMax);
float3 vCenterModel = (vMax + vMin) * 0.5f;
float3 vNewPos = vCurrPos + (level_editor::pAxesHelper->getPosition() - vCenterModel);
if (vCurrPos.x != vNewPos.x || vCurrPos.y != vNewPos.y || vCurrPos.z != vNewPos.z)
SGeom_ModelSetPosition(level_editor::idActiveElement, &vNewPos);
isStartScale = true;
}
//
else if (level_editor::pAxesHelper->getType() == CAxesHelper::HANDLER_TYPE_ROTATE)
......@@ -261,19 +276,34 @@ void level_editor::GeomTransformByHelper()
float3 vNewRot = level_editor::pAxesHelper->getRotation();
if (vCurrRot.x != vNewRot.x || vCurrRot.y != vNewRot.y || vCurrRot.z != vNewRot.z)
SGeom_ModelSetRotation(level_editor::idActiveElement, &vNewRot);
isStartScale = true;
}
//
else if (level_editor::pAxesHelper->getType() == CAxesHelper::HANDLER_TYPE_SCALE)
{
float3 vCurrcale = *SGeom_ModelGetScale(level_editor::idActiveElement);
float3 vNewScale = level_editor::pAxesHelper->getScale() - float3(1, 1, 1);
if (vCurrcale.x != vNewScale.x || vCurrcale.y != vNewScale.y || vCurrcale.z != vNewScale.z)
float3 vCurrScale = *SGeom_ModelGetScale(level_editor::idActiveElement);
float3 vNewScale;
if (isStartScale)
{
isStartScale = false;
vStartScale = vCurrScale;
vNewScale = vCurrScale;
}
else
{
vNewScale = vStartScale + (level_editor::pAxesHelper->getScale() - float3(1, 1, 1));
}
//float3 vNewScale = vCurrScale + (level_editor::pAxesHelper->getScale() - float3(1, 1, 1));
if (vCurrScale.x != vNewScale.x || vCurrScale.y != vNewScale.y || vCurrScale.z != vNewScale.z)
SGeom_ModelSetScale(level_editor::idActiveElement, &vNewScale);
}
float3 vMin, vMax;
/*float3 vMin, vMax;
SGeom_ModelGetMinMax(level_editor::idActiveElement, &vMin, &vMax);
level_editor::vHelperPos = (vMax + vMin) * 0.5f;
level_editor::vHelperPos = (vMax + vMin) * 0.5f;*/
}
void level_editor::GeomDelete(int iSelected)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment