Init
This commit is contained in:
@@ -0,0 +1,144 @@
|
||||
/***********************************************************************************************************************
|
||||
*
|
||||
* Copyright (c) 2010 - 2022 by Tech Soft 3D, Inc.
|
||||
* The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret
|
||||
* as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event
|
||||
* of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized
|
||||
* employees of Tech Soft 3D, Inc. is granted only under a written non-disclosure agreement, expressly prescribing the
|
||||
* scope and manner of such use.
|
||||
*
|
||||
***********************************************************************************************************************/
|
||||
/**
|
||||
* Sample CreatePRCCubes
|
||||
* file CreateGraphics.cpp
|
||||
* This file is containing the function allowing to create graphics.
|
||||
*
|
||||
*
|
||||
***********************************************************************************************************************/
|
||||
#include "CreateGraphics.h"
|
||||
|
||||
//######################################################################################################################
|
||||
// Color creation
|
||||
A3DStatus createRGBColor(A3DUns32& uiIndexRgbColor, A3DDouble dRed, A3DDouble dGreen, A3DDouble dBlue)
|
||||
{
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
A3DGraphRgbColorData sData;
|
||||
A3D_INITIALIZE_DATA(A3DGraphRgbColorData, sData);
|
||||
sData.m_dRed = dRed;
|
||||
sData.m_dGreen = dGreen;
|
||||
sData.m_dBlue = dBlue;
|
||||
iRet = A3DGlobalInsertGraphRgbColor(&sData, &uiIndexRgbColor);
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
// Material creation: Creates a material, then inserts it into the global material table.
|
||||
A3DStatus createMaterial(A3DUns32& uiMaterialGenericIndex, A3DDouble dRed, A3DDouble dGreen, A3DDouble dBlue)
|
||||
{
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
A3DUns32 uiAmbient, uiDiffuse, uiEmissive, uiSpecular;
|
||||
|
||||
CHECK_RET(createRGBColor(uiAmbient, dRed, dGreen, dBlue));
|
||||
CHECK_RET(createRGBColor(uiDiffuse, dRed, dGreen, dBlue));
|
||||
CHECK_RET(createRGBColor(uiEmissive, dRed, dGreen, dBlue));
|
||||
CHECK_RET(createRGBColor(uiSpecular, dRed, dGreen, dBlue));
|
||||
|
||||
A3DGraphMaterialData sMaterialData;
|
||||
A3D_INITIALIZE_DATA(A3DGraphMaterialData, sMaterialData);
|
||||
sMaterialData.m_uiAmbient = uiAmbient;
|
||||
sMaterialData.m_uiDiffuse = uiDiffuse;
|
||||
sMaterialData.m_uiEmissive = uiEmissive;
|
||||
sMaterialData.m_uiSpecular = uiSpecular;
|
||||
sMaterialData.m_dAmbientAlpha = 1.0;
|
||||
sMaterialData.m_dDiffuseAlpha = 1.0;
|
||||
sMaterialData.m_dEmissiveAlpha = 1.0;
|
||||
sMaterialData.m_dSpecularAlpha = 1.0;
|
||||
sMaterialData.m_dShininess = 0.0;
|
||||
CHECK_RET(A3DGlobalInsertGraphMaterial(&sMaterialData, &uiMaterialGenericIndex));
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus setGraphicsColor(A3DRootBaseWithGraphicsData* pOutRootBaseWithGraphics, A3DDouble dRed, A3DDouble dGreen, A3DDouble dBlue, A3DDouble dAlpha)
|
||||
{
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
|
||||
//Create a style color
|
||||
A3DUns32 uiColorIndex = 0;
|
||||
CHECK_RET(createRGBColor(uiColorIndex, dRed, dGreen, dBlue));
|
||||
|
||||
A3DUns32 uiStyleIndex = 0;
|
||||
A3DGraphStyleData sStyleData;
|
||||
A3D_INITIALIZE_DATA(A3DGraphStyleData, sStyleData);
|
||||
sStyleData.m_bMaterial = false;
|
||||
sStyleData.m_bVPicture = false;
|
||||
sStyleData.m_dWidth = 0.1; // default
|
||||
sStyleData.m_bIsTransparencyDefined = true;
|
||||
sStyleData.m_ucTransparency = (A3DUns8) (dAlpha * 255.0);
|
||||
sStyleData.m_bSpecialCulling = false;
|
||||
sStyleData.m_bBackCulling = false;
|
||||
sStyleData.m_uiRgbColorIndex = uiColorIndex;
|
||||
CHECK_RET(A3DGlobalInsertGraphStyle(&sStyleData, &uiStyleIndex));
|
||||
|
||||
A3DGraphicsData sGraphicsData;
|
||||
A3D_INITIALIZE_DATA(A3DGraphicsData, sGraphicsData);
|
||||
|
||||
sGraphicsData.m_uiStyleIndex = uiStyleIndex;
|
||||
sGraphicsData.m_usBehaviour = kA3DGraphicsShow;
|
||||
sGraphicsData.m_usBehaviour |= kA3DGraphicsSonHeritColor;
|
||||
|
||||
CHECK_RET(A3DGraphicsCreate(&sGraphicsData, &(pOutRootBaseWithGraphics->m_pGraphics)));
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
A3DStatus setEntityColor(A3DEntity* inEntity, A3DDouble dRed, A3DDouble dGreen, A3DDouble dBlue, A3DDouble dAlpha)
|
||||
{
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
|
||||
A3DRootBaseWithGraphicsData sBaseWithGraphicsData;
|
||||
A3D_INITIALIZE_DATA(A3DRootBaseWithGraphicsData, sBaseWithGraphicsData);
|
||||
CHECK_RET(A3DRootBaseWithGraphicsGet(inEntity, &sBaseWithGraphicsData));
|
||||
|
||||
CHECK_RET(setGraphicsColor(&sBaseWithGraphicsData, dRed, dGreen, dBlue, dAlpha));
|
||||
|
||||
CHECK_RET(A3DRootBaseWithGraphicsSet(inEntity, &sBaseWithGraphicsData));
|
||||
CHECK_RET(A3DGraphicsDelete(sBaseWithGraphicsData.m_pGraphics));
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
A3DStatus setGraphicsHidden(A3DRootBaseWithGraphicsData* pOutRootBaseWithGraphics)
|
||||
{
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
|
||||
A3DGraphicsData sGraphicsData;
|
||||
A3D_INITIALIZE_DATA(A3DGraphicsData, sGraphicsData);
|
||||
CHECK_RET(A3DGraphicsGet(pOutRootBaseWithGraphics->m_pGraphics, &sGraphicsData));
|
||||
|
||||
sGraphicsData.m_usBehaviour &= ~kA3DGraphicsShow;
|
||||
sGraphicsData.m_usBehaviour |= kA3DGraphicsSonHeritShow;
|
||||
|
||||
CHECK_RET(A3DGraphicsCreate(&sGraphicsData, &(pOutRootBaseWithGraphics->m_pGraphics)));
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
A3DStatus setEntityHidden(A3DEntity* inEntity)
|
||||
{
|
||||
A3DStatus iRet = A3D_SUCCESS;
|
||||
|
||||
A3DRootBaseWithGraphicsData sBaseWithGraphicsData;
|
||||
A3D_INITIALIZE_DATA(A3DRootBaseWithGraphicsData, sBaseWithGraphicsData);
|
||||
CHECK_RET(A3DRootBaseWithGraphicsGet(inEntity, &sBaseWithGraphicsData));
|
||||
|
||||
CHECK_RET(setGraphicsHidden(&sBaseWithGraphicsData));
|
||||
|
||||
CHECK_RET(A3DRootBaseWithGraphicsSet(inEntity, &sBaseWithGraphicsData));
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user