Download

Online

Gallery

Blog

  Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 10
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 1959 times and has 9 replies Next Thread
zerogravity90
Newbie




Joined: Apr 22, 2016
Post Count: 8
Status: Offline
Reply to this Post  Reply with Quote 
confused 3D rendering question



Hi bros,

I load a 5 piece door like in image from obj file. I want to render in 3D that can keep piece fixed size is 70mm for left, top, right and bottom piece.
Thank you so much for any help or any diea.
[Jan 29, 2018, 9:25:09 AM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
bdfd
Advanced Member
Member's Avatar

Western Europa
Joined: Mar 29, 2014
Post Count: 2346
Status: Offline
Reply to this Post  Reply with Quote 
Re: 3D rendering question

Hi,

Not easy to understand you.
Can you send us a drawing (started and finished) ?

smile
----------------------------------------
SH3D 6.5 and nothing else - W10 64b
Asus TUF Z390 , Intel Core i9-9900KF (4.0 GHz) , Chipset Z390 Exp, RAM 32 Go DDR4 3 Ghz, SSD M.2 512 Go + HDD 3 To,
MSI GeForce RTX 2080 8Go
[Jan 30, 2018, 6:37:03 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
zerogravity90
Newbie




Joined: Apr 22, 2016
Post Count: 8
Status: Offline
Reply to this Post  Reply with Quote 
Re: 3D rendering question

Hi,

Thank you so much for your answer,

It mean I load object from obj file. The object contain 5 piece door as in image. When i change ojbect size (width, height or depth), I want control 3D render which can keep 4 piece on door fixed size, just change the center piece of door.

Sorry for my bad English. Waiting for your answer.
Thanks!
[Jan 30, 2018, 4:42:36 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
okh
Advanced Member




Joined: May 12, 2013
Post Count: 1556
Status: Offline
Reply to this Post  Reply with Quote 
Re: 3D rendering question

keep 4 piece on door fixed size, just change the center piece of door
If I understand correctly, you probably want to edit the .obj with another software. The only way I know to do this with SH3D is if the centre piece has a different colour in the SH3D file (that is a different material in the .mtl file. Then you can set first the centre piece to invisible and export the rest. Then set the rest to invisible, make the door visible, and export. Then you have two different element you can import individually, scale and fit together with SH3D.

But, editing the .obj file with other software is probably easier.

ok
[Jan 30, 2018, 5:23:51 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
bdfd
Advanced Member
Member's Avatar

Western Europa
Joined: Mar 29, 2014
Post Count: 2346
Status: Offline
Reply to this Post  Reply with Quote 
Re: 3D rendering question

Another easy idea is to put these 5 objects in a group. wink
After you can update the group or one or more easily.

smile
----------------------------------------
SH3D 6.5 and nothing else - W10 64b
Asus TUF Z390 , Intel Core i9-9900KF (4.0 GHz) , Chipset Z390 Exp, RAM 32 Go DDR4 3 Ghz, SSD M.2 512 Go + HDD 3 To,
MSI GeForce RTX 2080 8Go
[Jan 31, 2018, 6:06:07 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
zerogravity90
Newbie




Joined: Apr 22, 2016
Post Count: 8
Status: Offline
Reply to this Post  Reply with Quote 
Re: 3D rendering question

Sorry for wrong meaning about question. I loaded obj file, in the applet, when i resize cabinet has 5 piece door above, but when i resized it, cabinet scale all piece by ratio. So 4 piece of out side scaled,too. I already fixed size for them. But it's take effect for every cabinet on same original model. I try modify ModelManager.java and HomePieceOfFurniture3D but not lucky.
[Feb 1, 2018, 4:43:07 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 7587
Status: Offline
Reply to this Post  Reply with Quote 
Re: 3D rendering question

Every part of a 3D model is proportionally enlarged or reduced when you resize it.
If you want that the frame of the door keeps the same width for a larger door, you'll have to use other software like Blender.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
[Feb 2, 2018, 12:06:38 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
zerogravity90
Newbie




Joined: Apr 22, 2016
Post Count: 8
Status: Offline
Reply to this Post  Reply with Quote 
Re: 3D rendering question

Hi Emmanuel Puybaret,

That's what i need. I'm using Blender to create object, but how can i do to keep the frame of the door keeps the same width for a larger door on Blender? You mean I need to create other model for the same cabinet?
Thank you so much!
[Feb 3, 2018, 1:45:40 AM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 7587
Status: Offline
Reply to this Post  Reply with Quote 
Re: 3D rendering question

Blender is not easy to learn but once mastered, it’s a great tool to update vertices in a 3D model, moreover because it preserves pretty well OBJ files at import/export.
If you want a larger cabinet you’all have to modify its 3D model and save it as an other OBJ file. Good luck!
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
[Feb 3, 2018, 4:40:13 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
zerogravity90
Newbie




Joined: Apr 22, 2016
Post Count: 8
Status: Offline
Reply to this Post  Reply with Quote 
smile Re: 3D rendering question

Finally, I solved it by modify Piece of Cabinet on UpdatePieceOfFurnitureModelNode funcion. But it's a bit slower
Any idea or improve that code.

/**
* Updates transform group children with <code>modelMode</code>.
*/
public void updatePieceOfFurnitureModelNode(Node modelNode, TransformGroup normalization, boolean ignoreDrawingMode,
boolean waitTextureLoadingEnd) {

HomePieceOfFurniture piece = (HomePieceOfFurniture)getUserData();
try {
float originalWidth = piece.getFloatValueFromMiscDataString("OriginalWidth"); //Get original define width
float scaleRatioW = (float)(originalWidth / piece.getWidth()); //Get current width

float originalHeight = piece.getFloatValueFromMiscDataString("OriginalHeight");
//Get original define height
float scaleRatioH = (float)(originalHeight / piece.getHeight());//Get current height

if (!piece.getReloaded())//If Piece need reload
{
for (int k = 0; k < ((Group)modelNode).numChildren(); k++) {

Node t = ((Group)modelNode).getChild(k).cloneNode(false);

if (scaleRatioW != 1 || scaleRatioH != 1) {
if (scaleRatioW != 1.0 && !t.getUserData().toString().contains("angle")) {
if (t.getUserData().toString().contains("Shaker_fl")) { //Left piece
Shape3D shape = (Shape3D)t.cloneNode(false);

for (int c = 0, n = shape.numGeometries(); c < n; c++) {
Geometry geometry = shape.getGeometry(c);
if (geometry instanceof GeometryArray) {

GeometryArray geometryArray = (GeometryArray)geometry;
int vertexCount = geometryArray.getVertexCount();

if ((geometryArray.getVertexFormat() & GeometryArray.BY_REFERENCE) != 0) {
if ((geometryArray.getVertexFormat() & GeometryArray.INTERLEAVED) != 0) {
float [] vertexData = geometryArray.getInterleavedVertices();
int vertexSize = vertexData.length / vertexCount;

float leftMostValue = 1000;
float rightMostValue = -1000;
for (int index = 0, j = vertexSize - 3; index < vertexCount; j += vertexSize, index++) {

if (vertexData [j] < leftMostValue) {
leftMostValue = vertexData [j];
}

if (vertexData [j] > rightMostValue) {
rightMostValue = vertexData [j];
}
}

for (int index = 0, j = vertexSize - 3; index < vertexCount; j += vertexSize, index++) {
if (vertexData [j] == rightMostValue) {
vertexData [j] = (float)(leftMostValue + 0.7 * scaleRatioW);
}
}

geometryArray.setInterleavedVertices(vertexData);
shape.setCapability(ALLOW_AUTO_COMPUTE_BOUNDS_WRITE);
shape.setCapability(ALLOW_BOUNDS_WRITE);
shape.setCapability(ALLOW_CHILDREN_WRITE);
shape.setGeometry(geometryArray, c);
}
}
}
}

} else if (t.getUserData().toString().contains("Shaker_fr")) { //Right piece

Shape3D shape = (Shape3D)t.cloneNode(false);

for (int c = 0, n = shape.numGeometries(); c < n; c++) {
Geometry geometry = shape.getGeometry(c);
if (geometry instanceof GeometryArray) {

GeometryArray geometryArray = (GeometryArray)geometry;
int vertexCount = geometryArray.getVertexCount();

if ((geometryArray.getVertexFormat() & GeometryArray.BY_REFERENCE) != 0) {
if ((geometryArray.getVertexFormat() & GeometryArray.INTERLEAVED) != 0) {
float [] vertexData = geometryArray.getInterleavedVertices();
int vertexSize = vertexData.length / vertexCount;

float leftMostValue = 1000;
float rightMostValue = -1000;
for (int index = 0, j = vertexSize - 3; index < vertexCount; j += vertexSize, index++) {

if (vertexData [j] < leftMostValue) {
leftMostValue = vertexData [j];
}

if (vertexData [j] > rightMostValue) {
rightMostValue = vertexData [j];
}
}

for (int index = 0, j = vertexSize - 3; index < vertexCount; j += vertexSize, index++) {
if (vertexData [j] == leftMostValue) {
vertexData [j] = (float)(rightMostValue - 0.7 * scaleRatioW);
}
}

geometryArray.setInterleavedVertices(vertexData);
shape.setCapability(ALLOW_AUTO_COMPUTE_BOUNDS_WRITE);
shape.setCapability(ALLOW_BOUNDS_WRITE);
shape.setCapability(ALLOW_CHILDREN_WRITE);
shape.setGeometry(geometryArray, c);

// System.out.println("fr1");
}
}
}
}
}
} else if (scaleRatioH != 1.0) {
if (t.getUserData().toString().contains("Shaker_fb")) {

// System.out.println("ft");
Shape3D shape = (Shape3D)t.cloneNode(false);

for (int c = 0, n = shape.numGeometries(); c < n; c++) {
Geometry geometry = shape.getGeometry(c);
if (geometry instanceof GeometryArray) {

GeometryArray geometryArray = (GeometryArray)geometry;
int vertexCount = geometryArray.getVertexCount();

if ((geometryArray.getVertexFormat() & GeometryArray.BY_REFERENCE) != 0) {
if ((geometryArray.getVertexFormat() & GeometryArray.INTERLEAVED) != 0) {
float [] vertexData = geometryArray.getInterleavedVertices();
int vertexSize = vertexData.length / vertexCount;

float topMostValue = 1000;
float bottomMostValue = -1000;
for (int index = 0, j = vertexSize - 3; index < vertexCount; j += vertexSize, index++) {

if (vertexData [j + 1] < topMostValue) {
topMostValue = vertexData [j + 1];
}

if (vertexData [j + 1] > bottomMostValue) {
bottomMostValue = vertexData [j + 1];
}
}

for (int index = 0, j = vertexSize - 3; index < vertexCount; j += vertexSize, index++) {
if (vertexData [j + 1] == bottomMostValue) {
if (t.getUserData().toString().contains("Drawer_Small")) {
vertexData [j + 1] = (float)(topMostValue + 0.37 * scaleRatioH);
} else {
vertexData [j + 1] = (float)(topMostValue + 0.7 * scaleRatioH);
}
}
}

geometryArray.setInterleavedVertices(vertexData);
shape.setCapability(ALLOW_AUTO_COMPUTE_BOUNDS_WRITE);
shape.setCapability(ALLOW_BOUNDS_WRITE);
shape.setCapability(ALLOW_CHILDREN_WRITE);
shape.setGeometry(geometryArray, c);

// System.out.println("ft1");
}
}
}
}
} else if (t.getUserData().toString().contains("Shaker_ft")) {
Shape3D shape = (Shape3D)t.cloneNode(false);

for (int c = 0, n = shape.numGeometries(); c < n; c++) {
Geometry geometry = shape.getGeometry(c);
if (geometry instanceof GeometryArray) {

GeometryArray geometryArray = (GeometryArray)geometry;
int vertexCount = geometryArray.getVertexCount();

if ((geometryArray.getVertexFormat() & GeometryArray.BY_REFERENCE) != 0) {
if ((geometryArray.getVertexFormat() & GeometryArray.INTERLEAVED) != 0) {
float [] vertexData = geometryArray.getInterleavedVertices();
int vertexSize = vertexData.length / vertexCount;

float topMostValue = 1000;
float bottomMostValue = -1000;
for (int index = 0, j = vertexSize - 3; index < vertexCount; j += vertexSize, index++) {

if (vertexData [j + 1] < topMostValue) {
topMostValue = vertexData [j + 1];
}

if (vertexData [j + 1] > bottomMostValue) {
bottomMostValue = vertexData [j + 1];
}
}

for (int index = 0, j = vertexSize - 3; index < vertexCount; j += vertexSize, index++) {
if (vertexData [j + 1] == topMostValue) {
if (t.getUserData().toString().contains("Drawer_Small")) {
vertexData [j + 1] = (float)(bottomMostValue - 0.37 * scaleRatioH);
} else {
vertexData [j + 1] = (float)(bottomMostValue - 0.7 * scaleRatioH);
}

}
}

geometryArray.setInterleavedVertices(vertexData);
shape.setCapability(ALLOW_AUTO_COMPUTE_BOUNDS_WRITE);
shape.setCapability(ALLOW_BOUNDS_WRITE);
shape.setCapability(ALLOW_CHILDREN_WRITE);
shape.setGeometry(geometryArray, c);
}
}
}
}
}
}
}
}
}

normalization.addChild(modelNode);
setModelCapabilities(normalization);
// Add model node to branch group
BranchGroup modelBranch = new BranchGroup();
modelBranch.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
modelBranch.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
modelBranch.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
modelBranch.setCapability(BranchGroup.ALLOW_DETACH);
modelBranch.addChild(normalization);

if (!ignoreDrawingMode) {
// Add outline model node
modelBranch.addChild(createOutlineModelNode(normalization));
}

// TransformGroup transformGroup = (TransformGroup)modelNode;
TransformGroup transformGroup = (TransformGroup)getChild(0);
// Remove previous nodes
transformGroup.removeAllChildren();
// Add model branch to live scene
transformGroup.addChild(modelBranch);

if (piece instanceof HomeLight) {
BranchGroup lightBranch = new BranchGroup();
lightBranch.setCapability(ALLOW_CHILDREN_READ);
HomeLight light = (HomeLight)piece;
for (int i = light.getLightSources().length; i > 0; i--) {
PointLight pointLight = new PointLight(new Color3f(), new Point3f(), new Point3f(0.25f, 0, 0.0000025f));
pointLight.setCapability(PointLight.ALLOW_POSITION_WRITE);
pointLight.setCapability(PointLight.ALLOW_COLOR_WRITE);
pointLight.setCapability(PointLight.ALLOW_STATE_WRITE);
BoundingLeaf bounds = (BoundingLeaf)getChild(1);
pointLight.setInfluencingBoundingLeaf(bounds);
lightBranch.addChild(pointLight);
}
addChild(lightBranch);
}

// Flip normals if back faces of model are shown
if (piece.isBackFaceShown()) {
setBackFaceNormalFlip(getFilledModelNode(), true);
}

} catch (Exception ex) {

}

// Update piece color, visibility and model mirror in dispatch thread as
// these attributes may be changed in that thread
updatePieceOfFurnitureModelMirrored();
updatePieceOfFurnitureColorAndTexture(waitTextureLoadingEnd);
updateLight();
updatePieceOfFurnitureVisibility();

// Manage light sources visibility
if (this.home != null && getUserData() instanceof Light) {
this.home.addSelectionListener(new LightSelectionListener(this));
}
}

p/s : Shaker_fl : is fix left, same with ft, fr, fb.
Thanks for all of your comment!
[Mar 5, 2018, 6:54:59 AM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

    Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads
   
© Copyright 2006-2021 eTeks - All rights reserved