how to rotate the yellow cube towards the car? - godot

how to rotate the yellow cube towards the car ? I have a spinning camera, I think this is the case

Are you trying to do with with code? I remind you StackOverflow is for programming. For other game related things there is gamedev.stackexchange.com.
If you are doing this with code - and given that I don't know how the scene tree looks like - I suggest using look_at. Something like this (code for the Camera):
look_at(car.global_transform.origin, car.global_transform.basis.y)
There car is a reference to the car. I can't tell you how to get one without looking at the scene tree, beyond that you can probably use get_node. So car.global_transform.origin is the position of the car in global coordinates. And car.global_transform.basis.y is the direction towards the up of the car.
The method look_at needs an up vector because there are infinite ways to look at a given point (rotate around the view line). Thus, we do not want an up vector that matches the view line. For example, Vector3.UP won't work if the camera is looking directly up or directly down.
And if you just want to rotate this in the designer. You can use the gizmo you see when you select it. You can drag the blue ring until it is aligned correctly.
The de facto standard for this gizmos is that x is red, y is green, and z is blue (this is true in Godot, Blender, and plenty of other software). So the blue ring rotates around the z axis. You can also find that rotation in the inspector panel, look for rotation degrees for the z under transform.
I remind you that if you place the Camera as a child node of another Spatial, it will keep its position and orientation relative to it. So placing the Camera as child of your player character (e.g. a KinematicBody) is often good enough for the early stages of development, as that guarantees that the Camera follows the player character. No coding necessary. You may want a more elaborate Camera control later, which would require some code.
Since you mention "spinning camera", perhaps you want a Camera that orbits around a point. The easier way to do this is to add an auxiliary Spatial for the point the Camera rotates around. Let us call it Pivot, and rotate that. For clarity, I'm suggesting a setup like this:
PlayerCharacter
└ Pivot
└ Camera
Here the Pivot follows the player character. And the Camera follows the Pivot. So moving the player character moves the Camera, and rotating the Pivot makes the Camera orbit. This is just lacking some code to make the Pivot rotate. For example something like this (code for Pivot):
global_transform.rotate_y(Input.get_axis("camera_left", "camera_right"))
Where "camera_left" and "camera_right" are actions configured in the Input Map (in Project settings). Which reminds me, you can set actions from code with Input.action_press, so there could be code somewhere else (e.g. _input) writing these actions from mouse movement.
Camera Control does not have to be hard.

Related

AnyLogic - Move presentation frame dynamicaly

I've got a model with cars moving over the road. To make roads length similar to real-life sizes I had to change the scale so the cars turned into points (4px*2px).
Are there any facilities in AnyLogic 7 PLE to, for ex, zoom one of the cars and track it?
Yes, it is possible. If you want to zoom in one car and follow it in 3D (like if the car has GoPro at top), use Camera object with dynamic coordinates. Railway Station example model and its cameraOnTrain object illustrates the concept.
In case if you want to do similar thing in 2D space (GTA2 view mode), you may drag & drop empty Group element. In its On Draw action use the code:
getPresentation().getPanel().setOffsets( 300-agent.getX(), 300-agent.getY());
The code will constantly move frame, so car always will appear with in the bottom right corner of the 300x300 square, drawn from top left corner. Zoom can be adjusted with mouse wheel, or with code as well:
getPresentation().getPanel().setZoom( double value);

Libgdx sprite ring object passing through it

How is it possible object can pass through ring spirte like in the image below?
Please can you help me I have no idea how can i do that.
I think you posted a incorrect image. To get the image you posted you just have to draw the red bar on top of the black ring.
I guess you want the ring on the left side to be on top and the right side to be over so it visually goes through. Well this is simply not so easy in 2D since draw order.
I have a couple of suggestion you can explore.
Always draw the ring on top of the bar but when a collision is happening you calculate where the bar overlaps and don't draw the pixels in that place. You can use a Pixmap for calculations like this. Depending on the size of your images this could be very expensive to calculate each frame.
A faster but slightly more hacky way could be to split red bar in multiple images and if a certain part of it should be overlapped by the ring draw it first otherwise draw it after the ring. Depending on what the red bar is going to look in your end product and how much possible angles the bar could have I can imagine this can be very tricky to get right.
Use 3D for this. You could have a billboard with a slight angle for the ring and have the bar locked on the distance axis at the rings center. However, on certain angles of entrance and exit you will get Z fighting since the pixels will be at the same distance from the camera. This might or might not be noticable and I have no idea how LibGDX would handle Z fighting.
I wanna add this solution :
if the object gonna pass through the ring horizontally i propose to devise sprite ring in to to sprite (sprite 1 & sprite 2)
you just have to draw sprites in that order :
Sprite1
Sprite Object
Sprite2
You can do the same if the object is gonna pass through ring vertically
PS : this solution don't work if the object is going to passs through ring both Vertically and Horizontally
Hope this was helpfull
Good luck

Erase Pixels From Sprite Cocos2d-JS

I'm getting the feeling this won't be possible, but worth asking anyway I guess.
I have a background sprite and a foreground sprite, both are the same size as the window/view.
As the player sprite moves across the screen I want to delete the pixels it touches to reveal the background sprite.
This is not just for display purposes, I want the gaps the player has drawn or "dug" out of the foreground layer to allow enemies to travel through, or objects to fall into. So hit detection will be needed with the foreground layer.
This is quite complex and maybe Cocos2D-JS is not the best platform to use, if not possible could you recommend another which would be easier to achieve this effect with?
I believe it's possible, but I'm not capable of giving you a proper answer.
All I can say is that you'll most likely have two choices:
a. Make a physics polygonal shape and deform it, then use it as a "filter" to display your terrain image (here's a proof of concept example in another language using box2d).
b. Directly manipulate pixels and use a mask for collision detection (here's pixel-perfect collision detection in cocos2d-js, sadly I've got no info in modifying pixels).

How to construct ground surface of infinite size in a 3D CAD application?

I am trying to create an application similar in UI to Sketchup. As a first step, I need to display the ground surface stretching out in all directions. What is the best way to do this?
Options:
Create a sufficiently large regular polygon stretching out in all directions from the origin. Here there is a possibility of the user hitting the edges and falling off the surface of the earth.
Model the surface of the earth as a sphere/spheroid. Here I will be limiting my vertex co-ordinates to very large values prone to rounding off errors. (Radius of earth is 6371000000 millimeter).
Same as 1 but dynamically extend the ends of the earth as the user gets close to them.
What is the usual practice?
I guess you would do neither of these, but instead use a virtual ground.
So you just find out, what portion of the ground is visible in the viewport and then create a plane large enough to fill that. With some reasonable maxiumum, which simulates the end of the line of sight aka horizon as we know it.

"Virtual screens" in 3D engines (displaying on a wall another portion of the 3D world)

To clarify the technical problem i have, i want to describe the scene i have in mind:
In a 3D computer simulation, I want to build a kind of cabin (cube form) that stands isolated in a large plane. There's 1 door to enter the cabin. Next to this door I want to show a movie playing (avi file or something) on the wall of the cabin.
If you enter the cabin, on all 4 sides I want to show a virtual 3D landscape projection that is based on the input of the video projected outside: every pixel in the video will be represented as a cube (rgb -> height width depth). The resulting landscape of cubes needs to be projected on the inside walls of the cabin. And as a user, you will not be able to walk into this projection (it's a virtual window, not a portal).
Technically, for me this translates into these questions: i want to
display a movie inside the 3D world on a wall
access the pixel data of this movie
transform on the fly these pixels into 3D representation of cubes
show these cubes as a virtual projection on a wall in the game. (as a kind of visual teleport that you can't cross)
I was wondering which 3d engine would allow this? I don't mind any programming language. I'm fluent in mono/.net or java, but i can manage c++ or other languages (as long as the engine is well documented).
Kind Regards,
Ruben.
ps:
I don't know if this question is of interest to anybody else. At least not in the functional kind of way. But maybe it triggers a hypothetical interest :)
Any engine that supports dynamic texture maps and multiple viewports (rendering surfaces).
render the scene you want on your wall
texture wall with the output of 1
render your room scene
Many engines support this. The Unreal Tournament Engine (UT2004) supports this, as evidenced by the dynamic texture on carried sniper scopes (example, Killing Floor). Security camera screens in Half-life 2 do this as well (source engine).

Resources