简体   繁体   English

在模型上使用Java 3D绘图

[英]Java 3D Draw on models

How to draw on a 3D model in java 3D. 如何在Java 3D中绘制3D模型。 Like draw Line or a point. 像画线或点。

I have been able to import models. 我已经能够导入模型。 But stuck on how to draw on models. 但是停留在如何绘制模型上。

Please Help 请帮忙

Thanks 谢谢

In java3d you don't really "draw" on a model. 在java3d中,您并不是真正地“绘制”模型。 In java3d you create a scene graph with the model to be displayed. 在java3d中,使用要显示的模型创建一个场景图。 Then you compile the scene and display it in a view. 然后,编译场景并将其显示在视图中。 If you want to draw something else in the display you have to create geometry that represents what you are drawing in the model. 如果要在显示中绘制其他内容,则必须创建表示要在模型中绘制内容的几何图形。 You can place text and words on the geometry using texture mapping. 您可以使用纹理映射将文本和单词放置在几何图形上。 You can place words in the scene using Text3D. 您可以使用Text3D在场景中放置单词。 If you haven't done much 3D stuff before it takes a while to learn. 如果您还没花太多时间来学习3D资料。 There are a lot of good examples and tutorials on the java3d site https://java3d.dev.java.net /. java3d站点https://java3d.dev.java.net /上有很多很好的示例和教程。

For simple primitive models like cube,follow this rule for static scenes 对于简单的原始模型(例如立方体),请遵循此规则处理静态场景

1)Decide the face on which you want to draw. 1)确定要绘制的面。

2)Note down the x,y,z co-ordinates .(if u are going to draw on the POLYGON,then you will get four points in space-coords each having x,y,z.) 2)记下x,y,z坐标。(如果您要在多边形上画图,那么您将在空间坐标中得到四个点,每个点都有x,y,z。)

3.)now use drawLine() of Graphics class. 3.)现在使用Graphics类的drawLine()。 Something like this 像这样

   public void drawsomething(Graphics g)
   {
         g.drawLine(originz,originy,x,y)        
   }

4.) make sure that the points originx,originy,x,y are within the bounds of the co-ords mentioned in point "2". 4.)确保点originx,originy,x,y在点“ 2”中提到的坐标的范围内。

For dynamic scenes, try different transformations, so they all move along. 对于动态场景,请尝试不同的变换,以使它们一起进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM