일요일, 7월 08, 2007

일기 (2007.07.08)

오늘 학도, 형진(with girl friend) 과 함께 '도가니탕' 을 먹으러 감사원 근처 식당에 갔다.
친구들 기다리는 동안 감사원 근처 '삼청공원' 에서 접사를 연습했다.





솜씨가 제법이지 않나 ? ^____^

월요일, 7월 02, 2007

Irrlicht + ActiveX (Internet Explorer) = ? (project linked)

***************************************************************************
// New Code
// Date: July.06.2007
// Author : June (godmode2k@hotmail.com | MSN)
***************************************************************************
Code:

//! ~Ctl.h
// ---------------------------------------------------------------
class ~Ctrl : public COleControl
{
public:
...
// ADD [
HWND m_hWnd;
HWND m_hIrrlichtWindow;
HINSTANCE m_hInstance;
bool m_IsFirst; // set flag, at drawing first time via OnDraw(...)
void EngineTest(CWnd* cWnd);
// ]
...
};
// ---------------------------------------------------------------


Code:

//! ~Ctl.cpp
// ---------------------------------------------------------------
// Global Variable
#include "stdafx.h"
#include "~.h"
#include "~Ctl.h"
#include "~Ppg.h"

//! Here !
#include

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

// 3D Engine Test
// -----------------------------------------------------------------------------
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#pragma comment(lib, "Irrlicht.lib")

video::IVideoDriver* driver = 0;
IGUIEnvironment* env = 0;
scene::ISceneManager* smgr = 0;
s32 cnt = 0;
IGUIListBox* listbox = 0;
HWND g_hWnd;
// -----------------------------------------------------------------------------
...

CTest_engine_activex_vc60Ctrl::CTest_engine_activex_vc60Ctrl()
{
InitializeIIDs(&IID_DTest_engine_activex_vc60, &IID_DTest_engine_activex_vc60Events);

// TODO: Initialize your control's instance data here.

// ADD [
m_IsFirst = true;
// ]
}

void ~Ctrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
// TODO: Replace the following code with your own drawing code.
// pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
// pdc->Ellipse(rcBounds);

// ADD [
if( m_IsFirst ) {
m_IsFirst = false;
EngineTest( pdc->GetWindow() );
}
// ]


//! EventReceiver
// Yes, you using your own EventReceiver class as before.
// ADD [
class MyEventReceiver : public IEventReceiver
{
private:
bool m_isRender;
IrrlichtDevice* device;
public:
void setDevice(IrrlichtDevice* v) { device = v; }
void setRender(bool v) { m_isRender = v; }
bool getRender(void) { return m_isRender; }

virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
IGUIEnvironment* env = device->getGUIEnvironment();

switch(event.GUIEvent.EventType)
{
case EGET_SCROLL_BAR_CHANGED:
if (id == 104)
{
s32 pos = ((IGUIScrollBar*)event.GUIEvent.Caller)->getPos();

for (u32 i=0; i {
SColor col = env->getSkin()->getColor((EGUI_DEFAULT_COLOR)i);
col.setAlpha(pos);
env->getSkin()->setColor((EGUI_DEFAULT_COLOR)i, col);
}

}
break;
case EGET_BUTTON_CLICKED:
if (id == 101)
{
setRender( false );
return true;
}
default:
break;
}
}

return false;
}
...
};
// ]

void ~Ctrl::EngineTest(CWnd* cWnd)
{
// ADD [
//! Set for Child Window as a Button
// -----------------------------------------
video::E_DRIVER_TYPE driverType;
driverType = video::EDT_OPENGL;
MyEventReceiver receiver;

irr::SIrrlichtCreationParameters param;
m_hWnd = cWnd->m_hWnd;
m_hInstance = AfxGetInstanceHandle();

m_hIrrlichtWindow = CreateWindow("BUTTON", "Test Engine On The ActiveX", WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 10, 200, 640, 480, m_hWnd, NULL, m_hInstance, NULL);
param.WindowId = reinterpret_cast( m_hIrrlichtWindow );
param.DriverType = driverType;
IrrlichtDevice* device = irr::createDeviceEx( param );

receiver.setDevice( device );
receiver.setRender( true );
device->setEventReceiver(&receiver);

// -----------------------------------------
// Your code
// -----------------------------------------

//! Prepare to Rendering
// -----------------------------------------
g_hWnd = m_hWnd;
::ShowWindow( m_hIrrlichtWindow , SW_SHOW );
::UpdateWindow( m_hIrrlichtWindow );

while( device->run() && driver ) {
if( !receiver.getRender() ) { break; }
//! "isWindowActivate()" isn't work here.
//if( device->isWindowActive() ) {
driver->beginScene(true, true, SColor(0,200,200,200));
smgr->drawAll();
env->drawAll();
driver->endScene();

//! ^___^
::UpdateWindow( m_hIrrlichtWindow );
//}
}
// ]

device->closeDevice();
device->drop();
}

//! Mouse Event
// ClassWizard -> add Message "WM_MOUSEACTIVATE"
int ~Ctrl::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or call default

// ADD [
OnActivateInPlace( true, NULL );
// ]

return COleControl::OnMouseActivate(pDesktopWnd, nHitTest, message);
}
// ---------------------------------------------------------------



***************************************************************************


***************************************************************************
// Source: posted in Irrlicht forum, see below link.
// http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=22652&start=0&postdays=0&postorder=asc&highlight=
***************************************************************************
Answer is ******. lol
but it works fine !

// ---------------------------------------------------------------
// Project: You wanna Rendering 3D materials using Irrlicht on the Web ?
// ---------------------------------------------------------------
// Purpose: Irrlicht as ActiveX Control on the Web Browser such as Internet Explorer.
// Author : June (godmode2k@hotmail.com | MSN)
// Date : July. 2nd. 2007, KST
// ---------------------------------------------------------------
// Note : Ready ?
// Update:
// + August 28, 2008:
// 1. You can check out full of source code relevant this thread below link.
// http://code.google.com/p/gedk/downloads/list
// ---------------------------------------------------------------

Q: I don't know how to create an ActiveX Control with Visual C++ !!!
A: Don't worry baby. See below site.
http://www.codeguru.com/cpp/com-tech/activex/
http://www.codeproject.com/KB/COM/CompleteActiveX.aspx

[STEP #1]
Make an ActiveX Control using MS-VC++ (6.0 or whatever) where Project - > "MFC ActiveX ControlWizard" tab.
Its done ?

[STEP #2]
Adds below code.

Code:

//! ~Ctl.h
// ---------------------------------------------------------------
class ~Ctrl : public COleControl
{
public:
...
// ADD [
HWND m_hWnd;
HWND m_hIrrlichtWindow;
HINSTANCE m_hInstance;
bool m_IsFirst; // set flag, at drawing first time via OnDraw(...)
void EngineTest(CWnd* cWnd);
// ]
...
};
// ---------------------------------------------------------------


Code:

//! ~Ctl.cpp
// ---------------------------------------------------------------
// Global Variable
#include "stdafx.h"
#include "~.h"
#include "~Ctl.h"
#include "~Ppg.h"

//! Here !
#include

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

// 3D Engine Test
// -----------------------------------------------------------------------------
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#pragma comment(lib, "Irrlicht.lib")

IrrlichtDevice *device = 0;
video::IVideoDriver* driver = 0;
IGUIEnvironment* env = 0;
scene::ISceneManager* smgr = 0;
s32 cnt = 0;
IGUIListBox* listbox = 0;
HWND g_hWnd;
// -----------------------------------------------------------------------------
...

CTest_engine_activex_vc60Ctrl::CTest_engine_activex_vc60Ctrl()
{
InitializeIIDs(&IID_DTest_engine_activex_vc60, &IID_DTest_engine_activex_vc60Events);

// TODO: Initialize your control's instance data here.

// ADD [
m_IsFirst = true;
// ]
}

void ~Ctrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
// TODO: Replace the following code with your own drawing code.
// pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
// pdc->Ellipse(rcBounds);

// ADD [
if( m_IsFirst ) {
m_IsFirst = false;
EngineTest( pdc->GetWindow() );
}
// ]


//! EventReceiver
// Yes, you using your own EventReceiver class as before.
// ADD [
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
...
}
...
};
// ]

void ~Ctrl::EngineTest(CWnd* cWnd)
{
// ADD [
//! Set for Child Window as a Button
// -----------------------------------------
video::E_DRIVER_TYPE driverType;
driverType = video::EDT_OPENGL;
MyEventReceiver receiver;

irr::SIrrlichtCreationParameters param;
m_hWnd = cWnd->m_hWnd;
m_hInstance = AfxGetInstanceHandle();

m_hIrrlichtWindow = CreateWindow("BUTTON", "Test Engine On The ActiveX", WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 10, 200, 640, 480, m_hWnd, NULL, m_hInstance, NULL);
param.WindowId = reinterpret_cast( m_hIrrlichtWindow );
param.DriverType = driverType;
device = createDeviceEx( param );
device->setEventReceiver(&receiver);

// -----------------------------------------
// Your code
// -----------------------------------------

//! Prepare to Rendering
// -----------------------------------------
g_hWnd = m_hWnd;
::ShowWindow( m_hIrrlichtWindow , SW_SHOW );
::UpdateWindow( m_hIrrlichtWindow );

while( device->run() && driver ) {
//! "isWindowActivate()" isn't work here.
//if( device->isWindowActive() ) {
driver->beginScene(true, true, SColor(0,200,200,200));
smgr->drawAll();
env->drawAll();
driver->endScene();

//! ^___^
::UpdateWindow( m_hIrrlichtWindow );
//}
}
// ]
}

//! Mouse Event
// ClassWizard -> add Message "WM_MOUSEACTIVATE"
int ~Ctrl::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or call default

// ADD [
OnActivateInPlace( true, NULL );
// ]

return COleControl::OnMouseActivate(pDesktopWnd, nHitTest, message);
}
// ---------------------------------------------------------------


* Screenshot *