MiniB3d for FreeBasic

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
D.J.Peters
Posts: 8631
Joined: May 28, 2005 3:28
Contact:

Re: MiniB3d for FreeBasic

Post by D.J.Peters »

Why are the most Stencil declares are functions? (they are sub's exept CreateStencil)
The declare of StencilMode() is wrong also (one param are missing).
and why is param stencil operator not used in sterncil.cpp ?

Joshy

Code: Select all

void Stencil::StencilMode(int m, int o){
  stencil_mode=m;
  stencil_operator=1;
}
the stencil_operator is 1 allways ?

Code: Select all

	switch (stencil_operator){
	case 0:
		glStencilFunc(GL_NOTEQUAL, stencil_mode + midStencilVal, 0xffffffff);  // We Draw Only Where The Stencil Is Not Equal to stencil_mode
		break;
	case 1:
		glStencilFunc(GL_EQUAL, stencil_mode + midStencilVal, 0xffffffff);     // We Draw Only Where The Stencil Is Equal to stencil_mode
		break;
	case 2:
		glStencilFunc(GL_LEQUAL, stencil_mode + midStencilVal, 0xffffffff);    // We Draw Only Where The Stencil Is Smaller or Equal to stencil_mode
		break;
	case 3:
		glStencilFunc(GL_GEQUAL, stencil_mode + midStencilVal, 0xffffffff);    // We Draw Only Where The Stencil Is Greater or Equal to stencil_mode
		break;
	}
angros47
Posts: 2387
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Post by angros47 »

Thank you, I'll check.

Maybe the error in setting stencil_operator is a test I made for debugging purposes... and I've forgot to set it to the correct behavior.
angros47
Posts: 2387
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Post by angros47 »

About AlignToVector: a stub is implemented in entity.cpp, but it's untested (I ported it from an example for blitzmax)

Keyframes are not yet implemented (for now, the option to create animation sequences is available only to be able to set animation time even on static meshes... I needed it in one program)
Kronos
Posts: 9
Joined: Dec 10, 2012 19:53

Re: MiniB3d for FreeBasic

Post by Kronos »

A couple of issues I have noticed.

1/ Createplane only ever creates a plane with 1 subdivision regardless of the number entered.
2/ When CreateShadow option for static shadows is set to true it does not always seem to create a shadow for that object or if it does it isn't visible.
3/ When hideentity is used on a shadowed object the shadow does not get hidden.


and a couple of requests.

1/ Can shadow range be independant of light range or even better linked to camera instead as I think this is more practical.
2/ Ability to disable a light from casting shadows. At the moment it seems shadows are created for all lights by default. This may be due to what lights are currently active when shadows are created I'm not sure.
D.J.Peters
Posts: 8631
Joined: May 28, 2005 3:28
Contact:

Re: MiniB3d for FreeBasic

Post by D.J.Peters »

I created and test DrawText2D and DrawText3D.
(lib ftgl https://sourceforge.net/apps/mediawiki/ ... =Main_Page)

Joshy
Image

Code: Select all

chdir exepath & "/media/"
LoadFont2D("vera.ttf")
LoadFont3D("vera.ttf")
...
RenderWorld()
frames+=1
DrawText3D("frame: " & str(frames),-100,0,-150)
DrawText2D("frame: " & str(frames),0,0)
...
D.J.Peters
Posts: 8631
Joined: May 28, 2005 3:28
Contact:

Re: MiniB3d for FreeBasic

Post by D.J.Peters »

the order of poping the matrixes are wrong in void ShadowObject::ShadowRenderWorldZFail()

Code: Select all

// NOTE: is it the projektion matrix ?
glPushMatrix();
  glLoadIdentity();
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
    glLoadIdentity();
    ...
  glPopMatrix();
  // NOTE: is it the projektion matrix ?
  glMatrixMode(GL_MODELVIEW); 
glPopMatrix();
should be

Code: Select all

// NOTE: is it the projektion matrix ?
glPushMatrix(); // proj. matrix
  glLoadIdentity();
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix(); // mod. matrix
    glLoadIdentity();
    ...
  glPopMatrix(); // restore mod.. matrix
  
glMatrixMode(GL_PROJECTION);
glPopMatrix(); // restore proj. matrix
// switch back to mod. matrix
glMatrixMode(GL_MODELVIEW);
by the way you should restore a more friendly material after the shadow pass also.

Code: Select all

	    float mat_ambient[]={ShadowRed,ShadowGreen,ShadowBlue,.5};
	    float mat_diffuse[]={0,0,0,0.5};
	    float mat_specular[]={0,0,0,0.5};
	    float mat_shininess[]={0.0}; // upto 128

	    glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambient);
	    glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffuse);
	    glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
	    glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
If a openb3d user will render any own things (text in my case) after RenderWorld()
the last material properties from shadow pass are not so fine.

Joshy
Last edited by D.J.Peters on Dec 10, 2012 22:41, edited 1 time in total.
D.J.Peters
Posts: 8631
Joined: May 28, 2005 3:28
Contact:

Re: MiniB3d for FreeBasic

Post by D.J.Peters »

I will share my own version of openb3d.bi here.

It's sorted by categories and I added all missing enum's.

Joshy

Code: Select all

#ifndef __OPENB3D_BI__
#define __OPENB3D_BI__

#include once "GL/gl.bi"
#include once "GL/glu.bi"

#inclib "openb3d"

#ifndef _DS_
#define _DS_ declare sub 
#endif

#ifndef _DF_
#define _DF_ declare function 
#endif

' collisions
enum COLLISION_METHODS
  COLLISION_METHOD_ELLIPSOID = 1
  COLLISION_METHOD_POLYGONE
  COLLISION_METHOD_BOX
end enum

enum COLLISION_RESPONCES
  COLLISION_RESPONCE_NO = 0
  COLLISION_RESPONCE_STOP
  COLLISION_RESPONCE_SLIDE1 ' full sliding collision
  COLLISION_RESPONCE_SLIDE2 ' prevent entities from sliding down slopes
end enum

' brushes
enum BRUSH_FLAGS
  BRUSH_FLAG_COLOR      =  1 ' (default)
  BRUSH_FLAG_ALPHA      =  2
  BRUSH_FLAG_MASKED     =  4
  BRUSH_FLAG_MIPMAPPED  =  8 
  BRUSH_FLAG_CLAMPU     = 16 
  BRUSH_FLAG_CLAMPV     = 32
  BRUSH_FLAG_SPHERICAL  = 64
end enum

enum BRUSH_BLEND_MODES
  BRUSH_BLEND_MODE_ALPHA = 1 ' (default)
  BRUSH_BLEND_MODE_MULTIPLY
  BRUSH_BLEND_MODE_ADD
end enum

enum BRUSH_FX_MODES
  BRUSH_FX_MODE_NOTHING           =  0 '(default)
  BRUSH_FX_MODE_FULLBRIGHT        =  1
  BRUSH_FX_MODE_VERTEXCOLOR       =  2
  BRUSH_FX_MODE_FLATSHADED        =  4
  BRUSH_FX_MODE_NOFOG             =  8
  BRUSH_FX_MODE_NOBACKFACECULLING = 16
  BRUSH_FX_MODE_ALPHABLENDING     = 32 ' only for Entity
end enum

' lights
enum LIGHT_TYPES
  LIGHT_TYPE_DIRECTIONAL = 1 '(default)
  LIGHT_TYPE_POINT
  LIGHT_TYPE_SPOT
end enum  

' sprites
enum SPRITE_VIEW_MODES
  SPRITE_VIEW_MODE_FIXED = 1 ' (sprite always faces camera - default)
  SPRITE_VIEW_MODE_FREE      ' (sprite is independent of camera)
  SPRITE_VIEW_MODE_UPRIGHT1  ' (sprite always faces camera, but rolls with camera as well, unlike mode no.1)
  SPRITE_VIEW_MODE_UPRIGHT2  ' (sprite always remains upright. Gives a 'billboard' effect. Good for trees, spectators etc.)
end enum

' textures
enum TEXTURE_BLEND_MODES
  TEXTURE_BLEND_MODE_NO = 0
  TEXTURE_BLEND_MODE_NO_ALPHA  ' (alpha when texture loaded with alpha flag)
  TEXTURE_BLEND_MODE_MULTIPLY  ' (default)
  TEXTURE_BLEND_MODE_ADD
  TEXTURE_BLEND_MODE_DOT3 
  TEXTURE_BLEND_MODE_MULTIPLY2
end enum

enum TEXTURE_COORD_SETS
  TEXTURE_COORD_SET_FIRST = 0 ' (default)
  TEXTURE_COORD_SET_SECOND
end enum

enum TEXTURE_CUBE_FACES
  TEXTURE_CUBE_FACE_LEFT = 0 ' (negative X) face
  TEXTURE_CUBE_FACE_FORWARD  ' (positive Z) face - (default)
  TEXTURE_CUBE_FACE_RIGHT    ' (positive X) face
  TEXTURE_CUBE_FACE_BACKWARD ' (negative Z) face
  TEXTURE_CUBE_FACE_UP       ' (positive Y) face
  TEXTURE_CUBE_FACE_DOWN     ' (negative Y) face
end enum

enum TEXTURE_CUBE_MODES
  TEXTURE_CUBE_MODE_SPECULAR = 1 '(default)
  TEXTURE_CUBE_MODE_DIFFUSE
  TEXTURE_CUBE_MODE_REFRATION
end enum  

enum TEXTURE_FLAGS
  TEXTURE_FLAG_COLOR           =   1 '(default)
  TEXTURE_FLAG_ALPHA           =   2 
  TEXTURE_FLAG_MASKED          =   4
  TEXTURE_FLAG_MIPMAPPED       =   8
  TEXTURE_FLAG_CLAMPU          =  16
  TEXTURE_FLAG_CLAMPV          =  32
  TEXTURE_FLAG_SPHERICAL       =  64
  TEXTURE_FLAG_CUBIC           = 128 
  TEXTURE_FLAG_STORE_VRAM      = 256
  TEXTURE_FLAG_FORCE_HIGHCOLOR = 512
end enum

' entities
enum ENTITY_PICK_MODES
  ENTITY_PICK_MODE_UNPICKABLE = 0 ' (default)
  ENTITY_PICK_MODE_SPHERE         ' (EntityRadius is used)
  ENTITY_PICK_MODE_POLYGONE
  ENTITY_PICK_MODE_BOX            ' (EntityBox is used)
end enum

enum ENTITY_ANIM_MODES
  ENTITY_ANIM_MODE_STOP = 0 
  ENTITY_ANIM_MODE_LOOP      ' (default)
  ENTITY_ANIM_MODE_PING_PONG
  ENTITY_ANIM_MODE_ONE_SHOT
end enum

' cameras
enum  CAMERA_PROJECTION_MODES
  CAMERA_PROJECTION_MODE_NO = 0      ' disables camera (faster than HideEntity)
  CAMERA_PROJECTION_MODE_PERSPECTIVE ' (default)
  CAMERA_PROJECTION_MODE_OTHOGRAPHIC
end enum

enum  CAMERA_FOG_MODES
  CAMERA_FOG_MODE_NO = 0 '(default)
  CAMERA_FOG_MODE_LINEARE
end enum

' meshes
enum CSG_METHODS
  CSG_METHOD_SUBTRACTION = 0
  CSG_METHOD_UNION          ' (default)
  CSG_METHOD_INTERSECTION
end enum

' stencil
enum STENCIL_MODES
  STENCIL_MODE_CULL_INCR = -2
  STENCIL_MODE_DECR = -1
  STENCIL_MODE_INCR = 1
  STENCIL_MODE_CULL_DECR = 2
end enum  

enum STENCIL_OPERATORS
  STENCIL_OPERATOR_NOT_EQUAL = 0
  STENCIL_OPERATOR_EQUAL
  STENCIL_OPERATOR_SHORTER_EQUAL
  STENCIL_OPERATOR_GREATER_EQUAL
end enum

extern "c"

' GLOBAL
_DF_ Graphics3D  (w as integer, h as integer, depth as integer=0, mode as integer=0, rate as integer=60) as integer
_DF_ AntiAlias   (samples as integer) as integer
_DF_ Wireframe   (enable as integer) as integer

_DF_ AmbientLight(r as single, g as single, b as single) as integer
_DF_ ClearTextureFilters () as integer

_DF_ RenderWorld() as integer
_DF_ UpdateWorld (anim_speed as single=1) as integer
_DF_ ClearWorld (entities as integer=1, brushes as integer=1, textures as integer=1) as integer

_DF_ Collisions(src_no as integer, dest_no as integer, method as COLLISION_METHODS, response as COLLISION_RESPONCES=0) as integer

' tools (texture)
_DF_ BackBufferToTex(tex as any ptr, frame as integer=0) as integer
_DF_ BufferToTex    (tex as any ptr, buffer as any ptr, frame as integer) as integer
_DF_ TexToBuffer    (tex as any ptr, buffer as any ptr, frame as integer) as integer
_DS_ CameraToTex    (tex as any ptr, cam as any ptr, frame as integer=0)

' math
_DF_ VectorPitch(vx as single, vy as single, vz as single) as single
_DF_ VectorYaw  (vx as single, vy as single, vz as single) as single

' BRUSH
_DF_ LoadBrush  (file as zstring ptr, flags as BRUSH_FLAGS = BRUSH_FLAG_COLOR, u_scale as single=1, v_scale as single=1) as any ptr
_DF_ CreateBrush(r as single=255, g as single=255, b as single=255) as any ptr
_DF_ FreeBrush  (brush as any ptr) as integer

_DF_ BrushColor     (brush as any ptr, r as single, g as single, b as single) as integer
_DF_ BrushAlpha     (brush as any ptr, a as single) as integer
_DF_ BrushShininess (brush as any ptr, s as single) as integer
_DF_ BrushBlend     (brush as any ptr, BlendMode as BRUSH_BLEND_MODES = BRUSH_BLEND_MODE_ALPHA) as integer
_DF_ BrushFX        (brush as any ptr, FXMode as BRUSH_FX_MODES = BRUSH_FX_MODE_NOTHING) as integer
_DF_ BrushTexture   (brush as any ptr, tex as any ptr, frame as integer=0, index as integer=0) as integer
_DF_ GetBrushTexture(brush as any ptr, index as integer=0) as any ptr

' CAMERA
_DF_ CreateCamera   (parent as any ptr=0) as any ptr
_DF_ CameraClsColor (cam as any ptr, r as single, g as single, b as single) as integer
_DF_ CameraClsMode  (cam as any ptr, cls_depth as integer, cls_zbuffer as integer) as integer
_DF_ CameraFogColor (cam as any ptr, r as single, g as single, b as single) as integer
_DF_ CameraFogMode  (cam as any ptr, mode as CAMERA_FOG_MODES) as integer
_DF_ CameraFogRange (cam as any ptr, nnear as single, nfar as single) as integer
_DF_ CameraPick     (cam as any ptr, x as single, y as single) as any ptr
_DS_ CameraProject  (cam as any ptr, x as single, y as single, z as single)
_DF_ CameraProjMode (cam as any ptr, mode as CAMERA_PROJECTION_MODES) as integer
_DF_ CameraRange    (cam as any ptr, nnear as single, nfar as single) as integer
_DF_ CameraViewport (cam as any ptr, x as integer, y as integer, w as integer, h as integer) as integer
_DF_ CameraZoom     (cam as any ptr, zoom as single) as integer


' ENTITY
_DF_ FreeEntity(ent as any ptr) as integer
_DF_ CopyEntity(ent as any ptr, parent as any ptr=0) as any ptr
_DF_ ResetEntity(ent as any ptr) as integer
_DF_ EntityClass    (ent as any ptr) as zstring ptr
_DF_ EntityType(ent as any ptr, type_no as integer, recursive as integer=0) as integer
_DF_ GetEntityType(ent as any ptr) as integer

' ENTITY (matrix)
_DF_ GetMatElement (ent as any ptr, row as integer, col as integer) as single

#ifdef PRIVATE_BUILD
' position & rotation (no scaling)
_DS_ TransformEntity(ent as any ptr, pMatrix16 as single ptr)
_DS_ EntityTransform(ent as any ptr, pMatrix16 as single ptr)
#endif

' ENTITY position
_DF_ PositionEntity (ent as any ptr, x as single, y as single, z as single, glob as integer=0) as integer
_DF_ MoveEntity     (ent as any ptr, x as single, y as single, z as single) as integer
_DF_ TranslateEntity(ent as any ptr, x as single, y as single, z as single, glob as integer=0) as integer
_DF_ EntityX(ent as any ptr, glob as integer=0) as single
_DF_ EntityY(ent as any ptr, glob as integer=0) as single
_DF_ EntityZ(ent as any ptr, glob as integer=0) as single

' ENTITY rotation
_DF_ RotateEntity(ent as any ptr, x as single, y as single, z as single, glob as integer=0) as integer
_DF_ TurnEntity  (ent as any ptr, x as single, y as single, z as single, glob as integer=0) as integer
_DF_ PointEntity (ent as any ptr, target_ent as any ptr, roll as single=0) as integer
_DF_ EntityPitch (ent as any ptr, glob as integer=0) as single
_DF_ EntityYaw   (ent as any ptr, glob as integer=0) as single
_DF_ EntityRoll  (ent as any ptr, glob as integer=0) as single

_DF_ DeltaPitch  (ent1 as any ptr, ent2 as any ptr) as single
_DF_ DeltaYaw    (ent1 as any ptr, ent2 as any ptr) as single

' ENTITY size
_DF_ ScaleEntity (ent as any ptr, x as single, y as single, z as single, glob as integer=0) as integer
_DF_ EntityScaleX(ent as any ptr, glob as integer=0) as single
_DF_ EntityScaleY(ent as any ptr, glob as integer=0) as single
_DF_ EntityScaleZ(ent as any ptr, glob as integer=0) as single

_DF_ MeshCullRadius(ent as any ptr, radius as single) as integer

_DF_ NameEntity(ent as any ptr, name as zstring ptr) as integer
_DF_ EntityName(ent as any ptr) as zstring ptr

_DF_ ShowEntity(ent as any ptr) as integer
_DF_ HideEntity(ent as any ptr) as integer
_DF_ EntityVisible(src_ent as any ptr, dest_ent as any ptr) as integer

_DF_ PaintEntity(ent as any ptr, brush as any ptr) as integer
_DS_ ShadeEntity(ent as any ptr, material as any ptr) 

_DF_ EntityAutoFade (ent as any ptr, near as single, far as single) as integer

' ENTITY (brush)
_DF_ EntityColor    (ent as any ptr, r as single, g as single, b as single) as integer
_DF_ EntityAlpha    (ent as any ptr, a as single) as integer
_DF_ EntityShininess(ent as any ptr, shine as single) as integer
_DF_ EntityTexture (ent as any ptr, tex as any ptr, frame as integer=0, index as integer=0) as integer
_DF_ EntityBlend    (ent as any ptr, blend as BRUSH_BLEND_MODES) as integer
_DF_ EntityFX       (ent as any ptr, fx as BRUSH_FX_MODES) as integer

_DF_ GetEntityBrush (ent as any ptr) as any ptr

_DF_ EntityDistance (ent as any ptr, ent2 as any ptr) as single
_DF_ EntityInView   (ent as any ptr, cam as any ptr) as integer
_DF_ EntityOrder(ent as any ptr, order as integer) as integer

_DF_ EntityPick    (ent as any ptr, range as single) as any ptr
_DF_ EntityPickMode(ent as any ptr, pick_mode as ENTITY_PICK_MODES, obscurer as integer=1) as integer
_DF_ EntityRadius  (ent as any ptr, radius_x as single, radius_y as single=0) as integer
_DF_ EntityBox     (ent as any ptr, x as single, y as single, z as single, w as single, h as single, d as single) as integer


' ENTITY (hierarchy)
_DF_ EntityParent   (ent as any ptr, parent_ent as any ptr, glob as integer=1) as integer
_DF_ GetParentEntity(ent as any ptr) as any ptr
_DF_ FindChild      (ent as any ptr, child_name as zstring ptr) as any ptr
_DF_ CountChildren  (ent as any ptr) as integer
_DF_ GetChild       (ent as any ptr, child_no as integer) as any ptr

' ENTITY (animation)
_DF_ Animate        (ent as any ptr, mode as ENTITY_ANIM_MODES=ENTITY_ANIM_MODE_LOOP, speed as single=1.0, seq as integer=0, trans_ as integer=0) as integer
_DF_ Animating      (ent as any ptr) as integer
_DF_ AnimLength     (ent as any ptr) as integer
_DF_ AnimSeq        (ent as any ptr) as integer
_DF_ AnimTime       (ent as any ptr) as single
_DF_ AddAnimSeq     (ent as any ptr, length as integer) as integer
_DF_ ExtractAnimSeq (ent as any ptr, first_frame as integer, last_frame as integer, seq as integer=0) as integer
_DF_ SetAnimTime    (ent as any ptr, time_ as single, seq as integer=0) as integer

' ENTITY (collision)
_DF_ EntityCollided (ent as any ptr, type_no as integer) as any ptr
_DF_ CollisionEntity(ent as any ptr, index as integer) as any ptr
_DF_ CountCollisions(ent as any ptr) as integer

_DF_ CollisionSurface (ent as any ptr, index as integer) as any ptr
_DF_ CollisionTime    (ent as any ptr, index as integer) as single
_DF_ CollisionTriangle(ent as any ptr, index as integer) as integer

_DF_ CollisionNX(ent as any ptr, index as integer) as single
_DF_ CollisionNY(ent as any ptr, index as integer) as single
_DF_ CollisionNZ(ent as any ptr, index as integer) as single

_DF_ CollisionX   (ent as any ptr, index as integer) as single
_DF_ CollisionY   (ent as any ptr, index as integer) as single
_DF_ CollisionZ   (ent as any ptr, index as integer) as single

_DF_ TFormNormal(x as single, y as single, z as single, src_ent as any ptr, dest_ent as any ptr) as integer
_DF_ TFormPoint (x as single, y as single, z as single, src_ent as any ptr, dest_ent as any ptr) as integer
_DF_ TFormVector(x as single, y as single, z as single, src_ent as any ptr, dest_ent as any ptr) as integer

_DF_ TFormedX() as single
_DF_ TFormedY() as single
_DF_ TFormedZ() as single


' LIGHT
_DF_ CreateLight    (lighttype as LIGHT_TYPES =  LIGHT_TYPE_DIRECTIONAL, parent as any ptr=0) as any ptr
_DF_ LightColor     (light as any ptr, red as single, green as single, blue as single) as integer
_DF_ LightConeAngles(light as any ptr, inner_ang as single, outer_ang as single) as integer
_DF_ LightRange     (light as any ptr, range as single) as integer

' MESH
_DF_ LoadMesh    (file as zstring ptr, parent as any ptr=0) as any ptr
_DF_ LoadAnimMesh(file as zstring ptr, parent as any ptr=0) as any ptr
_DF_ CreateMesh  (parent as any ptr=0) as any ptr
_DF_ CreateCone(segments as integer=8, solid as integer=1, parent as any ptr=0) as any ptr
_DF_ CreateCylinder(segments as integer=8, solid as integer=1, parent as any ptr=0) as any ptr
_DF_ CreateCube (parent as any ptr=0) as any ptr
_DF_ CreateQuad (parent as any ptr=0) as any ptr
_DF_ CreatePivot(parent as any ptr=0) as any ptr
_DF_ CreatePlane(Divisions as integer=1, parent as any ptr=0) as any ptr
_DF_ CreateSphere(segments as integer=8, parent as any ptr=0) as any ptr

_DF_ CopyMesh    (mesh as any ptr, parent as any ptr=0) as any ptr

_DF_ RepeatMesh  (mesh as any ptr, parent as any ptr=0) as any ptr
_DF_ UpdateNormals(mesh as any ptr) as integer
_DF_ MeshesIntersect(mesh as any ptr, mesh2 as any ptr) as any ptr
_DF_ AddMesh(mesh as any ptr, mesh2 as any ptr) as any ptr

_DF_ CountSurfaces(mesh as any ptr) as integer
' surface_index = 1 to CountSurfaces()
_DF_ GetSurface(mesh as any ptr, surface_index as integer) as any ptr
_DF_ FindSurface(mesh as any ptr, brush as any ptr) as any ptr

_DF_ FitMesh(mesh as any ptr, x as single, y as single, z as single, w as single, h as single, depth as single, uniform as integer=0) as any ptr

_DF_ PaintMesh(mesh as any ptr, brush as any ptr) as any ptr
_DS_ ShadeMesh(mesh as any ptr, material as any ptr) 

_DF_ PositionMesh(mesh as any ptr, px as single, py as single, pz as single) as integer
_DF_ RotateMesh  (mesh as any ptr, pitch as single, yaw as single, roll as single) as any ptr
_DF_ ScaleMesh   (mesh as any ptr, sx as single, sy as single, sz as single) as integer
_DF_ FlipMesh    (mesh as any ptr) as any ptr

_DF_ MeshWidth (mesh as any ptr) as single
_DF_ MeshHeight(mesh as any ptr) as single
_DF_ MeshDepth (mesh as any ptr) as single

_DF_ MeshCSG(mesh as any ptr,mesh2 as any ptr,method as CSG_METHODS=CSG_METHOD_UNION) as any ptr

' picking
_DF_ LinePick(px as single, py as single, pz as single, dx as single, dy as single, dz as single, radius as single=0) as any ptr
_DF_ PickedEntity() as any ptr
_DF_ PickedSurface() as any ptr
_DF_ PickedTime() as single
_DF_ PickedTriangle() as integer

_DF_ PickedNX() as single
_DF_ PickedNY() as single
_DF_ PickedNZ() as single

_DF_ PickedX() as single
_DF_ PickedY() as single
_DF_ PickedZ() as single

_DF_ ProjectedX() as single
_DF_ ProjectedY() as single
_DF_ ProjectedZ() as single

' SHADOW
_DF_ CreateShadow (parent as any ptr, Static_ as integer=0) as any ptr
_DS_ FreeShadow   (ShadowObject as any ptr)

' SPRITE
_DF_ CreateSprite  (parent as any ptr=0) as any ptr
_DF_ LoadSprite    (tex_file as zstring ptr, tex_flag as integer=1, parent as any ptr=0) as any ptr
_DF_ SpriteViewMode(sprite as any ptr, ViewMode as SPRITE_VIEW_MODES = SPRITE_VIEW_MODE_FIXED) as integer
_DF_ HandleSprite  (sprite as any ptr, h_x as single, h_y as single) as integer
_DF_ ScaleSprite   (sprite as any ptr, s_x as single, s_y as single) as integer
_DF_ RotateSprite  (sprite as any ptr, ang as single) as integer

_DF_ CreateVoxelSprite  (slices as integer=64, parent as any ptr=0) as any ptr
_DS_ VoxelSpriteMaterial(voxelspr as any ptr, mat as any ptr) 

' SURFACE
_DF_ CreateSurface   (mesh as any ptr, brush as any ptr=0) as any ptr
_DF_ ClearSurface    (surf as any ptr, clear_verts as integer=1, clear_tris as integer=1) as integer
_DF_ PaintSurface    (surf as any ptr, brush as any ptr) as integer
_DS_ ShadeSurface    (surf as any ptr, material as any ptr) 
_DF_ GetSurfaceBrush (surf as any ptr) as any ptr

_DF_ AddTriangle   (surf as any ptr, v0 as integer, v1 as integer, v2 as integer) as integer
_DF_ CountTriangles(surf as any ptr) as integer
_DF_ TriangleVertex(surf as any ptr, tri_no as integer, corner as integer) as integer

_DF_ AddVertex    (surf as any ptr, x as single, y as single, z as single, u as single=0, v as single=0, w as single=0) as integer
_DF_ CountVertices(surf as any ptr) as integer
_DF_ VertexColor  (surf as any ptr, vid as integer, r as single, g as single, b as single, a as single=1) as integer
_DF_ VertexRed    (surf as any ptr, vid as integer) as single
_DF_ VertexGreen  (surf as any ptr, vid as integer) as single
_DF_ VertexBlue   (surf as any ptr, vid as integer) as single
_DF_ VertexAlpha  (surf as any ptr, vid as integer) as single

_DS_ VertexCoords (surf as any ptr, vid as integer, x as single, y as single, z as single)
_DF_ VertexX (surf as any ptr, vid as integer) as single
_DF_ VertexY (surf as any ptr, vid as integer) as single
_DF_ VertexZ (surf as any ptr, vid as integer) as single

_DF_ VertexNormal (surf as any ptr, vid as integer, nx as single, ny as single, nz as single) as integer
_DF_ VertexNX     (surf as any ptr, vid as integer) as single
_DF_ VertexNY     (surf as any ptr, vid as integer) as single
_DF_ VertexNZ     (surf as any ptr, vid as integer) as single

_DF_ VertexTexCoords (surf as any ptr, vid as integer, u as single, v as single, w as single=0, coord_set as integer=0) as integer
_DF_ VertexU (surf as any ptr, vid as integer, coord_set as integer=0) as single
_DF_ VertexV (surf as any ptr, vid as integer, coord_set as integer=0) as single
_DF_ VertexW (surf as any ptr, vid as integer, coord_set as integer=0) as single

' TERRAIN
_DF_ CreateTerrain (size as integer, parent as any ptr=0) as any ptr
_DF_ LoadTerrain   (file as zstring ptr, parent as any ptr=0) as any ptr
_DF_ ModifyTerrain (terr as any ptr, x as integer, z as integer, height as single) as any ptr
_DF_ TerrainHeight (terr as any ptr, x as integer, z as integer) as single
_DF_ TerrainX      (terr as any ptr, x as single, y as single, z as single) as single
_DF_ TerrainY      (terr as any ptr, x as single, y as single, z as single) as single
_DF_ TerrainZ      (terr as any ptr, x as single, y as single, z as single) as single

' TEXTURE
_DF_ CreateTexture  (w as integer, h as integer, flags as TEXTURE_FLAGS = TEXTURE_FLAG_COLOR, frames as integer = 1) as any ptr
_DF_ LoadTexture    (file as zstring ptr, flags as TEXTURE_FLAGS = TEXTURE_FLAG_COLOR) as any ptr
_DF_ LoadAnimTexture(file as zstring ptr, flags as TEXTURE_FLAGS = TEXTURE_FLAG_COLOR, frame_width as integer, frame_height as integer, first_frame as integer, frame_count as integer) as any ptr
_DF_ FreeTexture    (tex as any ptr) as integer

_DF_ PositionTexture(tex as any ptr, u_pos as integer, v_pos as integer) as integer
_DF_ RotateTexture  (tex as any ptr, ang as single) as integer
_DF_ ScaleTexture   (tex as any ptr, u_scale as single, v_scale as single) as integer

_DF_ SetCubeFace    (tex as any ptr, face as TEXTURE_CUBE_FACES = TEXTURE_CUBE_FACE_FORWARD) as integer
_DF_ SetCubeMode    (tex as any ptr, mode as TEXTURE_CUBE_MODES = TEXTURE_CUBE_MODE_SPECULAR) as integer

_DF_ TextureBlend   (tex as any ptr, BlendMode as TEXTURE_BLEND_MODES = TEXTURE_BLEND_MODE_MULTIPLY) as integer
_DF_ TextureCoords  (tex as any ptr, coords as TEXTURE_COORD_SETS = TEXTURE_COORD_SET_FIRST) as integer
_DF_ TextureWidth   (tex as any ptr) as integer
_DF_ TextureHeight  (tex as any ptr) as integer
_DF_ TextureName    (tex as any ptr) as zstring ptr
_DF_ TextureFilter  (match_text as zstring ptr, flags as TEXTURE_FLAGS) as integer

' STENCIL
_DF_ CreateStencil() as any ptr
_DS_ StencilAlpha   (stencil as any ptr, a as single)
_DS_ StencilClsColor(stencil as any ptr, r as single, g as single, b as single)
_DS_ StencilClsMode (stencil as any ptr, cls_depth as integer, cls_zbuffer as integer)
_DS_ StencilMesh    (stencil as any ptr, mesh as any ptr, mode as STENCIL_MODES=STENCIL_MODE_INCR)
_DS_ StencilMode    (stencil as any ptr, mode as STENCIL_MODES, operation as STENCIL_OPERATORS=STENCIL_OPERATOR_EQUAL)

' MATERIAL
_DF_ LoadShader   (ShaderName as zstring ptr, VertexFile   as zstring ptr, FragmentFile   as zstring ptr) as any ptr
_DF_ CreateShader (shaderName as zstring ptr, VertexSource as zstring ptr, FragmentSource as zstring ptr) as any ptr
_DS_ ShaderTexture (material as any ptr, tex as any ptr, name_ as zstring ptr, index as integer=0) 

_DS_ SetFloat    (material as any ptr, name_ as zstring ptr, v1 as single) 
_DS_ SetFloat2   (material as any ptr, name_ as zstring ptr, v1 as single, v2 as single) 
_DS_ SetFloat3   (material as any ptr, name_ as zstring ptr, v1 as single, v2 as single, v3 as single) 
_DS_ SetFloat4   (material as any ptr, name_ as zstring ptr, v1 as single, v2 as single, v3 as single, v4 as single) 

_DS_ UseFloat    (material as any ptr, name_ as zstring ptr, byref v1 as single) 
_DS_ UseFloat2   (material as any ptr, name_ as zstring ptr, byref v1 as single, byref v2 as single) 
_DS_ UseFloat3   (material as any ptr, name_ as zstring ptr, byref v1 as single, byref v2 as single, byref v3 as single) 
_DS_ UseFloat4   (material as any ptr, name_ as zstring ptr, byref v1 as single, byref v2 as single, byref v3 as single, byref v4 as single) 

_DS_ SetInteger  (material as any ptr, name_ as zstring ptr, v1 as single) 
_DS_ SetInteger2 (material as any ptr, name_ as zstring ptr, v1 as single, v2 as single) 
_DS_ SetInteger3 (material as any ptr, name_ as zstring ptr, v1 as single, v2 as single, v3 as single) 
_DS_ SetInteger4 (material as any ptr, name_ as zstring ptr, v1 as single, v2 as single, v3 as single, v4 as single) 

_DS_ UseInteger  (material as any ptr, name_ as zstring ptr, byref v1 as single) 
_DS_ UseInteger2 (material as any ptr, name_ as zstring ptr, byref v1 as single, byref v2 as single) 
_DS_ UseInteger3 (material as any ptr, name_ as zstring ptr, byref v1 as single, byref v2 as single, byref v3 as single) 
_DS_ UseInteger4 (material as any ptr, name_ as zstring ptr, byref v1 as single, byref v2 as single, byref v3 as single, byref v4 as single) 

_DS_ UseSurface (material as any ptr, name_ as zstring ptr, surf as any ptr, vbo as integer) 
_DS_ UseMatrix  (material as any ptr, name_ as zstring ptr, mode as integer) 

end extern

#endif
Last edited by D.J.Peters on Dec 11, 2012 17:43, edited 2 times in total.
angros47
Posts: 2387
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Post by angros47 »

Thank you. I'll include your fixes in the next version.
D.J.Peters
Posts: 8631
Joined: May 28, 2005 3:28
Contact:

Re: MiniB3d for FreeBasic

Post by D.J.Peters »

angros47 wrote:Thank you. I'll include your fixes in the next version.
can you include this in next realease also ?
Every new version i must add it manualy again and again.

If you won't make it official don't add it to the *.bi file.

Thank you very mutch.

Joshy

Code: Select all

	// entity.h set/get matrix
	void TransformEntity(float m[16]);
	void EntityTransform(float m[16]);

Code: Select all

// entity.cpp
// entity.cpp set/get matrix
void Entity::TransformEntity(float m[16]){
  rotmat.grid[0][0] = m[ 0];rotmat.grid[0][1] = m[ 1];rotmat.grid[0][2] = m[ 2];
  rotmat.grid[1][0] = m[ 4];rotmat.grid[1][1] = m[ 5];rotmat.grid[1][2] = m[ 6];
  rotmat.grid[2][0] = m[ 8];rotmat.grid[2][1] = m[ 9];rotmat.grid[2][2] = m[10];
                 px = m[12];               py = m[13];               pz =-m[14];
  MQ_Update();
}
void Entity::EntityTransform(float m[16]){
  m[ 0] = rotmat.grid[0][0]; m[ 1] = rotmat.grid[0][1]; m[ 2] = rotmat.grid[0][2]; m[ 3] = 1.0f;
  m[ 4] = rotmat.grid[1][0]; m[ 5] = rotmat.grid[1][1]; m[ 6] = rotmat.grid[1][2]; m[ 7] = 1.0f;
  m[ 8] = rotmat.grid[2][0]; m[ 9] = rotmat.grid[2][1]; m[10] = rotmat.grid[2][2]; m[11] = 1.0f;
  m[12] = px;                m[13] = py;                m[14] = -pz;
}

Code: Select all

// functions.h set/get matrix
void TransformEntity(Entity* ent, float m[16]);
void EntityTransform(Entity* ent, float m[16]);

Code: Select all

// functions.cpp set/get matrix
void TransformEntity(Entity* ent, float m[16]){
  ent->TransformEntity(m);
}
void EntityTransform(Entity* ent, float m[16]){
  ent->EntityTransform(m);
}

Code: Select all

' openb3d.bi get/set matrix
declare sub TransformEntity(ent as any ptr, pMatrix4x4 as single ptr)
declare sub EntityTransform(ent as any ptr, pMatrix4x4 as single ptr)
D.J.Peters
Posts: 8631
Joined: May 28, 2005 3:28
Contact:

Re: MiniB3d for FreeBasic

Post by D.J.Peters »

I suggest you to use my posted *.bi file, can't remember how many wrong declares I fixed in the past.

for example you define:
declare function FreeShadow (parent as any ptr, Static_ as integer=0) as any ptr

but it must be:
declare sub FreeShadow(ShadowObject as any ptr)

I wonder me why you don't get any stack crashes ?.

Joshy
angros47
Posts: 2387
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Post by angros47 »

A function can be used as a sub. As long as you don't try to actually use the returned vale, there is no stack crash.
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: MiniB3d for FreeBasic

Post by counting_pine »

How about the extra parameter pushed onto the stack?
angros47
Posts: 2387
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Post by angros47 »

Which extra parameters? As far as I recall, the caller program should not push on the stack a parameter that is returned from the called routine.
Kronos
Posts: 9
Joined: Dec 10, 2012 19:53

Re: MiniB3d for FreeBasic

Post by Kronos »

Can someone confirm whether PositionTexture is working correctly. I am not seeing a scrolling texture when using this example from Blitz3d land.

http://www.blitzmax.com/b3ddocs/command ... ref=3d_cat
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: MiniB3d for FreeBasic

Post by counting_pine »

angros47 wrote:Which extra parameters? As far as I recall, the caller program should not push on the stack a parameter that is returned from the called routine.
Compared to Joshy's FreeShadow(), the modified one has not just a return type but an additional parameter: Static_ as integer=0.
If I understand right, StdCall functions clean up the stack themselves, so the first parameter will not get taken off the stack when the callee returns. I don't know what the consequences of that would be.
Post Reply