My hello message is not visible...
I'm writing a 3D video game using Python (3.10) language with Panda3d (1.10) as 3D game engine.
Some graphical parts of the game are not 3D, there are just 2D elements:
spell bar,
player resume
quest panel
skill tree
etc
spells/attacks book
and others
I see on the web that pictures are used to styling Panda3D Direct* components.
However, in my opinion, I think use statics pictures (.png for exemple) is not efficient when game design must be evolved. That's why I prefer use HTML/CSS to render 2D elements, especially since CSS is very powerful if you know how to use it. I prefere to use SVG into the scene but I don't understand how create SVG file.
So, my question is:
Can I use HTML/CSS inside a Panda3d application?
Thank to all!
Have a nice day!
I think I've found a workaround (temporary).
I create HTML/CSS file that styling my 2D component that must be injected inside the Panda3D scene
I create a Python script that convert an HTML part as PNG picture using RGBA for transparency
I use the generated PNG picture inside my Panda3D scene on the target component.
It's not pure HTML/CSS, but it can works.
Related
I am new to game development. I am trying to start high and make a 3D RPG. I know the road is not gonna be easy. That is why i decided to use Ursina and python to make my game.
However i wanna add a cutscene showing a Backstory. I have the video in mp4 format but i cannot seem to know how to play it inside the game with Ursina.
Anyhelp will be much appreciated.
(Side question : do you think Ursina is good for a beginner in 3D gaming? If i want to publish my game on my website, isn't it better for me to learn javascript ? I read about Unity but it is too big to download for a little side project)
You can set the video as a texture of any element. You'll want to fix it to the UI using its parent attribute and you have to load the sound separately from the same file (as described in the Panda3D documentation).
from ursina import *
app = Ursina()
video = 'video.mp4'
video_player = Entity(model='quad', parent=camera.ui, scale=(1.5, 1), texture=video)
video_sound = loader.loadSfx(video)
video_player.texture.synchronizeTo(video_sound)
video_sound.play()
app.run()
The above code assumes that the video file is in the same folder as the Python script.
Well, I don't think there is a way to do that. the closest thing you can do to that is having a folder filled with all the frames of your video in .png or .jpg files, then adding a quad to the world and changing the texture of it to the next frame every fraction of a second depending on the framerate. this, however would make your computer l a g. trust me, I've tried it. it would probably be better to have a separate window with some sort of module that plays .mp4 files for playing the file.
In other words, there is no feasible way to do that.
From Entity Basics in the documentation:
e4 = Entity(model='cube', texture='movie_name.mp4') # set video texture
I am trying to build an application that builds tool-strings by selecting and inserting pre-made png that are saved in a folder. The pngs need to be placed onto a canvas and built up one by one by selecting an image from a folder and placing onto the canvas in a grid like format.
I have including an example of the toolstring I am trying to make. Currently this is being built manually in a photo manipulation software but I would like to automate the process in a stand alone python application.
Any pointers in the right direction would be grateful, I'm not sure what to google. (Relevant plugins, tutorials, examples). I have a small amount of experience in python programming.
You will want to look at this Python library, PIL
As a class project, I need to create a graphics library in Python. What is the most basic way I can create windows and access individual pixels? Tkinter seems like an over kill since it already has built-in methods to draw lines. Is there a more basic way to do graphics in python?
If you want to just create bitmaps and save them as jpeg or pngs or bmps see Save as image?
If you want to get graphics contexts and draw to the screen see How can I draw a pixel to screen in python? or Best Python library for drawing?.
If you want to play with Graphical User Interfaces see Python any good for GUI dev?
I am currently in the planing stage of building an interactive periodic table of the elements program in python 3. It won't be a super advanced program, since I am only a beginner in python 3 (4-5 months of self-training).
Basically, when you click on an element of the periodic table, you will look at its properties in more detail and would have a dynamic 3D view of the an animated atom (with the electrons circling around it) which I would create in Blender. Here is a simple mockup I just made for people who are visual (lots of stuff missing here, but it's only the basic shell).
Ok, so my question is: How can I interact with 3D objects in Python 3? I have searched, and have found that PyGame can handle this, but it seems it's not the best to handle 3D graphics, and I am not sure if PyGame is ideal for this kind of program. Of course, there is vpython, but it doesn't work with Python 3. So how can I manage to do this?
Please keep in mind that I am a beginner, so any resources you think can help me would be of great appreciation!
Thanks to all.
The easiest could be to use images and videos.
But if you want to manipulate 3D, there are PyOpenGL and VPython.
PyOpenGL provides low level interface to display 3D objects.
PyOpenGL can be used with PyQt or PyGame to have a 3D display within a 2D GUI.
Edit: there is also a build of vpython for 32bit python 3.1 on windows
My next work is going to be heavily focused on working with data that is best understood when organized on a two-dimensional zoomable plane or canvas, instead of using lists and property forms.
The library can be based on OpenGL, GTK+ or Cairo. It should allow me to:
build widgets out of vector shapes and text (perhaps even SVG based?)
arrange these widgets on a 2D plane
catch widget-related events
zoom deeply into a widget to reveal additional data
arrange widgets in a tree
animate widgets fluidly
It wouldn't hurt if it would also allow for some databinding or model/view concept.
Qt has this covered... check PyQt
I think Clutter is perfect for you.
From the web site:
Clutter is an open source software
library for creating fast, visually
rich and animated graphical user
interfaces.
Clutter is written in C, but it has great Python bindings.
A very similar project is Pigment:
Pigment is a 3D scene graph library
designed to easily create rich
application user interfaces.