'2009/03'에 해당되는 글 11건

  1. 2009/03/28 Marshal 을 이용해서 string 을 byte로 변환(복사) 하기 (2)
  2. 2009/03/24 Ogre3D용 Flash 연동 라이브러리 - Hikari (2)
  3. 2009/03/16 테이블간 관계 추가해서 자동 삭제 처리 하기
  4. 2009/03/13 Ogre 용 SceneEditor 제작중
  5. 2009/03/13 [MOgre] 윈폼 마우스로 3D 화면 움직이기
  6. 2009/03/13 [MOgre] 마우스 픽킹 테스트, 객체 선택 (펌)
  7. 2009/03/13 [MOgre] Grid 생성 함수 (펌)
  8. 2009/03/13 [MOgre] 폴리곤 모드 (PolygonMode) 변경방법
  9. 2009/03/13 [MOgre] 윈도우 폼의 사이즈 변경시 3D 화면 재 설정
  10. 2009/03/07 한국 지역별 소트 하기
  11. 2009/03/02 민정이 2009-03-01 (3)
2009/03/28 17:12

Marshal 을 이용해서 string 을 byte로 변환(복사) 하기


string의 값을 byte로 변환하는 것이 C#은 참 복잡하다는 생각이 든다.
왜 Marshal을 이용하는지는 댓글 달아 주심 감사 ^^.

우선 아래 코드는 사용법에 대해서만 작성합니다.

byte[] MsgAscii = System.Text.Encoding.GetEncoding(0).GetBytes(obj);
byte[] arr = new byte[100];
...
for( int i = 0; i < MsgAscii.Length; ++i)
{
    Marshal.WriteByte(arr, i, MsgAscii[i]);
}

크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 Comment 2
2009/03/24 02:30

Ogre3D용 Flash 연동 라이브러리 - Hikari


게임의  UI 는 아무래도 라이브러가 제공되지 않고서는
구축, 제어가 어려운거 같다.

Ogre3D 게임엔진을 사용해서 지금 프로젝트를 진행하면서
Flash가 지원되지 않는지 보다 보니 역쉬 지원 되는게 있었다.
어찌 보면 UI쪽의 개발 기간을 단축할 수 있기 때문에,
다행인듯 하다.

해당 자료 링크 : Hikary-Flash-Library
크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 Comment 2
2009/03/16 04:35

테이블간 관계 추가해서 자동 삭제 처리 하기


두개의 테이블이 있다.

GalleryBoard2 에는 게시물이 저장된다.
그리고 GalleryBoard2File 에는 게시물에서 첨부이미지가 저장된다.
idx - imgIDX 를 통해서 해당 게시물의 이미지 파일을 연결한다.

이때 GalleryBoard2의 해당 게시물을 삭제 하게 될때
GalleryBoard2File의 내용도 같이 삭제를 해야 한다.
하지만, 두개의 테이블을 따로따로 삭제할 경우 좀 번거롭고 문제가 생기기 마련이다.
그래서 관계를 위의 이미지와 같이 형성하고 GalleryBoard2를 삭제 하면 GalleryBoard2File의 내용도 같이 포함된다.

간단하게 설명하면
1. MSSql 2005에서 데이터베이스 다이어그램을 새로 생성한다.
2. GalleryBoard2, BalleryBoard2File을 두개 추가한다.
3. 두개의 테이블에서 GalleryBoard2의 idx GalleryBoard2FileimgIDX를 드래그해서 연결한다.
4. 연결후에 속성을 아래와 같이 변경한다.
  - 기본으로 설정된 속성은 그대로 둔다.
  - INSERT 및 UPDATE 사양 에서 삭제 규칙 을 "계단식 배열"로 정한다.
    (사실 여기에 몇개 설정값이 있지만, 잘 모른다. 혹시 아신다면 코멘트 부탁해요)
5. 이게 정상적으로 되었다면 삭제처리를 해보기 바란다. 자동으로 삭제가 되니 코딩도 편해진다.
크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 Comment 0
2009/03/13 03:15

Ogre 용 SceneEditor 제작중


요즘  Ogre용 개발을 위한 씬 에디터를 제작 중이다.
아직 기본 틀만 잡힌 상태며,  MOgre 1.4 버젼을 사용해서 C#, Winform을 사용해서 구현하고 있다.
크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 Comment 0
2009/03/13 03:11

[MOgre] 윈폼 마우스로 3D 화면 움직이기


protected bool mLMBDown = false;
const float ROTATE = 0.2f;
const float TRANSLATE = 1;
Point mLastPosition;
Vector3 mTranslation = Vector3.ZERO;

.....

void mogrepanel_MouseDown(object sender, MouseEventArgs e)
{
    mLMBDown = true;
    mLastPosition = e.Location;
}

void mogrepanel_MouseUp(object sender, MouseEventArgs e)
{
    mLMBDown = false;
}

void mogrepanel_MouseMove(object sender, MouseEventArgs e)
{
    mTranslation = Vector3.ZERO;

    if (e.Button == MouseButtons.Left)
    {
        float x = mLastPosition.X - e.Location.X;
        float y = mLastPosition.Y - e.Location.Y;

        // 화면을 Dolly 모드 처럼 구현하기
        mogreWin.camera.Yaw(new Degree(x * ROTATE));
        mogreWin.camera.Pitch(new Degree(y * ROTATE));
    }
    else if (e.Button == MouseButtons.Right)
    {
        float y = mLastPosition.Y - e.Location.Y;

        mTranslation.z = y * TRANSLATE;

        // 화면을 줌인, 줌아웃 처리 하는 것
        mogreWin.camera.Position += mogreWin.camera.Orientation * mTranslation;
    }
    else if (e.Button == MouseButtons.Middle)
    {
        float x = mLastPosition.X - e.Location.X;
        float y = mLastPosition.Y - e.Location.Y;

        mTranslation.x = x * TRANSLATE;
        mTranslation.y = -(y * TRANSLATE);

        // 화면을 좌우상하 움직이는 것
        mogreWin.camera.Position += mTranslation;
    }

    mogreWin.Paint();

    mLastPosition = e.Location;
}

크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 Comment 0
2009/03/13 03:08

[MOgre] 마우스 픽킹 테스트, 객체 선택 (펌)


윈폼에서 3D 뷰에서 객체를 선택하는 로직이다.
아무래도 바운딩 박스 구조로 선택이 되는거 같다.

void mogrepanel_MouseDown(object sender, MouseEventArgs e)
{
    mLMBDown = true;
    mLastPosition = e.Location;

    // 히트 테스트
    mogreWin.ClickedOnHead(e.X, e.Y);
}
.....
public bool ClickedOnHead(int mx, int my)
{
    float scrx = (float)mx / viewport.ActualWidth;
    float scry = (float)my / viewport.ActualHeight;

    Ray ray = camera.GetCameraToViewportRay(scrx, scry);
    RaySceneQuery query = sceneMgr.CreateRayQuery(ray);
    RaySceneQueryResult results = query.Execute();

    boxsceneNode.ShowBoundingBox = false;
    sceneNode.ShowBoundingBox = false;
    foreach (RaySceneQueryResultEntry entry in results)
    {
        if (entry.movable.Name == "ogre")
        {
            //boxsceneNode.ShowBoundingBox = false;
            sceneNode.ShowBoundingBox = true;
        }
        else if (entry.movable.Name == "box")
        {
            //sceneNode.ShowBoundingBox = false;
            boxsceneNode.ShowBoundingBox = true;
        }
        // 위의 entry.movable.Name 를 사용해서 적당하게 처리 하면 될듯 하다.
    }

    return results.Count > 0;
}

크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 Comment 0
2009/03/13 03:05

[MOgre] Grid 생성 함수 (펌)


private void CreateGrid(int numcols, int numrows, float unitsize)
{
    // 생성
    ManualObject grid = sceneMgr.CreateManualObject("grid");

    grid.Begin("BaseWhiteNoLighting", RenderOperation.OperationTypes.OT_LINE_LIST);

    float width = (float)numcols * unitsize;
    float depth = (float)numrows * unitsize;
    Vector3 center = new Vector3(-width / 2.0f, 0, -depth / 2.0f);

    for (int i = 0; i < numrows; ++i)
    {
        Vector3 s, e;
        s.x = 0.0f;
        s.z = i * unitsize;
        s.y = 0.0f;

        e.x = width;
        e.z = i * unitsize;
        e.y = 0.0f;

        grid.Position(s + center);
        grid.Position(e + center);
    }
    grid.Position(new Vector3(0.0f, 0.0f, numrows * unitsize) + center);
    grid.Position(new Vector3(width, 0.0f, numrows * unitsize) + center);

    for (int i = 0; i < numcols; ++i)
    {
        Vector3 s, e;
        s.x = i * unitsize;
        s.z = depth;
        s.y = 0.0f;

        e.x = i * unitsize;
        e.z = 0.0f;
        e.y = 0.0f;

        grid.Position(s + center);
        grid.Position(e + center);
    }
    grid.Position(new Vector3(numcols * unitsize, 0.0f, 0.0f) + center);
    grid.Position(new Vector3(numcols * unitsize, 0.0f, depth) + center);
    grid.End();

    sceneMgr.RootSceneNode.AttachObject(grid);
}

크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 Comment 0
2009/03/13 03:03

[MOgre] 폴리곤 모드 (PolygonMode) 변경방법


카메라의 폴리곤 모드가 존재 한다.
이걸 사용해서 처리 하면 된다.

camera.PolygonMode = PolygonMode.PM_SOLID;
종류 :
- PolygonMode.PM_SOLID
- PolygonMode.PM_POINTS
- PolygonMode.PM_WIREFRAME

왜 이게 카메라에 존재 하는지는 잘 모르겠다.
크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 Comment 0
2009/03/13 03:00

[MOgre] 윈도우 폼의 사이즈 변경시 3D 화면 재 설정


윈폼의 UI 기반의 코드를 작성하다 보면
3D의 화면은 사이즈가 빈번하게 변경된다.
이때 뷰포트와 카메라의 비율은 변경을 해주어야 한다.
아래의 코드는 그 일부분이다.

protected RenderWindow window;
public Camera camera;
protected Viewport viewport;
.......
// 윈도우 사이즈가 변하면 여기서 WindowMovedOrResized 메소드를 호출해 주어야 한다.
window.WindowMovedOrResized();
// 호출후에 생성된 윈도우 사이즈를 SetConfigOption()에 추가해 주어야 한다.
string videomode = string.Format("{0} x {1} @ 32-bit colour", window.Width, window.Height);
root.RenderSystem.SetConfigOption("Video Mode", videomode);
// 카메라의 비율을 재 생성한다.
camera.AspectRatio = ((float)viewport.ActualWidth) / ((float)viewport.ActualHeight); 

크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 Comment 0
2009/03/07 06:26

한국 지역별 소트 하기

작업 하다가 대리점별 지역 주소를 정렬하는 부분에 사용한 쿼리
지역 코드가 여러개의 혼합으로 되어 있어서 그걸로 안되고 해서
주소의 내용 일부를 order by 해서 사용하도록 했다.


SELECT * FROM dbo.Agency order by case left(ConAddr,2)
 when '서울' then 1
 when '경기' then 2
 when '인천' then 3
 when '강원' then 4
 when '대전' then 5
 when '충남' then 6
 when '충분' then 7
 when '부산' then 8
 when '울산' then 9
 when '경남' then 10
 when '대구' then 11
 when '경북' then 12
 when '광주' then 13
 when '전남' then 14
 when '전북' then 15
 when '제주' then 16
 end
크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 Comment 0
2009/03/02 00:11

민정이 2009-03-01

사랑 스런 우리딸..

항상 행복한 날만 가득하길 빈다. 우리딸~!
크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 Comment 3