x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Resize of StaticMesh using C++

The task is to change the size of StaticMesh from C++.

There is base C++ class. StaticMesh is choosed from BP class. I want to use the same BP for different sizes.

From Blueprints I can do it here (see picture). Is it possible to do the same from C++ for one copy only? Or advise the way to do it proper. Textures should not be resized.

alt text

Product Version: UE 4.18
Tags:
question.jpg (69.0 kB)
more ▼

asked Nov 30 '17 at 08:55 AM in C++ Programming

avatar image

SvarogZ
49 10 12 21

avatar image Firefly74 Nov 30 '17 at 10:13 AM

Not Sure exactly what you want, why don't you simply scale the component ? (UStaticMeshComponent)

 UStaticMeshComponent* staticMesh;
 staticMesh->SetWorldScale3D(FVector(2, 2, 2));
 staticMesh->SetRelativeScale3D(FVector(2, 2, 2));


avatar image SvarogZ Nov 30 '17 at 10:54 AM

In that case textures on the edges are stretched also.

alt text

question2.jpg (25.3 kB)
avatar image Napoleonite Nov 30 '17 at 11:32 AM

You could change the material so that the edges won't stretch.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

alt text

Now i know what you whant, I would recommend you to do it in material to avoid having to manually code dynamic scaling.

Material has a TextCood node, multiply it with the object scale node and 'voila'

You should keep a correct scale ratio. but i don't think there is a magic solution for that case

capture.jpg (30.8 kB)
more ▼

answered Nov 30 '17 at 12:32 PM

avatar image

Firefly74
1.5k 14 18 33

avatar image SvarogZ Dec 07 '17 at 08:52 PM

Yes. Thank you.

I can't do exactly the same. I have to use one BP material.

There are 3 materials (one for opposite sides of a cube).

alt text

DataAsset contains size scale, material and other information.

alt text

Using C++ I can change any scale of the cube and adjust UVs in BP already.

alt text

question5.jpg (57.6 kB)
question4.jpg (66.7 kB)
question3.jpg (171.3 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question