LightMesh

Started by DragonEgg, January 14, 2019, 20:49:25

Previous topic - Next topic

DragonEgg

Hi guys
I do not post here very much,but i have been using OpenB3DMax for a while,and wondered if the creator markcwm is still working on it.If so are you/is he thinking of adding LightMesh to it.
thnx guys.

markcwm

Hi DragonEgg,

yes I am still working on Openb3dmax and should have an update out soon with LightMesh in it and some examples, I'm just finishing off the new 3DS loader.

LightMesh was just lifted it from the Blitz3d source and it seems to work the same. One thing I noticed is if the LightRange intensity is too high it looks ugly, like sharp vertex shading.

RemiD


DragonEgg

Thank you markcmw nice to no you are still working on OpenB3dMax.
Remid your post is worthless.There is no Lightmesh in OpenB3dMax at the moment.
Which is what im looking for.

markcwm

Er, yes LightMesh is now in Openb3dmax. Look again.

DragonEgg

Hi markcwm downloaded latest github,build went fine,but when i try to build an example. It throws an error
undefined reference to Log2_.

markcwm

Yes sorry, I forgot a file and didn't double-check.

DragonEgg

#7
Hi Markcwm
I have used a Blitz3d Lightmesh example by MadJack
and the main sphere looks a bit off,not sure of the problem.
All i am using is CreateSphere()
Thnx

' ------------------------------------------------------------------------------
' WARNING: This code has Not been declared as Public Domain!
' ------------------------------------------------------------------------------

' ID: 249
' Author: MadJack
' Date: 2002-02-27 17:50:12
' Title: Lightmesh And rotation
' Description: Using lightmesh To fakelight a rotating, moving entity

Import Openb3dmax.b3dglgraphics

Graphics3D 800, 600,0,2,60

Local lights:Int [21,10]
    x# = 0
    y# = 0
    z# = 0
   
    ' setup the fakelight markers And place in array - obviously this could be done differently Or with types
    count = 1
    For angle = 0 To 360 Step 36
            ob:TMesh  = CreateSphere(8)

            lights[count,0] = ob
            lights[count,1] = Rnd(50) '; red
            lights[count,2] = Rnd(50) '; green
            lights[count,3] = Rnd(50) '; blue                   
           
      ' position lightmarkers
      EntityColor ob ,lights[count,1]*8,lights[count,2]*8,lights[count,3]*8
      EntityFX ob,1
      ScaleEntity ob, 2,2,2
      PositionEntity ob, Cos(angle)*50,30,Sin(angle)*50

            count = count + 1

    Next

    ' Create mesh To be lit
    Local ball:TMesh = CreateSphere()
    ScaleEntity ball ,20,20,20
    EntityFX ball ,7 ' set flags For fullbright, vertex lighting, flatshaded
           
    Local camera:TCamera = CreateCamera()
    CameraRange camera,1,5000
    PositionEntity camera , 0,100,0
    PointEntity camera,ball

    p2 = CreatePivot() ' this is used in lighting process below
   
   
    'Main LOOP
    While Not KeyHit(key_escape)
   
   x# = (KeyDown(key_left))-(KeyDown(key_right)) + EntityX(ball)
   y# = (KeyDown(key_down))-(KeyDown(key_up)) + EntityZ(ball)
   
    ' move And turn the Object To be lit
    PositionEntity ball,x,0,y   
    TurnEntity ball,1,2,1
       
   'clear Object's vertex color ready for the lightmapping below
   For Local loop=1 To CountSurfaces(ball)
      surf:TSurface=GetSurface(ball,loop)
            For Local vert=0 To CountVertices(surf)-1
                VertexColor surf,vert,0,0,0
            Next
        Next
   
        For count = 1 To 10 '; 10 lights   

'      get light's basic info
            light = lights[count,0]
            Red = lights[count,1]
            Green = lights[count,2]
            Blue = lights[count,3]

            xl# = EntityX(light)
            yl# = EntityY(light)
            zl# = EntityZ(light)
       
            yaw# = EntityYaw(ball)
            pitch# = EntityPitch(ball)
            roll# = EntityRoll(ball)   
       
            EntityParent p2,ball
            PositionEntity p2,xl,yl,zl,1 ' place the pivot at the light's global xyz
            RotateEntity ball,0,0,0 ' reset the meshes rotation
   
            x = EntityX(p2) '; get the pivot's new position
            y = EntityY(p2)
            z = EntityZ(p2)


'      do the business
'      a higher range value than 6 will make lights brighter.
'      For larger game worlds, can use something like EntityDistance/3
'      (along with the lights RGB values), To alter brightness

            LightMesh ball,Red,Green,Blue,4,x,y,z   
       
            RotateEntity ball,pitch,yaw,roll ' reset the Object's rotation
   
        Next ' Next light

      UpdateWorld   
      RenderWorld
      
    Text 0,0,"Use Arrow Keys"

    Flip

    Wend
   End



markcwm

Hi DragonEgg,

you just need to use CreateSphere(32) for the main sphere to make it look more subdivided.

DragonEgg

Did you look at the demo code the sphere is totally borked.

markcwm

Hi DragonEgg,

yes I ran your code and it worked fine, lit just like in Blitz3d. Can you explain what you mean by totally borked?