Each object, when loaded in DarkBASIC, is completely white. It has no colors. But you can texture them using images exported at the time of exporting them.
In short, there are 3 steps
- Load Object
- Load Image
- Texture the Object with Image
load object "path or filename",ObjID
load image "path or filename",ImgID
texture object ObjID,ImgID
ObjID & ImgID are also integers as MatrixID. All of them are different from each other, so you can use similar IDs for relevent files.
load object "car.x",1
load image "car.jpg",1
texture object 1,1
and you have a colored car!
They also have similar commands like camera. The only difference is that we have to provide the ID of the object we want to work with.
Move Object ObjID,Distance#
Turn Object Left ObjID,Angle#
Turn Object Right ObjID,Angle#
Pitch Object Up ObjID,Angle#
Pitch Object Down ObjID,Angle#
Object position x(ObjID)
Object position y(ObjID)
Object position z(ObjID)
Position Object ObjID,x#,y#,z#
And some additional commands like
hide object ObjID
show object ObjID
Now, say you are moving your car but your camera won't follow it, how to do that?
One way is to find the object positions and reposition your camera with values decreased by lets say 10 (Camera Distance) and y value increased by 5 (Camera Height).
But even after that it is not necessary that camera is facing the object itself. It may be facing some other direction. So we must rotate it in a manner that it points the object we are following.
For that we can use
Point Camera x#,y#,z#
whare the co-ordinates are those of the object.
This is the called logic.