hello,
i publish a 3D library to using at a b4a project (android 5.x+ phone or tablet)
currently it knows:
Camera
Light
Cube
Vector,Color,Texture
Entity,Mesh,Surface,Vertex
Line (at Surface)
01.02.2019 21:00
OpenGL.zip is my test project.
03.02.2019 19:00
ThreeD.zip is the lib to place unzipped in additional libraries folder.
base of the ThreeD library is a Project in Android Studio 3.3
(which was compiled with SimpleLibraryCompiler)
to do:
line order in grid because lighting
(anytime switch to GLES 3.0 or 3.1 but it is completely different)
note: my android emulator does not show alpha blending!
ThreeD
Author: Markus Rauch
Version: 0.04
i publish a 3D library to using at a b4a project (android 5.x+ phone or tablet)
currently it knows:
Camera
Light
Cube
Vector,Color,Texture
Entity,Mesh,Surface,Vertex
Line (at Surface)
01.02.2019 21:00
OpenGL.zip is my test project.
03.02.2019 19:00
ThreeD.zip is the lib to place unzipped in additional libraries folder.
base of the ThreeD library is a Project in Android Studio 3.3
(which was compiled with SimpleLibraryCompiler)
to do:
line order in grid because lighting
(anytime switch to GLES 3.0 or 3.1 but it is completely different)
note: my android emulator does not show alpha blending!
ThreeD
Author: Markus Rauch
Version: 0.04
- Functions:
- clone As Object
- compareTo (arg0 As E) As Int
- equals (arg0 As Object) As Boolean
- finalize
- hashCode As Int
- name As String
- ordinal As Int
- toString As String
- valueOf (name As String) As com.rauch.threedimensional.Surface.ETyp
- values As com.rauch.threedimensional.Surface.ETyp()
- clone As Object
- Properties:
- DeclaringClass As Class [read only]
- DeclaringClass As Class [read only]
- Functions:
- Camera
- Fields:
- ID As String
- Position As Vector
- PositionLookAt As Vector
- Rotate As Vector
- Scale As Vector
- ID As String
- Functions:
- AddMesh (m As Mesh)
- ClearMeshes
- ListMeshes As java.util.List
- AddMesh (m As Mesh)
- Fields:
- Color
- Fields:
- Alpha As Float
- Blue As Float
- Green As Float
- Red As Float
- Alpha As Float
- Functions:
- Set (Red As Float, Green As Float, Blue As Float, Alpha As Float)
set the color red,green,blue,alpha
all r g b a values from 0.0 to 1.0
Red: 0.0 to 1.0
Green: 0.0 to 1.0
Blue: 0.0 to 1.0
Alpha: 0.0 to 1.0 (1.0 = visible)
- Set (Red As Float, Green As Float, Blue As Float, Alpha As Float)
- Fields:
- Cube
- Fields:
- ID As String
- Position As Vector
- Rotate As Vector
- Scale As Vector
- ID As String
- Functions:
- AddMesh (m As Mesh)
- ClearMeshes
- ListMeshes As java.util.List
- Set (Position As Vector, Length As Float, Width As Float, Height As Float, Color1 As Color)
create a cube
Position:
Length:
Width:
Height:
Color1: - SetColor (Red As Float, Green As Float, Blue As Float, Alpha As Float)
colorize the cube
(a cube with texture should be white)
Red:
Green:
Blue:
Alpha: - SetColorFaces (Color1 As Color, Color2 As Color, Color3 As Color, Color4 As Color, Color5 As Color, Color6 As Color)
colorize each face of the cube
Color1:
Color2:
Color3:
Color4:
Color5:
Color6: - SetTexture (Bitmap1 As android.graphics.Bitmap)
give the cube an bitmap/texture for all faces
Example:<code>Dim bmp As Bitmap = LoadBitmap(File.DirAssets,"wood.png")
Cube1.SetTexture(bmp)</code>
Bitmap1:
- AddMesh (m As Mesh)
- Fields:
- Entity
- Fields:
- ID As String
- Position As Vector
- Rotate As Vector
- Scale As Vector
- ID As String
- Functions:
- AddMesh (m As Mesh)
- ClearMeshes
- ListMeshes As java.util.List
- AddMesh (m As Mesh)
- Fields:
- Light
- Fields:
- ID As String
- Position As Vector
- PositionLookAt As Vector
- Rotate As Vector
- Scale As Vector
- ID As String
- Functions:
- AddMesh (m As Mesh)
- ClearMeshes
- ListMeshes As java.util.List
- SetPosition (Position As Vector)
- SetPositionLookAt (PositionLookAt As Vector)
- AddMesh (m As Mesh)
- Fields:
- Line
- Fields:
- Color1 As Color
- ID As String
- Position As Vector
- Rotate As Vector
- Scale As Vector
- Color1 As Color
- Functions:
- AddMesh (m As Mesh)
- ClearMeshes
- GetP1 As Vector
- GetP2 As Vector
- ListMeshes As java.util.List
- Set (P1 As Vector, P2 As Vector)
- SetColor (Red As Float, Green As Float, Blue As Float, Alpha As Float)
- SetColorObj (Color1 As Color)
- SetP1 (X As Float, Y As Float, Z As Float)
- SetP12 (X1 As Float, Y1 As Float, Z1 As Float, X2 As Float, Y2 As Float, Z2 As Float)
- SetP2 (X As Float, Y As Float, Z As Float)
- AddMesh (m As Mesh)
- Fields:
- Mesh
- Fields:
- ID As String
- Position As Vector
- Rotate As Vector
- Scale As Vector
- ID As String
- Functions:
- AddMesh (m As Mesh)
- AddSurface (s As Surface)
- ClearMeshes
- ClearSurfaces
- ListMeshes As java.util.List
- ListSurfaces As java.util.List
- AddMesh (m As Mesh)
- Fields:
- Surface
- Fields:
- Color1 As Color
- Color1 As Color
- Functions:
- AddLine (v1 As Vertex, v2 As Vertex)
- AddQuad (v1 As Vertex, v2 As Vertex, v3 As Vertex, v4 As Vertex)
(GL_TRIANGLE_STRIP)
v1:
v2:
v3:
v4: - AddTriangle (v1 As Vertex, v2 As Vertex, v3 As Vertex)
- AddVertex (v As Vertex)
- ClearVertices
- ListVertices As java.util.List
- SetColor (Red As Float, Green As Float, Blue As Float, Alpha As Float)
colorize the surface
(a surface with texture should be white)
Red: 0 to 1
Green: 0 to 1
Blue: 0 to 1
Alpha: 0 to 1 (1 visible) - SetTexture (Bitmap1 As android.graphics.Bitmap)
give the surface an bitmap/texture
Example:<code>Dim bmp As Bitmap = LoadBitmap(File.DirAssets,"wood.png")
Surface1.SetTexture(bmp)</code>
Bitmap1: - SetType (Type As com.rauch.threedimensional.Surface.ETyp)
set the surface typ LINES,TRIANGLES,TRIANGLE_STRIP (default is TRIANGLES)
Type: - SetTypeLineLoop
- SetTypeLines
- SetTypeLineStrip
- SetTypeTriangles
- SetTypeTriangleStrip
- AddLine (v1 As Vertex, v2 As Vertex)
- Fields:
- ThreeDimensional
- Fields:
- CameraFar As Float
- CameraFieldOfViewY As Float
- CameraNear As Float
- CullBackFace As Boolean
- LineWidth As Float
- CameraFar As Float
- Functions:
- AddCube (Cube1 As Cube)
use AddEntity - AddCube2 (x As Float, y As Float, z As Float, l As Float, w As Float, h As Float, r As Float, g As Float, b As Float, a As Float)
use AddEntity - AddEntity (Entity1 As Entity)
add a entity to your scene camera,light,cube,line,...
(use in pause mode) - CreateCubeWireframe (Position As Vector, Length As Float, Height As Float, Width As Float, Color1 As Color) As Entity
create a cube with lines
Position: X,Y,Z
Length: (X)
Height: (Y)
Width: (Z)
Color1: Object
Return type: @return:new Entity - CreateEntityAxis (Position As Vector, Length As Float, ColorX As Color, ColorY As Color, ColorZ As Color) As Entity
create a 3d axis Entity with lines
use returned Entity at AddEntity to add it into scene object list
Position:
Length:
ColorX:
ColorY:
ColorZ:
Return type: @return:new Entity - CreateEntityGridXZ (Size As Float, Step As Float, Color1 As Color) As Entity
create a ground grid entity step ? unit
use at AddEntity
Size: X and Z = -Size to Size Step ?
Step: Gap
Color1:
Return type: @return:new Entity - Init (Activity1 As Activity) As View
define the 3d class and add the surface view to a activity
also add pause and resume
in pause mode or before it run you can set your scene
Example:<code>
Sub Process_Globals
Dim Three As ThreeDimensional
Sub Activity_Create(FirstTime As Boolean)
Activity.AddView( Three.Init(GetActivity),0%x,0%y,100%x,100%y)
Sub Activity_Resume
Three.Resume
Sub Activity_Pause(UserClosed As Boolean)
Three.Pause
Sub GetActivity As Object
Dim R As Reflector
Return R.GetActivity
End Sub</code>
Activity1:
Return type: @return:View - Lerp (a As Float, b As Float, t As Float) As Float
lerp interpolates from one value (a) to another (b) over a given range (t)
a:
b:
t: is clamped between 0 and 1
Return type: @return: - mm_to_m (mm As Float) As Float
millimeter to meter
mm:
Return type: @return:m - Pause
pause the renderer - Resume
resume the renderer - Scene1
test scene 1 - Scene1New
test scene 1 new - SceneDefault (camx As Float, camy As Float, camz As Float, centerx As Float, centery As Float, centerz As Float)
scene with camera and light
camera position and look at center point
camx:
camy:
camz:
centerx:
centery:
centerz: - SceneEmpty
clear the scene list
(use in pause mode) - SearchEntity (ID As String) As Object
search in scene object list by id
ID:
Return type: @return:Entity Object
- AddCube (Cube1 As Cube)
- Fields:
- Vector
- Fields:
- X As Float
- Y As Float
- Z As Float
- X As Float
- Functions:
- Add (V As Vector)
Add a Vector to it
V: - Direction (A As Vector, B As Vector) As Vector
static function return a normalized direction vector from 2 positions
A:
B:
Return type: @return:direction Vector - Set (X As Float, Y As Float, Z As Float)
set the vector x,y,z
X:
Y:
Z:
- Add (V As Vector)
- Fields:
- Vertex
- Fields:
- Normal As Vector
- Position As Vector
- TextureUVW As Vector
- Normal As Vector
- Fields:
Attachments
Last edited: