CPP - Extended 3D Horde Language
From Global Programming Syntax
Status note: The python script has been embeded into cwarn23's 3D Blender ready for basic model exports such as a cube, cylinder etc.
Contents |
Up to date design
Creates a 3D object. Below is the usage example:
//object name
obj_create("my first object");
object_id
//position
obj_setposition("my first object",300,200,25);
// object_id x y z
//texture, - transparency percentage
obj_texture("my first object","mytexture.jpg", 50);
// object_id texture transparency
//shape template, - solid boundaries enabled
obj_shape("my first object","cube",true);
// object_id shape, boundaries
//override shape template with custom and make
//object have no boundaries
obj_shape("my first object","shape.obj",false);
// object_id object boundaries
//Solid boundaries physics properties
obj_solid("my first object",true,"object solid to");
//In the above function, the first parameter is the current object id is
//while the second enables solid boundaries. Then the rest third parameter
//determines what the object it is solid to. If however the third
//paramater is blank then it is solid to all other solid objects.
myobject.obj_solid("my first object",true,"");
//So with the above line, the object would be solid to all other solid objects
//shape size
obj_size("my first object",20,30,25);
// object_id x y z
//rotate in degrees
obj_rotate("my first object",45,45,0);
// object_id x y z
Previous design
update_3d_object() provides the same functionality as create_3d_object except instead of creating a new object it updates an existing object.
OBJECT myobject;
//object name
myobject.obj_name("my first object");
//position
myobject.obj_position(300,200,25);
// x y z
//texture, - transparency percentage
myobject.obj_texture("mytexture.jpg", 50);
// texture transparency
//shape template, - solid boundaries enabled
myobject.obj_shape("cube",true);
//override shape template with custom and make
//object have no boundaries
myobject.obj_shape("shape.obj",false);
//Solid boundaries physics properties
myobject.obj_solid(true,"object solid to","object 2 solid to",
"object 3 solid to etc.");
//In the above function, the first parameter enables solid boundaries while
//the rest of the parameters determine what objects it is solid to. To
//identify objects, the obj_name input is used to identify each object. These
//identifications are used in the 2nd, 3rd, 4th etc parameters to determin
//what objects the this object is solid with. The number of parameters is
//unlimited to specify unlimited objects and below is an example for an
//object to be solid to all other objects.
myobject.obj_solid(true,"");
//So with the above line, the object would be solid to all other solid objects
//shape size
myobject.obj_size(20,30,25);
// x y z
//rotate in degrees
myobject.obj_rotate(45,45,0);
// x y z
//-----------------------
//process the above data
update_3d_object(&myobject);
Events Engine
For the events engine, use a function to determine if an event has occured. An example is the following:
if (mouse_x()==400 && mouse_y()==300) {
int var = getobj_position_z("my first object");
var = var+1;
OBJECT myobject
myobject.obj_name("my first object");
myobject.obj_position(NULL,NULL,var);
update_3d_object(myobject);
}
David's tut for OOP
sorry, this isn't as good as i'd hope it would be as it almost makes C++ look bad, but see what u think.
// I want to create a city full of skyscrapers, each a different height.
// firstly, we hire an architect to create a blue-print for it,
// We will call this blue-print a class
// To save costs, we'll use that same design for every tower in the city,
// but we'll change the height of some to add variety
class CityTower
// the insides of the blueprint:
{
// internal data, don't want it to be messed around with unexpectedly, so private,
private:
// the tower should have this information
int x, y; // place in the world
int height; // height of the tower
// we'll make this function return a random value
int getRandomPlaceInCity ();
// we'll give other people the ability to interact with us
public:
CityTower (); // this function is automatically called when the tower is created
SetHeight (int newheight);
};
// when the tower is created it should do this
CityTower:: CityTower ()
{
x = getRandomPlaceInCity ();
y = getRandomPlaceInCity ();
height = 100; // metres
}
// this is the SetHeight method
CityTower:: SetHeight (int newheight)
{
height = newheight;
}
int getRandomPlaceInCity ()
{
// I won't bother putting the insides here.
}
// ok now to create them all
CityTower tower [200];
int main ()
{
// set some individual towers
tower[0].SetHeight( 200 );
tower[1].SetHeight( 300 );
tower[20].SetHeight( 400 );
tower[10].SetHeight( 150 );
tower[3].SetHeight( 175 );
// set the 50th tower, the 60th tower, the 70th tower.... etc, the 149th tower, the 150th tower. All to 160.
for (int i = 50; i<150; ++i)
{
tower[i].SetHeight( 160 );
}
}
This is how i would do it (David):
Object3D myobject;
//position
myobject.x=300;
myobject.y=200;
myobject.z=25;
//texture
myobject.SetTexture ("mytexture.jpg");
//shape template
myobject.SetShape ("cube");
//override shape template with custom
myobject.SetShape ("shape.obj");
//shape size
myobject.size_x=20;
myobject.size_y=30;
myobject.size_z=25;
//rotate in degrees
myobject.rotate_x=45;
myobject.rotate_y=45;
myobject.rotate_z=0;
//-----------------------
//process the above data
process_3d_object(&myobject);
