Best way to create an office room in Matlab

8 次查看(过去 30 天)
Hi,
I want to make an office room to be modelled in Matlab. I was wondering which was the easies way to build structures, using .ply files.
I know for the floor I can use this function:
surf([-1.8,-1.8;1.8,1.8],[-1.8,1.8;-1.8,1.8],[0.01,0.01;0.01,0.01],'CData',imread('woodfloor.jpg'),'FaceColor','texturemap');
Where woodfloor would be just a jpg file that I want to set as the floor, but for putting objects around the room, what would be the best function for that?

回答(1 个)

Amish
Amish 2023-10-30
Hi Bobby,
I understand that you are trying to create a 3D model of an office room in MATLAB using .ply files and need a way to place different objects around the room.
You can use the patch function to create and position 3D objects within the room. This method allows you to describe your objects' vertices and faces, specify their appearance parameters, and put them in your 3D scene.
Here is a generic example of showing the use the patch function to place objects within your room:
% Create the room floor as you mentioned
surf([-1.8, -1.8; 1.8, 1.8],[-1.8, 1.8; -1.8,1.8],[0.01,0.01;0.01,0.01],'CData',imread('woodfloor.jpg'),'FaceColor','texturemap');
% Define object vertices and faces (you can import these from .ply files)
object_vertices = ...; % Replace with your object's vertex data
object_faces = ...; % Replace with your object's face data
% Position and scale the object
object_translation = [x, y, z]; % Replace with the desired coordinates
object_scale = [scaleX, scaleY, scaleZ]; % Replace with the desired scaling factors
% Create and display the object using patch
patch('Faces', object_faces, 'Vertices', object_vertices * object_scale + object_translation, 'FaceColor', 'g', 'EdgeColor', 'k');
In the code above, the object's vertices and faces are defined and the object's translation and scale within the room is considered for appropriate positioning. Then the patch function is used to create and display the object. You can repeat this process for each object you want to add to your room.
You can import the object's vertex and face data from .ply files using the plyread function.
Additionally, you can also refer to the some of the documentations:
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by