Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

[ad_1]

I am making an attempt to make a illustration of a airplane that rotates round a gap in a MeshInstance3D.

To date I’ve managed to make the circle’s gap, however I am unable to make the airplane rotate across the gap. (The opening cannot rotate, simply the airplane)

Here’s what I’ve now:



extends MeshInstance3D

@export var xSize = 20
@export var zSize = 20

@export var replace = false
@export var clear_vert_vis = false
var velocity = 0.001

# Referred to as when the node enters the scene tree for the primary time.
func _ready():
    #generate_terrain(velocity : float)
    cross # Exchange with perform physique.

func generate_terrain(velocity : float):
    var a_mesh: ArrayMesh
    var surftool = SurfaceTool.new()
    
    var n = FastNoiseLite.new()
    
    n.noise_type = FastNoiseLite.TYPE_PERLIN
    n.frequency = 0.1 * velocity
    
    
    
    surftool.start(Mesh.PRIMITIVE_TRIANGLES)
    
    
    
    for z in vary(zSize +1):
        for x in vary(xSize+1):
            var y_variation = cos(velocity)
            var y = 0 #n.get_noise_2d(x*0.5,z*0.5) * 4* y_variation
            
            if inside_circle(xSize/2,x, z, 4):
                y = velocity * -1
                cross
            
            # Place in middle 0, 0
            var x1 = x -xSize/2
            var z1 = z -zSize/2
            # tying to make the rotation, however it's on improper axis
            var xNew = x1 * cos(velocity) - z1 * sin(velocity)
            var zNew = x1 * sin(velocity) - z1 * cos(velocity)
            
            # uv
            var uv = Vector2()
            
            uv.x = inverse_lerp(0,xSize, xNew)
            uv.y = inverse_lerp(0, zSize, zNew)
            surftool.set_uv(uv)
            
            # vertex
            surftool.add_vertex(Vector3(xNew,y,zNew))
            
    
    var vert = 0
    for z in zSize:
        for x in xSize:
            surftool.add_index(vert+0)
            surftool.add_index(vert+1)
            surftool.add_index(vert+xSize+1)
            
            surftool.add_index(vert+xSize+1)
            surftool.add_index(vert+1)
            surftool.add_index(vert+xSize+2)
            vert += 1
        vert += 1
    
    surftool.generate_normals()
    
    a_mesh = surftool.commit()
    
    mesh = a_mesh
    
    
    
    cross

# return the circle across the airplane
func inside_circle(middle: float, x: float, z: float, radius : float):
    var dx = middle - x
    var dz = middle - z
    var distance_squared = dx * dx + dz * dz
    return distance_squared <= radius * radius


# Referred to as each body. 'delta' is the elapsed time because the earlier body.
func _process(delta):
    velocity += 0.001264
    generate_terrain(velocity)
        
    if clear_vert_vis:
        for i in get_children():
            i.free()
    cross



How can I make this airplane rotate across the gap, with out the outlet rotating?

This image is before I try to apply rotation

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *