示例#1
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();
    }
示例#2
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;
}
示例#3
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;
        }
    }
示例#4
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);
     }
 }
示例#5
0
 bool DiCommandManager::SetStringVar(const DiString& name, const DiString& var)
 {
     DiConsoleVar* cv = GetConsoleVar(name);
     if(!cv)
         return false;
     
     if(cv->GetType() != CONSOLE_VAR_STRING)
     {
         DI_WARNING("Cannot set come variable : %s, bad type cast", name.c_str());
         return false;
     }
     DiConsoleVariableString* v = (DiConsoleVariableString*)cv;
     v->Set(var.c_str());
     return true;
 }
示例#6
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;
 }
示例#7
0
    void DiK2Configs::LoadConfig(const DiString& config)
    {
        auto file = DiAssetManager::GetInstance().OpenArchive(config, true);
        if (!file)
        {
            DI_WARNING("Failed to load the config: %s", config.c_str());
            return;
        }

        shared_ptr<DiXMLFile> xmlfile(new DiXMLFile());
        xmlfile->Load(file->GetAsString());
        DiXMLElement node = xmlfile->GetRoot();
        DiXMLElement child = node.GetChild();
        while (child)
        {
            DiString name = child.GetName();
            if (name == "Property")
            {
                DiString key = child.GetAttribute("key");
                DiString val = child.GetAttribute("value");
                CommandMgr->RegisterString(key, val, 0);
            }

            child = child.GetNext();
        }
    }
示例#8
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());
        }
    }
示例#9
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;
    }
示例#10
0
 DiString DiEditorManager::GenerateControllerName(const DiString& type)
 {
     static int id = 0;
     DiString ret;
     ret.Format("%s_%d", type.c_str(), id++);
     return ret;
 }
示例#11
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);
            }
        }
    }
示例#12
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);
        }
    }
示例#13
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);
            }
        }
    }
示例#14
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;
    }
示例#15
0
    void DiK2World::Load(const DiString& path)
    {
        DI_LOG("Loading world: %s", path.c_str());

        DiK2WorldSerial serial;
        serial.Load(path,this);
        mRootNode->AttachObject(mTerrain);
        
        // sun light
        mSun = make_shared<DiDirLight>();
        DiSceneManager* sm = DiBase::Driver->GetSceneManager();
        DiCullNode* dirNode = sm->GetRootNode()->CreateChild();
        dirNode->AttachObject(mSun);
        mSun->SetColor(DiColor());
        
        DiRadian altitude(DiDegree(mConfigs.mSunAltitude));
        DiVec3 dir(0,-DiMath::Sin(altitude),DiMath::Cos(altitude));
        
        DiRadian azimuth(DiDegree(mConfigs.mSunAzimuth));
        DiQuat rot(azimuth, DiVec3::UNIT_Y);
        dir = rot * dir;
        mSun->SetDirection(dir);
        
        sm->SetAmbientColor(DiColor());
    
        Demi::DiRenderBatchGroup* group = Driver->GetPipeline()->GetBatchGroup(Demi::BATCH_MODEL);
        group->SetPreProcess([this](){
            Driver->GetPipeline()->GetShaderEnvironment()->globalAmbient = mConfigs.mEntityAmbient;
            Driver->GetPipeline()->GetShaderEnvironment()->dirLightsColor[0] = mConfigs.mEntitySunColor;
        });
    }
示例#16
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);
        }
    }
示例#17
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);
    }
示例#18
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);
        }
    }
示例#19
0
 void DiD3D9ErrorCheck::CheckError(HRESULT hr)
 {
     if (hr != S_OK)
     {
         DiString desc = "Direct3D API Error:\n";
         desc += GetResultString(hr);
         DI_ERROR(desc.c_str());
     }
 }
示例#20
0
    void DiRenderWindow::Create(uint32 width, uint32 height, const DiString& title, bool fullscreen)
    {
        mWindow = DiWindow::CreateWnd();
        mWindow->SetParentRenderWnd(this);
        mWindow->Create(width, height, title.c_str(), fullscreen);
        mWndHandle = mWindow->GetWndHandle();

        Init();
    }
示例#21
0
void DiFileLogger::OutputLog(const char* szMessage, const char* levelInfo,
                           const char* fileName, long line)
{
    DiString datetime = DiTimer::GetCurrentTime();

    DiString log;
    log.Format( "[%s] %s%s", datetime.c_str(), levelInfo, szMessage);
    mFile << log.c_str();

    if (fileName)
    {
        DiString file = fileName;
        file = file.ExtractFileName();
        mFile << ", " << file.c_str() << "(" << line << ")";
    }

    mFile << std::endl;
}
示例#22
0
 void DiEditorManager::OpenFx(const DiString& fxFileName)
 {
     DiString base = fxFileName.ExtractFileName();
     if(!DiAssetManager::GetInstance().HasArchive(base))
     {
         DiString message;
         message.Format("Cannot find the effect file(%s) in our media folders!", base.c_str());
         MyGUI::Message::createMessageBox("Message", "Error", message.c_str(),
                                          MyGUI::MessageBoxStyle::Ok|MyGUI::MessageBoxStyle::IconError);
         
         return;
     }
     
     DiFxTokensParser parser;
     
     auto stream = DiAssetManager::GetInstance().OpenArchive(base);
     shared_ptr<DiXMLFile> xmlfile(DI_NEW DiXMLFile());
     xmlfile->Load(stream->GetAsString());
     DiXMLElement root = xmlfile->GetRoot();
     
     if (!root.CheckName("Effects"))
     {
         DI_WARNING("Bad effect file: %s", base.c_str());
         return;
     }
     
     auto child = root.GetChild();
     while (child)
     {
         if (child.CheckName("ParticleSystem"))
         {
             auto ps = parser.ReadSystem(child);
             LoadParticleSystem(ps);
         }
         else if(child.CheckName("ReferenceModel"))
         {
             LoadRefModel(child);
         }
         
         child = child.GetNext();
     }
     
     SetCurrentFileName(fxFileName);
 }
示例#23
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());
 }
示例#24
0
    void DiEffectManager::AddParticleSystemTemplate(const DiString& name, DiParticleSystemPtr systemTemplate)
    {
        if (mParticleSystemTemplates.find(name) != mParticleSystemTemplates.end())
        {
            DI_WARNING("The effect template: %s has already existed", name.c_str());
            return;
        }

        mParticleSystemTemplates[name] = systemTemplate;
    }
示例#25
0
 float DiCommandManager::GetFloatVar(const DiString& name)
 {
     DiConsoleVar* var = GetConsoleVar(name);
     if(var)
         return var->GetAsFloat();
     else
     {
         DI_WARNING("Cannot locate the command variable: %s", name.c_str());
         return 0;
     }
 }
示例#26
0
    void DiEffectManager::RemoveRendererFactory(const DiString& rendererType)
    {
        auto it = mRendererFactories.find(rendererType);
        if (it == mRendererFactories.end())
        {
            DI_WARNING("Cannot find the renderer type: %s", rendererType.c_str());
            return;
        }

        mRendererFactories.erase(it);
    }
示例#27
0
    DiTransUnitPtr DiCullNode::GetAttachedObject( const DiString& name )
    {
        ObjectMap::iterator i = mObjectsByName.find(name);

        if (i == mObjectsByName.end())
        {
            DI_ERROR("Cannot find the attachment object by name : %s",name.c_str());
        }

        return i->second;
    }
示例#28
0
    void DiEffectManager::RemoveEmitterFactory(const DiString& emitterType)
    {
        auto it = mEmitterFactories.find(emitterType);
        if (it == mEmitterFactories.end())
        {
            DI_WARNING("Cannot find the emitter type: %s", emitterType.c_str());
            return;
        }

        mEmitterFactories.erase(it);
    }
示例#29
0
 void DiEffectManager::DestroyParticleSystemTemplate(const DiString& templateName)
 {
     auto i = mParticleSystemTemplates.find(templateName);
     if (i != mParticleSystemTemplates.end())
     {
         mParticleSystemTemplates.erase(i);
         return;
     }
     
     DI_WARNING("Cannot locate the ps template: %s", templateName.c_str());
 }
示例#30
0
    void DiEffectManager::RemoveControllerFactory(const DiString& controllerType)
    {
        auto it = mControllerFactories.find(controllerType);
        if (it == mControllerFactories.end())
        {
            DI_WARNING("Cannot find the controller type: %s", controllerType.c_str());
            return;
        }

        mControllerFactories.erase(it);
    }