示例#1
0
    DiTexturePtr DiShaderParameter::WriteTexture2D( const DiString& name, 
        const DiString& textureName )
    {
        DiString texfile = textureName;
#if DEMI_PLATFORM == DEMI_PLATFORM_IOS
        if(texfile.CheckFileExtension("dds"))
            texfile = texfile.ExtractBaseName() + ".pvr";
#endif
        
        //DI_LOG("Writing 2d texture name: %s, %s [%x]", name.c_str(), textureName.c_str(),this);
        
        DiAssetManager& assetMgr = DiAssetManager::GetInstance();
        DiTexturePtr textureAsset = assetMgr.GetAsset<DiTexture>(texfile);

        if (!textureAsset)
        {
            textureAsset = DiTexture::GetDefaultTexture();
            DI_WARNING("Cannot write the texture(%s), using default texture", texfile.c_str());
        }

        auto it = mShaderParams[VARIABLE_SAMPLER2D].find(name);
        if (it != mShaderParams[VARIABLE_SAMPLER2D].end())
        {
            DiTexture* tex = textureAsset.get();
            DiAny an(tex);
            it->second = an;
        }
        return textureAsset;
    }
示例#2
0
    void DiMotionSerializerImpl::ReadAttachParents( DiDataStreamPtr& stream,DiAttachSet* attachset,DiSkeleton* skeleton )
    {
        DiString strChildName = ReadString(stream);
        DiString strParentName = ReadString(stream);

        DiNode* son = attachset->GetAttachNode(strChildName);
        DiNode* parent = NULL;
        parent = attachset->GetAttachNode(strParentName);

        if(!parent && skeleton)
        {
            if(skeleton->HasBone(strParentName))
            {
                parent = skeleton->GetBone(strParentName);
            }
        }

        if(parent)
        {
            parent->AddChild(son);
        }
        else
        {
            DI_WARNING("No parent : %s",strParentName.c_str());
        }
    }
示例#3
0
    DiTexturePtr DiShaderParameter::WriteTextureCUBE( const DiString& name, 
        const DiString& textureName )
    {
        DiString texfile = textureName;
#if DEMI_PLATFORM == DEMI_PLATFORM_IOS
        if(texfile.CheckFileExtension("dds"))
            texfile = texfile.ExtractBaseName() + ".pvr";
#endif
        
        DiAssetManager& assetMgr = DiAssetManager::GetInstance();
        DiTexturePtr textureAsset = assetMgr.GetAsset<DiTexture>(texfile);

        if (!textureAsset)
        {
            DI_WARNING("Failed to load the textureCUBE resource : %s",texfile.c_str());
            return DiTexturePtr();
        }

        auto it = mShaderParams[VARIABLE_SAMPLERCUBE].find(name);
        if (it != mShaderParams[VARIABLE_SAMPLERCUBE].end())
        {
            DiTexture* tex = textureAsset.get();
            DiAny an(tex);
            it->second = an;
        }
        return textureAsset;
    }
示例#4
0
 DiString DiEditorManager::GenerateControllerName(const DiString& type)
 {
     static int id = 0;
     DiString ret;
     ret.Format("%s_%d", type.c_str(), id++);
     return ret;
 }
示例#5
0
    void DiInfo::Update(float delta)
    {
        //Change("FPS", 1.0f / delta);

        if (mInfo != nullptr)
        {
            //std::ostringstream stream;
            //for (MyGUI::VectorStringPairs::iterator iter = mParams.begin(); iter != mParams.end(); ++iter)
            //{
            //    if (iter != mParams.begin())
            //        stream << "\n";
            //    stream << iter->first << " :\t" << iter->second;
            //}

            //mInfo->setCaption(stream.str());
            DiString info = DiProfiler::GetInstancePtr()->GetData();
            DiString fps;
            fps.Format("\nFPS: %f", 1.0f / delta);
            info += fps;
            mInfo->setCaption(info.c_str());

            DI_PROFILE_BEGIN_INTERVAL

            MyGUI::ISubWidgetText* text = mInfo->getSubWidgetText();
            if (text != nullptr)
            {
                const MyGUI::IntSize& size = text->getTextSize() + mInfo->getSize() - text->getSize();
                const MyGUI::IntSize& size_view = MyGUI::RenderManager::getInstance().getViewSize();
                mInfo->setCoord(10, 10, size.width, size.height);
            }
        }
    }
示例#6
0
    void DiLight::CreateShadowTextures(DiSceneManager* sm)
    {
        mShadowTextures.resize(mShadowConfig.size());
        mShadowCameras.resize(mShadowConfig.size());
        
        for (size_t i = 0; i < mShadowConfig.size(); ++i)
        {
            static int st = 0;
            DiString camname;
            camname.Format("_shad_cam_%d", st);
            DiString name;
            name.Format("_shad_tex_%d", st++);
            
            mShadowTextures[i] = DiAssetManager::GetInstance().CreateOrReplaceAsset<DiTexture>(name);
            mShadowTextures[i]->SetDimensions(mShadowConfig[i].width, mShadowConfig[i].height);
            mShadowTextures[i]->SetFormat(mShadowConfig[i].format);
            mShadowTextures[i]->SetUsage(TU_RENDER_TARGET);
            mShadowTextures[i]->SetAddressing(AM_CLAMP);
            mShadowTextures[i]->CreateTexture();
            auto rt = mShadowTextures[i]->GetRenderTarget();
            
            rt->SetFlippingUV(true);
            rt->SetClearColor(DiColor::White);
            
            DiCamera* cam = sm->CreateCamera(camname);
			cam->SetAspectRatio((float)mShadowConfig[i].width / (float)mShadowConfig[i].height);
            mShadowCameras[i] = cam;
        }
    }
示例#7
0
    void CurveEditor::NotifyPointMove(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
    {
        if (_id != MyGUI::MouseButton::Left)
            return;

        if (!CheckPosition(_left, _top))
            return;

        auto pos = MyGUI::IntPoint(_left, _top) - _sender->getCroppedParent()->getAbsolutePosition();
        auto value = GetValue(pos.left, pos.top);

        pos.left -= 7;
        pos.top -= 7;
        _sender->setPosition(pos);

        DiString str;
        str.Format("%.3g", value.x);
        mEditTimeEditBox->setCaption(str.c_str());
        str.Format("%.3g", value.y);
        mEditValueEditBox->setCaption(str.c_str());

        std::sort(mButtons.begin(), mButtons.end(),
            [](MyGUI::Button* a, MyGUI::Button* b) {
            return a->getPosition().left < b->getPosition().left;
        });

        RefreshCurve();
    }
    void SetGameLocWindow::notifyOk(MyGUI::Widget* _sender)
	{
        auto gameloc = mTextLocation->getCaption();
        DiString exeFile = gameloc.asUTF8_c_str();
        exeFile += "/";
#if DEMI_PLATFORM == DEMI_PLATFORM_WIN32
        exeFile += "hon.exe";
#else
        exeFile += "hon";
#endif
        if (DiPathLib::FileExisted(exeFile))
        {
            DiString path = gameloc.asUTF8_c_str();
            DiString respack = path + "/game/resources0.s2z";
            DiString texpack = path + "/game/textures.s2z";
            HonViewerApp::GetViewerApp()->SetResourceLocation(respack, texpack);

            SettingsManager::getInstance().getSector("Settings")->setPropertyValue("ResourcePack", respack.c_str());
            SettingsManager::getInstance().getSector("Settings")->setPropertyValue("TexturePack", texpack.c_str());
        }
        else
        {
            MyGUI::Message::createMessageBox("Message", "Invalid HON game folder",
                "Cannot locate executable file of HON",
                MyGUI::MessageBoxStyle::Ok | MyGUI::MessageBoxStyle::IconError);
        }

        eventEndDialog(this, true);
	}
示例#9
0
    DiDataStreamPtr DiK2Configs::GetDataStream(const DiString& relPath, K2ResourceType type)
    {
#ifdef _K2_RECORD_USED_RESOURCE
        sUsedResources.insert(relPath);
#endif

        DiString full = GetK2MediaPath(relPath, type == K2_RES_TEXTURE);

        if (RESOURCE_PACK)
        {
            DiDataStreamPtr data = RESOURCE_PACK->Open(full);
            return data;
        }
        else
        {
            // now we just simply using OS's file system
            FILE* fp = fopen(full.c_str(), type == K2_RES_XML ? "r" : "rb");
            if (!fp)
            {
                DI_WARNING("Cannot open the file: %s", full.c_str());
                return nullptr;
            }
            DiDataStreamPtr data(DI_NEW DiFileHandleDataStream(fp));
            return data;
        }
    }
示例#10
0
 DiString DiEditorManager::GenerateElementName()
 {
     static int id = 0;
     DiString ret;
     ret.Format("Element_%d", id++);
     return ret;
 }
示例#11
0
    void DiConsoleLogger::OutputLog(const char* szMessage, const char* levelInfo)
    {
        static DiLogInfo logInfo;
        if (::IsWindow(mWnd))
        {
            DiString msg = szMessage;
            DiString lv = levelInfo;

            logInfo.type = LOG_LEVEL_LOG;
            if (lv == "error")
                logInfo.type = LOG_LEVEL_ERROR;
            else if (lv == "info")
                logInfo.type = LOG_LEVEL_LOG;
            else if (lv == "debug")
                logInfo.type = LOG_LEVEL_DEBUG;
            else if (lv == "warning")
                logInfo.type = LOG_LEVEL_WARNING;
            else
                logInfo.type = 0xFFFF;

            if (Driver)
                logInfo.hwnd = mMainHwnd;

            ZeroMemory(logInfo.message, sizeof(logInfo.message));
            strcpy_s(logInfo.message, 4096, msg.c_str());
            COPYDATASTRUCT cpd;
            cpd.dwData = 0;
            cpd.cbData = sizeof(logInfo);
            cpd.lpData = &logInfo;
            ::SendMessage(mWnd, WM_COPYDATA, 0, (LPARAM)(LPVOID)&cpd);
        }
    }
示例#12
0
 DiString DiEditorManager::GenerateSystemName()
 {
     static int id = 0;
     DiString ret;
     ret.Format("ParticleSystem_%d", id++);
     return ret;
 }
示例#13
0
 DiString DiEditorManager::GenerateRefModelName()
 {
     static int id = 0;
     DiString ret;
     ret.Format("Model_%d", id++);
     return ret;
 }
示例#14
0
 void DiEditorManager::Command_ToolNew(const MyGUI::UString& _commandName, bool& _result)
 {
     DiString msg;
     
     if (!mFxFileName.empty())
         msg = "Do you want to keep the new effects?";
     else
         msg = "Do you want to save the effects?";
     
     auto msgBox = MyGUI::Message::createMessageBox("Message", "New",
                                                 msg.c_str(),
                                                 MyGUI::MessageBoxStyle::Yes|MyGUI::MessageBoxStyle::No|
                                                 MyGUI::MessageBoxStyle::Cancel|MyGUI::MessageBoxStyle::IconDefault);
     
     msgBox->eventMessageBoxResultLambda = [this](MyGUI::Message*, MyGUI::MessageBoxStyle style){
         if(style == MyGUI::MessageBoxStyle::Yes)
         {
             SaveAll();
             NewFx();
         }
         else if(style == MyGUI::MessageBoxStyle::No)
         {
             NewFx();
         }
     };
     _result = true;
 }
示例#15
0
    void DiMeshSerializerImpl::ReadSubMesh( DiDataStreamPtr& stream, DiMesh* pMesh )
    {
        DI_SERIAL_LOG("Reading submesh..");

        DiSubMesh* sm = pMesh->CreateSubMesh();

        unsigned short streamID = 0;

        DiString material = ReadString(stream);
        sm->SetMaterialName(material);

        DI_SERIAL_LOG("Liking material: %s", material.c_str());

        unsigned int indexCount = 0;
        ReadInts(stream, &indexCount, 1);

        DI_SERIAL_LOG("Indeices count: %d", indexCount);

        bool idx32bit;
        ReadBools(stream, &idx32bit, 1);

        DI_SERIAL_LOG("Index size: %d", idx32bit?32:16);

        uint16 primitive;
        ReadShorts(stream,&primitive,1);
        sm->SetPrimitiveType((DiPrimitiveType)primitive);

        DI_SERIAL_LOG("Primitive type: %d", primitive);

        if (indexCount > 0)
        {
            void* indexdata = sm->CreateIndexData(indexCount,idx32bit?TRUE:FALSE);
            int size = indexCount * (sm->GetIndexSize() / 8);
            stream->Read(indexdata, size);
            DI_SERIAL_LOG("%d bytes readed", size);
        }

        streamID = ReadChunk(stream);
        if (streamID != DI_GEOMETRY)
        {
            DI_ERROR("Bad stream ID");
            return;
        }

        ReadGeometry(stream, sm);

        if (!stream->Eof())
        {
            streamID = ReadChunk(stream);
            if (streamID == DI_MESH_WEIGHTS)
            {
                ReadSubMeshBoneWeights(stream,sm);
            }
            else
            {
                if (!stream->Eof())
                    stream->Skip(-MSTREAM_OVERHEAD_SIZE);
            }
        }
    }
示例#16
0
void Demi::DiLogManager::Error( const char* szFileName, unsigned int uiLine, const char* pacFormat, ... )
{
    const int MAX_CHAR = 10 * 1024;
    static char szLog[MAX_CHAR + 1];
    szLog[MAX_CHAR] = '\0';

    va_list args;    
    va_start(args, pacFormat);    
    SAFE_VSPRINTF(szLog, MAX_CHAR, pacFormat, args);
    va_end(args);

    OutputUnformat(LOG_LEVEL_ERROR,szFileName,uiLine,szLog);

    DiString fileName = szFileName;
    DiString lines;
    lines.SetInt(uiLine);
    DiString outstr("A fatal error occured:\n\nFilename:");
    outstr += fileName;
    outstr += "\n\nLine:";
    outstr += lines;
    outstr += "\n\nDescription:";
    outstr += szLog;
    DiPlatformFunc::ErrorDlg(outstr.c_str());

#if DEMI_PLATFORM == DEMI_PLATFORM_WIN32
    __asm int 3
#endif
}
示例#17
0
int main(int numargs, char** args)
{
	if (numargs < 2)
        return -1;

	parseArgs(numargs, args);

    auto root = OGRE_NEW Ogre::Root("", "", "ogre.log");
    root->loadPlugin("RenderSystem_Direct3D9_d");
    root->setRenderSystem(root->getRenderSystemByName("Direct3D9 Rendering Subsystem"));
    root->getRenderSystem()->setConfigOption("Full Screen","No");
    root->initialise(true);
	converterMgr = new ConverterMgr();

	CovOptions option;
	option.source = srcName.c_str();
	option.dest   = destName.c_str();

	Ogre::ResourceGroupManager::getSingleton().addResourceLocation(srcName.ExtractDirName().c_str(),"FileSystem");
	Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);

	if (isAnimation)
	{
		converterMgr->SkeletonToMotion(option);
	}
	else
	{
		converterMgr->MeshToModel(option);
	}

	delete converterMgr;
    delete root;
    return 0;
}
示例#18
0
    void DiFoliageLayer::CreateMaterial()
    {
        DiString uniqueStr;
        static int uq = 0;
        uniqueStr.Format("_fol_mat_%d",uq++);

        DiCompileDesc desc;
        desc.entryName = "vs_main";
        desc.profile = DiShaderProgram::GetDefaultVsProfile();

        desc.marcos.push_back(DiPair<DiString,DiString>("_GRASS_FADE_ALPHA"        ,"0"));
        desc.marcos.push_back(DiPair<DiString,DiString>("_GRASS_FADE_GROW"        ,"1"));
        desc.marcos.push_back(DiPair<DiString,DiString>("_GRASS_FADE_ALPHA_GROW","2"));

        desc.marcos.push_back(DiPair<DiString,DiString>("_GRASS_LIGHTING"        ,"0"));
        desc.marcos.push_back(DiPair<DiString,DiString>("_GRASS_ANIMATE"        ,"0"));
        desc.marcos.push_back(DiPair<DiString,DiString>("_GRASS_BLEND"            ,"0"));
        desc.marcos.push_back(DiPair<DiString,DiString>("_GRASS_FADE_TECH"        ,"0"));
        desc.marcos.push_back(DiPair<DiString,DiString>("_GRASS_RENDER_TECH"    ,"0"));

        mMaterial = DiAssetManager::GetInstance().CreateManualAsset<DiMaterial>(uniqueStr);

        mMaterial->SetBlendMode(BLEND_ALPHA);
        mMaterial->SetCullMode(CULL_NONE);

        mMaterial->LoadVertexShader("grass.vsh");
        mMaterial->LoadPixelShader("unlighting_diffuse_color.psh");

        mNeedUpdateMaterial = true;
    }
示例#19
0
    void CurveEditor::RefreshNumbers()
    {
        DeleteNumbersY();

        auto size = mCurveCanvasWidget->getSize();
        auto width = size.width;
        auto height = size.height;

        auto inteveralX = width / (gridNumX + 2);
        auto inteveralY = height / (gridNumY + 2);

        float step = (mValueRange.y - mValueRange.x) / gridNumY;
        
        for (auto i = 0; i <= gridNumY; i += 2)
        {
            MyGUI::TextBox* text = mCurveCanvasWidget->createWidget<MyGUI::TextBox>("TextBox",
                MyGUI::IntCoord(3, i * inteveralY + 5, 30, 15), MyGUI::Align::Default);
            text->setFontHeight(14);
            text->setTextShadow(true);
            text->setTextShadowColour(MyGUI::Colour::Black);
            DiString s;
            s.Format("%.1f", step*(gridNumY - i) + mValueRange.x);
            text->setCaption(s.c_str());
            mNumbersY.push_back(text);
        }
    }
示例#20
0
void ModelConverter::ExportMesh( const Mesh* pMesh, const String& filename )
{
	LogManager::getSingleton().logMessage("XMLMeshSerializer writing mesh data to " + filename + "...");
	
	mMesh = const_cast<Mesh*>(pMesh);

	LogManager::getSingleton().logMessage("Populating DOM...");

	DiMeshPtr mesh = WriteMesh(pMesh);

	LogManager::getSingleton().logMessage("DOM populated, writing model file..");

	if (mesh)
	{
		// save to file
		DiMeshSerializer ms;
		ms.ExportMesh(mesh,filename);

		// write material files
		DiMesh::SubMeshIterator it = mesh->GetSubMeshs();
		while (it.HasMoreElements())
		{
			DiSubMesh* subMesh = it.GetNext();
			unsigned int maxw = subMesh->GetMaxWeights();
			DiString matname = subMesh->GetMaterialName();

			DiString matfile = filename.c_str();
			matfile = matfile.ExtractDirName();
			matfile += matname;

			WriteSimpleMaterial(maxw,matfile);
		}
	}
}
示例#21
0
    void* mac_loadDylib(const char* name)
    {
        DiString fullPath = name;
        if (name[0] != '/')
            fullPath = macPluginPath() + "/" + fullPath;

        return dlopen(fullPath.c_str(), RTLD_LAZY | RTLD_GLOBAL);
    }
示例#22
0
    void CurveEditor::InitGrid()
    {
        auto size = mCurveCanvasWidget->getSize();
        auto width = size.width;
        auto height= size.height;

        auto inteveralX = width / (gridNumX + 2);
        auto inteveralY = height / (gridNumY + 2);

        MyGUI::Colour dark(0.1f, 0.1f, 0.1f);
        MyGUI::Colour light(0.2f, 0.2f, 0.2f);

        std::vector<MyGUI::Colour> colors;
        std::vector<MyGUI::FloatPoint> lines;
        for (auto i = 1; i <= gridNumX+1; ++i)
        {
            lines.push_back(MyGUI::FloatPoint(i*inteveralX, 3));
            lines.push_back(MyGUI::FloatPoint(i*inteveralX, height-4));

            colors.push_back(i == 1 ? dark : light);
            colors.push_back(i == 1 ? dark : light);
        }

        lines.push_back(MyGUI::FloatPoint(inteveralX - 1, 3));
        lines.push_back(MyGUI::FloatPoint(inteveralX - 1, height - 4));
        colors.push_back(dark);
        colors.push_back(dark);

        for (auto i = 1; i <= gridNumY + 1; ++i)
        {
            lines.push_back(MyGUI::FloatPoint(3, i*inteveralY));
            lines.push_back(MyGUI::FloatPoint(width - 4, i*inteveralY));

            colors.push_back(i == gridNumY + 1 ? dark : light);
            colors.push_back(i == gridNumY + 1 ? dark : light);
        }

        lines.push_back(MyGUI::FloatPoint(3, (gridNumY + 1)*inteveralY + 1));
        lines.push_back(MyGUI::FloatPoint(width - 4, (gridNumY + 1)*inteveralY + 1));
        colors.push_back(dark);
        colors.push_back(dark);

        mCurveLines->setPoints(lines, true);
        mCurveLines->setColors(colors);

        for (auto i = 1; i <= gridNumX + 1; i += 2)
        {
            MyGUI::TextBox* text = mCurveCanvasWidget->createWidget<MyGUI::TextBox>("TextBox",
                MyGUI::IntCoord(i * inteveralX + 2, height - 19, 30, 15), MyGUI::Align::Default);
            text->setFontHeight(14);
            text->setTextShadow(true);
            text->setTextShadowColour(MyGUI::Colour::Black);
            DiString s;
            s.Format("%.1f", (i - 1) / (float)gridNumX);
            text->setCaption(s.c_str());
            mNumbersX.push_back(text);
        }
    }
示例#23
0
 void DiD3D9ErrorCheck::CheckError(HRESULT hr)
 {
     if (hr != S_OK)
     {
         DiString desc = "Direct3D API Error:\n";
         desc += GetResultString(hr);
         DI_ERROR(desc.c_str());
     }
 }
示例#24
0
 void DiEditorManager::SetCurrentFileName(const DiString& name)
 {
     mFxFileName = name;
     
     DiString title = "Hon Fxer";
     if(!name.empty())
         title.Format("Hon Fxer - %s",name.ExtractFileName().c_str());
     
     DiBase::Driver->GetMainRenderWindow()->GetWindow()->SetTitle(title.c_str());
 }
示例#25
0
    void CurveEditor::RefreshRange()
    {
        DiString minStr = mRangeMinEditBox->getCaption().asUTF8_c_str();
        DiString maxStr = mRangeMaxEditBox->getCaption().asUTF8_c_str();

        mValueRange.x = minStr.AsFloat();
        mValueRange.y = maxStr.AsFloat();

        RefreshNumbers();
    }
示例#26
0
    void DiK2Configs::DumpUsedRes()
    {
        DiString path = DiPathLib::GetApplicationPath();
        path += "used_k2_res.txt";

        FILE* fp = fopen(path.c_str(), "w+");
        for (auto i = sUsedResources.begin(); i != sUsedResources.end(); ++i)
        {
            fprintf(fp, "%s\n", i->c_str());
        }
        fclose(fp);
    }
示例#27
0
    DiInstanceBatchPtr DiInstanceManager::BuildNewBatch(const DiString& materialName, bool firstTime)
    {
        DiSubMesh::IndexMap &idxMap = mMeshReference->GetSubMesh(mSubMeshIdx)->GetBlendIndexToBoneIndexMap();
        //idxMap = idxMap.empty() ? mMeshReference->sharedBlendIndexToBoneIndexMap : idxMap;

        DiMaterialPtr mat = DiAssetManager::GetInstance().GetAsset<DiMaterial>( materialName );

        InstanceBatchVec &materialInstanceBatch = mInstanceBatches[materialName];

        DiInstanceBatchPtr batch;

        DiString name;
        name.Format("%s_InstanceBatch_%d",mName.c_str(),mIdCount++);

        switch( mInstancingTechnique )
        {
        case INSTANCE_SHADER_BASED:
            batch = make_shared<DiInstanceBatchShader>( this, mMeshReference, mMotionReference, mat, mInstancesPerBatch,
                &idxMap, name );
            break;
        case INSTANCE_HARDWARE_BASED:
            batch = make_shared<DiInstanceBatchHardware>(this, mMeshReference, mat, mInstancesPerBatch,
                name );
            break;
        default:
            DI_ERROR("Unsupported instanced technique.");
            break;
        }

        if( !firstTime )
        {
            batch->BuildFrom( mMeshReference->GetSubMesh(mSubMeshIdx) );
        }
        else
        {
            const size_t maxInstPerBatch = batch->CalculateMaxNumInstances( mMeshReference->
                GetSubMesh(mSubMeshIdx) );
            mInstancesPerBatch = DiMath::Min( maxInstPerBatch, mInstancesPerBatch );
            batch->SetInstancesPerBatch( mInstancesPerBatch );

            batch->Build( mMeshReference->GetSubMesh(mSubMeshIdx) );
        }

        //const BatchSettings &batchSettings = mBatchSettings[materialName];
        //batch->SetCastShadows( batchSettings.setting[CAST_SHADOWS] );

        DiCullNode *sceneNode = mSceneManager->GetRootNode()->CreateChild();
        sceneNode->AttachObject( batch );

        materialInstanceBatch.push_back( batch );

        return batch;
    }
示例#28
0
    DiMaterialPtr DiMaterial::QuickCreate( const DiString& vs, const DiString& ps , uint64 flag)
    {
        static int quickcreateID = 0;
        DiString name;
        name.Format("quick_%d", quickcreateID++);
        DiMaterialPtr mat = DiAssetManager::GetInstance().CreateOrReplaceAsset<DiMaterial>(name);

        mat->SetShaderFlag(flag);
        mat->LoadShader(vs,ps);

        return mat;
    }
示例#29
0
 void CurveEditor::SetAttribute(DiAttributeCurved& rhs)
 {
     rhs.CopyTo(&mCurvedAttr);
     
     mSplineButton->setStateSelected(mCurvedAttr.GetInterpolationType() == IT_SPLINE);
     
     // delete all buttons
     for (auto i : mButtons)
         mCanvasWidget->_destroyChildWidget(i);
     mButtons.clear();
     
     auto& pts = mCurvedAttr.GetControlPoints();
     float minVal = 0;
     float maxVal = 10;
     
     // calculate the range
     for (auto p : pts)
     {
         minVal = DiMath::Min(minVal, p.y);
         maxVal = DiMath::Max(maxVal, p.y);
     }
     
     float defaultRangeMin = 0;
     float defaultRangeMax = 10;
     
     if(minVal < 0)
     {
         int v = minVal / 10 - 1;
         minVal = v * 10;
     }
     
     if(maxVal > 10)
     {
         int v = maxVal / 10 + 1;
         maxVal = v * 10;
     }
     
     DiString temp;
     temp.Format("%g", minVal);
     mRangeMinEditBox->setCaption(temp.c_str());
     
     temp.Format("%g", maxVal);
     mRangeMaxEditBox->setCaption(temp.c_str());
     
     RefreshRange();
     
     // add buttons
     for (auto p : pts)
     {
         auto point = GetButtonPoint(p);
         AddButton(point.left, point.top);
     }
 }
示例#30
0
 DiString DiShaderManager::CoverterFlags(uint64 flags)
 {
     DiString ret;
     MapNameFlagsIt it     = mCommonFlag.begin();
     MapNameFlagsIt itEnd = mCommonFlag.end();
     for(it = mCommonFlag.begin(); it != itEnd; ++it){
         if(flags & it->second){
             ret += it->first;
             ret += ",";
         }
     }
     ret.TrimRight(",");
     return ret;
 }