Jamagic Notation Standards CommitteeNINE CAMERA VIEWS EXAMPLE

This open source code creates nine child windows, each one with a different camera view from the same world.

If you do any changes to this source code, please send it to me!

Nine Camera Views into nine child windows

//Nine-view example by Giovanni@Cardona.com oct. 26
//This source code make use of the JNSC1.0 standards

//IMPORTANT: Delete the initialization window (defaultwin)!
//Be my guest and optimize this code, and let me know about
//any changes you made, ok?
//Make the proper changes in the Settings of the project
//to set the processor usage to 100%, etc.

//set this line with your favorite display interface :)
//Display.SetDisplayInterface(Display.DIRECT3D);

//Initialize variables
Var winMainWindow = New Window(480,360,160,120,GetRGB(255,255,255),16,"Nine-Views by Giovanni@Cardona.com",Window.TOOL);
	winMainWindow.WriteLn("Press button to create 9 child windows, each one");
	winMainWindow.WriteLn("will be assigned to render a different camera view");	
	winMainWindow.WriteLn("from the 9 cameras created in a single world.");
	winMainWindow.WriteLn("");
	winMainWindow.WriteLn("Try creating a single child window with other 3D creation tools! :)");	
	winMainWindow.SetAutoRefresh(OFF);
	
	//Button routines (create, wait for click, delete)
	winButton = New Button(winMainWindow,"GO!",200,100,64,32);
	winButton.OnClick()=ButtonClicked;	
	
	booTRUE = FALSE;
	While (booTRUE!);	
	Delete winButton;
	
	Function ButtonClicked(){
	Return booTRUE = TRUE; }

Var winViewWin = 0;	
Var camCamera = 0;
Var intCounter = 0;

//Create 9 child windows
For (intCounter = 0; intCounter != 3; intCounter++)
{
	winViewWin[intCounter] = New Window(160,120,160*intCounter,0,winMainWindow,Window.GAME);
	winViewWin[intCounter].SetAutoRefresh(OFF);
	winViewWin[intCounter+3] = New Window(160,120,160*intCounter,120,winMainWindow,Window.GAME);
	winViewWin[intCounter+3].SetAutoRefresh(OFF);
	winViewWin[intCounter+6] = New Window(160,120,160*intCounter,240,winMainWindow,Window.GAME);
	winViewWin[intCounter+6].SetAutoRefresh(OFF);		
}

//Create the world
objWorld = New World();
camCamera = New Camera(objWorld);

//Create 9 cameras, set position and focus
For(intCounter = 0; intCounter != 3; intCounter++)
{
	camCamera[intCounter] = New Camera(objWorld,winViewWin[intCounter]);
	camCamera[intCounter].SetFocus(80);
	camCamera[intCounter].Set(0,0,-100);
	camCamera[intCounter+3] = New Camera(objWorld,winViewWin[intCounter+3]);
	camCamera[intCounter+3].SetFocus(40);
	camCamera[intCounter+3].Set(0,0,-200);
	camCamera[intCounter+6] = New Camera(objWorld,winViewWin[intCounter+6]);
	camCamera[intCounter+6].SetFocus(20);
	camCamera[intCounter+6].Set(0,0,-400);	
}

//Create simple objects into the world!
//put some other objects if you want
matSphereMat = New Material(objWorld,GetRGB(255,0,0));
objSphere = objWorld.CreateSphere(100,100,100,10,10);
objSphere.ApplyMaterial(matSphereMat);
objSphere.SetGouraud(ON);
objSphere.SetFlat(ON);
objSphere.Set(0,0,500);

matCubeMat = New Material(objWorld,GetRGB(0,0,255));
objCube = objWorld.CreateBrick(10,10,10);
objCube.ApplyMaterial(matCubeMat);
objCube.SetGouraud(ON);
objCube.SetFlat(ON);

//Move the cube around the sphere to show something moving!
objCube.MoveAround(objSphere,10);

//Create different kind of movements for each camera
//Set each camera to different views or movements
camCamera[0].Walk();
camCamera[1].Follow(objCube,120,30);
camCamera[2].MoveAround(objSphere,100);
camCamera[3].Walk();
camCamera[4].Follow(objCube,240,20);
camCamera[5].MoveAround(objSphere,100);
camCamera[6].Walk();
camCamera[7].Follow(objCube,360,10);
camCamera[8].MoveAround(objSphere,100);

//switch cameras in each view
While(booTRUE)
{
	For (intCounter = 0; intCounter != 3; intCounter++)
	{
		camCamera[intCounter].ActivateRender();
		winViewWin[intCounter].Refresh();
		camCamera[intCounter+3].ActivateRender();
		winViewWin[intCounter+3].Refresh();		
		camCamera[intCounter+6].ActivateRender();
		winViewWin[intCounter+6].Refresh();			
	}
}

 


(c)2001 Giovanni Cardona
Jamagician Extraordinarie