Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wanted: Very Simple 3D system
#15
OK I revised the conversion forumlas for projecting onto the screen so that as depth distance decreases ie the x-y plane approaches the eye/camera the bigger the image gets in the x-y plane. I am of opinion that as distance is increased the image expands more rapidly than just linearly controlled by the PC constant to aid in making the model look right. New PC looks like around .5 for pyramid with base below origin and apex just above it by same amount:
Code: (Select All)
_Title "3D per Parallelism test 2 Pyramid" 'b+ 2024-02-20
'  "parallelism suggests a connection of meaning through an echo of form"
' 2024-02-21 screew around with pyramid numbers

Dim Shared As Long SW, SH: SW = 800: SH = 600
Screen _NewImage(SW, SH, 32)
_Delay .25 'need time for screen to load before attempting to move it.
_ScreenMove _Middle

Type XYZ
    As Double x, y, z
End Type
Type XY
    As Double x, y
End Type
Dim Shared As Double PC ': PC = .7 ' or something  PC = Parallel Constant

Window (-2, -2)-(2, 2)

' pyramid with square base and 4 iso-tri's to apex
Dim p3(1 To 5) As XYZ
Dim p2(1 To 5) As XY

' use all positive x, y, z in 3D Model
p3(1).x = 0: p3(1).y = 1: p3(1).z = 0 ' apex

p3(2).x = -1: p3(2).y = -1: p3(2).z = -1 ' back L
p3(3).x = 1: p3(3).y = -1: p3(3).z = -1 ' back R
p3(4).x = 1: p3(4).y = -1: p3(4).z = 1 ' front R
p3(5).x = -1: p3(5).y = -1: p3(5).z = 1 ' front L


' now draw the thing! and find ideal PC = Parallel Constant
PC = .5
While _KeyDown(27) = 0
    kh& = _KeyHit
    If kh& = 44 Then PC = PC - .001
    If kh& = 46 Then PC = PC + .001
    ' recalc new array
    For i = 1 To 5
        M2SPP p3(i), p2(i) ' that was easy now draw the thing!
    Next

    Cls
    Locate 2, 20: Print "Here, the 3D Model height at apex is same as a side at the base."
    Locate 4, 18: Print "Press  <, = less, >. = more    When does the base look square?  PC ="; PC
    Locate 6, 21: Print "Oh! PC is the Parallel Constant for this very simple 3D system."

    ' base
    Line (p2(2).x, p2(2).y)-(p2(3).x, p2(3).y), &HFFFF0000 ' back line base
    Line (p2(3).x, p2(3).y)-(p2(4).x, p2(4).y), &HFFFFFFFF ' right side
    Line (p2(4).x, p2(4).y)-(p2(5).x, p2(5).y), &HFFFFFFFF ' front front
    Line (p2(5).x, p2(5).y)-(p2(2).x, p2(2).y), &HFFFF0000 ' left side


    Line (p2(1).x, p2(1).y)-(p2(2).x, p2(2).y), &HFFFF0000 ' Back L
    Line (p2(1).x, p2(1).y)-(p2(3).x, p2(3).y), &HFFFFFFFF ' Back R
    Line (p2(1).x, p2(1).y)-(p2(4).x, p2(4).y), &HFFFFFFFF ' Front R
    Line (p2(1).x, p2(1).y)-(p2(5).x, p2(5).y), &HFFFFFFFF ' Front L

    _PrintString (PMap(p2(1).x, 0) - 4, PMap(p2(1).y, 1) - 17), "1" ' apex
    _PrintString (PMap(p2(2).x, 0) - 10, PMap(p2(2).y, 1) + 4), "2" ' Front L
    _PrintString (PMap(p2(3).x, 0) + 4, PMap(p2(3).y, 1) + 4), "3" ' Front R
    _PrintString (PMap(p2(4).x, 0) - 4, PMap(p2(4).y, 1) + 8), "4" ' Back R
    _PrintString (PMap(p2(5).x, 0) - 4, PMap(p2(5).y, 1) + 8), "5" ' Back L

    Locate 35, 10
    Print "Now the lower the z the smaller the image."
    Locate 36, 25
    Print "Mainly because the white face is bigger, I think.";
    _Display

Wend

' here I am working with a Window so Screen obeys right hand rule so as z increases
' the image x, y plane is closer to the eye/camera so is bigger
' but should be distance squared
' thankyou vince '2024-02  the bigger the Z the closer it is to the eye the greater the image
Sub M2SPP (pIN As XYZ, pOut As XY) 'M2SPP = Model (3D) 2 Screen Per Parallelism
    pOut.x = pIN.x - Sgn(pIN.z) * PC * (pIN.z) ^ 2
    pOut.y = pIN.y - Sgn(pIN.z) * PC * (pIN.z) ^ 2
End Sub

Update: something went horribly wrong when I tried that projection Sub to cubes in various positions in space. Back to the howl'n owl in the woods...
b = b + ...
Reply


Messages In This Thread
Wanted: Very Simple 3D system - by bplus - 02-15-2024, 03:56 PM
RE: Wanted: Very Simple 3D system - by dbox - 02-15-2024, 04:13 PM
RE: Wanted: Very Simple 3D system - by bplus - 02-15-2024, 04:57 PM
RE: Wanted: Very Simple 3D system - by vince - 02-15-2024, 09:10 PM
RE: Wanted: Very Simple 3D system - by bplus - 02-15-2024, 11:54 PM
RE: Wanted: Very Simple 3D system - by Abazek - 02-16-2024, 07:27 AM
RE: Wanted: Very Simple 3D system - by bplus - 02-19-2024, 11:17 AM
RE: Wanted: Very Simple 3D system - by bplus - 02-19-2024, 11:34 AM
RE: Wanted: Very Simple 3D system - by bert22306 - 02-19-2024, 11:22 PM
RE: Wanted: Very Simple 3D system - by vince - 02-20-2024, 03:36 AM
RE: Wanted: Very Simple 3D system - by bplus - 02-20-2024, 03:28 PM
RE: Wanted: Very Simple 3D system - by bplus - 02-20-2024, 04:01 PM
RE: Wanted: Very Simple 3D system - by bplus - 02-20-2024, 05:02 PM
RE: Wanted: Very Simple 3D system - by bert22306 - 02-23-2024, 01:37 AM
RE: Wanted: Very Simple 3D system - by bplus - 02-23-2024, 01:58 AM
RE: Wanted: Very Simple 3D system - by bplus - 02-20-2024, 10:22 PM
RE: Wanted: Very Simple 3D system - by bplus - 02-22-2024, 02:21 PM
RE: Wanted: Very Simple 3D system - by bplus - 02-21-2024, 02:58 PM
RE: Wanted: Very Simple 3D system - by bplus - 02-21-2024, 09:51 PM
RE: Wanted: Very Simple 3D system - by madscijr - 02-22-2024, 03:39 PM
RE: Wanted: Very Simple 3D system - by vince - 02-23-2024, 07:15 PM



Users browsing this thread: 10 Guest(s)