2016년 6월 7일 화요일

To draw a line, circle, box on the GEngine

- Change the background color

initData.SetBackgroundColor(CGColor(0.8f, 0.8f, 0.8f));



- Code for drawing a line

void CGSampleView::OnButtonDrawLine()
{
// Creates a new line object
CGObjectLine2D *pObjLine2D = new CGObjectLine2D;

// Defines a line data
CGLine2D line;
line.SetPoint(CGPoint2D(100, 100), true);
line.SetPoint(CGPoint2D(200, 300), false);

// Set the line data to the line object
pObjLine2D->SetLine2D(line);

// Adds the line object to the DB
m_3DDB.AddObject(pObjLine2D);

// Renders all object in the GVIEWLAYER_MAIN DB
m_3DView.Render(GVIEWLAYER_MAIN);

// Just redraws rendered all object in view;
m_3DView.Redraw();
}

- Runs a code for drawing a line



- Code for drawing a circle

void CGSampleView::OnButtonDrawCircle()
{
// Creates a new circle object
CGObjectCircle3D *pObCircle3D = new CGObjectCircle3D;

// Defines a circle data
CGCircle3D circle3D;
{
// center position
circle3D.SetCenterPos(CGPoint3D(100, 100, 10));

// radius
circle3D.SetRadius(30);
}

// Sets the circle data to the circle object
pObCircle3D->SetCircle3D(circle3D);

// Adds the circle object to the DB
m_3DDB.AddObject(pObCircle3D);

// Renders all object in the GVIEWLAYER_MAIN DB
m_3DView.Render(GVIEWLAYER_MAIN);

// Just redraws rendered all object in view.
m_3DView.Redraw();
}


- Runs a code for drawing a circle



- Code for drawing a box
void CGSampleView::OnButtonDrawBox()
{
// Creates a new box object.
CGObjectBox *pObBox = new CGObjectBox;

// Defines a box data 
CGBox box;
{
// Position of the box bottom center.
box.SetPos(CGPoint3D(-100, -100, 0), true);

// Position of the box top center.
box.SetPos(CGPoint3D(-100, -100, 100), false);

// Height of the box
box.SetHeight(50.0f);

// Width of the box;
box.SetWidth(50.0f);
}

// Sets the box data to the box object
pObBox->SetBox(box);

// Adds a box object in the DB
m_3DDB.AddObject(pObBox);

// Renders all object in the GVIEWLAYER_MAIN DB;
m_3DView.Render(GVIEWLAYER_MAIN);

// Just redraws rendered all object in view.
m_3DView.Redraw();
}

- Runs a code for drawing a box



It's too simple and bored.
Next time, I will make a code for mouse control.
It's a zoom all, zoom rotate, zoom pan.


2016년 6월 4일 토요일

Introducing the GEngine

Introducing my new hobby GEngine.

GEngine is 3D Graphics Framework.

The goal is the fastest, lightest, easiest 3D Engine.




Function list of GEngine.
- Dxf import
- View based on DirectX11
- Basic objects
  - 3D point
  - 2D line
  - 3D circle
  - Cylinder
  - Face
  - Box
  - Sphere
  - Proxy
  - Text
  - 2D polyline
  - 3D polyline
  - Triangle strip
- Fill mode
  - solid
  - wireframe
- Light
- Fog
- Material
- Action
  - Create line
  - Create circle
  - Move
  - Copy
  - 2D rotate
  - Scale
- Selection
  - Single selection
  - Window selection
- Camera


Tutorial link

Download link

How to attach a G3DView to a SDI View.

1. Summary :

Attach a 3D View to a program based on MFC SDI by a GEngine.

2. Requirements :

- Library :
  - GEngine-v0.1
    - https://github.com/gurum77/gengine/tree/master/gengine-0.1
  - DirectX11

- Visual Studio :
  - Visual Studio 2010
or
  - Visual Studio 2013

3. Training :

- Make a SDI program by MFC wizard.

















- Set the project setting.

  - Set the additional include directories.
















  - Set the additional library directories.
















- Include GEngine headers.








- Define member variables for CG3DView, CG3DDB, CGDCDirectX11
- Define handler function for initial of SDI View.












- Registe handling functions to the message map.







- Initialize a CG3DView.
- Call a Redraw() of CG3DView.
- Call a OnResize of CG3DView.




















- The SDI View Attached 3D View