March 28, 2024, 09:01:21 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


About the program structure

Started by barry, September 09, 2007, 03:25:58 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

barry

All the Aurora (and Ebasic too) 3D examples use the keyboard instead of the mouse and even in the few where the mouse is used a little the exit is via the escape key.

What I'm doing is trying to get a better grasp of how the programs are structured in Windows in procedural and OOP programming, so I'm looking at the various languages for samples.  I think I'm sort of beginning to see it until I get into the OOP 3D.  There none of the samples use anything like Windows style programming.

Can anyone provide a simple 3D example that uses the mouse and a SYSMENU and a regular menu and a button or two?  It doesn't have to do anything, really.  In fact it'll be easier for me to understand if it does very little.  I'm just trying to see how this works.

This isn't important so please don't anybody spend a lot of time writing a program for this question.  But if you have some little something that works in normal Windows ways and is also OOP could you post it?

Short of that, how do you get a CScreen to respond to the system menu?

Thanks,
Barry

barry

It just occurred to me that I probably didn't explain what I mean very well.  I'm toying with the 3D program points.src and lines.src and trying to figure out how to add the menu and sysmenu to points.  I have the sysmenu showing but I don't know how to make it do anything.

Again, this isn't something I have a need to get done.  It's just my way of better understanding this kind of structure.

Barry

pistol350

Hi Barry,
Could you please post what you've got so far ?
It may be helpful for anyone that wish to help.
Regards,

Peter B.

barry

I don't really have anything so far.  I've been looking at those two programs and trying to figure out how to proceed.  I don't know where to go with it.

Barry

Barney

If you can bear with me until I get back from the office I'll post something that might make your life easier. It took me sometime because I am not really working in Aurora but in EBasic, but I think I've managed to get it right.

Barney

barry

Thanks.  There's no rush on this.  It's just something I want to understand.

If you don't have an example already made, explanation might do me as well as an example.

Barry

Barney

Well... it took a bit longer than I anticipated due to the fact this was my first real entry into the Aurora world. Add the documentation that leaves a lot to be desired and it took almost a whole day of work to recreate what I already did in EBasic. Nevertheless, I must admit, during these two days I've grown to like what Aurora gives. If only the docs would be up to the usual technical standard I am used to, but that's something which will probably be solved one day. One hopes...

Mixing 3D stuff and GUI functions proved to be surprisingly easy. Even DirectInput played along nicely after I realized I need to use WAIT(1) function inside main 3D loop.

Program creates a standard 800 x 600 window, which can't be resized but can be minimized and restored. System menu is active as is the main menu and various buttons. You can exit the program in quite a few ways - by pressing the red X button, or by selecting Quit in the main menu, or by selecting Close in the System menu, or by clicking on the Quit button. Oh, yes. You can also press ESC anytime you want to exit. Plenty of choices, I'd say... ;) All the time there are two 3D screens active. The main one shows rather usual 3D scene where Moon orbits the Earth but take a closer look at Earth. It's a bit different than your average rotating Earth demo. Everything is enclosed in a Skysphere, which moves together with the camera, so don't worry, you'll never leave the boundaries of space and enter the BigBang continuum.

Program is still in very early development stage and represents just a quick proof of concept - not something of much use in real life. However, I'd still be happy if only one person finds it useful in learning how to use Aurora. EBasic version will probably follow soon, mainly for those of us who still prefer the good, old procedural approach to programming.

Attached is the ZIP file with exe, src and manifest files, together with all necessary media stuff. If you use XP themes, please use the manifest file. Everything looks so much better with themed buttons.



Here's the code:


// Aurora 3D example
// Created by Branko Spoljaric - Barney
// Based on Aurora and EBasic samples created by Paul Turley

declare import,timeGetTime(),int;
declare import,ZeroMemory alias RtlZeroMemory(pointer source,int size);
declare import,GetSysColor(int index),int;
const COLOR_BTNFACE = 15;

int run;

struct spritedata
{
float xPos; // Current X position
float yPos; // Current Y position
float xLimitLeft; // Left limit for horizontal movement
float xLimitRight; // Right limit for horizontal movement
float CurrentFrame; // Animation frame
int StartFrame; // Starting frame for animation
int EndFrame; // Last frame for animation
int dir; // Direction of sprite movement
int rotating; // Sprite rotation
float speed; // Movement speed
VECTOR2 scale; // Sprite size
uint modulate; // Modulation color/alpha
}

class myWin:CWindow
{
declare OnCreate(),int;
declare OnClose(),int;
declare OnControl(int nID, int nNotifyCode, unsigned int hControl),int;
declare OnMenuPick(int nID),int;
declare MoveSprite1();
declare MoveSprite2();
declare SetupSprite1();
declare SetupSprite2();
declare SetupMenu();
declare SetupScene1();
declare SetupScene2();
declare SetupControls();
C3DScreen s,s1;
C3DCamera c,c1;
C3DMesh mEarth,mMoon,mSkySphere;
C3DObject scene,scene1,oPivot;
C3DLight light,light1;
C3DSprite sprite,ghost1,ghost2;
CDirectInput di;
D3DMATERIAL matEarth,matMoon;
float fAspectRatio,fFOV;
spritedata sprite1,sprite2;
int l,t,w,h;
int w2,h2,w3,h3;
float fadjust,fTarget;
}

global sub main()
{
myWin win;
int swidth=800;
int sheight=600;
win.Create(-5000,-5000,swidth,sheight,AWS_CAPTION|AWS_MINIMIZEBOX|AWS_VISIBLE|AWS_SYSMENU,0,"3D Test - Two 3D screens - Many ways to exit the application",NULL);
win.SetWindowColor(GetSysColor(COLOR_BTNFACE));

// Setup menu (only Quit item active now)
win.SetupMenu();

// Calculate some useful positional values and store them for later use
rect rClientSize;
rClientSize=win.GetClientRect();
win.l=rClientSize.left; win.t=rClientSize.top;
win.w=rClientSize.right; win.h=rClientSize.bottom;
win.w2=win.w/2; win.w3=win.w/3; win.h2=win.h/2; win.h3=win.h/3;

win.SetupControls();

// We can create our main 3D window now. It will have no caption and single pixel border
// It is parented to main window (win)
win.s.CreateWindowed(win.l+10,win.t+10,win.w-20,win.h/3*2-20,AWS_BORDER|AWS_VISIBLE,0,"3DWindow",win,false);
win.s.Clear(0xFF0B86B8);
win.s.RenderScene();

// SetupScene1 sets 3D scene on the main 3D screen
win.SetupScene1();
// Create all necessary data for sprite1, which will move inside main 3D screen
win.SetupSprite1();

// We can create our second 3D window now. It will have no caption and single pixel border
// It is parented to main window (win)
win.s1.CreateWindowed(win.l+10,win.h3*2+128,win.w-20,win.h-(win.h3*2+120)-18,AWS_BORDER|AWS_VISIBLE,0,"",win,false);
win.s1.Clear(0xFF0B86B8);
win.s1.RenderScene();

// SetupScene1 sets 3D scene on the second 3D screen
win.SetupScene2();
// Create all necessary data for sprite2, which will move inside second 3D screen
win.SetupSprite2();

// Initialize direct input system
win.di.Init(win.s);

// Target 60FPS for camera movement
win.fTarget = 1.0f / /*FPS*/60.0f * 1000.0f;
win.fAdjust = 1.0f;

int fps = 0;
int startTime;

run = 1;
do
{
wait(1);

startTime = timeGetTime();
// Check for keys and move camera accordingly
if win.di.KeyDown(DIK_UP)
{
win.c.Move(0.0f,.25f * win.fAdjust);
if(win.scene.SphereCollided(win.c.GetPosition(),1.5f,true)) win.c.Move(0.0f,-.25f * win.fAdjust);
}
if win.di.KeyDown(DIK_DOWN)
{
win.c.Move(0.0f,-.25f * win.fAdjust);
if(win.scene.SphereCollided(win.c.GetPosition(),1.5f,true)) win.c.Move(0.0f,.25f * win.fAdjust);
}
if win.di.KeyDown(DIK_RIGHT) win.c.Rotate(1*.01745 * win.fAdjust,0,0);
if win.di.KeyDown(DIK_LEFT) win.c.Rotate(-1*.01745 * win.fAdjust,0,0);
if win.di.KeyDown(DIK_Z) win.c.Rotate(0,0,-1 *.01745 * win.fAdjust);
if win.di.KeyDown(DIK_X) win.c.Rotate(0,0,1 *.01745 * win.fAdjust);
if win.di.KeyDown(DIK_PRIOR) win.c.Rotate(0,-1 *.01745 * win.fAdjust,0);
if win.di.KeyDown(DIK_NEXT)win.c.Rotate(0,1 *.01745 * win.fAdjust,0);
if win.di.KeyDown(DIK_R) win.c.LookAt(0,0,0);

// Rotate earth and moon
win.mEarth.Rotate(0,-timeGetTime()/2000.0f,0);
win.oPivot.Rotate(45*.01745,timeGetTime()/2000.0f,0);
// Camera is always in the center of the skysphere
camPos=win.c.GetPosition();
win.mSkySphere.Position(camPos.x,camPos.y,camPos.z);
win.mSkySphere.Rotate(timeGetTime()/320000.0f,timeGetTime()/320000.0f,0);

// Clear 3D screen to very dark blue
win.s.Clear(RGBA(0,0,64,255));
// Draw the 3D scene
win.s.BeginScene(win.c);
win.scene.Draw();

// Move and draw sprite, which in reality is also 3D object
win.s.Begin2D();
win.MoveSprite1();
win.ghost1.Draw();
win.s.End2D();

// Render some text, which (unlike Blitz3D) does not mean any speed loss
win.s.RenderText(5,10,"FPS:"+NumToStr(fps),RGBA(255,255,0,255));
win.s.RenderText(5,30,"Use arrow keys to move around",RGBA(255,255,0,255));
win.s.RenderText(win.w-150,10,"FOV:"+NumToStr(win.fFOV,2),RGBA(0,255,0,255));

// Write FPS directly to static control
win.GetControl(9999)->SetText(NumToStr(fps));
// Finally render everything to the 3D screen
fps = win.s.RenderScene();
win.fAdjust = (timeGetTime() - startTime) / win.fTarget;

// Rendering stuff on 2nd 3D screen
win.s1.Clear(0xFF0B86B8);
// Move and draw sprite on 2nd screen
win.s1.RenderText(5,10,"This is second 3D screen!",RGBA(255,255,0,255));
win.s1.Begin2D();
win.MoveSprite2();
win.ghost2.Draw();
win.s1.End2D();
win.s1.RenderScene();
}until (win.di.KeyDown(DIK_ESCAPE) OR (run = 0));
// Housekeeping
win.scene.Free();
win.Destroy();
return 0;
}

// Method of the myWin class, called when window is about to be closed
myWin::OnClose(),int
{
run = 0;
return true;
}

// Method of the myWin class, called when window is created
// Used here to center the window on the desktop
myWin::OnCreate(),int
{
CenterWindow();
return true;
}

// Method of the myWin class, called when a control is activated
// Used here to test various GUI buttons
myWin::OnControl(int nID, int nNotifyCode, unsigned int hControl),int
{
if(nNotifyCode = 0)
{
select nID
{
CASE 1001:
run = 0;
CASE 1002:
sprite1.scale.x=1.0f;
sprite1.scale.y=1.0f;
sprite1.yPos=h3*2-50-32*(sprite1.scale.y-1);
CASE 1003:
sprite1.scale.x=2.0f;
sprite1.scale.y=2.0f;
sprite1.yPos=h3*2-50-32*(sprite1.scale.y-1);
CASE 1004:
sprite1.scale.x=3.0f;
sprite1.scale.y=3.0f;
sprite1.yPos=h3*2-50-32*(sprite1.scale.y-1);
CASE 1005:
sprite1.scale.x=4.0f;
sprite1.scale.y=4.0f;
sprite1.yPos=h3*2-50-32*(sprite1.scale.y-1);
CASE 1006:
sprite1.scale.x=5.0f;
sprite1.scale.y=5.0f;
sprite1.yPos=h3*2-50-32*(sprite1.scale.y-1);
CASE 1007:
fFOV=fFOV+0.1f;
c.SetFOV(fFOV);
CASE 1008:
fFOV=fFOV-0.1f;
c.SetFOV(fFOV);
CASE 1011:
ghost1.Load(s,GetStartPath()+"\\media\\ghost_0.bmp",32,32,8,0xFFFF00FF);
CASE 1012:
ghost1.Load(s,GetStartPath()+"\\media\\ghost_1.bmp",32,32,8,0xFFFF00FF);
CASE 1013:
ghost1.Load(s,GetStartPath()+"\\media\\ghost_2.bmp",32,32,8,0xFFFF00FF);
CASE 1014:
ghost1.Load(s,GetStartPath()+"\\media\\ghost_3.bmp",32,32,8,0xFFFF00FF);
CASE 1015:
ghost1.Load(s,GetStartPath()+"\\media\\ghost_4.bmp",32,32,8,0xFFFF00FF);
CASE 1018:
ghost1.Load(s,GetStartPath()+"\\media\\ghost_0.bmp",32,32,8,0xFFFF00FF);
sprite1.scale.x=1.0f;
sprite1.scale.y=1.0f;
sprite1.xPos=0;
sprite1.yPos=h3*2-50-32*(sprite1.scale.y-1);
sprite1.dir=1;

c.Position(0,0,-8);
c.Orient(0,0,1,0,1,0);
fFOV=1.4f;
c.SetFOV(fFOV);
}
}
return true;
}

myWin::OnMenuPick(int nID),int
{
select nID
{
case 4:
run = 0;
}
return true;
}

myWin::MoveSprite1()
{
INT iFrame;
// Frame animation
sprite1.CurrentFrame += .1 * fAdjust;
if (sprite1.CurrentFrame >= sprite1.EndFrame) sprite1.CurrentFrame = sprite1.StartFrame;

// Sprite movement
sprite1.xPos += sprite1.speed * fAdjust * sprite1.dir;
if (sprite1.xPos >= sprite1.xLimitRight)
{
sprite1.xPos = sprite1.xLimitRight;
sprite1.dir = -1;
sprite1.StartFrame=2;
sprite1.EndFrame=3;
}
if (sprite1.xPos < sprite1.xLimitLeft)
{
sprite1.xPos = sprite1.xLimitLeft;
sprite1.dir = 1;
sprite1.StartFrame=0;
sprite1.EndFrame=1;
}

// Transfer data to physical sprite
ghost1.SetFrame(sprite1.CurrentFrame);
ghost1.SetPosition(sprite1.xPos,sprite1.yPos);
ghost1.SetScaleFactor(sprite1.scale.x,sprite1.scale.y);
}

myWin::MoveSprite2()
{
INT iFrame;
// Frame animation
sprite2.CurrentFrame += .1 * fAdjust;
if (sprite2.CurrentFrame >= sprite2.EndFrame) sprite2.CurrentFrame = sprite2.StartFrame;

// Sprite movement
sprite2.xPos += sprite2.speed * fAdjust * sprite2.dir;
if (sprite2.xPos >= sprite2.xLimitRight)
{
sprite2.xPos = sprite2.xLimitRight;
sprite2.dir = -1;
sprite2.StartFrame=2;
sprite2.EndFrame=3;
}
if (sprite2.xPos < sprite2.xLimitLeft)
{
sprite2.xPos = sprite2.xLimitLeft;
sprite2.dir = 1;
sprite2.StartFrame=0;
sprite2.EndFrame=1;
}

// Transfer data to physical sprite
ghost2.SetFrame(sprite2.CurrentFrame);
ghost2.SetPosition(sprite2.xPos,sprite2.yPos);
ghost2.SetScaleFactor(sprite2.scale.x,sprite2.scale.y);
}

myWin::SetupSprite1()
{
// Initialize sprite data and create sprite with random movement speed
sprite1.xPos=0; sprite1.yPos=h3*2-50;
sprite1.xLimitLeft=0; sprite1.xLimitRight=w-64;
sprite1.CurrentFrame=0;
sprite1.StartFrame=0;
sprite1.EndFrame=1;
sprite1.dir=1;
sprite1.scale.x=1.0f; sprite1.scale.y=1.0f;
sprite1.speed=RND(0.8f,2.0f);
sprite1.modulate=RGBA(255,255,255,255);
ghost1.Load(s,GetStartPath()+"\\media\\ghost_0.bmp",32,32,8,0xFFFF00FF);
ghost1.SetPosition(sprite1.xPos,sprite1.yPos);
ghost1.SetFrame(sprite1.StartFrame);
ghost1.SetModulateColor(sprite1.modulate);
ghost1.SetScaleFactor(sprite1.scale.x,sprite1.scale.y);
}

myWin::SetupSprite2()
{
// Initialize sprite data and create sprite for 2nd 3D screen
sprite2.xPos=w-64; sprite2.yPos=5;
sprite2.xLimitLeft=0; sprite2.xLimitRight=w-64;
sprite2.CurrentFrame=0;
sprite2.StartFrame=0;
sprite2.EndFrame=1;
sprite2.dir=1;
sprite2.scale.x=1.0f; sprite2.scale.y=1.0f;
sprite2.speed=RND(0.8f,2.0f);
sprite2.modulate=RGBA(255,255,255,255);
ghost2.Load(s1,GetStartPath()+"\\media\\ghost_6.bmp",32,32,8,0xFFFF00FF);
ghost2.SetPosition(sprite2.xPos,sprite2.yPos);
ghost2.SetFrame(sprite2.StartFrame);
ghost2.SetModulateColor(sprite2.modulate);
ghost2.SetScaleFactor(sprite2.scale.x,sprite2.scale.y);
}

myWin::SetupScene1()
{
// Calculate aspect ratio of 3D screen and set camera FOV to initial value
fAspectRatio=((w-20)-(l+10))/((h/3*2-20)-(t+10));
fFOV=1.4f;

// Creating the camera and setting up initial parameters
c.Create(s);
c.Position(0,0,-8);
c.Orient(0,0,1,0,1,0);
c.SetBackPlane(1000);
c.SetAspectRatio(fAspectRatio);
c.SetFOV(fFOV);

// Clear the 3D screen to shade of light blue and draw a message
s.Clear(0xFF0B86B8);
s.BeginScene(c);
s.RenderText(0,10,"Camera created...",RGBA(255,255,0,255));
s.RenderScene();

// Creating earth
mEarth.CreateSphere(s,30,2.8f,false);
mEarth.LoadTexture(0,GetStartPath()+"\\media\\earthnight2.jpg",0);
mEarth.Position(0,0,0);
mEarth.EnableLighting(true);
mEarth.UseVertexColor(false);
s.RenderText(0,25,"Earth created...",RGBA(255,255,0,255));
s.RenderText(0,40,"Generating Octree...",RGBA(255,255,0,255));
s.RenderScene();
// Building an octree takes time but speeds up rendering and collision testing
mEarth.BuildOctree(500,4);
mEarth.InitCollision(false);

// Just playing with materials
ZeroMemory(matEarth,LEN(matEarth));
matEarth.diffuse.r = 1.0;
matEarth.diffuse.g = 1.0;
matEarth.diffuse.b = 1.0;
matEarth.diffuse.a = 0.8;
matEarth.ambient = matEarth.diffuse;
mEarth.SetMaterial(matEarth);
mEarth.UseVertexColor(false);
mEarth.EnableAlpha(true);
mEarth.SetAlphaOp(D3DBLENDOP_ADD);
mEarth.SetFill(FILL_SOLID);

// Creating moon
mMoon.CreateSphere(s,30,0.2f,false);
mMoon.LoadTexture(0,GetStartPath()+"\\media\\moontexture-02.jpg",0);
mMoon.Position(5,0,0);
s.RenderText(0,55,"Moon created...",RGBA(255,255,0,255));
s.RenderText(0,70,"Generating Octree...",RGBA(255,255,0,255));
s.RenderScene();
mMoon.BuildOctree(500,4);
mMoon.InitCollision(false);

// Playing with materials again
ZeroMemory(matMoon,LEN(matMoon));
matMoon.diffuse.r = 1.0;
matMoon.diffuse.g = 1.0;
matMoon.diffuse.b = 1.0;
matMoon.diffuse.a = 0.8;
matMoon.ambient = matMoon.diffuse;
mMoon.SetMaterial(matMoon);
mMoon.UseVertexColor(false);
mMoon.EnableAlpha(false);
mMoon.SetAlphaOp(D3DBLENDOP_ADD);

// Creating pivot for the moon rotation
oPivot.CreateTransform(s);

// Creating SkySphere, which will be moved in sync with camera
mSkySphere.CreateSphere(s,30,200,true);
mSkySphere.LoadTexture(0,GetStartPath()+"\\media\\Universe002.bmp",0);
mSkySphere.Position(0,0,0);
mSkySphere.SetVisible(true);
s.RenderText(0,85,"Moon pivot created...",RGBA(255,255,0,255));
s.RenderText(0,100,"SkySphere created...",RGBA(255,255,0,255));
s.RenderScene();

// Creating light
light.Create(s,LIGHT_POINT,1);
light.Position(0,20,-150);
light.SetAttenuation(0,1/200.0,0);
light.SetSpecular(.5,.5,.5,1);
light.SetAmbient(.4,.4,.4,1);

// Now we need to create scene and put objects in it
scene.CreateScene(s);
scene.AddChild(light);
scene.AddChild(mEarth);
oPivot.AddChild(mMoon);
scene.AddChild(oPivot);
scene.AddChild(mSkySphere);

s.RenderText(0,115,"Light created...",RGBA(255,255,0,255));
s.RenderText(0,130,"Scene objects added...",RGBA(255,255,0,255));
s.RenderScene();
}

myWin::SetupScene2()
{
// Creating the camera and setting up initial parameters for 2nd screen
c1.Create(s1);
c1.Position(0,0,-8);
c1.Orient(0,0,1,0,1,0);
c1.SetBackPlane(1000);

// Clear the 3D screen to shade of light blue and draw a message
s1.Clear(0xFF0B86B8);
s1.BeginScene(c1);
s1.RenderText(10,10,"This is 2nd 3D screen...",RGBA(255,255,0,255));
s1.RenderScene();

// Creating light
light1.Create(s1,LIGHT_POINT,1);
light1.Position(0,20,-150);
light1.SetAttenuation(0,1/200.0,0);
light1.SetSpecular(.5,.5,.5,1);
light1.SetAmbient(.4,.4,.4,1);

// Now we need to create scene and put objects in it
scene1.CreateScene(s1);
scene1.AddChild(light);
}

myWin::SetupMenu()
{
CMenu m;
m.BeginMenu();
m.MenuTitle("&File");
m.BeginPopup("Load");
m.MenuItem("Text file",0,100);
m.MenuItem("Word document",0,101);
m.MenuItem("RTF File",0,102);
m.EndPopup();
m.MenuItem("Close",0,2);
m.MenuItem("Save",0,3);
m.Separator();
m.MenuItem("Quit",0,4);
m.MenuTitle("Help");
m.MenuItem("Topics",0,254);
m.Separator();
m.MenuItem("About",0,255);
m.EndMenu();
SetMenu(m.Detach());
}

myWin::SetupControls()
{
// Let's create some controls
// Pressing this button will quit the application
AddControl(CTBUTTON,"Quit",w-130,h3*2+17+60,120,30,0x50000000,0x0,1001);

// This group controls the size (scale) of sprite
AddControl(CTGROUPBOX,"Sprite size:",10,h3*2,210,53,0x50000007,0x0,1009);
AddControl(CTBUTTON,"1",20,h3*2+17,30,30,0x50000000,0x0,1002);
AddControl(CTBUTTON,"2",60,h3*2+17,30,30,0x50000000,0x0,1003);
AddControl(CTBUTTON,"3",100,h3*2+17,30,30,0x50000000,0x0,1004);
AddControl(CTBUTTON,"4",140,h3*2+17,30,30,0x50000000,0x0,1005);
AddControl(CTBUTTON,"5",180,h3*2+17,30,30,0x50000000,0x0,1006);

// This one controls which sprite will be shown (pacman or one of four ghosts)
AddControl(CTGROUPBOX,"Sprite type:",10,h3*2+60,210,53,0x50000007,0x0,1010);
AddControl(CTBUTTON,"P",20,h3*2+17+60,30,30,0x50000000,0x0,1011);
AddControl(CTBUTTON,"G1",60,h3*2+17+60,30,30,0x50000000,0x0,1012);
AddControl(CTBUTTON,"G2",100,h3*2+17+60,30,30,0x50000000,0x0,1013);
AddControl(CTBUTTON,"G3",140,h3*2+17+60,30,30,0x50000000,0x0,1014);
AddControl(CTBUTTON,"G4",180,h3*2+17+60,30,30,0x50000000,0x0,1015);

// Status display box
AddControl(CTGROUPBOX,"FPS:",230,h3*2,60,53,0x50000007,0x0,1019);

// These buttons are controling camera FOV
AddControl(CTGROUPBOX,"FOV:",w-70-30,h3*2,90,53,0x50000007,0x0,1016);
AddControl(CTBUTTON,"+",w-70-20,h3*2+17,30,30,0x50000000,0x0,1007);
AddControl(CTBUTTON,"-",w-30-20,h3*2+17,30,30,0x50000000,0x0,1008);

// Pressing this button will restore 3D and sprite data
AddControl(CTBUTTON,"Reset",w2-30,h3*2+17+60,120,30,0x50000000,0x0,1018);

// Static control displays FPS value, which is also shown on 3D screen
AddControl(CTSTATIC,"1000",240,h3*2+24,48,20,0x50000000,0x0,9999);
}


Hope this will be of some use...

Barney

Ionic Wind Support Team

Looks like a very nice example program ;)
Ionic Wind Support Team

Barney

Feel free to use it in Aurora package, Paul.

I am planning to add more stuff into it so that people can see how powerful Aurora and the 3D system are. Any changes will be posted on the forum and you can put it into the package if you feel it deserves to be there.

Barney

barry

I just took a quick look and it looks like it does everything I was trying to do and more.  I'll now figure out how you did it. :)

This OOP stuff is just now how I'm used to thinking.  I did take a C++ course about 15 years ago (I was doing mostly C then) and I didn't really grasp it that well then.  I tried using it a little at work but it was taking too long and I had to get the job done so I dropped it.  I can follow the code and toy with what's there in the sample programs without much difficulty, as long as they're fairly straightforward programs but coming up with anything OOP on my own is hard.

I'll play with this and see what I can learn.  I suspect my first step will be to reduce a copy of it to it's basics and make a template for myself to do more playing with.

Thank you very much.

Barry

barry

A question: you declare the class myWin based on CWindow and declare all the functions or methods you use, but since those methods are already in CWindow isn't that enough?  Why do you also declare them?  Isn't OnClose() already declared when you declare the class?

Barry

Barney

Frankly, I pulled that stuff out from one of Paul's examples. If I remove the declares the program starts but nothing is shown on the screen. With the declares everything works as it should. For me, it's kind of, logical to have the declares in order to be able to override whatever is defined in place of those functions in the original CWindow class.

Barney

barry

Okay, thanks.  I'll keep playing.

Barry

barry

A couple more questions, too.

The Earth has some bands around it that you don't see in the bitmap.  There seems to be a fairly wide band of lighter blue along the equator and a little narrower one going vertically through the USA and another vertical one going through Africa.  They're hard to see with the current dark texture but they can be seen.  Lightening the texture or using a totally different but lighter bitmap for the texture makes them more obvious.  It seems to be happening in the render and not coming from the bitmap.  Any idea what the cause might be?

Also in the CreateSphere() method theres a boolean paramater called bInside that isn't explained.  Do you know what it is?  Could that be prevent it being drawn on the inside?

Thanks,
Barry

Bruce Peaslee

Quote from: Barney on September 10, 2007, 07:23:10 PM
Frankly, I pulled that stuff out from one of Paul's examples. If I remove the declares the program starts but nothing is shown on the screen. With the declares everything works as it should. For me, it's kind of, logical to have the declares in order to be able to override whatever is defined in place of those functions in the original CWindow class.

Barney
That's right. Some of the base class methods do nothing and others might needed something added or overridden.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

ExMember001


Barney

Quote from: barry on September 10, 2007, 09:06:12 PM
A couple more questions, too.

The Earth has some bands around it that you don't see in the bitmap.  There seems to be a fairly wide band of lighter blue along the equator and a little narrower one going vertically through the USA and another vertical one going through Africa.  They're hard to see with the current dark texture but they can be seen.  Lightening the texture or using a totally different but lighter bitmap for the texture makes them more obvious.  It seems to be happening in the render and not coming from the bitmap.  Any idea what the cause might be?

The "Earth by night" bitmap can be found all over the web and I did not change anything on it. The bands may come from the number of slices the sphere is created from. Try to increase the number of slices and see what happens.

QuoteAlso in the CreateSphere() method theres a boolean paramater called bInside that isn't explained.  Do you know what it is?  Could that be prevent it being drawn on the inside?

That parameter is responsible for the culling of the sphere. If set to false, a standard sphere will be created i.e. it will be visible from outside the sphere. If you set it to true the sphere would be "inverted" or turned "inside out". So, if you put the texture on such "inverted" sphere you'll be able to see it but only from the inside of the sphere. I used the true valuie for the bInside while creating a Skysphere, which represents the space background. We (our camera) are inside that particular sphere so it has to be inverted in order for us to see the "universe" texture.

Barney

barry

Quote from: peaslee on September 10, 2007, 09:24:33 PM
Quote from: Barney on September 10, 2007, 07:23:10 PM
Frankly, I pulled that stuff out from one of Paul's examples. If I remove the declares the program starts but nothing is shown on the screen. With the declares everything works as it should. For me, it's kind of, logical to have the declares in order to be able to override whatever is defined in place of those functions in the original CWindow class.

Barney
That's right. Some of the base class methods do nothing and others might needed something added or overridden.

So do I declare just the methods that I'm going to change or add something to?  And if I do override a method does my new method replace the original method or is it additional functionality added to the original method?  In other words, do I lose the original method's functionality if I don't provide it in the new method?

Barry

barry

Quote from: Barney on September 11, 2007, 02:02:14 AM
The "Earth by night" bitmap can be found all over the web and I did not change anything on it. The bands may come from the number of slices the sphere is created from. Try to increase the number of slices and see what happens.

I did find it and others the same size that are brighter and seem to work as well.  But they show up those bands better.  I'll play with the slices and see what happens.

QuoteThat parameter is responsible for the culling of the sphere. If set to false, a standard sphere will be created i.e. it will be visible from outside the sphere. If you set it to true the sphere would be "inverted" or turned "inside out". So, if you put the texture on such "inverted" sphere you'll be able to see it but only from the inside of the sphere. I used the true valuie for the bInside while creating a Skysphere, which represents the space background. We (our camera) are inside that particular sphere so it has to be inverted in order for us to see the "universe" texture.

This gives me a bunch of stuff to play with and learn.  I do appreciate it.

Barry

Barney

September 11, 2007, 09:58:36 AM #19 Last Edit: September 11, 2007, 10:01:08 AM by Barney
Quote from: barry on September 11, 2007, 05:40:00 AM
So do I declare just the methods that I'm going to change or add something to?  And if I do override a method does my new method replace the original method or is it additional functionality added to the original method?  In other words, do I lose the original method's functionality if I don't provide it in the new method?

The way I see it, the method must be defined in the base class in order for you to be able to override it. If there's nothing in there in the first place than there's nothing to override. As peaslee said, some of the base class methods do nothing, so obviously they are there just to be overridden if you need it.  I also think, if you override a method, you are then responsible for that particular method i.e. you are in control and not the in-built method. Actually, you can test it. Create a base class of your own put a method in that does something and then override that method and see what will happen. The best way to learn. By example. :)

Uh, oh. This is not good. Barry, you are pushing me into the OOP world. Me, the old, conservative, procedural dinosaur... ;)

Barney

barry

I sure agree about procedural programming.  This OOP stuff is weird.  But I want to play with the 3D and that's what the samples are in so here I go.  I'll do everything as procedural as I can because that's what I know.  But right now I'm modifying what's here to learn something about the 3D.

I don't think I'll do any OOP experimenting at the moment. I want to give the little energy I have right now to 3D but I may experiment with OOP later.

Something else, if you know:  what does BuildOctree actually do?

Also I played with the bands parameter to get rid of the banding on the Earth and I found that setting it to 15 seems to fix it, but the Earth isn't very round if I look close.  Any other number makes banding, including multiples of 15  That's okay for now but I just wonder if you have any idea what's going on?  And I thought that BuildOctree might have a clue.

I'm not trying to turn you into my teacher, by the way.  I'm curious and you have some answers so I'm taking advantage but please don't spend any time on this and if the answers stop or slow down my feelings won't be hurt.

Barry

Barney

I'll answer when I know the answer, or when I think I know the answer. I'll just warn you that I might be wrong, as I am learning, too. Remember that this was my first real Aurora program, so there's plenty for me to learn and discover. Actually, regarding OOP stuff, I suggest you read the OOP part of the help manual for EBasic. It's an excellent read and I can only hope all Aurora and EBasic help would be of that quality. It describes everything with great clarity and since Paul created both OOP implementations I am sure you can easily adapt it to Aurora's way of doing things.

Octree or octtree as it is sometimes (erroneously) called, is a data structure describing a 3D object in 3D space. The structure looks like a tree but each node has 8 branches, not the 2 like in the ubiquitous binary tree. Imagine a cube in 3D space and divide it internally into eight smaller cubes. Those cubes are now representing the big cube and can be used for all sorts of things, one of them being the collision between two 3D objects. A simple one level octree may be enough for a cube, but when object gets more complex you need to go deeper and basically subdivide object's volume into smaller and smaller cubes. The more cubes you have, the better they will represent the actual shape of your 3D object(s) with a net effect that the collisions between 3D objects will be more precise. However, one always must think of speed and memory and other problems, so there must be a limit how deep you want to go. That's the second parameter of the BuildOctree() method. The first parameter I believe is the maximal number of polygons that will be considered while creating the octree cubes. I may be wrong on this one. Rule of the thumb is that you need to build octree for all (?) objects as it will speed up rendering but enable collision testing only for those objects that really need it.

Barney

barry

Again, thanks for the help.  I'll take a look at the OOP help stuff for Ebasic.

Barry

J B Wood (Zumwalt)

bInside is supposed to be inversion, what I mean to say, is that if you have the camera inside the sphere and a light in the sphere, and an image mapped to the sphere with bInside to true, the image is placed facing inward on the inside of the sphere vs outside. Although I haven't used the function yet.