Click here to Skip to main content
Click here to Skip to main content

Miner3D_viewer ActiveX control (for Miner3D game)

, 25 Feb 2004 CPOL
Rate this:
Please Sign up or sign in to vote.
A solution for writing game 3D using VC combined with VB.

Sample Image

Introduction

Last month, I have written an article about OpenGL selection (You can find it in this section). And now you can see my full code!

Using the code

First, you need to know about using MFC ActiveX Control Wizard. You can visit here for a tutorial.

Miner3D_viewer control:

Methods:

  • AddChar: Paint a number
  • AddColorTile: Paint a cube with color defined
  • AddColorWireTile: Paint a wire frame cube with color defined
  • AddFace: Paint a rectangle
  • AddPoint: Paint a light point
  • AddTile: Paint a cube with default color (BLUE)
  • AddWireTile: Paint a wire frame cube with default color
  • ChangeTileColor: Change color of a cube
  • Clear All: Remove all things in the screen
  • GetCamDirX: Return the X dimension of camera direction
  • GetCamDirY: Return the Y dimension of camera direction
  • GetCamDirZ: Return the Z dimension of camera direction
  • GetHandleActiveWindow: Return the handle of active window this time
  • GetTilePos: Get position of cube
  • OpenTile: Do open a cube
  • Pick: Determine what cube is in that point of screen
  • PlayMidiFile: Play a MIDI file
  • Refresh: Paint again
  • StopPlayMidi: Turn off the sound

Properties:

  • BackColor: back ground color
  • CamAxz: angle follow xz face
  • CamAzy: angle follow zy face
  • CamPosX: X dimension of camera
  • CamPosY: Y dimension of camera
  • CamPosZ: Z dimension of camera
  • CharRotateDegree: the degree of rotated numbers
  • FogColor: color of the fog
  • FogDensity: the density of the fog
  • Interval: like timer but adding refresh screen
  • Light1: the light ray from up to down
  • PickLessExact: less exact when pick
  • SeeAngle: see angle
  • SeeFarthest: see farthest
  • SeeNearest: see nearest

Event:

  • EndPlayMidi: when finish, play a MIDI file
  • LeftButtonDown: when click left mouse (x, y follow pixel of screen)
  • RightButtonDown: when click right mouse (x, y follow pixel of screen)
  • Timer: like timer
  • VcKeyDown: like key down but catch adding arrow key
  • VcKeyUp: like key up but catch adding arrow key

To run this you have to register this OCX by two ways:

    • At "Run..." type : regsvr32.
    • Open Explorer and drag this OCX into Run dialog.

      (Some thing like this : regsvr32 d:\Miner3D_viewer.ocx)

    • "Enter".
  1. Compile the VC code!

After that you can run the the game or view the VB source!

Now I explain some parts of my code:

  • CMiner3D_viewerCtrl is what you have to write!
  • I make a list to save the way I paint the number: MakeCharList(). You can understand my number as an object and you can make it by this way:
    glNewList(1,GL_COMPILE); // call this by : glCallList(1);
        ... // code painting here
    glEndList();
  • For the selection I use function: CMiner3D_viewerCtrl::pick(double x,double y, BOOL FAR* miss)

    I don't know why the Z dimension is not work so I have to calculate the square of each distance to determine what object is nearest, and some time it throws "divided by zero" exception! If you know why, please tell me! Thank you!

  • Change RGB color to OpenGL color: The RGB COLORREF you can know as this: color = 0x00112233
    • 11 : Blue component. You can get it by (color & 0xff0000).
    • 22 : Green component. You can get it by (color & 0xff00).
    • 33 : Red component. You can get it by (color & 0xff).

    After that, divide 255 to get OpenGL color!

  • I will explain more if I have time, or you can mail to chithien@hotpop.com!

Points of Interest

  • I have tried to write a 3D game and find the way to combine VC with VB. I have done it!
  • I had used texture and blend function but my computer is too slow for it, and I have removed it!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

ICE_WIZARD
Software Developer (Junior)
Vietnam Vietnam
My subject is Information technology. I like programming and learn more about everything.

Comments and Discussions

 
GeneralGet 3D Coordinates from Screen Location PinmemberTedWu2-Mar-04 3:09 
GeneralRe: Get 3D Coordinates from Screen Location PinmemberTweety2-Mar-04 20:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141216.1 | Last Updated 26 Feb 2004
Article Copyright 2004 by ICE_WIZARD
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid