Unfortunately I had little time and I stopped.Another thought: Don't pass Point (a MyVertices object) to the AddVertice_If_not_Exist method, but the coordinates. This way you do not allocate a MyVertices object in case it does not need allocation. The method can decide if it needs to create a a MyVertices object or return an existing MyVertices object.
B4X:Dim newPoint as MyVertices = AddVertice_If_not_Exist(ArrayVertices, X, Y, Z)
For i=0 To (360*Precision)-1
MySin(i)=SinD(i/Precision)
MyCos(i)=CosD(i/Precision)
Next
Private Sub apSin(Degree As Float) As Double
Return MySin(((360+Degree) Mod 360)* Precision)
End Sub
Private Sub apCos(Degree As Float) As Double
Return MyCos(((360+Degree) Mod 360)* Precision)
End Sub
I am going to translate it for B4X XUI and if I can merge it with my 3D.
Strangely enough it is a very small code, unfortunately it is I who do not have the time but I think it could be done in just one dayOkay now that would be good. @Star-Dust that sounds rather difficult to implement and also to keep it running relatively smoothly will take some doing will it not???
If you're looking for faster math in B4A, you can also look at (file at the end):It is very interesting, I did not know of the existence of less accurate mathematics.
I will try to understand something.
For Q=0 To 1080 Step 10 ' 1080 = 360 *3
P3D.clear
Dim ID As Int = 0
For z=-120 To 120 Step 10
For x=-120 To 120 Step 10
Dim y1 As Int =50 * CosD(z*2+q) * SinD(x*2)
Dim y2 As Int =50 * CosD(z*2+q) * SinD(x*2+20)
Dim NewPointList(2) As Point_Type
NewPointList(0)=(P3D.CtP(X,y1,z))
NewPointList(1)=(P3D.CtP(X+10,y2,z))
P3D.AddPolygon(ID,NewPointList,xui.Color_White,xui.Color_Transparent)
ID=ID+1
Next
Next
For x=-120 To 120 Step 10
For z=-120 To 120 Step 10
Dim y1 As Int =50 * CosD(z*2+q) * SinD(x*2)
Dim y2 As Int =50 * CosD(z*2+20+q) * SinD(x*2)
Dim NewPointList(2) As Point_Type
NewPointList(0)=(P3D.CtP(X,y1,z))
NewPointList(1)=(P3D.CtP(X,y2,z+10))
P3D.AddPolygon(ID,NewPointList,xui.Color_White,xui.Color_Transparent)
ID=ID+1
Next
Next
P3D.RenderToView(Panel)
Sleep(0)
Next
It seems more complicated than I imagined, but I translated 9 classes out of 11.Okay now that would be good. @Star-Dust that sounds rather difficult to implement and also to keep it running relatively smoothly will take some doing will it not???
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Time load: 3476 Vertices: 432534
Start Draw to View
Time Priority Z calc: 130
Sort for Z: 579
Time Draw: 2015
Total Time: 2724
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Time load: 3384 Vertices: 432534
Start Draw to View
Time Priority Z calc: 92
Sort for Z: 482
Time Draw: 2108
Total Time: 2682
I've tried other algorithms, Bubble Sort, Quick Sort, Split & Merge ... but none of them is just as fast. Times quadruple.To sort by the Z axis use ListVertices.SortType ("Z", True) .. is there a faster method?
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Time load: 3384 Vertices: 432534
Start Draw to View
Time Priority Z calc: 0
Sort for Z: 362
Time Draw: 1744
Total Time: 2106
I like the mountains, my wife the sea. We have found a compromise, we are at home; I put a mountain background on my PC and she watches films that portray beaches.Hey you've been an extremelebusy busy little bumble bee @Star-Dust. What are you doing inside your home coding, shouldn't you be outside in the sun tanning it up
Dim Base() As String = Array As String( _
"*************", _
"* *", _
"* ** ** *", _
"* * * *", _
"* ** ** *", _
"* * * *", _
"* *", _
"* * * *", _
"* ** ** *", _
"* * * *", _
"* ** ** *", _
"* *", _
"*************" _
)
P3D.Initialize
'Draw Base of the labyrinth
Dim Center as float = Base.Length/2
For y=0 To Base.Length-1
For x=0 To Base(Y).Length-1
If Base(y).CharAt(x)="*" Then P3D.AddCube(0,-(Large*Center)+y*Large,-(Large*Center)+x*Large,Large,-(Large*(Center-1))+y*Large,-(Large*(Center-1))+x*Large,0,xui.Color_Gray,Array As Int(xui.Color_White))
Next
Next
'Draw PacMan
P3D.AddSpere2(1,PacManX,PacManY,Large/2,.Large/2,xui.Color_Gray,xui.Color_Yellow,0,225,0,180,10,10)
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Layout1")
P3D.Initialize
P3D.AddImage(1,xui.LoadBitmap(File.DirAssets,"StarDust.png"),P3D.CtP(-50,-50,0),P3D.CtP(50,-50,0),P3D.CtP(50,50,0),P3D.CtP(-50,50,0))
For i=0 To 360 Step 10
P3D.Rotate2(Null,0,i,i).RenderToView(PanelPresentation,PanelPresentation.Width/2,PanelPresentation.Height/2,i/180,1)
Sleep(20)
Next
P3D.RenderToView(PanelPresentation,PanelPresentation.Width/2,PanelPresentation.Height/2,2,1)
ButtonStart.SetVisibleAnimated(1000,True)
End Sub
Sub ButtonStart_Click
PanelPresentation.Visible=False
Activity.LoadLayout("Layout2")
End Sub
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?